├── .gitignore ├── DebugConfig └── Anopilot_STM32F407VG.dbgconf ├── F407_FC.uvopt ├── F407_FC.uvoptx ├── F407_FC.uvproj.saved_uv4 ├── F407_FC.uvprojx ├── JLinkSettings.ini ├── Libraries ├── CMSIS │ ├── CMSIS END USER LICENCE AGREEMENT.pdf │ ├── DSP_Lib │ │ └── Source │ │ │ ├── ARM │ │ │ ├── arm_cortexM0x_math.uvopt │ │ │ ├── arm_cortexM0x_math.uvproj │ │ │ ├── arm_cortexM3x_math.uvopt │ │ │ ├── arm_cortexM3x_math.uvproj │ │ │ ├── arm_cortexM4x_math.uvopt │ │ │ ├── arm_cortexM4x_math.uvproj │ │ │ └── arm_cortexMx_math_Build.bat │ │ │ ├── BasicMathFunctions │ │ │ ├── arm_abs_f32.c │ │ │ ├── arm_abs_q15.c │ │ │ ├── arm_abs_q31.c │ │ │ ├── arm_abs_q7.c │ │ │ ├── arm_add_f32.c │ │ │ ├── arm_add_q15.c │ │ │ ├── arm_add_q31.c │ │ │ ├── arm_add_q7.c │ │ │ ├── arm_dot_prod_f32.c │ │ │ ├── arm_dot_prod_q15.c │ │ │ ├── arm_dot_prod_q31.c │ │ │ ├── arm_dot_prod_q7.c │ │ │ ├── arm_mult_f32.c │ │ │ ├── arm_mult_q15.c │ │ │ ├── arm_mult_q31.c │ │ │ ├── arm_mult_q7.c │ │ │ ├── arm_negate_f32.c │ │ │ ├── arm_negate_q15.c │ │ │ ├── arm_negate_q31.c │ │ │ ├── arm_negate_q7.c │ │ │ ├── arm_offset_f32.c │ │ │ ├── arm_offset_q15.c │ │ │ ├── arm_offset_q31.c │ │ │ ├── arm_offset_q7.c │ │ │ ├── arm_scale_f32.c │ │ │ ├── arm_scale_q15.c │ │ │ ├── arm_scale_q31.c │ │ │ ├── arm_scale_q7.c │ │ │ ├── arm_shift_q15.c │ │ │ ├── arm_shift_q31.c │ │ │ ├── arm_shift_q7.c │ │ │ ├── arm_sub_f32.c │ │ │ ├── arm_sub_q15.c │ │ │ ├── arm_sub_q31.c │ │ │ └── arm_sub_q7.c │ │ │ ├── CommonTables │ │ │ └── arm_common_tables.c │ │ │ ├── ComplexMathFunctions │ │ │ ├── arm_cmplx_conj_f32.c │ │ │ ├── arm_cmplx_conj_q15.c │ │ │ ├── arm_cmplx_conj_q31.c │ │ │ ├── arm_cmplx_dot_prod_f32.c │ │ │ ├── arm_cmplx_dot_prod_q15.c │ │ │ ├── arm_cmplx_dot_prod_q31.c │ │ │ ├── arm_cmplx_mag_f32.c │ │ │ ├── arm_cmplx_mag_q15.c │ │ │ ├── arm_cmplx_mag_q31.c │ │ │ ├── arm_cmplx_mag_squared_f32.c │ │ │ ├── arm_cmplx_mag_squared_q15.c │ │ │ ├── arm_cmplx_mag_squared_q31.c │ │ │ ├── arm_cmplx_mult_cmplx_f32.c │ │ │ ├── arm_cmplx_mult_cmplx_q15.c │ │ │ ├── arm_cmplx_mult_cmplx_q31.c │ │ │ ├── arm_cmplx_mult_real_f32.c │ │ │ ├── arm_cmplx_mult_real_q15.c │ │ │ └── arm_cmplx_mult_real_q31.c │ │ │ ├── ControllerFunctions │ │ │ ├── arm_pid_init_f32.c │ │ │ ├── arm_pid_init_q15.c │ │ │ ├── arm_pid_init_q31.c │ │ │ ├── arm_pid_reset_f32.c │ │ │ ├── arm_pid_reset_q15.c │ │ │ ├── arm_pid_reset_q31.c │ │ │ ├── arm_sin_cos_f32.c │ │ │ └── arm_sin_cos_q31.c │ │ │ ├── FastMathFunctions │ │ │ ├── arm_cos_f32.c │ │ │ ├── arm_cos_q15.c │ │ │ ├── arm_cos_q31.c │ │ │ ├── arm_sin_f32.c │ │ │ ├── arm_sin_q15.c │ │ │ ├── arm_sin_q31.c │ │ │ ├── arm_sqrt_q15.c │ │ │ └── arm_sqrt_q31.c │ │ │ ├── FilteringFunctions │ │ │ ├── arm_biquad_cascade_df1_32x64_init_q31.c │ │ │ ├── arm_biquad_cascade_df1_32x64_q31.c │ │ │ ├── arm_biquad_cascade_df1_f32.c │ │ │ ├── arm_biquad_cascade_df1_fast_q15.c │ │ │ ├── arm_biquad_cascade_df1_fast_q31.c │ │ │ ├── arm_biquad_cascade_df1_init_f32.c │ │ │ ├── arm_biquad_cascade_df1_init_q15.c │ │ │ ├── arm_biquad_cascade_df1_init_q31.c │ │ │ ├── arm_biquad_cascade_df1_q15.c │ │ │ ├── arm_biquad_cascade_df1_q31.c │ │ │ ├── arm_biquad_cascade_df2T_f32.c │ │ │ ├── arm_biquad_cascade_df2T_init_f32.c │ │ │ ├── arm_conv_f32.c │ │ │ ├── arm_conv_fast_q15.c │ │ │ ├── arm_conv_fast_q31.c │ │ │ ├── arm_conv_partial_f32.c │ │ │ ├── arm_conv_partial_fast_q15.c │ │ │ ├── arm_conv_partial_fast_q31.c │ │ │ ├── arm_conv_partial_q15.c │ │ │ ├── arm_conv_partial_q31.c │ │ │ ├── arm_conv_partial_q7.c │ │ │ ├── arm_conv_q15.c │ │ │ ├── arm_conv_q31.c │ │ │ ├── arm_conv_q7.c │ │ │ ├── arm_correlate_f32.c │ │ │ ├── arm_correlate_fast_q15.c │ │ │ ├── arm_correlate_fast_q31.c │ │ │ ├── arm_correlate_q15.c │ │ │ ├── arm_correlate_q31.c │ │ │ ├── arm_correlate_q7.c │ │ │ ├── arm_fir_decimate_f32.c │ │ │ ├── arm_fir_decimate_fast_q15.c │ │ │ ├── arm_fir_decimate_fast_q31.c │ │ │ ├── arm_fir_decimate_init_f32.c │ │ │ ├── arm_fir_decimate_init_q15.c │ │ │ ├── arm_fir_decimate_init_q31.c │ │ │ ├── arm_fir_decimate_q15.c │ │ │ ├── arm_fir_decimate_q31.c │ │ │ ├── arm_fir_f32.c │ │ │ ├── arm_fir_fast_q15.c │ │ │ ├── arm_fir_fast_q31.c │ │ │ ├── arm_fir_init_f32.c │ │ │ ├── arm_fir_init_q15.c │ │ │ ├── arm_fir_init_q31.c │ │ │ ├── arm_fir_init_q7.c │ │ │ ├── arm_fir_interpolate_f32.c │ │ │ ├── arm_fir_interpolate_init_f32.c │ │ │ ├── arm_fir_interpolate_init_q15.c │ │ │ ├── arm_fir_interpolate_init_q31.c │ │ │ ├── arm_fir_interpolate_q15.c │ │ │ ├── arm_fir_interpolate_q31.c │ │ │ ├── arm_fir_lattice_f32.c │ │ │ ├── arm_fir_lattice_init_f32.c │ │ │ ├── arm_fir_lattice_init_q15.c │ │ │ ├── arm_fir_lattice_init_q31.c │ │ │ ├── arm_fir_lattice_q15.c │ │ │ ├── arm_fir_lattice_q31.c │ │ │ ├── arm_fir_q15.c │ │ │ ├── arm_fir_q31.c │ │ │ ├── arm_fir_q7.c │ │ │ ├── arm_fir_sparse_f32.c │ │ │ ├── arm_fir_sparse_init_f32.c │ │ │ ├── arm_fir_sparse_init_q15.c │ │ │ ├── arm_fir_sparse_init_q31.c │ │ │ ├── arm_fir_sparse_init_q7.c │ │ │ ├── arm_fir_sparse_q15.c │ │ │ ├── arm_fir_sparse_q31.c │ │ │ ├── arm_fir_sparse_q7.c │ │ │ ├── arm_iir_lattice_f32.c │ │ │ ├── arm_iir_lattice_init_f32.c │ │ │ ├── arm_iir_lattice_init_q15.c │ │ │ ├── arm_iir_lattice_init_q31.c │ │ │ ├── arm_iir_lattice_q15.c │ │ │ ├── arm_iir_lattice_q31.c │ │ │ ├── arm_lms_f32.c │ │ │ ├── arm_lms_init_f32.c │ │ │ ├── arm_lms_init_q15.c │ │ │ ├── arm_lms_init_q31.c │ │ │ ├── arm_lms_norm_f32.c │ │ │ ├── arm_lms_norm_init_f32.c │ │ │ ├── arm_lms_norm_init_q15.c │ │ │ ├── arm_lms_norm_init_q31.c │ │ │ ├── arm_lms_norm_q15.c │ │ │ ├── arm_lms_norm_q31.c │ │ │ ├── arm_lms_q15.c │ │ │ └── arm_lms_q31.c │ │ │ ├── MatrixFunctions │ │ │ ├── arm_mat_add_f32.c │ │ │ ├── arm_mat_add_q15.c │ │ │ ├── arm_mat_add_q31.c │ │ │ ├── arm_mat_init_f32.c │ │ │ ├── arm_mat_init_q15.c │ │ │ ├── arm_mat_init_q31.c │ │ │ ├── arm_mat_inverse_f32.c │ │ │ ├── arm_mat_mult_f32.c │ │ │ ├── arm_mat_mult_fast_q15.c │ │ │ ├── arm_mat_mult_fast_q31.c │ │ │ ├── arm_mat_mult_q15.c │ │ │ ├── arm_mat_mult_q31.c │ │ │ ├── arm_mat_scale_f32.c │ │ │ ├── arm_mat_scale_q15.c │ │ │ ├── arm_mat_scale_q31.c │ │ │ ├── arm_mat_sub_f32.c │ │ │ ├── arm_mat_sub_q15.c │ │ │ ├── arm_mat_sub_q31.c │ │ │ ├── arm_mat_trans_f32.c │ │ │ ├── arm_mat_trans_q15.c │ │ │ └── arm_mat_trans_q31.c │ │ │ ├── StatisticsFunctions │ │ │ ├── arm_max_f32.c │ │ │ ├── arm_max_q15.c │ │ │ ├── arm_max_q31.c │ │ │ ├── arm_max_q7.c │ │ │ ├── arm_mean_f32.c │ │ │ ├── arm_mean_q15.c │ │ │ ├── arm_mean_q31.c │ │ │ ├── arm_mean_q7.c │ │ │ ├── arm_min_f32.c │ │ │ ├── arm_min_q15.c │ │ │ ├── arm_min_q31.c │ │ │ ├── arm_min_q7.c │ │ │ ├── arm_power_f32.c │ │ │ ├── arm_power_q15.c │ │ │ ├── arm_power_q31.c │ │ │ ├── arm_power_q7.c │ │ │ ├── arm_rms_f32.c │ │ │ ├── arm_rms_q15.c │ │ │ ├── arm_rms_q31.c │ │ │ ├── arm_std_f32.c │ │ │ ├── arm_std_q15.c │ │ │ ├── arm_std_q31.c │ │ │ ├── arm_var_f32.c │ │ │ ├── arm_var_q15.c │ │ │ └── arm_var_q31.c │ │ │ ├── SupportFunctions │ │ │ ├── arm_copy_f32.c │ │ │ ├── arm_copy_q15.c │ │ │ ├── arm_copy_q31.c │ │ │ ├── arm_copy_q7.c │ │ │ ├── arm_fill_f32.c │ │ │ ├── arm_fill_q15.c │ │ │ ├── arm_fill_q31.c │ │ │ ├── arm_fill_q7.c │ │ │ ├── arm_float_to_q15.c │ │ │ ├── arm_float_to_q31.c │ │ │ ├── arm_float_to_q7.c │ │ │ ├── arm_q15_to_float.c │ │ │ ├── arm_q15_to_q31.c │ │ │ ├── arm_q15_to_q7.c │ │ │ ├── arm_q31_to_float.c │ │ │ ├── arm_q31_to_q15.c │ │ │ ├── arm_q31_to_q7.c │ │ │ ├── arm_q7_to_float.c │ │ │ ├── arm_q7_to_q15.c │ │ │ └── arm_q7_to_q31.c │ │ │ └── TransformFunctions │ │ │ ├── arm_cfft_radix4_f32.c │ │ │ ├── arm_cfft_radix4_init_f32.c │ │ │ ├── arm_cfft_radix4_init_q15.c │ │ │ ├── arm_cfft_radix4_init_q31.c │ │ │ ├── arm_cfft_radix4_q15.c │ │ │ ├── arm_cfft_radix4_q31.c │ │ │ ├── arm_dct4_f32.c │ │ │ ├── arm_dct4_init_f32.c │ │ │ ├── arm_dct4_init_q15.c │ │ │ ├── arm_dct4_init_q31.c │ │ │ ├── arm_dct4_q15.c │ │ │ ├── arm_dct4_q31.c │ │ │ ├── arm_rfft_f32.c │ │ │ ├── arm_rfft_init_f32.c │ │ │ ├── arm_rfft_init_q15.c │ │ │ ├── arm_rfft_init_q31.c │ │ │ ├── arm_rfft_q15.c │ │ │ └── arm_rfft_q31.c │ ├── Include │ │ ├── arm_common_tables.h │ │ ├── arm_math.h │ │ ├── core_cm0.h │ │ ├── core_cm3.h │ │ ├── core_cm4.h │ │ ├── core_cm4_simd.h │ │ ├── core_cmFunc.h │ │ └── core_cmInstr.h │ ├── README.txt │ └── ST │ │ └── STM32F4xx │ │ ├── Include │ │ ├── stm32f4xx.h │ │ └── system_stm32f4xx.h │ │ ├── Release_Notes.html │ │ └── Source │ │ └── Templates │ │ ├── TASKING │ │ └── cstart_thumb2.asm │ │ ├── TrueSTUDIO │ │ └── startup_stm32f4xx.s │ │ ├── arm │ │ └── startup_stm32f4xx.s │ │ ├── gcc_ride7 │ │ └── startup_stm32f4xx.s │ │ ├── iar │ │ └── startup_stm32f4xx.s │ │ └── system_stm32f4xx.c ├── FatFS │ └── src │ │ ├── 00readme.txt │ │ ├── diskio.c │ │ ├── diskio.h │ │ ├── ff.c │ │ ├── ff.h │ │ ├── ffconf.h │ │ ├── integer.h │ │ └── option │ │ ├── cc932.c │ │ ├── cc936.c │ │ ├── cc949.c │ │ ├── cc950.c │ │ ├── ccsbcs.c │ │ ├── syscall.c │ │ └── unicode.c ├── SConscript ├── STM32F4xx_StdPeriph_Driver │ ├── Release_Notes.html │ ├── inc │ │ ├── misc.h │ │ ├── stm32f4xx_adc.h │ │ ├── stm32f4xx_can.h │ │ ├── stm32f4xx_crc.h │ │ ├── stm32f4xx_cryp.h │ │ ├── stm32f4xx_dac.h │ │ ├── stm32f4xx_dbgmcu.h │ │ ├── stm32f4xx_dcmi.h │ │ ├── stm32f4xx_dma.h │ │ ├── stm32f4xx_exti.h │ │ ├── stm32f4xx_flash.h │ │ ├── stm32f4xx_fsmc.h │ │ ├── stm32f4xx_gpio.h │ │ ├── stm32f4xx_hash.h │ │ ├── stm32f4xx_i2c.h │ │ ├── stm32f4xx_iwdg.h │ │ ├── stm32f4xx_pwr.h │ │ ├── stm32f4xx_rcc.h │ │ ├── stm32f4xx_rng.h │ │ ├── stm32f4xx_rtc.h │ │ ├── stm32f4xx_sdio.h │ │ ├── stm32f4xx_spi.h │ │ ├── stm32f4xx_syscfg.h │ │ ├── stm32f4xx_tim.h │ │ ├── stm32f4xx_usart.h │ │ └── stm32f4xx_wwdg.h │ └── src │ │ ├── misc.c │ │ ├── stm32f4xx_adc.c │ │ ├── stm32f4xx_can.c │ │ ├── stm32f4xx_crc.c │ │ ├── stm32f4xx_cryp.c │ │ ├── stm32f4xx_cryp_aes.c │ │ ├── stm32f4xx_cryp_des.c │ │ ├── stm32f4xx_cryp_tdes.c │ │ ├── stm32f4xx_dac.c │ │ ├── stm32f4xx_dbgmcu.c │ │ ├── stm32f4xx_dcmi.c │ │ ├── stm32f4xx_dma.c │ │ ├── stm32f4xx_exti.c │ │ ├── stm32f4xx_flash.c │ │ ├── stm32f4xx_fsmc.c │ │ ├── stm32f4xx_gpio.c │ │ ├── stm32f4xx_hash.c │ │ ├── stm32f4xx_hash_md5.c │ │ ├── stm32f4xx_hash_sha1.c │ │ ├── stm32f4xx_i2c.c │ │ ├── stm32f4xx_iwdg.c │ │ ├── stm32f4xx_pwr.c │ │ ├── stm32f4xx_rcc.c │ │ ├── stm32f4xx_rng.c │ │ ├── stm32f4xx_rtc.c │ │ ├── stm32f4xx_sdio.c │ │ ├── stm32f4xx_spi.c │ │ ├── stm32f4xx_syscfg.c │ │ ├── stm32f4xx_tim.c │ │ ├── stm32f4xx_usart.c │ │ └── stm32f4xx_wwdg.c └── USBStack │ ├── INC │ ├── RTL.h │ ├── rl_usb.h │ ├── usb.h │ ├── usb_cdc.h │ ├── usb_def.h │ ├── usb_for_lib.h │ ├── usb_hid.h │ ├── usb_lib.c │ ├── usb_lib.h │ ├── usb_msc.h │ ├── usbd_cdc.h │ ├── usbd_cdc_acm.h │ ├── usbd_core.h │ ├── usbd_core_cdc.h │ ├── usbd_core_hid.h │ ├── usbd_core_msc.h │ ├── usbd_desc.h │ ├── usbd_event.h │ ├── usbd_hid.h │ ├── usbd_hw.h │ ├── usbd_lib_cdc.h │ ├── usbd_lib_hid.h │ ├── usbd_lib_msc.h │ └── usbd_msc.h │ └── SRC │ ├── usbd_cdc_acm.c │ ├── usbd_core.c │ ├── usbd_core_cdc.c │ ├── usbd_core_hid.c │ ├── usbd_core_msc.c │ ├── usbd_hid.c │ └── usbd_msc.c ├── README.md ├── RTE └── _Anopilot │ └── RTE_Components.h ├── TEST.ANO ├── applications ├── PID.c ├── PID.h ├── anotc_baro_ctrl.c ├── anotc_baro_ctrl.h ├── ctrl.c ├── ctrl.h ├── data_transfer.c ├── data_transfer.h ├── data_transfer.h.orig ├── filter.c ├── filter.h ├── fly_mode.c ├── fly_mode.h ├── height_ctrl.c ├── height_ctrl.h ├── imu.c ├── imu.h ├── include.h ├── init.c ├── init.h ├── main.c ├── mymath.c ├── mymath.h ├── parameter.c ├── parameter.h ├── rc.c ├── rc.h ├── scheduler.c ├── scheduler.h ├── stm32f4xx_conf.h ├── stm32f4xx_it.c ├── usb_config.c ├── usbd_user_hid.c ├── usbd_user_hid.h ├── usbd_user_msc.c ├── version.c └── version.h ├── build ├── F407_FC.hex └── F407_FC.sct ├── clear编译完的东西.bat ├── doc ├── note.txt └── record.txt └── drivers ├── ak8975.c ├── ak8975.h ├── drv_w25qxx.c ├── drv_w25qxx.h ├── i2c_soft.c ├── i2c_soft.h ├── led.c ├── led.h ├── mpu6050.c ├── mpu6050.c.orig ├── mpu6050.h ├── ms5611.c ├── ms5611.h ├── pwm_in.c ├── pwm_in.h ├── pwm_out.c ├── pwm_out.h ├── time.c ├── time.h ├── ultrasonic.c ├── ultrasonic.h ├── usart.c ├── usart.h └── usbd_STM32F4xx_FS.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.bak 2 | *.ddk 3 | *.edk 4 | *.lst 5 | *.lnp 6 | *.mpf 7 | *.mpj 8 | *.obj 9 | *.omf 10 | *.plg 11 | *.rpt 12 | *.tmp 13 | *.__i 14 | *.crf 15 | *.o 16 | *.d 17 | *.axf 18 | *.tra 19 | *.dep 20 | JLinkLog.txt 21 | 22 | *.iex 23 | *.htm 24 | *.map 25 | -------------------------------------------------------------------------------- /DebugConfig/Anopilot_STM32F407VG.dbgconf: -------------------------------------------------------------------------------- 1 | // <<< Use Configuration Wizard in Context Menu >>> 2 | 3 | // Debug MCU Configuration 4 | // DBG_SLEEP Debug Sleep Mode 5 | // DBG_STOP Debug Stop Mode 6 | // DBG_STANDBY Debug Standby Mode 7 | // 8 | DbgMCU_CR = 0x00000007; 9 | 10 | // Debug MCU APB1 Freeze 11 | // DBG_TIM2_STOP Timer 2 Stopped when Core is halted 12 | // DBG_TIM3_STOP Timer 3 Stopped when Core is halted 13 | // DBG_TIM4_STOP Timer 4 Stopped when Core is halted 14 | // DBG_TIM5_STOP Timer 5 Stopped when Core is halted 15 | // DBG_TIM6_STOP Timer 6 Stopped when Core is halted 16 | // DBG_TIM7_STOP Timer 7 Stopped when Core is halted 17 | // DBG_TIM12_STOP Timer 12 Stopped when Core is halted 18 | // DBG_TIM13_STOP Timer 13 Stopped when Core is halted 19 | // DBG_TIM14_STOP Timer 14 Stopped when Core is halted 20 | // DBG_RTC_STOP RTC Stopped when Core is halted 21 | // DBG_WWDG_STOP Window Watchdog Stopped when Core is halted 22 | // DBG_IWDG_STOP Independent Watchdog Stopped when Core is halted 23 | // DBG_I2C1_SMBUS_TIMEOUT I2C1 SMBUS Timeout Mode Stopped when Core is halted 24 | // DBG_I2C2_SMBUS_TIMEOUT I2C2 SMBUS Timeout Mode Stopped when Core is halted 25 | // DBG_I2C3_SMBUS_TIMEOUT I2C3 SMBUS Timeout Mode Stopped when Core is halted 26 | // DBG_CAN1_STOP CAN1 Stopped when Core is halted 27 | // DBG_CAN2_STOP CAN2 Stopped when Core is halted 28 | // 29 | DbgMCU_APB1_Fz = 0x00000000; 30 | 31 | 32 | // Debug MCU APB2 Freeze 33 | // DBG_TIM1_STOP Timer 1 Stopped when Core is halted 34 | // DBG_TIM8_STOP Timer 8 Stopped when Core is halted 35 | // DBG_TIM9_STOP Timer 9 Stopped when Core is halted 36 | // DBG_TIM10_STOP Timer 10 Stopped when Core is halted 37 | // DBG_TIM11_STOP Timer 11 Stopped when Core is halted 38 | // 39 | DbgMCU_APB2_Fz = 0x00000000; 40 | 41 | // <<< end of configuration section >>> -------------------------------------------------------------------------------- /JLinkSettings.ini: -------------------------------------------------------------------------------- 1 | [BREAKPOINTS] 2 | ShowInfoWin = 1 3 | EnableFlashBP = 2 4 | BPDuringExecution = 0 5 | [CFI] 6 | CFISize = 0x00 7 | CFIAddr = 0x00 8 | [CPU] 9 | OverrideMemMap = 0 10 | AllowSimulation = 1 11 | ScriptFile="" 12 | [FLASH] 13 | CacheExcludeSize = 0x00 14 | CacheExcludeAddr = 0x00 15 | MinNumBytesFlashDL = 0 16 | SkipProgOnCRCMatch = 1 17 | VerifyDownload = 1 18 | AllowCaching = 1 19 | EnableFlashDL = 2 20 | Override = 0 21 | Device="UNSPECIFIED" 22 | [GENERAL] 23 | WorkRAMSize = 0x00 24 | WorkRAMAddr = 0x00 25 | RAMUsageLimit = 0x00 26 | [SWO] 27 | SWOLogFile="" 28 | [MEM] 29 | RdOverrideOrMask = 0x00 30 | RdOverrideAndMask = 0xFFFFFFFF 31 | RdOverrideAddr = 0xFFFFFFFF 32 | WrOverrideOrMask = 0x00 33 | WrOverrideAndMask = 0xFFFFFFFF 34 | WrOverrideAddr = 0xFFFFFFFF 35 | -------------------------------------------------------------------------------- /Libraries/CMSIS/CMSIS END USER LICENCE AGREEMENT.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stulwd/Copter/126921b596dd64fe0527816fa0b4425fb100bfca/Libraries/CMSIS/CMSIS END USER LICENCE AGREEMENT.pdf -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/ARM/arm_cortexMx_math_Build.bat: -------------------------------------------------------------------------------- 1 | 2 | SET TMP=C:\Temp 3 | SET TEMP=C:\Temp 4 | 5 | SET UVEXE=C:\Keil\UV4\UV4.EXE 6 | 7 | %UVEXE% -rb arm_cortexM0x_math.uvproj -t"DSP_Lib CM0 LE" -o"DSP_Lib CM0 LE.txt" 8 | %UVEXE% -rb arm_cortexM0x_math.uvproj -t"DSP_Lib CM0 BE" -o"DSP_Lib CM0 BE.txt" 9 | %UVEXE% -rb arm_cortexM3x_math.uvproj -t"DSP_Lib CM3 LE" -o"DSP_Lib CM3 LE.txt" 10 | %UVEXE% -rb arm_cortexM3x_math.uvproj -t"DSP_Lib CM3 BE" -o"DSP_Lib CM3 BE.txt" 11 | %UVEXE% -rb arm_cortexM4x_math.uvproj -t"DSP_Lib CM4 LE" -o"DSP_Lib CM4 LE.txt" 12 | %UVEXE% -rb arm_cortexM4x_math.uvproj -t"DSP_Lib CM4 BE" -o"DSP_Lib CM4 BE.txt" 13 | %UVEXE% -rb arm_cortexM4x_math.uvproj -t"DSP_Lib CM4 LE FPU" -o"DSP_Lib CM4 LE FPU.txt" 14 | %UVEXE% -rb arm_cortexM4x_math.uvproj -t"DSP_Lib CM4 BE FPU" -o"DSP_Lib CM4 BE FPU.txt" -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/BasicMathFunctions/arm_negate_f32.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_negate_f32.c 9 | * 10 | * Description: Negates floating-point vectors. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------- */ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupMath 37 | */ 38 | 39 | /** 40 | * @defgroup negate Vector Negate 41 | * 42 | * Negates the elements of a vector. 43 | * 44 | *
   
 45 |  *     pDst[n] = -pSrc[n],   0 <= n < blockSize.   
 46 |  * 
47 | */ 48 | 49 | /** 50 | * @addtogroup negate 51 | * @{ 52 | */ 53 | 54 | /** 55 | * @brief Negates the elements of a floating-point vector. 56 | * @param[in] *pSrc points to the input vector 57 | * @param[out] *pDst points to the output vector 58 | * @param[in] blockSize number of samples in the vector 59 | * @return none. 60 | */ 61 | 62 | void arm_negate_f32( 63 | float32_t * pSrc, 64 | float32_t * pDst, 65 | uint32_t blockSize) 66 | { 67 | uint32_t blkCnt; /* loop counter */ 68 | 69 | 70 | #ifndef ARM_MATH_CM0 71 | 72 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 73 | /*loop Unrolling */ 74 | blkCnt = blockSize >> 2u; 75 | 76 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 77 | ** a second loop below computes the remaining 1 to 3 samples. */ 78 | while(blkCnt > 0u) 79 | { 80 | /* C = -A */ 81 | /* Negate and then store the results in the destination buffer. */ 82 | *pDst++ = -*pSrc++; 83 | *pDst++ = -*pSrc++; 84 | *pDst++ = -*pSrc++; 85 | *pDst++ = -*pSrc++; 86 | 87 | /* Decrement the loop counter */ 88 | blkCnt--; 89 | } 90 | 91 | /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 92 | ** No loop unrolling is used. */ 93 | blkCnt = blockSize % 0x4u; 94 | 95 | #else 96 | 97 | /* Run the below code for Cortex-M0 */ 98 | 99 | /* Initialize blkCnt with number of samples */ 100 | blkCnt = blockSize; 101 | 102 | #endif /* #ifndef ARM_MATH_CM0 */ 103 | 104 | while(blkCnt > 0u) 105 | { 106 | /* C = -A */ 107 | /* Negate and then store the results in the destination buffer. */ 108 | *pDst++ = -*pSrc++; 109 | 110 | /* Decrement the loop counter */ 111 | blkCnt--; 112 | } 113 | } 114 | 115 | /** 116 | * @} end of negate group 117 | */ 118 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/ControllerFunctions/arm_pid_init_f32.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_pid_init_f32.c 9 | * 10 | * Description: Floating-point PID Control initialization function 11 | * 12 | * 13 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 14 | * 15 | * Version 1.0.10 2011/7/15 16 | * Big Endian support added and Merged M0 and M3/M4 Source code. 17 | * 18 | * Version 1.0.3 2010/11/29 19 | * Re-organized the CMSIS folders and updated documentation. 20 | * 21 | * Version 1.0.2 2010/11/11 22 | * Documentation updated. 23 | * 24 | * Version 1.0.1 2010/10/05 25 | * Production release and review comments incorporated. 26 | * 27 | * Version 1.0.0 2010/09/20 28 | * Production release and review comments incorporated. 29 | * ------------------------------------------------------------------- */ 30 | 31 | #include "arm_math.h" 32 | 33 | /** 34 | * @addtogroup PID 35 | * @{ 36 | */ 37 | 38 | /** 39 | * @brief Initialization function for the floating-point PID Control. 40 | * @param[in,out] *S points to an instance of the PID structure. 41 | * @param[in] resetStateFlag flag to reset the state. 0 = no change in state & 1 = reset the state. 42 | * @return none. 43 | * \par Description: 44 | * \par 45 | * The resetStateFlag specifies whether to set state to zero or not. \n 46 | * The function computes the structure fields: A0, A1 A2 47 | * using the proportional gain( \c Kp), integral gain( \c Ki) and derivative gain( \c Kd) 48 | * also sets the state variables to all zeros. 49 | */ 50 | 51 | void arm_pid_init_f32( 52 | arm_pid_instance_f32 * S, 53 | int32_t resetStateFlag) 54 | { 55 | 56 | /* Derived coefficient A0 */ 57 | S->A0 = S->Kp + S->Ki + S->Kd; 58 | 59 | /* Derived coefficient A1 */ 60 | S->A1 = (-S->Kp) - ((float32_t) 2.0 * S->Kd); 61 | 62 | /* Derived coefficient A2 */ 63 | S->A2 = S->Kd; 64 | 65 | /* Check whether state needs reset or not */ 66 | if(resetStateFlag) 67 | { 68 | /* Clear the state buffer. The size will be always 3 samples */ 69 | memset(S->state, 0, 3u * sizeof(float32_t)); 70 | } 71 | 72 | } 73 | 74 | /** 75 | * @} end of PID group 76 | */ 77 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/ControllerFunctions/arm_pid_init_q15.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_pid_init_q15.c 9 | * 10 | * Description: Q15 PID Control initialization function 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * -------------------------------------------------------------------- */ 29 | 30 | #include "arm_math.h" 31 | 32 | /** 33 | * @addtogroup PID 34 | * @{ 35 | */ 36 | 37 | /** 38 | * @details 39 | * @param[in,out] *S points to an instance of the Q15 PID structure. 40 | * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state. 41 | * @return none. 42 | * \par Description: 43 | * \par 44 | * The resetStateFlag specifies whether to set state to zero or not. \n 45 | * The function computes the structure fields: A0, A1 A2 46 | * using the proportional gain( \c Kp), integral gain( \c Ki) and derivative gain( \c Kd) 47 | * also sets the state variables to all zeros. 48 | */ 49 | 50 | void arm_pid_init_q15( 51 | arm_pid_instance_q15 * S, 52 | int32_t resetStateFlag) 53 | { 54 | 55 | #ifndef ARM_MATH_CM0 56 | 57 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 58 | 59 | /* Derived coefficient A0 */ 60 | S->A0 = __QADD16(__QADD16(S->Kp, S->Ki), S->Kd); 61 | 62 | /* Derived coefficients and pack into A1 */ 63 | 64 | #ifndef ARM_MATH_BIG_ENDIAN 65 | 66 | S->A1 = __PKHBT(-__QADD16(__QADD16(S->Kd, S->Kd), S->Kp), S->Kd, 16); 67 | 68 | #else 69 | 70 | S->A1 = __PKHBT(S->Kd, -__QADD16(__QADD16(S->Kd, S->Kd), S->Kp), 16); 71 | 72 | #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ 73 | 74 | /* Check whether state needs reset or not */ 75 | if(resetStateFlag) 76 | { 77 | /* Clear the state buffer. The size will be always 3 samples */ 78 | memset(S->state, 0, 3u * sizeof(q15_t)); 79 | } 80 | 81 | #else 82 | 83 | /* Run the below code for Cortex-M0 */ 84 | 85 | q31_t temp; /*to store the sum */ 86 | 87 | /* Derived coefficient A0 */ 88 | temp = S->Kp + S->Ki + S->Kd; 89 | S->A0 = (q15_t) __SSAT(temp, 16); 90 | 91 | /* Derived coefficients and pack into A1 */ 92 | temp = -(S->Kd + S->Kd + S->Kp); 93 | S->A1 = (q15_t) __SSAT(temp, 16); 94 | S->A2 = S->Kd; 95 | 96 | 97 | 98 | /* Check whether state needs reset or not */ 99 | if(resetStateFlag) 100 | { 101 | /* Clear the state buffer. The size will be always 3 samples */ 102 | memset(S->state, 0, 3u * sizeof(q15_t)); 103 | } 104 | 105 | #endif /* #ifndef ARM_MATH_CM0 */ 106 | 107 | } 108 | 109 | /** 110 | * @} end of PID group 111 | */ 112 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/ControllerFunctions/arm_pid_init_q31.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_pid_init_q31.c 9 | * 10 | * Description: Q31 PID Control initialization function 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * ------------------------------------------------------------------- */ 29 | 30 | #include "arm_math.h" 31 | 32 | /** 33 | * @addtogroup PID 34 | * @{ 35 | */ 36 | 37 | /** 38 | * @brief Initialization function for the Q31 PID Control. 39 | * @param[in,out] *S points to an instance of the Q31 PID structure. 40 | * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state. 41 | * @return none. 42 | * \par Description: 43 | * \par 44 | * The resetStateFlag specifies whether to set state to zero or not. \n 45 | * The function computes the structure fields: A0, A1 A2 46 | * using the proportional gain( \c Kp), integral gain( \c Ki) and derivative gain( \c Kd) 47 | * also sets the state variables to all zeros. 48 | */ 49 | 50 | void arm_pid_init_q31( 51 | arm_pid_instance_q31 * S, 52 | int32_t resetStateFlag) 53 | { 54 | 55 | #ifndef ARM_MATH_CM0 56 | 57 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 58 | 59 | /* Derived coefficient A0 */ 60 | S->A0 = __QADD(__QADD(S->Kp, S->Ki), S->Kd); 61 | 62 | /* Derived coefficient A1 */ 63 | S->A1 = -__QADD(__QADD(S->Kd, S->Kd), S->Kp); 64 | 65 | 66 | #else 67 | 68 | /* Run the below code for Cortex-M0 */ 69 | 70 | q31_t temp; 71 | 72 | /* Derived coefficient A0 */ 73 | temp = clip_q63_to_q31((q63_t) S->Kp + S->Ki); 74 | S->A0 = clip_q63_to_q31((q63_t) temp + S->Kd); 75 | 76 | /* Derived coefficient A1 */ 77 | temp = clip_q63_to_q31((q63_t) S->Kd + S->Kd); 78 | S->A1 = -clip_q63_to_q31((q63_t) temp + S->Kp); 79 | 80 | #endif /* #ifndef ARM_MATH_CM0 */ 81 | 82 | /* Derived coefficient A2 */ 83 | S->A2 = S->Kd; 84 | 85 | /* Check whether state needs reset or not */ 86 | if(resetStateFlag) 87 | { 88 | /* Clear the state buffer. The size will be always 3 samples */ 89 | memset(S->state, 0, 3u * sizeof(q31_t)); 90 | } 91 | 92 | } 93 | 94 | /** 95 | * @} end of PID group 96 | */ 97 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/ControllerFunctions/arm_pid_reset_f32.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_pid_reset_f32.c 9 | * 10 | * Description: Floating-point PID Control reset function 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * ------------------------------------------------------------------- */ 29 | 30 | #include "arm_math.h" 31 | 32 | /** 33 | * @addtogroup PID 34 | * @{ 35 | */ 36 | 37 | /** 38 | * @brief Reset function for the floating-point PID Control. 39 | * @param[in] *S Instance pointer of PID control data structure. 40 | * @return none. 41 | * \par Description: 42 | * The function resets the state buffer to zeros. 43 | */ 44 | void arm_pid_reset_f32( 45 | arm_pid_instance_f32 * S) 46 | { 47 | 48 | /* Clear the state buffer. The size will be always 3 samples */ 49 | memset(S->state, 0, 3u * sizeof(float32_t)); 50 | } 51 | 52 | /** 53 | * @} end of PID group 54 | */ 55 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/ControllerFunctions/arm_pid_reset_q15.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_pid_reset_q15.c 9 | * 10 | * Description: Q15 PID Control reset function 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * -------------------------------------------------------------------- */ 29 | 30 | #include "arm_math.h" 31 | 32 | /** 33 | * @addtogroup PID 34 | * @{ 35 | */ 36 | 37 | /** 38 | * @brief Reset function for the Q15 PID Control. 39 | * @param[in] *S Instance pointer of PID control data structure. 40 | * @return none. 41 | * \par Description: 42 | * The function resets the state buffer to zeros. 43 | */ 44 | void arm_pid_reset_q15( 45 | arm_pid_instance_q15 * S) 46 | { 47 | /* Reset state to zero, The size will be always 3 samples */ 48 | memset(S->state, 0, 3u * sizeof(q15_t)); 49 | } 50 | 51 | /** 52 | * @} end of PID group 53 | */ 54 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/ControllerFunctions/arm_pid_reset_q31.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_pid_reset_q31.c 9 | * 10 | * Description: Q31 PID Control reset function 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * ------------------------------------------------------------------- */ 29 | 30 | #include "arm_math.h" 31 | 32 | /** 33 | * @addtogroup PID 34 | * @{ 35 | */ 36 | 37 | /** 38 | * @brief Reset function for the Q31 PID Control. 39 | * @param[in] *S Instance pointer of PID control data structure. 40 | * @return none. 41 | * \par Description: 42 | * The function resets the state buffer to zeros. 43 | */ 44 | void arm_pid_reset_q31( 45 | arm_pid_instance_q31 * S) 46 | { 47 | 48 | /* Clear the state buffer. The size will be always 3 samples */ 49 | memset(S->state, 0, 3u * sizeof(q31_t)); 50 | } 51 | 52 | /** 53 | * @} end of PID group 54 | */ 55 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_biquad_cascade_df2T_init_f32.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_biquad_cascade_df2T_init_f32.c 9 | * 10 | * Description: Initialization function for the floating-point transposed 11 | * direct form II Biquad cascade filter. 12 | * 13 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 14 | * 15 | * Version 1.0.10 2011/7/15 16 | * Big Endian support added and Merged M0 and M3/M4 Source code. 17 | * 18 | * Version 1.0.3 2010/11/29 19 | * Re-organized the CMSIS folders and updated documentation. 20 | * 21 | * Version 1.0.2 2010/11/11 22 | * Documentation updated. 23 | * 24 | * Version 1.0.1 2010/10/05 25 | * Production release and review comments incorporated. 26 | * 27 | * Version 1.0.0 2010/09/20 28 | * Production release and review comments incorporated 29 | * 30 | * Version 0.0.7 2010/06/10 31 | * Misra-C changes done 32 | * ---------------------------------------------------------------------------*/ 33 | 34 | #include "arm_math.h" 35 | 36 | /** 37 | * @ingroup groupFilters 38 | */ 39 | 40 | /** 41 | * @addtogroup BiquadCascadeDF2T 42 | * @{ 43 | */ 44 | 45 | /** 46 | * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. 47 | * @param[in,out] *S points to an instance of the filter data structure. 48 | * @param[in] numStages number of 2nd order stages in the filter. 49 | * @param[in] *pCoeffs points to the filter coefficients. 50 | * @param[in] *pState points to the state buffer. 51 | * @return none 52 | * 53 | * Coefficient and State Ordering: 54 | * \par 55 | * The coefficients are stored in the array pCoeffs in the following order: 56 | *
   
57 |  *     {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}   
58 |  * 
59 | * 60 | * \par 61 | * where b1x and a1x are the coefficients for the first stage, 62 | * b2x and a2x are the coefficients for the second stage, 63 | * and so on. The pCoeffs array contains a total of 5*numStages values. 64 | * 65 | * \par 66 | * The pState is a pointer to state array. 67 | * Each Biquad stage has 2 state variables d1, and d2. 68 | * The 2 state variables for stage 1 are first, then the 2 state variables for stage 2, and so on. 69 | * The state array has a total length of 2*numStages values. 70 | * The state variables are updated after each block of data is processed; the coefficients are untouched. 71 | */ 72 | 73 | void arm_biquad_cascade_df2T_init_f32( 74 | arm_biquad_cascade_df2T_instance_f32 * S, 75 | uint8_t numStages, 76 | float32_t * pCoeffs, 77 | float32_t * pState) 78 | { 79 | /* Assign filter stages */ 80 | S->numStages = numStages; 81 | 82 | /* Assign coefficient pointer */ 83 | S->pCoeffs = pCoeffs; 84 | 85 | /* Clear state buffer and size is always 2 * numStages */ 86 | memset(pState, 0, (2u * (uint32_t) numStages) * sizeof(float32_t)); 87 | 88 | /* Assign state pointer */ 89 | S->pState = pState; 90 | } 91 | 92 | /** 93 | * @} end of BiquadCascadeDF2T group 94 | */ 95 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_fir_init_f32.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_fir_init_f32.c 9 | * 10 | * Description: Floating-point FIR filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * 29 | * Version 0.0.5 2010/04/26 30 | * incorporated review comments and updated with latest CMSIS layer 31 | * 32 | * Version 0.0.3 2010/03/10 33 | * Initial version 34 | * ---------------------------------------------------------------------------*/ 35 | 36 | #include "arm_math.h" 37 | 38 | /** 39 | * @ingroup groupFilters 40 | */ 41 | 42 | /** 43 | * @addtogroup FIR 44 | * @{ 45 | */ 46 | 47 | /** 48 | * @details 49 | * 50 | * @param[in,out] *S points to an instance of the floating-point FIR filter structure. 51 | * @param[in] numTaps Number of filter coefficients in the filter. 52 | * @param[in] *pCoeffs points to the filter coefficients buffer. 53 | * @param[in] *pState points to the state buffer. 54 | * @param[in] blockSize number of samples that are processed per call. 55 | * @return none. 56 | * 57 | * Description: 58 | * \par 59 | * pCoeffs points to the array of filter coefficients stored in time reversed order: 60 | *
   
61 |  *    {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}   
62 |  * 
63 | * \par 64 | * pState points to the array of state variables. 65 | * pState is of length numTaps+blockSize-1 samples, where blockSize is the number of input samples processed by each call to arm_fir_f32(). 66 | */ 67 | 68 | void arm_fir_init_f32( 69 | arm_fir_instance_f32 * S, 70 | uint16_t numTaps, 71 | float32_t * pCoeffs, 72 | float32_t * pState, 73 | uint32_t blockSize) 74 | { 75 | /* Assign filter taps */ 76 | S->numTaps = numTaps; 77 | 78 | /* Assign coefficient pointer */ 79 | S->pCoeffs = pCoeffs; 80 | 81 | /* Clear state buffer and the size of state buffer is (blockSize + numTaps - 1) */ 82 | memset(pState, 0, (numTaps + (blockSize - 1u)) * sizeof(float32_t)); 83 | 84 | /* Assign state pointer */ 85 | S->pState = pState; 86 | 87 | } 88 | 89 | /** 90 | * @} end of FIR group 91 | */ 92 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_fir_init_q31.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_fir_init_q31.c 9 | * 10 | * Description: Q31 FIR filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * 29 | * Version 0.0.5 2010/04/26 30 | * incorporated review comments and updated with latest CMSIS layer 31 | * 32 | * Version 0.0.3 2010/03/10 33 | * Initial version 34 | * -------------------------------------------------------------------- */ 35 | 36 | #include "arm_math.h" 37 | 38 | /** 39 | * @ingroup groupFilters 40 | */ 41 | 42 | /** 43 | * @addtogroup FIR 44 | * @{ 45 | */ 46 | 47 | /** 48 | * @details 49 | * 50 | * @param[in,out] *S points to an instance of the Q31 FIR filter structure. 51 | * @param[in] numTaps Number of filter coefficients in the filter. 52 | * @param[in] *pCoeffs points to the filter coefficients buffer. 53 | * @param[in] *pState points to the state buffer. 54 | * @param[in] blockSize number of samples that are processed per call. 55 | * @return none. 56 | * 57 | * Description: 58 | * \par 59 | * pCoeffs points to the array of filter coefficients stored in time reversed order: 60 | *
   
61 |  *    {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}   
62 |  * 
63 | * \par 64 | * pState points to the array of state variables. 65 | * pState is of length numTaps+blockSize-1 samples, where blockSize is the number of input samples processed by each call to arm_fir_q31(). 66 | */ 67 | 68 | void arm_fir_init_q31( 69 | arm_fir_instance_q31 * S, 70 | uint16_t numTaps, 71 | q31_t * pCoeffs, 72 | q31_t * pState, 73 | uint32_t blockSize) 74 | { 75 | /* Assign filter taps */ 76 | S->numTaps = numTaps; 77 | 78 | /* Assign coefficient pointer */ 79 | S->pCoeffs = pCoeffs; 80 | 81 | /* Clear state buffer and state array size is (blockSize + numTaps - 1) */ 82 | memset(pState, 0, (blockSize + ((uint32_t) numTaps - 1u)) * sizeof(q31_t)); 83 | 84 | /* Assign state pointer */ 85 | S->pState = pState; 86 | 87 | } 88 | 89 | /** 90 | * @} end of FIR group 91 | */ 92 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_fir_init_q7.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_fir_init_q7.c 9 | * 10 | * Description: Q7 FIR filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * 29 | * Version 0.0.5 2010/04/26 30 | * incorporated review comments and updated with latest CMSIS layer 31 | * 32 | * Version 0.0.3 2010/03/10 33 | * Initial version 34 | * ------------------------------------------------------------------- */ 35 | 36 | #include "arm_math.h" 37 | 38 | /** 39 | * @ingroup groupFilters 40 | */ 41 | 42 | /** 43 | * @addtogroup FIR 44 | * @{ 45 | */ 46 | /** 47 | * @param[in,out] *S points to an instance of the Q7 FIR filter structure. 48 | * @param[in] numTaps Number of filter coefficients in the filter. 49 | * @param[in] *pCoeffs points to the filter coefficients buffer. 50 | * @param[in] *pState points to the state buffer. 51 | * @param[in] blockSize number of samples that are processed per call. 52 | * @return none 53 | * 54 | * Description: 55 | * \par 56 | * pCoeffs points to the array of filter coefficients stored in time reversed order: 57 | *
   
58 |  *    {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}   
59 |  * 
60 | * \par 61 | * pState points to the array of state variables. 62 | * pState is of length numTaps+blockSize-1 samples, where blockSize is the number of input samples processed by each call to arm_fir_q7(). 63 | */ 64 | 65 | void arm_fir_init_q7( 66 | arm_fir_instance_q7 * S, 67 | uint16_t numTaps, 68 | q7_t * pCoeffs, 69 | q7_t * pState, 70 | uint32_t blockSize) 71 | { 72 | 73 | /* Assign filter taps */ 74 | S->numTaps = numTaps; 75 | 76 | /* Assign coefficient pointer */ 77 | S->pCoeffs = pCoeffs; 78 | 79 | /* Clear the state buffer. The size is always (blockSize + numTaps - 1) */ 80 | memset(pState, 0, (numTaps + (blockSize - 1u)) * sizeof(q7_t)); 81 | 82 | /* Assign state pointer */ 83 | S->pState = pState; 84 | 85 | } 86 | 87 | /** 88 | * @} end of FIR group 89 | */ 90 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_fir_lattice_init_f32.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_fir_lattice_init_f32.c 9 | * 10 | * Description: Floating-point FIR Lattice filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------*/ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupFilters 37 | */ 38 | 39 | /** 40 | * @addtogroup FIR_Lattice 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Initialization function for the floating-point FIR lattice filter. 46 | * @param[in] *S points to an instance of the floating-point FIR lattice structure. 47 | * @param[in] numStages number of filter stages. 48 | * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages. 49 | * @param[in] *pState points to the state buffer. The array is of length numStages. 50 | * @return none. 51 | */ 52 | 53 | void arm_fir_lattice_init_f32( 54 | arm_fir_lattice_instance_f32 * S, 55 | uint16_t numStages, 56 | float32_t * pCoeffs, 57 | float32_t * pState) 58 | { 59 | /* Assign filter taps */ 60 | S->numStages = numStages; 61 | 62 | /* Assign coefficient pointer */ 63 | S->pCoeffs = pCoeffs; 64 | 65 | /* Clear state buffer and size is always numStages */ 66 | memset(pState, 0, (numStages) * sizeof(float32_t)); 67 | 68 | /* Assign state pointer */ 69 | S->pState = pState; 70 | 71 | } 72 | 73 | /** 74 | * @} end of FIR_Lattice group 75 | */ 76 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_fir_lattice_init_q15.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_fir_lattice_init_q15.c 9 | * 10 | * Description: Q15 FIR Lattice filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------*/ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupFilters 37 | */ 38 | 39 | /** 40 | * @addtogroup FIR_Lattice 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Initialization function for the Q15 FIR lattice filter. 46 | * @param[in] *S points to an instance of the Q15 FIR lattice structure. 47 | * @param[in] numStages number of filter stages. 48 | * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages. 49 | * @param[in] *pState points to the state buffer. The array is of length numStages. 50 | * @return none. 51 | */ 52 | 53 | void arm_fir_lattice_init_q15( 54 | arm_fir_lattice_instance_q15 * S, 55 | uint16_t numStages, 56 | q15_t * pCoeffs, 57 | q15_t * pState) 58 | { 59 | /* Assign filter taps */ 60 | S->numStages = numStages; 61 | 62 | /* Assign coefficient pointer */ 63 | S->pCoeffs = pCoeffs; 64 | 65 | /* Clear state buffer and size is always numStages */ 66 | memset(pState, 0, (numStages) * sizeof(q15_t)); 67 | 68 | /* Assign state pointer */ 69 | S->pState = pState; 70 | 71 | } 72 | 73 | /** 74 | * @} end of FIR_Lattice group 75 | */ 76 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_fir_lattice_init_q31.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_fir_lattice_init_q31.c 9 | * 10 | * Description: Q31 FIR lattice filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------*/ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupFilters 37 | */ 38 | 39 | /** 40 | * @addtogroup FIR_Lattice 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Initialization function for the Q31 FIR lattice filter. 46 | * @param[in] *S points to an instance of the Q31 FIR lattice structure. 47 | * @param[in] numStages number of filter stages. 48 | * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages. 49 | * @param[in] *pState points to the state buffer. The array is of length numStages. 50 | * @return none. 51 | */ 52 | 53 | void arm_fir_lattice_init_q31( 54 | arm_fir_lattice_instance_q31 * S, 55 | uint16_t numStages, 56 | q31_t * pCoeffs, 57 | q31_t * pState) 58 | { 59 | /* Assign filter taps */ 60 | S->numStages = numStages; 61 | 62 | /* Assign coefficient pointer */ 63 | S->pCoeffs = pCoeffs; 64 | 65 | /* Clear state buffer and size is always numStages */ 66 | memset(pState, 0, (numStages) * sizeof(q31_t)); 67 | 68 | /* Assign state pointer */ 69 | S->pState = pState; 70 | 71 | } 72 | 73 | /** 74 | * @} end of FIR_Lattice group 75 | */ 76 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_fir_sparse_init_f32.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_fir_sparse_init_f32.c 9 | * 10 | * Description: Floating-point sparse FIR filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------*/ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupFilters 37 | */ 38 | 39 | /** 40 | * @addtogroup FIR_Sparse 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Initialization function for the floating-point sparse FIR filter. 46 | * @param[in,out] *S points to an instance of the floating-point sparse FIR structure. 47 | * @param[in] numTaps number of nonzero coefficients in the filter. 48 | * @param[in] *pCoeffs points to the array of filter coefficients. 49 | * @param[in] *pState points to the state buffer. 50 | * @param[in] *pTapDelay points to the array of offset times. 51 | * @param[in] maxDelay maximum offset time supported. 52 | * @param[in] blockSize number of samples that will be processed per block. 53 | * @return none 54 | * 55 | * Description: 56 | * \par 57 | * pCoeffs holds the filter coefficients and has length numTaps. 58 | * pState holds the filter's state variables and must be of length 59 | * maxDelay + blockSize, where maxDelay 60 | * is the maximum number of delay line values. 61 | * blockSize is the 62 | * number of samples processed by the arm_fir_sparse_f32() function. 63 | */ 64 | 65 | void arm_fir_sparse_init_f32( 66 | arm_fir_sparse_instance_f32 * S, 67 | uint16_t numTaps, 68 | float32_t * pCoeffs, 69 | float32_t * pState, 70 | int32_t * pTapDelay, 71 | uint16_t maxDelay, 72 | uint32_t blockSize) 73 | { 74 | /* Assign filter taps */ 75 | S->numTaps = numTaps; 76 | 77 | /* Assign coefficient pointer */ 78 | S->pCoeffs = pCoeffs; 79 | 80 | /* Assign TapDelay pointer */ 81 | S->pTapDelay = pTapDelay; 82 | 83 | /* Assign MaxDelay */ 84 | S->maxDelay = maxDelay; 85 | 86 | /* reset the stateIndex to 0 */ 87 | S->stateIndex = 0u; 88 | 89 | /* Clear state buffer and size is always maxDelay + blockSize */ 90 | memset(pState, 0, (maxDelay + blockSize) * sizeof(float32_t)); 91 | 92 | /* Assign state pointer */ 93 | S->pState = pState; 94 | 95 | } 96 | 97 | /** 98 | * @} end of FIR_Sparse group 99 | */ 100 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_fir_sparse_init_q15.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_fir_sparse_init_q15.c 9 | * 10 | * Description: Q15 sparse FIR filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------*/ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupFilters 37 | */ 38 | 39 | /** 40 | * @addtogroup FIR_Sparse 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Initialization function for the Q15 sparse FIR filter. 46 | * @param[in,out] *S points to an instance of the Q15 sparse FIR structure. 47 | * @param[in] numTaps number of nonzero coefficients in the filter. 48 | * @param[in] *pCoeffs points to the array of filter coefficients. 49 | * @param[in] *pState points to the state buffer. 50 | * @param[in] *pTapDelay points to the array of offset times. 51 | * @param[in] maxDelay maximum offset time supported. 52 | * @param[in] blockSize number of samples that will be processed per block. 53 | * @return none 54 | * 55 | * Description: 56 | * \par 57 | * pCoeffs holds the filter coefficients and has length numTaps. 58 | * pState holds the filter's state variables and must be of length 59 | * maxDelay + blockSize, where maxDelay 60 | * is the maximum number of delay line values. 61 | * blockSize is the 62 | * number of words processed by arm_fir_sparse_q15() function. 63 | */ 64 | 65 | void arm_fir_sparse_init_q15( 66 | arm_fir_sparse_instance_q15 * S, 67 | uint16_t numTaps, 68 | q15_t * pCoeffs, 69 | q15_t * pState, 70 | int32_t * pTapDelay, 71 | uint16_t maxDelay, 72 | uint32_t blockSize) 73 | { 74 | /* Assign filter taps */ 75 | S->numTaps = numTaps; 76 | 77 | /* Assign coefficient pointer */ 78 | S->pCoeffs = pCoeffs; 79 | 80 | /* Assign TapDelay pointer */ 81 | S->pTapDelay = pTapDelay; 82 | 83 | /* Assign MaxDelay */ 84 | S->maxDelay = maxDelay; 85 | 86 | /* reset the stateIndex to 0 */ 87 | S->stateIndex = 0u; 88 | 89 | /* Clear state buffer and size is always maxDelay + blockSize */ 90 | memset(pState, 0, (maxDelay + blockSize) * sizeof(q15_t)); 91 | 92 | /* Assign state pointer */ 93 | S->pState = pState; 94 | 95 | } 96 | 97 | /** 98 | * @} end of FIR_Sparse group 99 | */ 100 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_fir_sparse_init_q31.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_fir_sparse_init_q31.c 9 | * 10 | * Description: Q31 sparse FIR filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------*/ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupFilters 37 | */ 38 | 39 | /** 40 | * @addtogroup FIR_Sparse 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Initialization function for the Q31 sparse FIR filter. 46 | * @param[in,out] *S points to an instance of the Q31 sparse FIR structure. 47 | * @param[in] numTaps number of nonzero coefficients in the filter. 48 | * @param[in] *pCoeffs points to the array of filter coefficients. 49 | * @param[in] *pState points to the state buffer. 50 | * @param[in] *pTapDelay points to the array of offset times. 51 | * @param[in] maxDelay maximum offset time supported. 52 | * @param[in] blockSize number of samples that will be processed per block. 53 | * @return none 54 | * 55 | * Description: 56 | * \par 57 | * pCoeffs holds the filter coefficients and has length numTaps. 58 | * pState holds the filter's state variables and must be of length 59 | * maxDelay + blockSize, where maxDelay 60 | * is the maximum number of delay line values. 61 | * blockSize is the number of words processed by arm_fir_sparse_q31() function. 62 | */ 63 | 64 | void arm_fir_sparse_init_q31( 65 | arm_fir_sparse_instance_q31 * S, 66 | uint16_t numTaps, 67 | q31_t * pCoeffs, 68 | q31_t * pState, 69 | int32_t * pTapDelay, 70 | uint16_t maxDelay, 71 | uint32_t blockSize) 72 | { 73 | /* Assign filter taps */ 74 | S->numTaps = numTaps; 75 | 76 | /* Assign coefficient pointer */ 77 | S->pCoeffs = pCoeffs; 78 | 79 | /* Assign TapDelay pointer */ 80 | S->pTapDelay = pTapDelay; 81 | 82 | /* Assign MaxDelay */ 83 | S->maxDelay = maxDelay; 84 | 85 | /* reset the stateIndex to 0 */ 86 | S->stateIndex = 0u; 87 | 88 | /* Clear state buffer and size is always maxDelay + blockSize */ 89 | memset(pState, 0, (maxDelay + blockSize) * sizeof(q31_t)); 90 | 91 | /* Assign state pointer */ 92 | S->pState = pState; 93 | 94 | } 95 | 96 | /** 97 | * @} end of FIR_Sparse group 98 | */ 99 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_fir_sparse_init_q7.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_fir_sparse_init_q7.c 9 | * 10 | * Description: Q7 sparse FIR filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------*/ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupFilters 37 | */ 38 | 39 | /** 40 | * @addtogroup FIR_Sparse 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Initialization function for the Q7 sparse FIR filter. 46 | * @param[in,out] *S points to an instance of the Q7 sparse FIR structure. 47 | * @param[in] numTaps number of nonzero coefficients in the filter. 48 | * @param[in] *pCoeffs points to the array of filter coefficients. 49 | * @param[in] *pState points to the state buffer. 50 | * @param[in] *pTapDelay points to the array of offset times. 51 | * @param[in] maxDelay maximum offset time supported. 52 | * @param[in] blockSize number of samples that will be processed per block. 53 | * @return none 54 | * 55 | * Description: 56 | * \par 57 | * pCoeffs holds the filter coefficients and has length numTaps. 58 | * pState holds the filter's state variables and must be of length 59 | * maxDelay + blockSize, where maxDelay 60 | * is the maximum number of delay line values. 61 | * blockSize is the 62 | * number of samples processed by the arm_fir_sparse_q7() function. 63 | */ 64 | 65 | void arm_fir_sparse_init_q7( 66 | arm_fir_sparse_instance_q7 * S, 67 | uint16_t numTaps, 68 | q7_t * pCoeffs, 69 | q7_t * pState, 70 | int32_t * pTapDelay, 71 | uint16_t maxDelay, 72 | uint32_t blockSize) 73 | { 74 | /* Assign filter taps */ 75 | S->numTaps = numTaps; 76 | 77 | /* Assign coefficient pointer */ 78 | S->pCoeffs = pCoeffs; 79 | 80 | /* Assign TapDelay pointer */ 81 | S->pTapDelay = pTapDelay; 82 | 83 | /* Assign MaxDelay */ 84 | S->maxDelay = maxDelay; 85 | 86 | /* reset the stateIndex to 0 */ 87 | S->stateIndex = 0u; 88 | 89 | /* Clear state buffer and size is always maxDelay + blockSize */ 90 | memset(pState, 0, (maxDelay + blockSize) * sizeof(q7_t)); 91 | 92 | /* Assign state pointer */ 93 | S->pState = pState; 94 | 95 | } 96 | 97 | /** 98 | * @} end of FIR_Sparse group 99 | */ 100 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_iir_lattice_init_f32.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_iir_lattice_init_f32.c 9 | * 10 | * Description: Floating-point IIR lattice filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------*/ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupFilters 37 | */ 38 | 39 | /** 40 | * @addtogroup IIR_Lattice 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Initialization function for the floating-point IIR lattice filter. 46 | * @param[in] *S points to an instance of the floating-point IIR lattice structure. 47 | * @param[in] numStages number of stages in the filter. 48 | * @param[in] *pkCoeffs points to the reflection coefficient buffer. The array is of length numStages. 49 | * @param[in] *pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1. 50 | * @param[in] *pState points to the state buffer. The array is of length numStages+blockSize. 51 | * @param[in] blockSize number of samples to process. 52 | * @return none. 53 | */ 54 | 55 | void arm_iir_lattice_init_f32( 56 | arm_iir_lattice_instance_f32 * S, 57 | uint16_t numStages, 58 | float32_t * pkCoeffs, 59 | float32_t * pvCoeffs, 60 | float32_t * pState, 61 | uint32_t blockSize) 62 | { 63 | /* Assign filter taps */ 64 | S->numStages = numStages; 65 | 66 | /* Assign reflection coefficient pointer */ 67 | S->pkCoeffs = pkCoeffs; 68 | 69 | /* Assign ladder coefficient pointer */ 70 | S->pvCoeffs = pvCoeffs; 71 | 72 | /* Clear state buffer and size is always blockSize + numStages */ 73 | memset(pState, 0, (numStages + blockSize) * sizeof(float32_t)); 74 | 75 | /* Assign state pointer */ 76 | S->pState = pState; 77 | 78 | 79 | } 80 | 81 | /** 82 | * @} end of IIR_Lattice group 83 | */ 84 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_iir_lattice_init_q15.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_iir_lattice_init_q15.c 9 | * 10 | * Description: Q15 IIR lattice filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------*/ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupFilters 37 | */ 38 | 39 | /** 40 | * @addtogroup IIR_Lattice 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Initialization function for the Q15 IIR lattice filter. 46 | * @param[in] *S points to an instance of the Q15 IIR lattice structure. 47 | * @param[in] numStages number of stages in the filter. 48 | * @param[in] *pkCoeffs points to reflection coefficient buffer. The array is of length numStages. 49 | * @param[in] *pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1. 50 | * @param[in] *pState points to state buffer. The array is of length numStages+blockSize. 51 | * @param[in] blockSize number of samples to process per call. 52 | * @return none. 53 | */ 54 | 55 | void arm_iir_lattice_init_q15( 56 | arm_iir_lattice_instance_q15 * S, 57 | uint16_t numStages, 58 | q15_t * pkCoeffs, 59 | q15_t * pvCoeffs, 60 | q15_t * pState, 61 | uint32_t blockSize) 62 | { 63 | /* Assign filter taps */ 64 | S->numStages = numStages; 65 | 66 | /* Assign reflection coefficient pointer */ 67 | S->pkCoeffs = pkCoeffs; 68 | 69 | /* Assign ladder coefficient pointer */ 70 | S->pvCoeffs = pvCoeffs; 71 | 72 | /* Clear state buffer and size is always blockSize + numStages */ 73 | memset(pState, 0, (numStages + blockSize) * sizeof(q15_t)); 74 | 75 | /* Assign state pointer */ 76 | S->pState = pState; 77 | 78 | 79 | } 80 | 81 | /** 82 | * @} end of IIR_Lattice group 83 | */ 84 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_iir_lattice_init_q31.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_iir_lattice_init_q31.c 9 | * 10 | * Description: Initialization function for the Q31 IIR lattice filter. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------*/ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupFilters 37 | */ 38 | 39 | /** 40 | * @addtogroup IIR_Lattice 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Initialization function for the Q31 IIR lattice filter. 46 | * @param[in] *S points to an instance of the Q31 IIR lattice structure. 47 | * @param[in] numStages number of stages in the filter. 48 | * @param[in] *pkCoeffs points to the reflection coefficient buffer. The array is of length numStages. 49 | * @param[in] *pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1. 50 | * @param[in] *pState points to the state buffer. The array is of length numStages+blockSize. 51 | * @param[in] blockSize number of samples to process. 52 | * @return none. 53 | */ 54 | 55 | void arm_iir_lattice_init_q31( 56 | arm_iir_lattice_instance_q31 * S, 57 | uint16_t numStages, 58 | q31_t * pkCoeffs, 59 | q31_t * pvCoeffs, 60 | q31_t * pState, 61 | uint32_t blockSize) 62 | { 63 | /* Assign filter taps */ 64 | S->numStages = numStages; 65 | 66 | /* Assign reflection coefficient pointer */ 67 | S->pkCoeffs = pkCoeffs; 68 | 69 | /* Assign ladder coefficient pointer */ 70 | S->pvCoeffs = pvCoeffs; 71 | 72 | /* Clear state buffer and size is always blockSize + numStages */ 73 | memset(pState, 0, (numStages + blockSize) * sizeof(q31_t)); 74 | 75 | /* Assign state pointer */ 76 | S->pState = pState; 77 | 78 | 79 | } 80 | 81 | /** 82 | * @} end of IIR_Lattice group 83 | */ 84 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_lms_init_f32.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_lms_init_f32.c 9 | * 10 | * Description: Floating-point LMS filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------*/ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @addtogroup LMS 37 | * @{ 38 | */ 39 | 40 | /** 41 | * @brief Initialization function for floating-point LMS filter. 42 | * @param[in] *S points to an instance of the floating-point LMS filter structure. 43 | * @param[in] numTaps number of filter coefficients. 44 | * @param[in] *pCoeffs points to the coefficient buffer. 45 | * @param[in] *pState points to state buffer. 46 | * @param[in] mu step size that controls filter coefficient updates. 47 | * @param[in] blockSize number of samples to process. 48 | * @return none. 49 | */ 50 | 51 | /** 52 | * \par Description: 53 | * pCoeffs points to the array of filter coefficients stored in time reversed order: 54 | *
   
55 |  *    {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}   
56 |  * 
57 | * The initial filter coefficients serve as a starting point for the adaptive filter. 58 | * 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(). 59 | */ 60 | 61 | void arm_lms_init_f32( 62 | arm_lms_instance_f32 * S, 63 | uint16_t numTaps, 64 | float32_t * pCoeffs, 65 | float32_t * pState, 66 | float32_t mu, 67 | uint32_t blockSize) 68 | { 69 | /* Assign filter taps */ 70 | S->numTaps = numTaps; 71 | 72 | /* Assign coefficient pointer */ 73 | S->pCoeffs = pCoeffs; 74 | 75 | /* Clear state buffer and size is always blockSize + numTaps */ 76 | memset(pState, 0, (numTaps + (blockSize - 1)) * sizeof(float32_t)); 77 | 78 | /* Assign state pointer */ 79 | S->pState = pState; 80 | 81 | /* Assign Step size value */ 82 | S->mu = mu; 83 | } 84 | 85 | /** 86 | * @} end of LMS group 87 | */ 88 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_lms_init_q15.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_lms_init_q15.c 9 | * 10 | * Description: Q15 LMS filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------*/ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupFilters 37 | */ 38 | 39 | /** 40 | * @addtogroup LMS 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Initialization function for the Q15 LMS filter. 46 | * @param[in] *S points to an instance of the Q15 LMS filter structure. 47 | * @param[in] numTaps number of filter coefficients. 48 | * @param[in] *pCoeffs points to the coefficient buffer. 49 | * @param[in] *pState points to the state buffer. 50 | * @param[in] mu step size that controls filter coefficient updates. 51 | * @param[in] blockSize number of samples to process. 52 | * @param[in] postShift bit shift applied to coefficients. 53 | * @return none. 54 | * 55 | * \par Description: 56 | * pCoeffs points to the array of filter coefficients stored in time reversed order: 57 | *
   
58 | *    {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}   
59 | * 
60 | * The initial filter coefficients serve as a starting point for the adaptive filter. 61 | * pState points to the array of state variables and size of array is 62 | * numTaps+blockSize-1 samples, where blockSize is the number of 63 | * input samples processed by each call to arm_lms_q15(). 64 | */ 65 | 66 | void arm_lms_init_q15( 67 | arm_lms_instance_q15 * S, 68 | uint16_t numTaps, 69 | q15_t * pCoeffs, 70 | q15_t * pState, 71 | q15_t mu, 72 | uint32_t blockSize, 73 | uint32_t postShift) 74 | { 75 | /* Assign filter taps */ 76 | S->numTaps = numTaps; 77 | 78 | /* Assign coefficient pointer */ 79 | S->pCoeffs = pCoeffs; 80 | 81 | /* Clear state buffer and size is always blockSize + numTaps - 1 */ 82 | memset(pState, 0, (numTaps + (blockSize - 1u)) * sizeof(q15_t)); 83 | 84 | /* Assign state pointer */ 85 | S->pState = pState; 86 | 87 | /* Assign Step size value */ 88 | S->mu = mu; 89 | 90 | /* Assign postShift value to be applied */ 91 | S->postShift = postShift; 92 | 93 | } 94 | 95 | /** 96 | * @} end of LMS group 97 | */ 98 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_lms_init_q31.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_lms_init_q31.c 9 | * 10 | * Description: Q31 LMS filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------*/ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupFilters 37 | */ 38 | 39 | /** 40 | * @addtogroup LMS 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Initialization function for Q31 LMS filter. 46 | * @param[in] *S points to an instance of the Q31 LMS filter structure. 47 | * @param[in] numTaps number of filter coefficients. 48 | * @param[in] *pCoeffs points to coefficient buffer. 49 | * @param[in] *pState points to state buffer. 50 | * @param[in] mu step size that controls filter coefficient updates. 51 | * @param[in] blockSize number of samples to process. 52 | * @param[in] postShift bit shift applied to coefficients. 53 | * @return none. 54 | * 55 | * \par Description: 56 | * pCoeffs points to the array of filter coefficients stored in time reversed order: 57 | *
   
58 |  *    {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}   
59 |  * 
60 | * The initial filter coefficients serve as a starting point for the adaptive filter. 61 | * pState points to an array of length numTaps+blockSize-1 samples, 62 | * where blockSize is the number of input samples processed by each call to 63 | * arm_lms_q31(). 64 | */ 65 | 66 | void arm_lms_init_q31( 67 | arm_lms_instance_q31 * S, 68 | uint16_t numTaps, 69 | q31_t * pCoeffs, 70 | q31_t * pState, 71 | q31_t mu, 72 | uint32_t blockSize, 73 | uint32_t postShift) 74 | { 75 | /* Assign filter taps */ 76 | S->numTaps = numTaps; 77 | 78 | /* Assign coefficient pointer */ 79 | S->pCoeffs = pCoeffs; 80 | 81 | /* Clear state buffer and size is always blockSize + numTaps - 1 */ 82 | memset(pState, 0, ((uint32_t) numTaps + (blockSize - 1u)) * sizeof(q31_t)); 83 | 84 | /* Assign state pointer */ 85 | S->pState = pState; 86 | 87 | /* Assign Step size value */ 88 | S->mu = mu; 89 | 90 | /* Assign postShift value to be applied */ 91 | S->postShift = postShift; 92 | 93 | } 94 | 95 | /** 96 | * @} end of LMS group 97 | */ 98 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_lms_norm_init_f32.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_lms_norm_init_f32.c 9 | * 10 | * Description: Floating-point NLMS filter initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------*/ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupFilters 37 | */ 38 | 39 | /** 40 | * @addtogroup LMS_NORM 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Initialization function for floating-point normalized LMS filter. 46 | * @param[in] *S points to an instance of the floating-point LMS filter structure. 47 | * @param[in] numTaps number of filter coefficients. 48 | * @param[in] *pCoeffs points to coefficient buffer. 49 | * @param[in] *pState points to state buffer. 50 | * @param[in] mu step size that controls filter coefficient updates. 51 | * @param[in] blockSize number of samples to process. 52 | * @return none. 53 | * 54 | * \par Description: 55 | * pCoeffs points to the array of filter coefficients stored in time reversed order: 56 | *
   
57 |  *    {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}   
58 |  * 
59 | * The initial filter coefficients serve as a starting point for the adaptive filter. 60 | * pState points to an array of length numTaps+blockSize-1 samples, 61 | * where blockSize is the number of input samples processed by each call to arm_lms_norm_f32(). 62 | */ 63 | 64 | void arm_lms_norm_init_f32( 65 | arm_lms_norm_instance_f32 * S, 66 | uint16_t numTaps, 67 | float32_t * pCoeffs, 68 | float32_t * pState, 69 | float32_t mu, 70 | uint32_t blockSize) 71 | { 72 | /* Assign filter taps */ 73 | S->numTaps = numTaps; 74 | 75 | /* Assign coefficient pointer */ 76 | S->pCoeffs = pCoeffs; 77 | 78 | /* Clear state buffer and size is always blockSize + numTaps - 1 */ 79 | memset(pState, 0, (numTaps + (blockSize - 1u)) * sizeof(float32_t)); 80 | 81 | /* Assign state pointer */ 82 | S->pState = pState; 83 | 84 | /* Assign Step size value */ 85 | S->mu = mu; 86 | 87 | /* Initialise Energy to zero */ 88 | S->energy = 0.0f; 89 | 90 | /* Initialise x0 to zero */ 91 | S->x0 = 0.0f; 92 | 93 | } 94 | 95 | /** 96 | * @} end of LMS_NORM group 97 | */ 98 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_lms_norm_init_q31.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_lms_norm_init_q31.c 9 | * 10 | * Description: Q31 NLMS initialization function. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------*/ 32 | 33 | #include "arm_math.h" 34 | #include "arm_common_tables.h" 35 | 36 | /** 37 | * @addtogroup LMS_NORM 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @brief Initialization function for Q31 normalized LMS filter. 43 | * @param[in] *S points to an instance of the Q31 normalized LMS filter structure. 44 | * @param[in] numTaps number of filter coefficients. 45 | * @param[in] *pCoeffs points to coefficient buffer. 46 | * @param[in] *pState points to state buffer. 47 | * @param[in] mu step size that controls filter coefficient updates. 48 | * @param[in] blockSize number of samples to process. 49 | * @param[in] postShift bit shift applied to coefficients. 50 | * @return none. 51 | * 52 | * Description: 53 | * \par 54 | * pCoeffs points to the array of filter coefficients stored in time reversed order: 55 | *
   
 56 |  *    {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}   
 57 |  * 
58 | * The initial filter coefficients serve as a starting point for the adaptive filter. 59 | * pState points to an array of length numTaps+blockSize-1 samples, 60 | * where blockSize is the number of input samples processed by each call to arm_lms_norm_q31(). 61 | */ 62 | 63 | void arm_lms_norm_init_q31( 64 | arm_lms_norm_instance_q31 * S, 65 | uint16_t numTaps, 66 | q31_t * pCoeffs, 67 | q31_t * pState, 68 | q31_t mu, 69 | uint32_t blockSize, 70 | uint8_t postShift) 71 | { 72 | /* Assign filter taps */ 73 | S->numTaps = numTaps; 74 | 75 | /* Assign coefficient pointer */ 76 | S->pCoeffs = pCoeffs; 77 | 78 | /* Clear state buffer and size is always blockSize + numTaps - 1 */ 79 | memset(pState, 0, (numTaps + (blockSize - 1u)) * sizeof(q31_t)); 80 | 81 | /* Assign post Shift value applied to coefficients */ 82 | S->postShift = postShift; 83 | 84 | /* Assign state pointer */ 85 | S->pState = pState; 86 | 87 | /* Assign Step size value */ 88 | S->mu = mu; 89 | 90 | /* Initialize reciprocal pointer table */ 91 | S->recipTable = armRecipTableQ31; 92 | 93 | /* Initialise Energy to zero */ 94 | S->energy = 0; 95 | 96 | /* Initialise x0 to zero */ 97 | S->x0 = 0; 98 | 99 | } 100 | 101 | /** 102 | * @} end of LMS_NORM group 103 | */ 104 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/MatrixFunctions/arm_mat_init_f32.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_mat_init_f32.c 9 | * 10 | * Description: Floating-point matrix initialization. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * 29 | * Version 0.0.5 2010/04/26 30 | * incorporated review comments and updated with latest CMSIS layer 31 | * 32 | * Version 0.0.3 2010/03/10 33 | * Initial version 34 | * -------------------------------------------------------------------------- */ 35 | 36 | #include "arm_math.h" 37 | 38 | /** 39 | * @ingroup groupMatrix 40 | */ 41 | 42 | /** 43 | * @defgroup MatrixInit Matrix Initialization 44 | * 45 | * Initializes the underlying matrix data structure. 46 | * The functions set the numRows, 47 | * numCols, and pData fields 48 | * of the matrix data structure. 49 | */ 50 | 51 | /** 52 | * @addtogroup MatrixInit 53 | * @{ 54 | */ 55 | 56 | /** 57 | * @brief Floating-point matrix initialization. 58 | * @param[in,out] *S points to an instance of the floating-point matrix structure. 59 | * @param[in] nRows number of rows in the matrix. 60 | * @param[in] nColumns number of columns in the matrix. 61 | * @param[in] *pData points to the matrix data array. 62 | * @return none 63 | */ 64 | 65 | void arm_mat_init_f32( 66 | arm_matrix_instance_f32 * S, 67 | uint16_t nRows, 68 | uint16_t nColumns, 69 | float32_t * pData) 70 | { 71 | /* Assign Number of Rows */ 72 | S->numRows = nRows; 73 | 74 | /* Assign Number of Columns */ 75 | S->numCols = nColumns; 76 | 77 | /* Assign Data pointer */ 78 | S->pData = pData; 79 | } 80 | 81 | /** 82 | * @} end of MatrixInit group 83 | */ 84 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/MatrixFunctions/arm_mat_init_q15.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_mat_init_q15.c 9 | * 10 | * Description: Q15 matrix initialization. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * 29 | * Version 0.0.5 2010/04/26 30 | * incorporated review comments and updated with latest CMSIS layer 31 | * 32 | * Version 0.0.3 2010/03/10 33 | * Initial version 34 | * -------------------------------------------------------------------------- */ 35 | 36 | 37 | #include "arm_math.h" 38 | 39 | /** 40 | * @ingroup groupMatrix 41 | */ 42 | 43 | /** 44 | * @addtogroup MatrixInit 45 | * @{ 46 | */ 47 | 48 | /** 49 | * @brief Q15 matrix initialization. 50 | * @param[in,out] *S points to an instance of the floating-point matrix structure. 51 | * @param[in] nRows number of rows in the matrix. 52 | * @param[in] nColumns number of columns in the matrix. 53 | * @param[in] *pData points to the matrix data array. 54 | * @return none 55 | */ 56 | 57 | void arm_mat_init_q15( 58 | arm_matrix_instance_q15 * S, 59 | uint16_t nRows, 60 | uint16_t nColumns, 61 | q15_t * pData) 62 | { 63 | /* Assign Number of Rows */ 64 | S->numRows = nRows; 65 | 66 | /* Assign Number of Columns */ 67 | S->numCols = nColumns; 68 | 69 | /* Assign Data pointer */ 70 | S->pData = pData; 71 | } 72 | 73 | /** 74 | * @} end of MatrixInit group 75 | */ 76 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/MatrixFunctions/arm_mat_init_q31.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_mat_init_q31.c 9 | * 10 | * Description: Q31 matrix initialization. 11 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 12 | * 13 | * Version 1.0.10 2011/7/15 14 | * Big Endian support added and Merged M0 and M3/M4 Source code. 15 | * 16 | * Version 1.0.3 2010/11/29 17 | * Re-organized the CMSIS folders and updated documentation. 18 | * 19 | * Version 1.0.2 2010/11/11 20 | * Documentation updated. 21 | * 22 | * Version 1.0.1 2010/10/05 23 | * Production release and review comments incorporated. 24 | * 25 | * Version 1.0.0 2010/09/20 26 | * Production release and review comments incorporated. 27 | * 28 | * Version 0.0.5 2010/04/26 29 | * incorporated review comments and updated with latest CMSIS layer 30 | * 31 | * Version 0.0.3 2010/03/10 32 | * Initial version 33 | * -------------------------------------------------------------------------- */ 34 | 35 | 36 | #include "arm_math.h" 37 | 38 | /** 39 | * @ingroup groupMatrix 40 | */ 41 | 42 | /** 43 | * @defgroup MatrixInit Matrix Initialization 44 | * 45 | */ 46 | 47 | /** 48 | * @addtogroup MatrixInit 49 | * @{ 50 | */ 51 | 52 | /** 53 | * @brief Q31 matrix initialization. 54 | * @param[in,out] *S points to an instance of the floating-point matrix structure. 55 | * @param[in] nRows number of rows in the matrix. 56 | * @param[in] nColumns number of columns in the matrix. 57 | * @param[in] *pData points to the matrix data array. 58 | * @return none 59 | */ 60 | 61 | void arm_mat_init_q31( 62 | arm_matrix_instance_q31 * S, 63 | uint16_t nRows, 64 | uint16_t nColumns, 65 | q31_t * pData) 66 | { 67 | /* Assign Number of Rows */ 68 | S->numRows = nRows; 69 | 70 | /* Assign Number of Columns */ 71 | S->numCols = nColumns; 72 | 73 | /* Assign Data pointer */ 74 | S->pData = pData; 75 | } 76 | 77 | /** 78 | * @} end of MatrixInit group 79 | */ 80 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/StatisticsFunctions/arm_max_q15.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_max_q15.c 9 | * 10 | * Description: Maximum value of a Q15 vector. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * ---------------------------------------------------------------------------- */ 29 | 30 | #include "arm_math.h" 31 | 32 | /** 33 | * @ingroup groupStats 34 | */ 35 | 36 | /** 37 | * @addtogroup Max 38 | * @{ 39 | */ 40 | 41 | 42 | /** 43 | * @brief Maximum value of a Q15 vector. 44 | * @param[in] *pSrc points to the input vector 45 | * @param[in] blockSize length of the input vector 46 | * @param[out] *pResult maximum value returned here 47 | * @param[out] *pIndex index of maximum value returned here 48 | * @return none. 49 | */ 50 | 51 | void arm_max_q15( 52 | q15_t * pSrc, 53 | uint32_t blockSize, 54 | q15_t * pResult, 55 | uint32_t * pIndex) 56 | { 57 | q15_t maxVal, out; /* Temporary variables to store the output value. */ 58 | uint32_t blkCnt, outIndex; /* loop counter */ 59 | 60 | /* Initialise the index value to zero. */ 61 | outIndex = 0u; 62 | /* Load first input value that act as reference value for comparision */ 63 | out = *pSrc++; 64 | 65 | /* Loop over blockSize number of values */ 66 | blkCnt = (blockSize - 1u); 67 | 68 | #ifndef ARM_MATH_CM0 69 | 70 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 71 | 72 | do 73 | { 74 | /* Initialize maxVal to the next consecutive values one by one */ 75 | maxVal = *pSrc++; 76 | 77 | /* compare for the maximum value */ 78 | if(out < maxVal) 79 | { 80 | /* Update the maximum value and its index */ 81 | out = maxVal; 82 | outIndex = blockSize - blkCnt; 83 | } 84 | 85 | blkCnt--; 86 | 87 | } while(blkCnt > 0u); 88 | 89 | #else 90 | 91 | /* Run the below code for Cortex-M0 */ 92 | 93 | while(blkCnt > 0u) 94 | { 95 | /* Initialize maxVal to the next consecutive values one by one */ 96 | maxVal = *pSrc++; 97 | 98 | /* compare for the maximum value */ 99 | if(out < maxVal) 100 | { 101 | /* Update the maximum value and its index */ 102 | out = maxVal; 103 | outIndex = blockSize - blkCnt; 104 | } 105 | /* Decrement the loop counter */ 106 | blkCnt--; 107 | 108 | } 109 | 110 | #endif /* #ifndef ARM_MATH_CM0 */ 111 | 112 | /* Store the maximum value and its index into destination pointers */ 113 | *pResult = out; 114 | *pIndex = outIndex; 115 | } 116 | 117 | /** 118 | * @} end of Max group 119 | */ 120 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/StatisticsFunctions/arm_max_q31.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_max_q31.c 9 | * 10 | * Description: Maximum value of a Q31 vector. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * ---------------------------------------------------------------------------- */ 29 | 30 | #include "arm_math.h" 31 | 32 | /** 33 | * @ingroup groupStats 34 | */ 35 | 36 | /** 37 | * @addtogroup Max 38 | * @{ 39 | */ 40 | 41 | 42 | /** 43 | * @brief Maximum value of a Q31 vector. 44 | * @param[in] *pSrc points to the input vector 45 | * @param[in] blockSize length of the input vector 46 | * @param[out] *pResult maximum value returned here 47 | * @param[out] *pIndex index of maximum value returned here 48 | * @return none. 49 | */ 50 | 51 | void arm_max_q31( 52 | q31_t * pSrc, 53 | uint32_t blockSize, 54 | q31_t * pResult, 55 | uint32_t * pIndex) 56 | { 57 | q31_t maxVal, out; /* Temporary variables to store the output value. */ 58 | uint32_t blkCnt, outIndex; /* loop counter */ 59 | 60 | /* Initialise the index value to zero. */ 61 | outIndex = 0u; 62 | /* Load first input value that act as reference value for comparision */ 63 | out = *pSrc++; 64 | 65 | /* Loop over blockSize number of values */ 66 | blkCnt = (blockSize - 1u); 67 | 68 | #ifndef ARM_MATH_CM0 69 | 70 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 71 | 72 | do 73 | { 74 | /* Initialize maxVal to the next consecutive values one by one */ 75 | maxVal = *pSrc++; 76 | 77 | /* compare for the maximum value */ 78 | if(out < maxVal) 79 | { 80 | /* Update the maximum value and its index */ 81 | out = maxVal; 82 | outIndex = blockSize - blkCnt; 83 | } 84 | 85 | /* Decrement the loop counter */ 86 | blkCnt--; 87 | 88 | } while(blkCnt > 0u); 89 | 90 | #else 91 | 92 | /* Run the below code for Cortex-M0 */ 93 | 94 | while(blkCnt > 0u) 95 | { 96 | /* Initialize maxVal to the next consecutive values one by one */ 97 | maxVal = *pSrc++; 98 | 99 | /* Compare for the maximum value */ 100 | if(out < maxVal) 101 | { 102 | /* Update the maximum value and its index */ 103 | out = maxVal; 104 | outIndex = blockSize - blkCnt; 105 | } 106 | 107 | /* Decrement the loop counter */ 108 | blkCnt--; 109 | 110 | } 111 | 112 | #endif /* #ifndef ARM_MATH_CM0 */ 113 | 114 | /* Store the maximum value and its index into destination pointers */ 115 | *pResult = out; 116 | *pIndex = outIndex; 117 | } 118 | 119 | /** 120 | * @} end of Max group 121 | */ 122 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/SupportFunctions/arm_copy_f32.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_copy_f32.c 9 | * 10 | * Description: Copies the elements of a floating-point vector. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------- */ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupSupport 37 | */ 38 | 39 | /** 40 | * @defgroup copy Vector Copy 41 | * 42 | * Copies sample by sample from source vector to destination vector. 43 | * 44 | *
   
 45 |  * 	pDst[n] = pSrc[n];   0 <= n < blockSize.   
 46 |  * 
47 | * 48 | * There are separate functions for floating point, Q31, Q15, and Q7 data types. 49 | */ 50 | 51 | /** 52 | * @addtogroup copy 53 | * @{ 54 | */ 55 | 56 | /** 57 | * @brief Copies the elements of a floating-point vector. 58 | * @param[in] *pSrc points to input vector 59 | * @param[out] *pDst points to output vector 60 | * @param[in] blockSize length of the input vector 61 | * @return none. 62 | * 63 | */ 64 | 65 | 66 | void arm_copy_f32( 67 | float32_t * pSrc, 68 | float32_t * pDst, 69 | uint32_t blockSize) 70 | { 71 | uint32_t blkCnt; /* loop counter */ 72 | 73 | #ifndef ARM_MATH_CM0 74 | 75 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 76 | 77 | /*loop Unrolling */ 78 | blkCnt = blockSize >> 2u; 79 | 80 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 81 | ** a second loop below computes the remaining 1 to 3 samples. */ 82 | while(blkCnt > 0u) 83 | { 84 | /* C = A */ 85 | /* Copy and then store the results in the destination buffer */ 86 | *pDst++ = *pSrc++; 87 | *pDst++ = *pSrc++; 88 | *pDst++ = *pSrc++; 89 | *pDst++ = *pSrc++; 90 | 91 | /* Decrement the loop counter */ 92 | blkCnt--; 93 | } 94 | 95 | /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 96 | ** No loop unrolling is used. */ 97 | blkCnt = blockSize % 0x4u; 98 | 99 | #else 100 | 101 | /* Run the below code for Cortex-M0 */ 102 | 103 | /* Loop over blockSize number of values */ 104 | blkCnt = blockSize; 105 | 106 | #endif /* #ifndef ARM_MATH_CM0 */ 107 | 108 | while(blkCnt > 0u) 109 | { 110 | /* C = A */ 111 | /* Copy and then store the results in the destination buffer */ 112 | *pDst++ = *pSrc++; 113 | 114 | /* Decrement the loop counter */ 115 | blkCnt--; 116 | } 117 | } 118 | 119 | /** 120 | * @} end of BasicCopy group 121 | */ 122 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/SupportFunctions/arm_copy_q31.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_copy_q31.c 9 | * 10 | * Description: Copies the elements of a Q31 vector. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * -------------------------------------------------------------------- */ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupSupport 37 | */ 38 | 39 | /** 40 | * @addtogroup copy 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Copies the elements of a Q31 vector. 46 | * @param[in] *pSrc points to input vector 47 | * @param[out] *pDst points to output vector 48 | * @param[in] blockSize length of the input vector 49 | * @return none. 50 | * 51 | */ 52 | 53 | void arm_copy_q31( 54 | q31_t * pSrc, 55 | q31_t * pDst, 56 | uint32_t blockSize) 57 | { 58 | uint32_t blkCnt; /* loop counter */ 59 | 60 | 61 | #ifndef ARM_MATH_CM0 62 | 63 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 64 | 65 | /*loop Unrolling */ 66 | blkCnt = blockSize >> 2u; 67 | 68 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 69 | ** a second loop below computes the remaining 1 to 3 samples. */ 70 | while(blkCnt > 0u) 71 | { 72 | /* C = A */ 73 | /* Copy and then store the values in the destination buffer */ 74 | *pDst++ = *pSrc++; 75 | *pDst++ = *pSrc++; 76 | *pDst++ = *pSrc++; 77 | *pDst++ = *pSrc++; 78 | 79 | /* Decrement the loop counter */ 80 | blkCnt--; 81 | } 82 | 83 | /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 84 | ** No loop unrolling is used. */ 85 | blkCnt = blockSize % 0x4u; 86 | 87 | #else 88 | 89 | /* Run the below code for Cortex-M0 */ 90 | 91 | /* Loop over blockSize number of values */ 92 | blkCnt = blockSize; 93 | 94 | #endif /* #ifndef ARM_MATH_CM0 */ 95 | 96 | while(blkCnt > 0u) 97 | { 98 | /* C = A */ 99 | /* Copy and then store the value in the destination buffer */ 100 | *pDst++ = *pSrc++; 101 | 102 | /* Decrement the loop counter */ 103 | blkCnt--; 104 | } 105 | } 106 | 107 | /** 108 | * @} end of BasicCopy group 109 | */ 110 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/SupportFunctions/arm_copy_q7.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_copy_q7.c 9 | * 10 | * Description: Copies the elements of a Q7 vector. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * -------------------------------------------------------------------- */ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupSupport 37 | */ 38 | 39 | /** 40 | * @addtogroup copy 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Copies the elements of a Q7 vector. 46 | * @param[in] *pSrc points to input vector 47 | * @param[out] *pDst points to output vector 48 | * @param[in] blockSize length of the input vector 49 | * @return none. 50 | * 51 | */ 52 | 53 | void arm_copy_q7( 54 | q7_t * pSrc, 55 | q7_t * pDst, 56 | uint32_t blockSize) 57 | { 58 | uint32_t blkCnt; /* loop counter */ 59 | 60 | #ifndef ARM_MATH_CM0 61 | 62 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 63 | 64 | /*loop Unrolling */ 65 | blkCnt = blockSize >> 2u; 66 | 67 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 68 | ** a second loop below computes the remaining 1 to 3 samples. */ 69 | while(blkCnt > 0u) 70 | { 71 | /* C = A */ 72 | /* Copy and then store the results in the destination buffer */ 73 | /* 4 samples are copied and stored at a time using SIMD */ 74 | *__SIMD32(pDst)++ = *__SIMD32(pSrc)++; 75 | 76 | /* Decrement the loop counter */ 77 | blkCnt--; 78 | } 79 | 80 | /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 81 | ** No loop unrolling is used. */ 82 | blkCnt = blockSize % 0x4u; 83 | 84 | #else 85 | 86 | /* Run the below code for Cortex-M0 */ 87 | 88 | /* Loop over blockSize number of values */ 89 | blkCnt = blockSize; 90 | 91 | #endif /* #ifndef ARM_MATH_CM0 */ 92 | 93 | 94 | while(blkCnt > 0u) 95 | { 96 | /* C = A */ 97 | /* Copy and then store the results in the destination buffer */ 98 | *pDst++ = *pSrc++; 99 | 100 | /* Decrement the loop counter */ 101 | blkCnt--; 102 | } 103 | } 104 | 105 | /** 106 | * @} end of BasicCopy group 107 | */ 108 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/SupportFunctions/arm_fill_f32.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_fill_f32.c 9 | * 10 | * Description: Fills a constant value into a floating-point vector. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * ---------------------------------------------------------------------------- */ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupSupport 37 | */ 38 | 39 | /** 40 | * @defgroup Fill Vector Fill 41 | * 42 | * Fills the destination vector with a constant value. 43 | * 44 | *
   
 45 |  * 	pDst[n] = value;   0 <= n < blockSize.   
 46 |  * 
47 | * 48 | * There are separate functions for floating point, Q31, Q15, and Q7 data types. 49 | */ 50 | 51 | /** 52 | * @addtogroup Fill 53 | * @{ 54 | */ 55 | 56 | /** 57 | * @brief Fills a constant value into a floating-point vector. 58 | * @param[in] value input value to be filled 59 | * @param[out] *pDst points to output vector 60 | * @param[in] blockSize length of the output vector 61 | * @return none. 62 | * 63 | */ 64 | 65 | 66 | void arm_fill_f32( 67 | float32_t value, 68 | float32_t * pDst, 69 | uint32_t blockSize) 70 | { 71 | uint32_t blkCnt; /* loop counter */ 72 | 73 | #ifndef ARM_MATH_CM0 74 | 75 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 76 | 77 | /*loop Unrolling */ 78 | blkCnt = blockSize >> 2u; 79 | 80 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 81 | ** a second loop below computes the remaining 1 to 3 samples. */ 82 | while(blkCnt > 0u) 83 | { 84 | /* C = value */ 85 | /* Fill the value in the destination buffer */ 86 | *pDst++ = value; 87 | *pDst++ = value; 88 | *pDst++ = value; 89 | *pDst++ = value; 90 | 91 | /* Decrement the loop counter */ 92 | blkCnt--; 93 | } 94 | 95 | /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 96 | ** No loop unrolling is used. */ 97 | blkCnt = blockSize % 0x4u; 98 | 99 | #else 100 | 101 | /* Run the below code for Cortex-M0 */ 102 | 103 | /* Loop over blockSize number of values */ 104 | blkCnt = blockSize; 105 | 106 | #endif /* #ifndef ARM_MATH_CM0 */ 107 | 108 | 109 | while(blkCnt > 0u) 110 | { 111 | /* C = value */ 112 | /* Fill the value in the destination buffer */ 113 | *pDst++ = value; 114 | 115 | /* Decrement the loop counter */ 116 | blkCnt--; 117 | } 118 | } 119 | 120 | /** 121 | * @} end of Fill group 122 | */ 123 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/SupportFunctions/arm_fill_q15.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_fill_q15.c 9 | * 10 | * Description: Fills a constant value into a Q15 vector. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * -------------------------------------------------------------------- */ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupSupport 37 | */ 38 | 39 | /** 40 | * @addtogroup Fill 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Fills a constant value into a Q15 vector. 46 | * @param[in] value input value to be filled 47 | * @param[out] *pDst points to output vector 48 | * @param[in] blockSize length of the output vector 49 | * @return none. 50 | * 51 | */ 52 | 53 | void arm_fill_q15( 54 | q15_t value, 55 | q15_t * pDst, 56 | uint32_t blockSize) 57 | { 58 | uint32_t blkCnt; /* loop counter */ 59 | 60 | #ifndef ARM_MATH_CM0 61 | 62 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 63 | 64 | q31_t packedValue; /* value packed to 32 bits */ 65 | 66 | 67 | /*loop Unrolling */ 68 | blkCnt = blockSize >> 2u; 69 | 70 | /* Packing two 16 bit values to 32 bit value in order to use SIMD */ 71 | packedValue = __PKHBT(value, value, 16u); 72 | 73 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 74 | ** a second loop below computes the remaining 1 to 3 samples. */ 75 | while(blkCnt > 0u) 76 | { 77 | /* C = value */ 78 | /* Fill the value in the destination buffer */ 79 | *__SIMD32(pDst)++ = packedValue; 80 | *__SIMD32(pDst)++ = packedValue; 81 | 82 | /* Decrement the loop counter */ 83 | blkCnt--; 84 | } 85 | 86 | /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 87 | ** No loop unrolling is used. */ 88 | blkCnt = blockSize % 0x4u; 89 | 90 | #else 91 | 92 | /* Run the below code for Cortex-M0 */ 93 | 94 | /* Loop over blockSize number of values */ 95 | blkCnt = blockSize; 96 | 97 | #endif /* #ifndef ARM_MATH_CM0 */ 98 | 99 | while(blkCnt > 0u) 100 | { 101 | /* C = value */ 102 | /* Fill the value in the destination buffer */ 103 | *pDst++ = value; 104 | 105 | /* Decrement the loop counter */ 106 | blkCnt--; 107 | } 108 | } 109 | 110 | /** 111 | * @} end of Fill group 112 | */ 113 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/SupportFunctions/arm_fill_q31.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_fill_q31.c 9 | * 10 | * Description: Fills a constant value into a Q31 vector. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * -------------------------------------------------------------------- */ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupSupport 37 | */ 38 | 39 | /** 40 | * @addtogroup Fill 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Fills a constant value into a Q31 vector. 46 | * @param[in] value input value to be filled 47 | * @param[out] *pDst points to output vector 48 | * @param[in] blockSize length of the output vector 49 | * @return none. 50 | * 51 | */ 52 | 53 | void arm_fill_q31( 54 | q31_t value, 55 | q31_t * pDst, 56 | uint32_t blockSize) 57 | { 58 | uint32_t blkCnt; /* loop counter */ 59 | 60 | 61 | #ifndef ARM_MATH_CM0 62 | 63 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 64 | 65 | /*loop Unrolling */ 66 | blkCnt = blockSize >> 2u; 67 | 68 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 69 | ** a second loop below computes the remaining 1 to 3 samples. */ 70 | while(blkCnt > 0u) 71 | { 72 | /* C = value */ 73 | /* Fill the value in the destination buffer */ 74 | *pDst++ = value; 75 | *pDst++ = value; 76 | *pDst++ = value; 77 | *pDst++ = value; 78 | 79 | /* Decrement the loop counter */ 80 | blkCnt--; 81 | } 82 | 83 | /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 84 | ** No loop unrolling is used. */ 85 | blkCnt = blockSize % 0x4u; 86 | 87 | #else 88 | 89 | /* Run the below code for Cortex-M0 */ 90 | 91 | /* Loop over blockSize number of values */ 92 | blkCnt = blockSize; 93 | 94 | #endif /* #ifndef ARM_MATH_CM0 */ 95 | 96 | while(blkCnt > 0u) 97 | { 98 | /* C = value */ 99 | /* Fill the value in the destination buffer */ 100 | *pDst++ = value; 101 | 102 | /* Decrement the loop counter */ 103 | blkCnt--; 104 | } 105 | } 106 | 107 | /** 108 | * @} end of Fill group 109 | */ 110 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/SupportFunctions/arm_fill_q7.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_fill_q7.c 9 | * 10 | * Description: Fills a constant value into a Q7 vector. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * 29 | * Version 0.0.7 2010/06/10 30 | * Misra-C changes done 31 | * -------------------------------------------------------------------- */ 32 | 33 | #include "arm_math.h" 34 | 35 | /** 36 | * @ingroup groupSupport 37 | */ 38 | 39 | /** 40 | * @addtogroup Fill 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Fills a constant value into a Q7 vector. 46 | * @param[in] value input value to be filled 47 | * @param[out] *pDst points to output vector 48 | * @param[in] blockSize length of the output vector 49 | * @return none. 50 | * 51 | */ 52 | 53 | void arm_fill_q7( 54 | q7_t value, 55 | q7_t * pDst, 56 | uint32_t blockSize) 57 | { 58 | uint32_t blkCnt; /* loop counter */ 59 | 60 | #ifndef ARM_MATH_CM0 61 | 62 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 63 | 64 | q31_t packedValue; /* value packed to 32 bits */ 65 | 66 | /*loop Unrolling */ 67 | blkCnt = blockSize >> 2u; 68 | 69 | /* Packing four 8 bit values to 32 bit value in order to use SIMD */ 70 | packedValue = __PACKq7(value, value, value, value); 71 | 72 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 73 | ** a second loop below computes the remaining 1 to 3 samples. */ 74 | while(blkCnt > 0u) 75 | { 76 | /* C = value */ 77 | /* Fill the value in the destination buffer */ 78 | *__SIMD32(pDst)++ = packedValue; 79 | 80 | /* Decrement the loop counter */ 81 | blkCnt--; 82 | } 83 | 84 | /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 85 | ** No loop unrolling is used. */ 86 | blkCnt = blockSize % 0x4u; 87 | 88 | #else 89 | 90 | /* Run the below code for Cortex-M0 */ 91 | 92 | /* Loop over blockSize number of values */ 93 | blkCnt = blockSize; 94 | 95 | #endif /* #ifndef ARM_MATH_CM0 */ 96 | 97 | while(blkCnt > 0u) 98 | { 99 | /* C = value */ 100 | /* Fill the value in the destination buffer */ 101 | *pDst++ = value; 102 | 103 | /* Decrement the loop counter */ 104 | blkCnt--; 105 | } 106 | } 107 | 108 | /** 109 | * @} end of Fill group 110 | */ 111 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/SupportFunctions/arm_q15_to_q31.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_q15_to_q31.c 9 | * 10 | * Description: Converts the elements of the Q15 vector to Q31 vector. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * ---------------------------------------------------------------------------- */ 29 | 30 | #include "arm_math.h" 31 | 32 | /** 33 | * @ingroup groupSupport 34 | */ 35 | 36 | /** 37 | * @addtogroup q15_to_x 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @brief Converts the elements of the Q15 vector to Q31 vector. 43 | * @param[in] *pSrc points to the Q15 input vector 44 | * @param[out] *pDst points to the Q31 output vector 45 | * @param[in] blockSize length of the input vector 46 | * @return none. 47 | * 48 | * \par Description: 49 | * 50 | * The equation used for the conversion process is: 51 | * 52 | *
   
 53 |  * 	pDst[n] = (q31_t) pSrc[n] << 16;   0 <= n < blockSize.   
 54 |  * 
55 | * 56 | */ 57 | 58 | 59 | void arm_q15_to_q31( 60 | q15_t * pSrc, 61 | q31_t * pDst, 62 | uint32_t blockSize) 63 | { 64 | q15_t *pIn = pSrc; /* Src pointer */ 65 | uint32_t blkCnt; /* loop counter */ 66 | 67 | #ifndef ARM_MATH_CM0 68 | 69 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 70 | 71 | /*loop Unrolling */ 72 | blkCnt = blockSize >> 2u; 73 | 74 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 75 | ** a second loop below computes the remaining 1 to 3 samples. */ 76 | while(blkCnt > 0u) 77 | { 78 | /* C = (q31_t)A << 16 */ 79 | /* convert from q15 to q31 and then store the results in the destination buffer */ 80 | *pDst++ = (q31_t) * pIn++ << 16; 81 | *pDst++ = (q31_t) * pIn++ << 16; 82 | *pDst++ = (q31_t) * pIn++ << 16; 83 | *pDst++ = (q31_t) * pIn++ << 16; 84 | 85 | /* Decrement the loop counter */ 86 | blkCnt--; 87 | } 88 | 89 | /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 90 | ** No loop unrolling is used. */ 91 | blkCnt = blockSize % 0x4u; 92 | 93 | #else 94 | 95 | /* Run the below code for Cortex-M0 */ 96 | 97 | /* Loop over blockSize number of values */ 98 | blkCnt = blockSize; 99 | 100 | #endif /* #ifndef ARM_MATH_CM0 */ 101 | 102 | while(blkCnt > 0u) 103 | { 104 | /* C = (q31_t)A << 16 */ 105 | /* convert from q15 to q31 and then store the results in the destination buffer */ 106 | *pDst++ = (q31_t) * pIn++ << 16; 107 | 108 | /* Decrement the loop counter */ 109 | blkCnt--; 110 | } 111 | 112 | } 113 | 114 | /** 115 | * @} end of q15_to_x group 116 | */ 117 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/SupportFunctions/arm_q15_to_q7.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_q15_to_q7.c 9 | * 10 | * Description: Converts the elements of the Q15 vector to Q7 vector. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * ---------------------------------------------------------------------------- */ 29 | 30 | #include "arm_math.h" 31 | 32 | /** 33 | * @ingroup groupSupport 34 | */ 35 | 36 | /** 37 | * @addtogroup q15_to_x 38 | * @{ 39 | */ 40 | 41 | 42 | /** 43 | * @brief Converts the elements of the Q15 vector to Q7 vector. 44 | * @param[in] *pSrc points to the Q15 input vector 45 | * @param[out] *pDst points to the Q7 output vector 46 | * @param[in] blockSize length of the input vector 47 | * @return none. 48 | * 49 | * \par Description: 50 | * 51 | * The equation used for the conversion process is: 52 | * 53 | *
   
 54 |  * 	pDst[n] = (q7_t) pSrc[n] >> 8;   0 <= n < blockSize.   
 55 |  * 
56 | * 57 | */ 58 | 59 | 60 | void arm_q15_to_q7( 61 | q15_t * pSrc, 62 | q7_t * pDst, 63 | uint32_t blockSize) 64 | { 65 | q15_t *pIn = pSrc; /* Src pointer */ 66 | uint32_t blkCnt; /* loop counter */ 67 | 68 | #ifndef ARM_MATH_CM0 69 | 70 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 71 | 72 | /*loop Unrolling */ 73 | blkCnt = blockSize >> 2u; 74 | 75 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 76 | ** a second loop below computes the remaining 1 to 3 samples. */ 77 | while(blkCnt > 0u) 78 | { 79 | /* C = (q7_t) A >> 8 */ 80 | /* convert from q15 to q7 and then store the results in the destination buffer */ 81 | *pDst++ = (q7_t) (*pIn++ >> 8); 82 | *pDst++ = (q7_t) (*pIn++ >> 8); 83 | *pDst++ = (q7_t) (*pIn++ >> 8); 84 | *pDst++ = (q7_t) (*pIn++ >> 8); 85 | 86 | /* Decrement the loop counter */ 87 | blkCnt--; 88 | } 89 | 90 | /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 91 | ** No loop unrolling is used. */ 92 | blkCnt = blockSize % 0x4u; 93 | 94 | #else 95 | 96 | /* Run the below code for Cortex-M0 */ 97 | 98 | /* Loop over blockSize number of values */ 99 | blkCnt = blockSize; 100 | 101 | #endif /* #ifndef ARM_MATH_CM0 */ 102 | 103 | while(blkCnt > 0u) 104 | { 105 | /* C = (q7_t) A >> 8 */ 106 | /* convert from q15 to q7 and then store the results in the destination buffer */ 107 | *pDst++ = (q7_t) (*pIn++ >> 8); 108 | 109 | /* Decrement the loop counter */ 110 | blkCnt--; 111 | } 112 | 113 | } 114 | 115 | /** 116 | * @} end of q15_to_x group 117 | */ 118 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/SupportFunctions/arm_q31_to_q7.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_q31_to_q7.c 9 | * 10 | * Description: Converts the elements of the Q31 vector to Q7 vector. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * ---------------------------------------------------------------------------- */ 29 | 30 | #include "arm_math.h" 31 | 32 | /** 33 | * @ingroup groupSupport 34 | */ 35 | 36 | /** 37 | * @addtogroup q31_to_x 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @brief Converts the elements of the Q31 vector to Q7 vector. 43 | * @param[in] *pSrc points to the Q31 input vector 44 | * @param[out] *pDst points to the Q7 output vector 45 | * @param[in] blockSize length of the input vector 46 | * @return none. 47 | * 48 | * \par Description: 49 | * 50 | * The equation used for the conversion process is: 51 | * 52 | *
   
 53 |  * 	pDst[n] = (q7_t) pSrc[n] >> 24;   0 <= n < blockSize.    
 54 |  * 
55 | * 56 | */ 57 | 58 | 59 | void arm_q31_to_q7( 60 | q31_t * pSrc, 61 | q7_t * pDst, 62 | uint32_t blockSize) 63 | { 64 | q31_t *pIn = pSrc; /* Src pointer */ 65 | uint32_t blkCnt; /* loop counter */ 66 | 67 | #ifndef ARM_MATH_CM0 68 | 69 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 70 | 71 | /*loop Unrolling */ 72 | blkCnt = blockSize >> 2u; 73 | 74 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 75 | ** a second loop below computes the remaining 1 to 3 samples. */ 76 | while(blkCnt > 0u) 77 | { 78 | /* C = (q7_t) A >> 24 */ 79 | /* convert from q31 to q7 and then store the results in the destination buffer */ 80 | *pDst++ = (q7_t) (*pIn++ >> 24); 81 | *pDst++ = (q7_t) (*pIn++ >> 24); 82 | *pDst++ = (q7_t) (*pIn++ >> 24); 83 | *pDst++ = (q7_t) (*pIn++ >> 24); 84 | 85 | /* Decrement the loop counter */ 86 | blkCnt--; 87 | } 88 | 89 | /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 90 | ** No loop unrolling is used. */ 91 | blkCnt = blockSize % 0x4u; 92 | 93 | #else 94 | 95 | /* Run the below code for Cortex-M0 */ 96 | 97 | /* Loop over blockSize number of values */ 98 | blkCnt = blockSize; 99 | 100 | #endif /* #ifndef ARM_MATH_CM0 */ 101 | 102 | while(blkCnt > 0u) 103 | { 104 | /* C = (q7_t) A >> 24 */ 105 | /* convert from q31 to q7 and then store the results in the destination buffer */ 106 | *pDst++ = (q7_t) (*pIn++ >> 24); 107 | 108 | /* Decrement the loop counter */ 109 | blkCnt--; 110 | } 111 | 112 | } 113 | 114 | /** 115 | * @} end of q31_to_x group 116 | */ 117 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/SupportFunctions/arm_q7_to_q15.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_q7_to_q15.c 9 | * 10 | * Description: Converts the elements of the Q7 vector to Q15 vector. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * ---------------------------------------------------------------------------- */ 29 | 30 | #include "arm_math.h" 31 | 32 | /** 33 | * @ingroup groupSupport 34 | */ 35 | 36 | /** 37 | * @addtogroup q7_to_x 38 | * @{ 39 | */ 40 | 41 | 42 | 43 | 44 | /** 45 | * @brief Converts the elements of the Q7 vector to Q15 vector. 46 | * @param[in] *pSrc points to the Q7 input vector 47 | * @param[out] *pDst points to the Q15 output vector 48 | * @param[in] blockSize length of the input vector 49 | * @return none. 50 | * 51 | * \par Description: 52 | * 53 | * The equation used for the conversion process is: 54 | * 55 | *
   
 56 |  * 	pDst[n] = (q15_t) pSrc[n] << 8;   0 <= n < blockSize.   
 57 |  * 
58 | * 59 | */ 60 | 61 | 62 | void arm_q7_to_q15( 63 | q7_t * pSrc, 64 | q15_t * pDst, 65 | uint32_t blockSize) 66 | { 67 | q7_t *pIn = pSrc; /* Src pointer */ 68 | uint32_t blkCnt; /* loop counter */ 69 | 70 | #ifndef ARM_MATH_CM0 71 | 72 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 73 | 74 | /*loop Unrolling */ 75 | blkCnt = blockSize >> 2u; 76 | 77 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 78 | ** a second loop below computes the remaining 1 to 3 samples. */ 79 | while(blkCnt > 0u) 80 | { 81 | /* C = (q15_t) A << 8 */ 82 | /* convert from q7 to q15 and then store the results in the destination buffer */ 83 | *pDst++ = (q15_t) * pIn++ << 8; 84 | *pDst++ = (q15_t) * pIn++ << 8; 85 | *pDst++ = (q15_t) * pIn++ << 8; 86 | *pDst++ = (q15_t) * pIn++ << 8; 87 | 88 | /* Decrement the loop counter */ 89 | blkCnt--; 90 | } 91 | 92 | /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 93 | ** No loop unrolling is used. */ 94 | blkCnt = blockSize % 0x4u; 95 | 96 | #else 97 | 98 | /* Run the below code for Cortex-M0 */ 99 | 100 | /* Loop over blockSize number of values */ 101 | blkCnt = blockSize; 102 | 103 | #endif /* #ifndef ARM_MATH_CM0 */ 104 | 105 | while(blkCnt > 0u) 106 | { 107 | /* C = (q15_t) A << 8 */ 108 | /* convert from q7 to q15 and then store the results in the destination buffer */ 109 | *pDst++ = (q15_t) * pIn++ << 8; 110 | 111 | /* Decrement the loop counter */ 112 | blkCnt--; 113 | } 114 | 115 | } 116 | 117 | /** 118 | * @} end of q7_to_x group 119 | */ 120 | -------------------------------------------------------------------------------- /Libraries/CMSIS/DSP_Lib/Source/SupportFunctions/arm_q7_to_q31.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 15. July 2011 5 | * $Revision: V1.0.10 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_q7_to_q31.c 9 | * 10 | * Description: Converts the elements of the Q7 vector to Q31 vector. 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 13 | * 14 | * Version 1.0.10 2011/7/15 15 | * Big Endian support added and Merged M0 and M3/M4 Source code. 16 | * 17 | * Version 1.0.3 2010/11/29 18 | * Re-organized the CMSIS folders and updated documentation. 19 | * 20 | * Version 1.0.2 2010/11/11 21 | * Documentation updated. 22 | * 23 | * Version 1.0.1 2010/10/05 24 | * Production release and review comments incorporated. 25 | * 26 | * Version 1.0.0 2010/09/20 27 | * Production release and review comments incorporated. 28 | * ---------------------------------------------------------------------------- */ 29 | 30 | #include "arm_math.h" 31 | 32 | /** 33 | * @ingroup groupSupport 34 | */ 35 | 36 | /** 37 | * @addtogroup q7_to_x 38 | * @{ 39 | */ 40 | 41 | /** 42 | * @brief Converts the elements of the Q7 vector to Q31 vector. 43 | * @param[in] *pSrc points to the Q7 input vector 44 | * @param[out] *pDst points to the Q31 output vector 45 | * @param[in] blockSize length of the input vector 46 | * @return none. 47 | * 48 | * \par Description: 49 | * 50 | * The equation used for the conversion process is: 51 | * 52 | *
   
 53 |  * 	pDst[n] = (q31_t) pSrc[n] << 24;   0 <= n < blockSize.  
 54 |  * 
55 | * 56 | */ 57 | 58 | 59 | void arm_q7_to_q31( 60 | q7_t * pSrc, 61 | q31_t * pDst, 62 | uint32_t blockSize) 63 | { 64 | q7_t *pIn = pSrc; /* Src pointer */ 65 | uint32_t blkCnt; /* loop counter */ 66 | 67 | #ifndef ARM_MATH_CM0 68 | 69 | /* Run the below code for Cortex-M4 and Cortex-M3 */ 70 | 71 | /*loop Unrolling */ 72 | blkCnt = blockSize >> 2u; 73 | 74 | /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 75 | ** a second loop below computes the remaining 1 to 3 samples. */ 76 | while(blkCnt > 0u) 77 | { 78 | /* C = (q31_t) A << 24 */ 79 | /* convert from q7 to q31 and then store the results in the destination buffer */ 80 | *pDst++ = (q31_t) * pIn++ << 24; 81 | *pDst++ = (q31_t) * pIn++ << 24; 82 | *pDst++ = (q31_t) * pIn++ << 24; 83 | *pDst++ = (q31_t) * pIn++ << 24; 84 | 85 | /* Decrement the loop counter */ 86 | blkCnt--; 87 | } 88 | 89 | /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 90 | ** No loop unrolling is used. */ 91 | blkCnt = blockSize % 0x4u; 92 | 93 | #else 94 | 95 | /* Run the below code for Cortex-M0 */ 96 | 97 | /* Loop over blockSize number of values */ 98 | blkCnt = blockSize; 99 | 100 | #endif /* #ifndef ARM_MATH_CM0 */ 101 | 102 | while(blkCnt > 0u) 103 | { 104 | /* C = (q31_t) A << 24 */ 105 | /* convert from q7 to q31 and then store the results in the destination buffer */ 106 | *pDst++ = (q31_t) * pIn++ << 24; 107 | 108 | /* Decrement the loop counter */ 109 | blkCnt--; 110 | } 111 | 112 | } 113 | 114 | /** 115 | * @} end of q7_to_x group 116 | */ 117 | -------------------------------------------------------------------------------- /Libraries/CMSIS/Include/arm_common_tables.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 11. November 2010 5 | * $Revision: V1.0.2 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_common_tables.h 9 | * 10 | * Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3 13 | * 14 | * Version 1.0.2 2010/11/11 15 | * Documentation updated. 16 | * 17 | * Version 1.0.1 2010/10/05 18 | * Production release and review comments incorporated. 19 | * 20 | * Version 1.0.0 2010/09/20 21 | * Production release and review comments incorporated. 22 | * -------------------------------------------------------------------- */ 23 | 24 | #ifndef _ARM_COMMON_TABLES_H 25 | #define _ARM_COMMON_TABLES_H 26 | 27 | #include "arm_math.h" 28 | 29 | extern uint16_t armBitRevTable[256]; 30 | extern q15_t armRecipTableQ15[64]; 31 | extern q31_t armRecipTableQ31[64]; 32 | extern const q31_t realCoefAQ31[1024]; 33 | extern const q31_t realCoefBQ31[1024]; 34 | 35 | #endif /* ARM_COMMON_TABLES_H */ 36 | -------------------------------------------------------------------------------- /Libraries/CMSIS/README.txt: -------------------------------------------------------------------------------- 1 | * ------------------------------------------------------------------- 2 | * Copyright (C) 2011 ARM Limited. All rights reserved. 3 | * 4 | * Date: 25 July 2011 5 | * Revision: V2.10 6 | * 7 | * Project: Cortex Microcontroller Software Interface Standard (CMSIS) 8 | * Title: Release Note for CMSIS 9 | * 10 | * ------------------------------------------------------------------- 11 | 12 | 13 | NOTE - Open the index.html file to access CMSIS documentation 14 | 15 | 16 | The Cortex Microcontroller Software Interface Standard (CMSIS) provides a single standard across all 17 | Cortex-Mx processor series vendors. It enables code re-use and code sharing across software projects 18 | and reduces time-to-market for new embedded applications. 19 | 20 | CMSIS is released under the terms of the end user license agreement ("CMSIS END USER LICENCE AGREEMENT.pdf"). 21 | Any user of the software package is bound to the terms and conditions of the end user license agreement. 22 | 23 | 24 | You will find the following sub-directories: 25 | 26 | Documentation - Contains CMSIS documentation. 27 | 28 | DSP_Lib - MDK project files, Examples and source files etc.. to build the 29 | CMSIS DSP Software Library for Cortex-M0, Cortex-M3, Cortex-M4 processors. 30 | 31 | Include - CMSIS Core Support and CMSIS DSP Include Files. 32 | 33 | Lib - CMSIS DSP Binaries 34 | --- -------------------------------------------------------------------------------- /Libraries/CMSIS/ST/STM32F4xx/Include/system_stm32f4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f4xx.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 30-September-2011 7 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /** @addtogroup CMSIS 23 | * @{ 24 | */ 25 | 26 | /** @addtogroup stm32f4xx_system 27 | * @{ 28 | */ 29 | 30 | /** 31 | * @brief Define to prevent recursive inclusion 32 | */ 33 | #ifndef __SYSTEM_STM32F4XX_H 34 | #define __SYSTEM_STM32F4XX_H 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** @addtogroup STM32F4xx_System_Includes 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @addtogroup STM32F4xx_System_Exported_types 50 | * @{ 51 | */ 52 | 53 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 54 | 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | /** @addtogroup STM32F4xx_System_Exported_Constants 61 | * @{ 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @addtogroup STM32F4xx_System_Exported_Macros 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @addtogroup STM32F4xx_System_Exported_Functions 77 | * @{ 78 | */ 79 | 80 | extern void SystemInit(void); 81 | extern void SystemCoreClockUpdate(void); 82 | /** 83 | * @} 84 | */ 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /*__SYSTEM_STM32F4XX_H */ 91 | 92 | /** 93 | * @} 94 | */ 95 | 96 | /** 97 | * @} 98 | */ 99 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 100 | -------------------------------------------------------------------------------- /Libraries/FatFS/src/00readme.txt: -------------------------------------------------------------------------------- 1 | FatFs Module Source Files R0.11 2 | 3 | 4 | FILES 5 | 6 | 00readme.txt This file. 7 | history.txt Revision history. 8 | ffconf.h Configuration file for FatFs module. 9 | ff.h Common include file for FatFs and application module. 10 | ff.c FatFs module. 11 | diskio.h Common include file for FatFs and disk I/O module. 12 | diskio.c An example of glue function to attach existing disk I/O module to FatFs. 13 | integer.h Integer type definitions for FatFs. 14 | option Optional external functions. 15 | 16 | 17 | Low level disk I/O module is not included in this archive because the FatFs 18 | module is only a generic file system layer and not depend on any specific 19 | storage device. You have to provide a low level disk I/O module that written 20 | to control the target storage device. 21 | 22 | -------------------------------------------------------------------------------- /Libraries/FatFS/src/diskio.h: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------------------/ 2 | / Low level disk interface modlue include file (C)ChaN, 2014 / 3 | /-----------------------------------------------------------------------*/ 4 | 5 | #ifndef _DISKIO_DEFINED 6 | #define _DISKIO_DEFINED 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #define _USE_WRITE 1 /* 1: Enable disk_write function */ 13 | #define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ 14 | 15 | #include "integer.h" 16 | 17 | 18 | /* Status of Disk Functions */ 19 | typedef BYTE DSTATUS; 20 | 21 | /* Results of Disk Functions */ 22 | typedef enum { 23 | RES_OK = 0, /* 0: Successful */ 24 | RES_ERROR, /* 1: R/W Error */ 25 | RES_WRPRT, /* 2: Write Protected */ 26 | RES_NOTRDY, /* 3: Not Ready */ 27 | RES_PARERR /* 4: Invalid Parameter */ 28 | } DRESULT; 29 | 30 | 31 | /*---------------------------------------*/ 32 | /* Prototypes for disk control functions */ 33 | 34 | 35 | DSTATUS disk_initialize (BYTE pdrv); 36 | DSTATUS disk_status (BYTE pdrv); 37 | DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); 38 | DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); 39 | DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); 40 | 41 | 42 | /* Disk Status Bits (DSTATUS) */ 43 | 44 | #define STA_NOINIT 0x01 /* Drive not initialized */ 45 | #define STA_NODISK 0x02 /* No medium in the drive */ 46 | #define STA_PROTECT 0x04 /* Write protected */ 47 | 48 | 49 | /* Command code for disk_ioctrl fucntion */ 50 | 51 | /* Generic command (Used by FatFs) */ 52 | #define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ 53 | #define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ 54 | #define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ 55 | #define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ 56 | #define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ 57 | 58 | /* Generic command (Not used by FatFs) */ 59 | #define CTRL_POWER 5 /* Get/Set power status */ 60 | #define CTRL_LOCK 6 /* Lock/Unlock media removal */ 61 | #define CTRL_EJECT 7 /* Eject media */ 62 | #define CTRL_FORMAT 8 /* Create physical format on the media */ 63 | 64 | /* MMC/SDC specific ioctl command */ 65 | #define MMC_GET_TYPE 10 /* Get card type */ 66 | #define MMC_GET_CSD 11 /* Get CSD */ 67 | #define MMC_GET_CID 12 /* Get CID */ 68 | #define MMC_GET_OCR 13 /* Get OCR */ 69 | #define MMC_GET_SDSTAT 14 /* Get SD status */ 70 | 71 | /* ATA/CF specific ioctl command */ 72 | #define ATA_GET_REV 20 /* Get F/W revision */ 73 | #define ATA_GET_MODEL 21 /* Get model name */ 74 | #define ATA_GET_SN 22 /* Get serial number */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /Libraries/FatFS/src/integer.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------*/ 2 | /* Integer type definitions for FatFs module */ 3 | /*-------------------------------------------*/ 4 | 5 | #ifndef _FF_INTEGER 6 | #define _FF_INTEGER 7 | 8 | #ifdef _WIN32 /* FatFs development platform */ 9 | 10 | #include 11 | #include 12 | 13 | #else /* Embedded platform */ 14 | 15 | /* This type MUST be 8 bit */ 16 | typedef unsigned char BYTE; 17 | 18 | /* These types MUST be 16 bit */ 19 | typedef short SHORT; 20 | typedef unsigned short WORD; 21 | typedef unsigned short WCHAR; 22 | 23 | /* These types MUST be 16 bit or 32 bit */ 24 | typedef int INT; 25 | typedef unsigned int UINT; 26 | 27 | /* These types MUST be 32 bit */ 28 | typedef long LONG; 29 | typedef unsigned long DWORD; 30 | 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Libraries/FatFS/src/option/unicode.c: -------------------------------------------------------------------------------- 1 | #include "../ff.h" 2 | 3 | #if _USE_LFN != 0 4 | 5 | #if _CODE_PAGE == 932 /* Japanese Shift_JIS */ 6 | #include "cc932.c" 7 | #elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ 8 | #include "cc936.c" 9 | #elif _CODE_PAGE == 949 /* Korean */ 10 | #include "cc949.c" 11 | #elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ 12 | #include "cc950.c" 13 | #else /* Single Byte Character-Set */ 14 | #include "ccsbcs.c" 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /Libraries/SConscript: -------------------------------------------------------------------------------- 1 | import rtconfig 2 | Import('RTT_ROOT') 3 | from building import * 4 | 5 | # get current directory 6 | cwd = GetCurrentDir() 7 | 8 | # The set of source files associated with this SConscript file. 9 | src = Split(""" 10 | CMSIS/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c 11 | """) 12 | 13 | src += Glob('STM32F4xx_StdPeriph_Driver/src/*.c') 14 | 15 | # starupt scripts for each STM32 kind 16 | # startup_scripts = {} 17 | # startup_scripts['STM32F10X_CL'] = 'startup_stm32f10x_cl.s' 18 | # startup_scripts['STM32F10X_HD'] = 'startup_stm32f10x_hd.s' 19 | # startup_scripts['STM32F10X_HD_VL'] = 'startup_stm32f10x_hd_vl.s' 20 | # startup_scripts['STM32F10X_LD'] = 'startup_stm32f10x_ld.s' 21 | # startup_scripts['STM32F10X_LD_VL'] = 'startup_stm32f10x_ld_vl.s' 22 | # startup_scripts['STM32F10X_MD'] = 'startup_stm32f10x_md.s' 23 | # startup_scripts['STM32F10X_MD_VL'] = 'startup_stm32f10x_md_vl.s' 24 | # startup_scripts['STM32F10X_XL'] = 'startup_stm32f10x_xl.s' 25 | 26 | #add for startup script 27 | if rtconfig.CROSS_TOOL == 'gcc': 28 | src = src + ['CMSIS/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f4xx.s'] 29 | elif rtconfig.CROSS_TOOL == 'keil': 30 | src = src + ['CMSIS/ST/STM32F4xx/Source/Templates/arm/startup_stm32f4xx.s'] 31 | # elif rtconfig.CROSS_TOOL == 'iar': 32 | # src = src + ['CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/iar/' + startup_scripts[rtconfig.STM32_TYPE]] 33 | 34 | path = [cwd + '/STM32F4xx_StdPeriph_Driver/inc', 35 | cwd + '/CMSIS/ST/STM32F4xx/Include', 36 | cwd + '/CMSIS/Include', 37 | cwd + '/CMSIS/CM3/DeviceSupport/ST/STM32F10x'] 38 | 39 | #CPPDEFINES = ['USE_STDPERIPH_DRIVER', rtconfig.STM32_TYPE] 40 | CPPDEFINES = ['USE_STDPERIPH_DRIVER'] 41 | group = DefineGroup('STM32_StdPeriph', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) 42 | 43 | Return('group') 44 | -------------------------------------------------------------------------------- /Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_crc.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 30-September-2011 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2011 STMicroelectronics

20 | ****************************************************************************** 21 | */ 22 | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ 24 | #ifndef __STM32F4xx_CRC_H 25 | #define __STM32F4xx_CRC_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Includes ------------------------------------------------------------------*/ 32 | #include "stm32f4xx.h" 33 | 34 | /** @addtogroup STM32F4xx_StdPeriph_Driver 35 | * @{ 36 | */ 37 | 38 | /** @addtogroup CRC 39 | * @{ 40 | */ 41 | 42 | /* Exported types ------------------------------------------------------------*/ 43 | /* Exported constants --------------------------------------------------------*/ 44 | 45 | /** @defgroup CRC_Exported_Constants 46 | * @{ 47 | */ 48 | 49 | /** 50 | * @} 51 | */ 52 | 53 | /* Exported macro ------------------------------------------------------------*/ 54 | /* Exported functions --------------------------------------------------------*/ 55 | 56 | void CRC_ResetDR(void); 57 | uint32_t CRC_CalcCRC(uint32_t Data); 58 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 59 | uint32_t CRC_GetCRC(void); 60 | void CRC_SetIDRegister(uint8_t IDValue); 61 | uint8_t CRC_GetIDRegister(void); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /* __STM32F4xx_CRC_H */ 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /Libraries/USBStack/INC/usb.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __USB_H__ 17 | #define __USB_H__ 18 | 19 | /* General USB header files */ 20 | #include "usb_def.h" 21 | #include "usb_cdc.h" 22 | #include "usb_hid.h" 23 | #include "usb_msc.h" 24 | 25 | /* USB Device header files */ 26 | #include "usbd_core.h" 27 | #include "usbd_core_cdc.h" 28 | #include "usbd_core_hid.h" 29 | #include "usbd_core_msc.h" 30 | 31 | #include "usbd_desc.h" 32 | #include "usbd_event.h" 33 | #include "usbd_cdc_acm.h" 34 | #include "usbd_hid.h" 35 | #include "usbd_msc.h" 36 | #include "usbd_hw.h" 37 | 38 | #endif /* __USB_H__ */ 39 | -------------------------------------------------------------------------------- /Libraries/USBStack/INC/usb_for_lib.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __USB_FOR_LIB_H__ 17 | #define __USB_FOR_LIB_H__ 18 | 19 | /* USB Device header files */ 20 | #include "usbd_lib_cdc.h" 21 | #include "usbd_lib_hid.h" 22 | #include "usbd_lib_msc.h" 23 | 24 | /* USB System Configuration header file */ 25 | #include "usb_lib.h" 26 | 27 | #endif /* __USB_FOR_LIB_H__ */ 28 | -------------------------------------------------------------------------------- /Libraries/USBStack/INC/usbd_cdc.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __USBD_CDC_H__ 17 | #define __USBD_CDC_H__ 18 | 19 | 20 | /*--------------------------- Event handling routines ------------------------*/ 21 | 22 | extern void usbd_vcom_serial2usb (void); 23 | extern void usbd_vcom_chkserstate (void); 24 | extern void usbd_vcom_usb2serial (void); 25 | extern void usbd_cdc_ser_flush (void); 26 | 27 | extern void USBD_CDC_SOF_Event (void); 28 | 29 | extern void USBD_CDC_EP_INTIN_Event (U32 event); 30 | extern void USBD_CDC_EP_BULKIN_Event (U32 event); 31 | extern void USBD_CDC_EP_BULKOUT_Event (U32 event); 32 | extern void USBD_CDC_EP_BULK_Event (U32 event); 33 | 34 | extern void USBD_RTX_CDC_EP_INTIN_Event (void); 35 | extern void USBD_RTX_CDC_EP_BULKIN_Event (void); 36 | extern void USBD_RTX_CDC_EP_BULKOUT_Event (void); 37 | extern void USBD_RTX_CDC_EP_BULK_Event (void); 38 | 39 | 40 | #endif /* __USBD_CDC_H__ */ 41 | -------------------------------------------------------------------------------- /Libraries/USBStack/INC/usbd_cdc_acm.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __USBD_CDC_ACM_H__ 17 | #define __USBD_CDC_ACM_H__ 18 | 19 | 20 | /*--------------------------- Event handling routines ------------------------*/ 21 | 22 | extern void USBD_CDC_ACM_Reset_Event (void); 23 | 24 | extern void USBD_CDC_ACM_SOF_Event (void); 25 | 26 | extern void USBD_CDC_ACM_EP_INTIN_Event (U32 event); 27 | extern void USBD_CDC_ACM_EP_BULKIN_Event (U32 event); 28 | extern void USBD_CDC_ACM_EP_BULKOUT_Event (U32 event); 29 | extern void USBD_CDC_ACM_EP_BULK_Event (U32 event); 30 | 31 | extern __task void USBD_RTX_CDC_ACM_EP_INTIN_Event (void); 32 | extern __task void USBD_RTX_CDC_ACM_EP_BULKIN_Event (void); 33 | extern __task void USBD_RTX_CDC_ACM_EP_BULKOUT_Event (void); 34 | extern __task void USBD_RTX_CDC_ACM_EP_BULK_Event (void); 35 | 36 | 37 | #endif /* __USBD_CDC_ACM_H__ */ 38 | -------------------------------------------------------------------------------- /Libraries/USBStack/INC/usbd_core.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __USBD_CORE_H__ 17 | #define __USBD_CORE_H__ 18 | 19 | 20 | /*--------------------------- Data structures --------------------------------*/ 21 | 22 | /* USB Device Core Endpoint Data Structure */ 23 | typedef struct _USBD_EP_DATA { 24 | U8 *pData; 25 | U16 Count; 26 | } USBD_EP_DATA; 27 | 28 | 29 | /*--------------------------- Global variables -------------------------------*/ 30 | 31 | /* USB Device Core Global Variables */ 32 | extern U16 USBD_DeviceStatus; 33 | extern U8 USBD_DeviceAddress; 34 | extern U8 USBD_Configuration; 35 | extern U32 USBD_EndPointMask; 36 | extern U32 USBD_EndPointHalt; 37 | extern U32 USBD_EndPointStall; 38 | extern U8 USBD_NumInterfaces; 39 | extern U8 USBD_HighSpeed; 40 | extern U8 USBD_ZLP; 41 | 42 | extern USBD_EP_DATA USBD_EP0Data; 43 | extern USB_SETUP_PACKET USBD_SetupPacket; 44 | 45 | extern OS_TID USBD_RTX_DevTask; 46 | extern OS_TID USBD_RTX_EPTask[]; 47 | extern OS_TID USBD_RTX_CoreTask; 48 | 49 | 50 | /*--------------------------- Functions exported to class specific files -----*/ 51 | 52 | extern void USBD_SetupStage (void); 53 | extern void USBD_DataInStage (void); 54 | extern void USBD_DataOutStage (void); 55 | extern void USBD_StatusInStage (void); 56 | extern void USBD_StatusOutStage (void); 57 | 58 | 59 | /*--------------------------- Event handling routines ------------------------*/ 60 | 61 | extern void usbd_class_init (void); 62 | 63 | extern void USBD_EndPoint0 (U32 event); 64 | 65 | extern __task void USBD_RTX_EndPoint0 (void); 66 | 67 | 68 | #endif /* __USBD_CORE_H__ */ 69 | -------------------------------------------------------------------------------- /Libraries/USBStack/INC/usbd_core_cdc.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __USBD_CORE_CDC_H__ 17 | #define __USBD_CORE_CDC_H__ 18 | 19 | 20 | /*--------------------------- Core overridable class specific functions ------*/ 21 | 22 | extern BOOL USBD_EndPoint0_Setup_CDC_ReqToIF (void); 23 | extern BOOL USBD_EndPoint0_Out_CDC_ReqToIF (void); 24 | 25 | 26 | #endif /* __USBD_CORE_CDC_H__ */ 27 | -------------------------------------------------------------------------------- /Libraries/USBStack/INC/usbd_core_hid.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __USBD_CORE_HID_H__ 17 | #define __USBD_CORE_HID_H__ 18 | 19 | 20 | /*--------------------------- Core overridable class specific functions ------*/ 21 | 22 | extern BOOL USBD_ReqGetDescriptor_HID (U8 **pD, U32 *len); 23 | extern BOOL USBD_EndPoint0_Setup_HID_ReqToIF (void); 24 | extern BOOL USBD_EndPoint0_Out_HID_ReqToIF (void); 25 | 26 | 27 | #endif /* __USBD_CORE_HID_H__ */ 28 | -------------------------------------------------------------------------------- /Libraries/USBStack/INC/usbd_core_msc.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __USBD_CORE_MSC_H__ 17 | #define __USBD_CORE_MSC_H__ 18 | 19 | 20 | /*--------------------------- Core overridable class specific functions ------*/ 21 | 22 | extern void USBD_ReqClrFeature_MSC (U32 EPNum); 23 | extern BOOL USBD_EndPoint0_Setup_MSC_ReqToIF (void); 24 | extern BOOL USBD_EndPoint0_Out_MSC_ReqToIF (void); 25 | 26 | 27 | #endif /* __USBD_CORE_MSC_H__ */ 28 | -------------------------------------------------------------------------------- /Libraries/USBStack/INC/usbd_desc.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __USBD_DESC_H__ 17 | #define __USBD_DESC_H__ 18 | 19 | #define WBVAL(x) (x & 0xFF),((x >> 8) & 0xFF) 20 | #define B3VAL(x) (x & 0xFF),((x >> 8) & 0xFF),((x >> 16) & 0xFF) 21 | #define USB_DEVICE_DESC_SIZE (sizeof(USB_DEVICE_DESCRIPTOR)) 22 | #define USB_DEVICE_QUALI_SIZE (sizeof(USB_DEVICE_QUALIFIER_DESCRIPTOR)) 23 | #define USB_CONFIGUARTION_DESC_SIZE (sizeof(USB_CONFIGURATION_DESCRIPTOR)) 24 | #define USB_INTERFACE_ASSOC_DESC_SIZE (sizeof(USB_INTERFACE_ASSOCIATION_DESCRIPTOR)) 25 | #define USB_INTERFACE_DESC_SIZE (sizeof(USB_INTERFACE_DESCRIPTOR)) 26 | #define USB_ENDPOINT_DESC_SIZE (sizeof(USB_ENDPOINT_DESCRIPTOR)) 27 | #define USB_HID_DESC_SIZE (sizeof(HID_DESCRIPTOR)) 28 | #define USB_HID_REPORT_DESC_SIZE (sizeof(USBD_HID_ReportDescriptor)) 29 | 30 | #endif /* __USBD_DESC_H__ */ 31 | -------------------------------------------------------------------------------- /Libraries/USBStack/INC/usbd_hid.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __USBD_HID_H__ 17 | #define __USBD_HID_H__ 18 | 19 | 20 | /*--------------------------- Global constants -------------------------------*/ 21 | 22 | /* USB HID Class API enumerated constants */ 23 | enum { 24 | USBD_HID_REQ_EP_CTRL = 0, /* Request from control endpoint */ 25 | USBD_HID_REQ_EP_INT, /* Request from interrupt endpoint */ 26 | USBD_HID_REQ_PERIOD_UPDATE /* Request from periodic update */ 27 | }; 28 | 29 | 30 | /*--------------------------- Event handling routines ------------------------*/ 31 | 32 | extern void USBD_HID_Configure_Event (void); 33 | extern void USBD_HID_SOF_Event (void); 34 | 35 | extern void USBD_HID_EP_INTIN_Event (U32 event); 36 | extern void USBD_HID_EP_INTOUT_Event (U32 event); 37 | extern void USBD_HID_EP_INT_Event (U32 event); 38 | 39 | extern __task void USBD_RTX_HID_EP_INTIN_Event (void); 40 | extern __task void USBD_RTX_HID_EP_INTOUT_Event(void); 41 | extern __task void USBD_RTX_HID_EP_INT_Event (void); 42 | 43 | 44 | #endif /* __USBD_HID_H__ */ 45 | -------------------------------------------------------------------------------- /Libraries/USBStack/INC/usbd_hw.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __USBD_HW_H__ 17 | #define __USBD_HW_H__ 18 | 19 | 20 | /* USB Hardware Functions */ 21 | extern void USBD_Init (void); 22 | extern void USBD_Connect (BOOL con); 23 | extern void USBD_Reset (void); 24 | extern void USBD_Suspend (void); 25 | extern void USBD_Resume (void); 26 | extern void USBD_WakeUp (void); 27 | extern void USBD_WakeUpCfg (BOOL cfg); 28 | extern void USBD_SetAddress (U32 adr, U32 setup); 29 | extern void USBD_Configure (BOOL cfg); 30 | extern void USBD_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD); 31 | extern void USBD_DirCtrlEP (U32 dir); 32 | extern void USBD_EnableEP (U32 EPNum); 33 | extern void USBD_DisableEP (U32 EPNum); 34 | extern void USBD_ResetEP (U32 EPNum); 35 | extern void USBD_SetStallEP (U32 EPNum); 36 | extern void USBD_ClrStallEP (U32 EPNum); 37 | extern void USBD_ClearEPBuf (U32 EPNum); 38 | extern U32 USBD_ReadEP (U32 EPNum, U8 *pData); 39 | extern U32 USBD_WriteEP (U32 EPNum, U8 *pData, U32 cnt); 40 | extern U32 USBD_GetFrame (void); 41 | extern U32 USBD_GetError (void); 42 | 43 | #endif /* __USBD_HW_H__ */ 44 | -------------------------------------------------------------------------------- /Libraries/USBStack/INC/usbd_lib_cdc.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __USBD_LIB_CDC_H__ 17 | #define __USBD_LIB_CDC_H__ 18 | 19 | 20 | /*--------------------------- USB Requests -----------------------------------*/ 21 | 22 | extern int32_t USBD_CDC_ACM_SendEncapsulatedCommand (void); 23 | extern int32_t USBD_CDC_ACM_GetEncapsulatedResponse (void); 24 | extern int32_t USBD_CDC_ACM_SetCommFeature (uint16_t feat); 25 | extern int32_t USBD_CDC_ACM_GetCommFeature (uint16_t feat); 26 | extern int32_t USBD_CDC_ACM_ClearCommFeature (uint16_t feat); 27 | extern int32_t USBD_CDC_ACM_SetLineCoding (void); 28 | extern int32_t USBD_CDC_ACM_GetLineCoding (void); 29 | extern int32_t USBD_CDC_ACM_SetControlLineState (uint16_t ctrl_bmp); 30 | extern int32_t USBD_CDC_ACM_SendBreak (uint16_t dur); 31 | 32 | 33 | #endif /* __USBD_LIB_CDC_H__ */ 34 | -------------------------------------------------------------------------------- /Libraries/USBStack/INC/usbd_lib_hid.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __USBD_LIB_HID_H__ 17 | #define __USBD_LIB_HID_H__ 18 | 19 | 20 | /*--------------------------- USB Requests -----------------------------------*/ 21 | 22 | extern BOOL USBD_HID_GetReport (void); 23 | extern BOOL USBD_HID_SetReport (void); 24 | extern BOOL USBD_HID_GetIdle (void); 25 | extern BOOL USBD_HID_SetIdle (void); 26 | extern BOOL USBD_HID_GetProtocol (void); 27 | extern BOOL USBD_HID_SetProtocol (void); 28 | 29 | 30 | #endif /* __USBD_LIB_HID_H__ */ 31 | -------------------------------------------------------------------------------- /Libraries/USBStack/INC/usbd_lib_msc.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __USBD_LIB_MSC_H__ 17 | #define __USBD_LIB_MSC_H__ 18 | 19 | 20 | /*--------------------------- USB Requests -----------------------------------*/ 21 | 22 | extern void USBD_MSC_ClrStallEP(U32 EPNum); 23 | extern BOOL USBD_MSC_Reset (void); 24 | extern BOOL USBD_MSC_GetMaxLUN (void); 25 | extern void USBD_MSC_GetCBW (void); 26 | extern void USBD_MSC_SetCSW (void); 27 | 28 | 29 | #endif /* __USBD_LIB_MSC_H__ */ 30 | -------------------------------------------------------------------------------- /Libraries/USBStack/INC/usbd_msc.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __USBD_MSC_H__ 17 | #define __USBD_MSC_H__ 18 | 19 | 20 | /*--------------------------- Global variables -------------------------------*/ 21 | 22 | /* USB Device Mass Storage Device Class Global Variables */ 23 | extern BOOL USBD_MSC_MediaReady; 24 | extern BOOL USBD_MSC_ReadOnly; 25 | extern U32 USBD_MSC_MemorySize; 26 | extern U32 USBD_MSC_BlockSize; 27 | extern U32 USBD_MSC_BlockGroup; 28 | extern U32 USBD_MSC_BlockCount; 29 | extern U8 *USBD_MSC_BlockBuf; 30 | 31 | 32 | /*--------------------------- Event handling routines ------------------------*/ 33 | 34 | extern void USBD_MSC_EP_BULKIN_Event (U32 event); 35 | extern void USBD_MSC_EP_BULKOUT_Event (U32 event); 36 | extern void USBD_MSC_EP_BULK_Event (U32 event); 37 | 38 | extern __task void USBD_RTX_MSC_EP_BULKIN_Event (void); 39 | extern __task void USBD_RTX_MSC_EP_BULKOUT_Event (void); 40 | extern __task void USBD_RTX_MSC_EP_BULK_Event (void); 41 | 42 | 43 | #endif /* __USBD_MSC_H__ */ 44 | -------------------------------------------------------------------------------- /Libraries/USBStack/SRC/usbd_core_msc.c: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "RTL.h" 17 | #include "rl_usb.h" 18 | #include "string.h" 19 | #include "usb_for_lib.h" 20 | 21 | 22 | /* 23 | * Clear Feature USB Device Request - MSC specific handling 24 | * Parameters: EPNum: Endpoint number 25 | * Return Value: None 26 | */ 27 | 28 | __weak void USBD_ReqClrFeature_MSC (U32 EPNum) { 29 | USBD_MSC_ClrStallEP (EPNum); 30 | } 31 | 32 | 33 | /* 34 | * USB Device Endpoint 0 Event Callback - MSC specific handling (Setup Request To Interface) 35 | * Parameters: none 36 | * Return Value: TRUE - Setup class request ok, FALSE - Setup class request not supported 37 | */ 38 | 39 | __weak BOOL USBD_EndPoint0_Setup_MSC_ReqToIF (void) { 40 | if (USBD_SetupPacket.wIndexL == usbd_msc_if_num) { /* IF number correct? */ 41 | switch (USBD_SetupPacket.bRequest) { 42 | case MSC_REQUEST_RESET: 43 | if ((USBD_SetupPacket.wValue == 0) && /* RESET with invalid parameters -> STALL */ 44 | (USBD_SetupPacket.wLength == 0)) { 45 | if (USBD_MSC_Reset()) { 46 | USBD_StatusInStage(); 47 | return (__TRUE); 48 | } 49 | } 50 | break; 51 | case MSC_REQUEST_GET_MAX_LUN: 52 | if ((USBD_SetupPacket.wValue == 0) && /* GET_MAX_LUN with invalid parameters -> STALL */ 53 | (USBD_SetupPacket.wLength == 1)) { 54 | if (USBD_MSC_GetMaxLUN()) { 55 | USBD_EP0Data.pData = USBD_EP0Buf; 56 | USBD_DataInStage(); 57 | return (__TRUE); 58 | } 59 | } 60 | break; 61 | } 62 | } 63 | return (__FALSE); 64 | } 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 我的Copter项目 2 | 3 | 这是项目 [Copter](https://github.com/shuanglengyunji/Copter) , 4 | 欢迎访问。 5 | 6 | ## 版本信息 7 | 8 | * [master](https://github.com/shuanglengyunji/Copter) 9 | :主版本,保存验证通过的代码。 10 | * [v0.1](https://github.com/shuanglengyunji/Copter/tree/v0.1) 11 | :对原有代码添加注释,排除错误,删除冗余代码,提取核心功能模块。 12 | * [testing](https://github.com/shuanglengyunji/Copter/tree/testing) 13 | :新功能测试代码 14 | * [ks103](https://github.com/shuanglengyunji/Copter/tree/ks103) 15 | :KS103驱动修复(已完成,合并入 [v0.1](https://github.com/shuanglengyunji/Copter/tree/v0.1)) 16 | -------------------------------------------------------------------------------- /RTE/_Anopilot/RTE_Components.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Auto generated Run-Time-Environment Component Configuration File 4 | * *** Do not modify ! *** 5 | * 6 | * Project: 'F407_FC' 7 | * Target: 'Anopilot' 8 | */ 9 | 10 | #ifndef RTE_COMPONENTS_H 11 | #define RTE_COMPONENTS_H 12 | 13 | 14 | /* 15 | * Define the Device Header File: 16 | */ 17 | #define CMSIS_device_header "stm32f4xx.h" 18 | 19 | 20 | #endif /* RTE_COMPONENTS_H */ 21 | -------------------------------------------------------------------------------- /TEST.ANO: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stulwd/Copter/126921b596dd64fe0527816fa0b4425fb100bfca/TEST.ANO -------------------------------------------------------------------------------- /applications/PID.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stulwd/Copter/126921b596dd64fe0527816fa0b4425fb100bfca/applications/PID.c -------------------------------------------------------------------------------- /applications/PID.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stulwd/Copter/126921b596dd64fe0527816fa0b4425fb100bfca/applications/PID.h -------------------------------------------------------------------------------- /applications/anotc_baro_ctrl.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stulwd/Copter/126921b596dd64fe0527816fa0b4425fb100bfca/applications/anotc_baro_ctrl.c -------------------------------------------------------------------------------- /applications/anotc_baro_ctrl.h: -------------------------------------------------------------------------------- 1 | #ifndef __ANOTC_BARO_H 2 | #define __ANOTC_BARO_H 3 | 4 | #include "stm32f4xx.h" 5 | #include "filter.h" 6 | #include "imu.h" 7 | #include "mymath.h" 8 | 9 | #include "parameter.h" 10 | 11 | #include "height_ctrl.h" 12 | 13 | #include "ultrasonic.h" 14 | 15 | //typedef xyz_f_t _xyz_f_t; 16 | #define _xyz_f_t xyz_f_t 17 | 18 | /*===================================================================================================================== 19 | ***** 20 | =====================================================================================================================*/ 21 | typedef struct 22 | { 23 | float b1; 24 | float b2; 25 | float b3; 26 | 27 | float g1; 28 | float g2; 29 | float g3; 30 | 31 | }_f_set_st; 32 | 33 | typedef struct 34 | { 35 | float est_acc_old; 36 | _filter_1_st fusion_acceleration; 37 | _filter_1_st fusion_speed_m; 38 | _filter_1_st fusion_speed_me; 39 | _filter_1_st fusion_displacement; 40 | 41 | }_fusion_st; 42 | extern _fusion_st sonar_fusion; 43 | extern _fusion_st baro_fusion; 44 | 45 | typedef struct 46 | { 47 | float dis_deadzone; 48 | float displacement; 49 | float displacement_old; 50 | float speed; 51 | float speed_old; 52 | float acceleration; 53 | 54 | }_fusion_p_st; 55 | extern _fusion_p_st baro_p; 56 | 57 | typedef struct 58 | { 59 | u8 item; 60 | float a; 61 | float b; 62 | float c; 63 | }_h_f_set_st; 64 | 65 | 66 | extern float wz_speed; 67 | 68 | float baro_compensate(float dT,float kup,float kdw,float vz,float lim); 69 | void baro_ctrl(float dT,_hc_value_st *); 70 | 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /applications/ctrl.h: -------------------------------------------------------------------------------- 1 | #ifndef _CTRL_H 2 | #define _CTRL_H 3 | 4 | #include "stm32f4xx.h" 5 | #include "include.h" 6 | #include "pwm_out.h" 7 | #include "rc.h" 8 | #include "imu.h" 9 | #include "mpu6050.h" 10 | 11 | enum { 12 | PIDROLL, 13 | PIDPITCH, 14 | PIDYAW, 15 | PID4, 16 | PID5, 17 | PID6, 18 | 19 | PIDITEMS 20 | }; 21 | 22 | 23 | 24 | typedef struct 25 | { 26 | xyz_f_t err; 27 | xyz_f_t err_old; 28 | xyz_f_t err_i; 29 | xyz_f_t eliminate_I; 30 | xyz_f_t err_d; 31 | xyz_f_t damp; 32 | xyz_f_t out; 33 | pid_t PID[PIDITEMS]; 34 | xyz_f_t err_weight; 35 | float FB; 36 | 37 | }ctrl_t; 38 | 39 | extern ctrl_t ctrl_1; 40 | extern ctrl_t ctrl_2; 41 | 42 | void CTRL_2(float); 43 | void CTRL_1(float); 44 | void Ctrl_Para_Init(void); 45 | void Thr_Ctrl(float); 46 | void All_Out(float x,float y,float z); 47 | 48 | extern u8 Thr_Low; 49 | extern float Thr_Weight; 50 | extern s16 motor_out[MAXMOTORS]; 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /applications/data_transfer.h: -------------------------------------------------------------------------------- 1 | #ifndef _DATA_TRANSFER_H 2 | #define _DATA_TRANSFER_H 3 | 4 | #include "stm32f4xx.h" 5 | #include "height_ctrl.h" 6 | 7 | 8 | typedef struct 9 | { 10 | u8 msg_id; 11 | u8 msg_data; 12 | u8 send_check; 13 | u8 send_version; 14 | u8 send_status; 15 | u8 send_senser; 16 | u8 send_senser2; 17 | u8 send_pid1; 18 | u8 send_pid2; 19 | u8 send_pid3; 20 | u8 send_pid4; 21 | u8 send_pid5; 22 | u8 send_pid6; 23 | u8 send_rcdata; 24 | u8 send_offset; 25 | u8 send_motopwm; 26 | u8 send_power; 27 | u8 send_user; 28 | u8 send_speed; 29 | u8 send_location; 30 | 31 | } dt_flag_t; 32 | 33 | extern dt_flag_t f; 34 | 35 | 36 | void ANO_DT_Data_Exchange(void); 37 | void ANO_DT_Data_Receive_Prepare(u8 data); 38 | void ANO_DT_Data_Receive_Anl(u8 *data_buf,u8 num); 39 | void ANO_DT_Send_Version(u8 hardware_type, u16 hardware_ver,u16 software_ver,u16 protocol_ver,u16 bootloader_ver); 40 | void ANO_DT_Send_Status(float angle_rol, float angle_pit, float angle_yaw, s32 alt, u8 fly_model, u8 armed); 41 | void ANO_DT_Send_Senser(s16 a_x,s16 a_y,s16 a_z,s16 g_x,s16 g_y,s16 g_z,s16 m_x,s16 m_y,s16 m_z); 42 | void ANO_DT_Send_Senser2(s32 bar_alt,u16 csb_alt); 43 | void ANO_DT_Send_RCData(u16 thr,u16 yaw,u16 rol,u16 pit,u16 aux1,u16 aux2,u16 aux3,u16 aux4,u16 aux5,u16 aux6); 44 | void ANO_DT_Send_Power(u16 votage, u16 current); 45 | void ANO_DT_Send_MotoPWM(u16 m_1,u16 m_2,u16 m_3,u16 m_4,u16 m_5,u16 m_6,u16 m_7,u16 m_8); 46 | void ANO_DT_Send_PID(u8 group,float p1_p,float p1_i,float p1_d,float p2_p,float p2_i,float p2_d,float p3_p,float p3_i,float p3_d); 47 | void ANO_DT_Send_User(void); 48 | void ANO_DT_Send_Speed(float,float,float); 49 | void ANO_DT_Send_Location(u8 state,u8 sat_num,s32 lon,s32 lat,float back_home_angle); 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /applications/data_transfer.h.orig: -------------------------------------------------------------------------------- 1 | #ifndef _DATA_TRANSFER_H 2 | #define _DATA_TRANSFER_H 3 | 4 | #include "stm32f4xx.h" 5 | #include "height_ctrl.h" 6 | 7 | 8 | typedef struct 9 | { 10 | u8 msg_id; 11 | u8 msg_data; 12 | u8 send_check; 13 | u8 send_version; 14 | u8 send_status; 15 | u8 send_senser; 16 | u8 send_senser2; 17 | u8 send_pid1; 18 | u8 send_pid2; 19 | u8 send_pid3; 20 | u8 send_pid4; 21 | u8 send_pid5; 22 | u8 send_pid6; 23 | u8 send_rcdata; 24 | u8 send_offset; 25 | u8 send_motopwm; 26 | u8 send_power; 27 | u8 send_user; 28 | u8 send_speed; 29 | u8 send_location; 30 | 31 | }dt_flag_t; 32 | 33 | extern dt_flag_t f; 34 | 35 | 36 | void ANO_DT_Data_Exchange(void); 37 | void ANO_DT_Data_Receive_Prepare(u8 data); 38 | void ANO_DT_Data_Receive_Anl(u8 *data_buf,u8 num); 39 | void ANO_DT_Send_Version(u8 hardware_type, u16 hardware_ver,u16 software_ver,u16 protocol_ver,u16 bootloader_ver); 40 | void ANO_DT_Send_Status(float angle_rol, float angle_pit, float angle_yaw, s32 alt, u8 fly_model, u8 armed); 41 | void ANO_DT_Send_Senser(s16 a_x,s16 a_y,s16 a_z,s16 g_x,s16 g_y,s16 g_z,s16 m_x,s16 m_y,s16 m_z); 42 | void ANO_DT_Send_Senser2(s32 bar_alt,u16 csb_alt); 43 | void ANO_DT_Send_RCData(u16 thr,u16 yaw,u16 rol,u16 pit,u16 aux1,u16 aux2,u16 aux3,u16 aux4,u16 aux5,u16 aux6); 44 | void ANO_DT_Send_Power(u16 votage, u16 current); 45 | void ANO_DT_Send_MotoPWM(u16 m_1,u16 m_2,u16 m_3,u16 m_4,u16 m_5,u16 m_6,u16 m_7,u16 m_8); 46 | void ANO_DT_Send_PID(u8 group,float p1_p,float p1_i,float p1_d,float p2_p,float p2_i,float p2_d,float p3_p,float p3_i,float p3_d); 47 | void ANO_DT_Send_User(void); 48 | void ANO_DT_Send_Speed(float,float,float); 49 | void ANO_DT_Send_Location(u8 state,u8 sat_num,s32 lon,s32 lat,float back_home_angle); 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /applications/filter.c: -------------------------------------------------------------------------------- 1 | #include "include.h" 2 | #include "filter.h" 3 | #include "mymath.h" 4 | 5 | // #define WIDTH_NUM 101 6 | // #define FIL_ITEM 10 7 | 8 | void anotc_filter_1(float base_hz,float gain_hz,float dT,float in,_filter_1_st *f1) 9 | { 10 | LPF_1_(gain_hz,dT,(in - f1->out),f1->a); //低通后的变化量 11 | 12 | f1->b = my_pow(in - f1->out); 13 | 14 | f1->e_nr = LIMIT(safe_div(my_pow(f1->a),((f1->b) + my_pow(f1->a)),0),0,1); //变化量的有效率 15 | 16 | LPF_1_(base_hz *f1->e_nr,dT,in,f1->out); //低通跟踪 17 | } 18 | 19 | 20 | void Moving_Average(float moavarray[],u16 len ,u16 *fil_cnt,float in,float *out) 21 | { 22 | u16 width_num; 23 | float last; 24 | 25 | width_num = len ; 26 | 27 | if( ++*fil_cnt >= width_num ) 28 | { 29 | *fil_cnt = 0; //now 30 | } 31 | 32 | last = moavarray[ *fil_cnt ]; 33 | 34 | moavarray[ *fil_cnt ] = in; 35 | 36 | *out += ( in - ( last ) )/(float)( width_num ) ; 37 | *out += 0.00001f *(in - *out); //次要修正 38 | 39 | } 40 | 41 | 42 | 43 | 44 | s32 Moving_Median(s32 moavarray[],u16 len ,u16 *fil_p,s32 in) 45 | { 46 | u16 width_num; 47 | u16 now_p; 48 | float t; 49 | s8 pn=0; 50 | u16 start_p,i; 51 | s32 sum = 0; 52 | 53 | width_num = len ; 54 | 55 | if( ++*fil_p >= width_num ) 56 | { 57 | *fil_p = 0; //now 58 | } 59 | 60 | now_p = *fil_p ; 61 | 62 | moavarray[ *fil_p ] = in; 63 | 64 | if(now_p moavarray[now_p + 1]) 67 | { 68 | t = moavarray[now_p]; 69 | moavarray[now_p] = moavarray[now_p + 1]; 70 | moavarray[now_p + 1] = t; 71 | pn = 1; 72 | now_p ++; 73 | if(now_p == (width_num-1)) 74 | { 75 | break; 76 | } 77 | } 78 | } 79 | 80 | if(now_p>0) //保证比较不越界 81 | { 82 | while(moavarray[now_p] < moavarray[now_p - 1]) 83 | { 84 | t = moavarray[now_p]; 85 | moavarray[now_p] = moavarray[now_p - 1]; 86 | moavarray[now_p - 1] = t; 87 | pn = -1; 88 | now_p--; 89 | if(now_p == 0) 90 | { 91 | break; 92 | } 93 | } 94 | 95 | } 96 | 97 | if(*fil_p == 0 && pn == 1) 98 | { 99 | *fil_p = width_num - 1; 100 | } 101 | else if(*fil_p == width_num - 1 && pn == -1) 102 | { 103 | *fil_p = 0; 104 | } 105 | else 106 | { 107 | *fil_p -= pn; 108 | } 109 | 110 | start_p = (u16)(0.25f * width_num ); 111 | for(i = 0; i < width_num/2;i++) 112 | { 113 | sum += moavarray[start_p + i]; 114 | } 115 | return (sum/(width_num/2)); 116 | } 117 | 118 | 119 | 120 | void simple_3d_trans(_xyz_f_t *ref, _xyz_f_t *in, _xyz_f_t *out) //小范围内正确。 121 | { 122 | static s8 pn; 123 | static float h_tmp_x,h_tmp_y; 124 | 125 | h_tmp_x = my_sqrt(my_pow(ref->z) + my_pow(ref->y)); 126 | h_tmp_y = my_sqrt(my_pow(ref->z) + my_pow(ref->x)); 127 | 128 | pn = ref->z < 0? -1 : 1; 129 | 130 | out->x = ( h_tmp_x *in->x - pn *ref->x *in->z ) ; 131 | out->y = ( pn *h_tmp_y *in->y - ref->y *in->z ) ; 132 | 133 | // out->x = h_tmp_x *in->x - ref->x *in->z; 134 | // out->y = ref->z *in->y - ref->y *in->z; 135 | 136 | out->z = ref->x *in->x + ref->y *in->y + ref->z *in->z ; 137 | 138 | } 139 | -------------------------------------------------------------------------------- /applications/filter.h: -------------------------------------------------------------------------------- 1 | #ifndef __FILTER_H 2 | #define __FILTER_H 3 | 4 | #include "parameter.h" 5 | 6 | #define LPF_1_(hz,t,in,out) ((out) += ( 1 / ( 1 + 1 / ( (hz) *6.28f *(t) ) ) ) *( (in) - (out) )) 7 | 8 | #define LPF_1(A,B,C,D) LPF_1_((A),(B),(C),*(D)); 9 | 10 | typedef struct 11 | { 12 | float a; 13 | float b; 14 | float e_nr; 15 | float out; 16 | } _filter_1_st; 17 | 18 | void anotc_filter_1(float base_hz,float gain_hz,float dT,float in,_filter_1_st *f1); 19 | 20 | void Moving_Average(float moavarray[],u16 len ,u16 *fil_cnt,float in,float *out); 21 | s32 Moving_Median(s32 moavarray[],u16 len ,u16 *fil_p,s32 in); 22 | #define _xyz_f_t xyz_f_t 23 | void simple_3d_trans(_xyz_f_t *ref, _xyz_f_t *in, _xyz_f_t *out); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /applications/fly_mode.c: -------------------------------------------------------------------------------- 1 | #include "fly_mode.h" 2 | #include "rc.h" 3 | 4 | u8 mode_value[10]; 5 | u8 mode_state,mode_state_old; 6 | void mode_check(float *ch_in,u8 *mode_value) 7 | { 8 | 9 | if(*(ch_in+AUX1) <-200) 10 | { 11 | mode_state = 0;//0; 12 | } 13 | else if(*(ch_in+AUX1) >200) 14 | { 15 | mode_state = 2; 16 | } 17 | else 18 | { 19 | mode_state = 1; 20 | } 21 | 22 | //=========== GPS、气压定高 =========== 23 | if(mode_state == 0 ) 24 | { 25 | *(mode_value+GPS) = *(mode_value+BARO) = 0; 26 | } 27 | else 28 | { 29 | *(mode_value+GPS) = *(mode_value+BARO) = 1; 30 | } 31 | 32 | // //=========== 返航模式 =========== 33 | // if(fly_ready ) 34 | // { 35 | // if(( mode_state == 2 && mode_state_old != 2) || rc_lose == 1) 36 | // { 37 | 38 | // *(mode_value+BACK_HOME) = 1; 39 | // 40 | 41 | // } 42 | // else if(mode_state != 2) 43 | // { 44 | // *(mode_value+BACK_HOME) = 0; 45 | // } 46 | // } 47 | // else 48 | // { 49 | // *(mode_value+BACK_HOME) = 0; 50 | // } 51 | 52 | 53 | 54 | //=========== =========== 55 | mode_state_old = mode_state; //历史模式 56 | } 57 | -------------------------------------------------------------------------------- /applications/fly_mode.h: -------------------------------------------------------------------------------- 1 | #ifndef __FLY_MODE_H 2 | #define __FLY_MODE_H 3 | 4 | #include "stm32f4xx.h" 5 | #include "include.h" 6 | #include "parameter.h" 7 | 8 | enum 9 | { 10 | BARO=0, 11 | GPS, 12 | BACK_HOME, 13 | //UTRASONIC, 14 | 15 | }; 16 | 17 | extern u8 mode_value[],mode_state; 18 | 19 | 20 | void mode_check(float *ch_in,u8 *mode_value); 21 | #endif 22 | -------------------------------------------------------------------------------- /applications/height_ctrl.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stulwd/Copter/126921b596dd64fe0527816fa0b4425fb100bfca/applications/height_ctrl.c -------------------------------------------------------------------------------- /applications/height_ctrl.h: -------------------------------------------------------------------------------- 1 | #ifndef __HEIGHT_CTRL_H 2 | #define __HEIGHT_CTRL_H 3 | 4 | #include "stm32f4xx.h" 5 | 6 | #include "parameter.h" 7 | 8 | //typedef xyz_f_t _xyz_f_t; 9 | #define _xyz_f_t xyz_f_t 10 | 11 | #define THR_TAKE_OFF_LIMIT 550 12 | typedef struct 13 | { 14 | float m_acc; 15 | float m_speed; 16 | float m_height; 17 | float fusion_acc; 18 | float fusion_speed; 19 | float fusion_height; 20 | 21 | }_hc_value_st; 22 | extern _hc_value_st hc_value; 23 | 24 | float auto_take_off_land(float dT,u8 ready); 25 | float Height_Ctrl(float T,float thr,u8 ready,float en); 26 | void h_pid_init(void); 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /applications/imu.h: -------------------------------------------------------------------------------- 1 | #ifndef _IMU_H_ 2 | #define _IMU_H_ 3 | 4 | #include "stm32f4xx.h" 5 | 6 | #include "parameter.h" 7 | #include "mymath.h" 8 | #include "math.h" 9 | 10 | typedef struct 11 | { 12 | xyz_f_t err; 13 | xyz_f_t err_tmp; 14 | xyz_f_t err_lpf; 15 | xyz_f_t err_Int; 16 | xyz_f_t g; 17 | 18 | }ref_t; 19 | 20 | extern xyz_f_t reference_v,acc_3d_hg; 21 | void IMUupdate(float half_T,float gx, float gy, float gz, float ax, float ay, float az,float *rol,float *pit,float *yaw); 22 | extern float Roll,Pitch,Yaw; 23 | 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /applications/include.h: -------------------------------------------------------------------------------- 1 | #ifndef _INCLUDE_H_ 2 | #define _INCLUDE_H_ 3 | 4 | #include "stm32f4xx.h" 5 | #include "scheduler.h" 6 | #include "time.h" 7 | #include "init.h" 8 | #include "parameter.h" 9 | #include "pwm_in.h" 10 | #include "usart.h" 11 | #include "usbd_user_hid.h" 12 | #include "data_transfer.h" 13 | 14 | //================系统=================== 15 | 16 | #define USE_US100 //使用us100型号超声波 17 | 18 | #define MAXMOTORS (4) //电机数量 19 | #define GET_TIME_NUM (5) //设置获取时间的数组数量 20 | #define CH_NUM (8) //接收机通道数量 21 | 22 | #define USE_TOE_IN_UNLOCK 0 // 0:默认解锁方式,1:外八解锁方式 23 | #define ANO_DT_USE_USART2 //开启串口2数传功能 24 | #define ANO_DT_USE_USB_HID //开启飞控USBHID连接上位机功能 25 | //======================================= 26 | /***************中断优先级******************/ 27 | #define NVIC_GROUP NVIC_PriorityGroup_3 //中断分组选择 28 | #define NVIC_PWMIN_P 1 //接收机采集 29 | #define NVIC_PWMIN_S 1 30 | #define NVIC_TIME_P 2 //暂未使用 31 | #define NVIC_TIME_S 0 32 | #define NVIC_UART_P 5 //暂未使用 33 | #define NVIC_UART_S 1 34 | #define NVIC_UART2_P 3 //串口2中断 35 | #define NVIC_UART2_S 1 36 | /***********************************************/ 37 | 38 | //================传感器=================== 39 | #define ACC_ADJ_EN //是否允许校准加速度计,(定义则允许) 40 | 41 | #define OFFSET_AV_NUM 50 //校准偏移量时的平均次数。 42 | #define FILTER_NUM 10 //滑动平均滤波数值个数 43 | 44 | #define TO_ANGLE 0.06103f //0.061036 // 4000/65536 +-2000 ??? 45 | 46 | #define FIX_GYRO_Y 1.02f //陀螺仪Y轴固有补偿 47 | #define FIX_GYRO_X 1.02f //陀螺仪X轴固有补偿 48 | 49 | #define TO_M_S2 0.23926f // 980cm/s2 +-8g 980/4096 50 | #define ANGLE_TO_RADIAN 0.01745329f //*0.01745 = /57.3 角度转弧度 51 | 52 | #define MAX_ACC 4096.0f //+-8G 加速度计量程 53 | #define TO_DEG_S 500.0f //T = 2ms 默认为2ms ,数值等于1/T 54 | 55 | enum 56 | { 57 | A_X = 0, 58 | A_Y , 59 | A_Z , 60 | G_Y , 61 | G_X , 62 | G_Z , 63 | TEM , 64 | ITEMS , 65 | }; 66 | 67 | // CH_filter[],0横滚,1俯仰,2油门,3航向 68 | enum 69 | { 70 | ROL= 0, 71 | PIT , 72 | THR , 73 | YAW , 74 | AUX1 , 75 | AUX2 , 76 | AUX3 , 77 | AUX4 , 78 | }; 79 | //========================================= 80 | 81 | //================控制===================== 82 | #define MAX_VERTICAL_SPEED_UP 5000 //最大上升速度mm/s 83 | #define MAX_VERTICAL_SPEED_DW 3000 //最大下降速度mm/s 84 | 85 | #define MAX_CTRL_ANGLE 30.0f //遥控能达到的最大角度 86 | #define ANGLE_TO_MAX_AS 30.0f //角度误差N时,期望角速度达到最大(可以通过调整CTRL_2的P值调整) 87 | #define CTRL_2_INT_LIMIT 0.5f *MAX_CTRL_ANGLE //外环积分幅度 88 | 89 | #define MAX_CTRL_ASPEED 300.0f //ROL,PIT允许的最大控制角速度 90 | #define MAX_CTRL_YAW_SPEED 150.0f //YAW允许的最大控制角速度 91 | #define CTRL_1_INT_LIMIT 0.5f *MAX_CTRL_ASPEED //内环积分幅度 92 | 93 | 94 | #define MAX_PWM 100 ///% 最大PWM输出为100%油门 95 | #define MAX_THR 80 ///% 油门通道最大占比80%,留20%给控制量 96 | #define READY_SPEED 20 ///% 解锁后电机转速20%油门 97 | //========================================= 98 | 99 | 100 | 101 | 102 | 103 | 104 | #endif 105 | 106 | -------------------------------------------------------------------------------- /applications/init.c: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2014 ANO Tech ******************************** 2 | * 作者 :匿名科创 3 | * 文件名 :init.c 4 | * 描述 :飞控初始化 5 | * 官网 :www.anotc.com 6 | * 淘宝 :anotc.taobao.com 7 | * 技术Q群 :190169595 8 | **********************************************************************************/ 9 | 10 | #include "include.h" 11 | #include "pwm_out.h" 12 | #include "mpu6050.h" 13 | #include "i2c_soft.h" 14 | #include "led.h" 15 | #include "ctrl.h" 16 | #include "ms5611.h" 17 | #include "ak8975.h" 18 | #include "ultrasonic.h" 19 | 20 | u8 All_Init() 21 | { 22 | NVIC_PriorityGroupConfig(NVIC_GROUP); //中断优先级组别设置 23 | 24 | SysTick_Configuration(); //滴答时钟 25 | 26 | I2c_Soft_Init(); //初始化模拟I2C 27 | 28 | PWM_IN_Init(); //初始化接收机采集功能 29 | 30 | PWM_Out_Init(400); //初始化电调输出功能 31 | 32 | Usb_Hid_Init(); //飞控usb接口的hid初始化 33 | 34 | MS5611_Init(); //气压计初始化 35 | 36 | Delay_ms(400); //延时 37 | 38 | MPU6050_Init(20); //加速度计、陀螺仪初始化,配置20hz低通 39 | 40 | LED_Init(); //LED功能初始化 41 | 42 | Usart2_Init(500000); //串口2初始化,函数参数为波特率 43 | //Usart2_Init(256000); 44 | 45 | 46 | 47 | //TIM_INIT(); 48 | 49 | Para_Init(); //参数初始化 50 | 51 | Delay_ms(100); //延时 52 | 53 | Ultrasonic_Init(); //超声波初始化 54 | 55 | ak8975_ok = !(ANO_AK8975_Run()); 56 | 57 | if( !mpu6050_ok ) 58 | { 59 | LED_MPU_Err(); 60 | } 61 | else if( !ak8975_ok ) 62 | { 63 | LED_Mag_Err(); 64 | } 65 | else if( !ms5611_ok ) 66 | { 67 | LED_MS5611_Err(); 68 | } 69 | 70 | aircraft_mode_led(MAXMOTORS); 71 | 72 | Cycle_Time_Init(); 73 | 74 | return (1); 75 | } 76 | /******************* (C) COPYRIGHT 2014 ANO TECH *****END OF FILE************/ 77 | -------------------------------------------------------------------------------- /applications/init.h: -------------------------------------------------------------------------------- 1 | #ifndef _INIT_H_ 2 | #define _INIT_H_ 3 | 4 | #include "stm32f4xx.h" 5 | 6 | u8 All_Init(void); 7 | extern u8 Init_Finish; 8 | #endif 9 | -------------------------------------------------------------------------------- /applications/main.c: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2014 ANO Tech ******************************** 2 | * 作者 :匿名科创 3 | * 文件名 :main.c 4 | * 描述 :主循环 5 | * 官网 :www.anotc.com 6 | * 淘宝 :anotc.taobao.com 7 | * 技术Q群 :190169595 8 | **********************************************************************************/ 9 | #include "include.h" 10 | 11 | #ifdef USE_FULL_ASSERT 12 | void assert_failed(uint8_t* file, uint32_t line) 13 | { 14 | while (1) 15 | { 16 | 17 | } 18 | } 19 | #endif 20 | //======================================================================================= 21 | 22 | 23 | //======================================================================================= 24 | u8 Init_Finish = 0; 25 | int main(void) 26 | { 27 | Init_Finish = All_Init(); 28 | while(1) 29 | { 30 | Duty_Loop(); 31 | } 32 | } 33 | /******************* (C) COPYRIGHT 2014 ANO TECH *****END OF FILE************/ 34 | 35 | -------------------------------------------------------------------------------- /applications/mymath.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stulwd/Copter/126921b596dd64fe0527816fa0b4425fb100bfca/applications/mymath.h -------------------------------------------------------------------------------- /applications/parameter.h: -------------------------------------------------------------------------------- 1 | #ifndef _PARAMETER_H 2 | #define _PARAMETER_H 3 | 4 | #include "stm32f4xx.h" 5 | 6 | typedef struct 7 | { 8 | float kp; 9 | float kd; 10 | float ki; 11 | float kdamp; 12 | 13 | }pid_t; 14 | 15 | typedef struct 16 | { 17 | float x; 18 | float y; 19 | float z; 20 | }xyz_f_t; 21 | 22 | typedef struct 23 | { 24 | s16 x; 25 | s16 y; 26 | s16 z; 27 | 28 | }xyz_s16_t; 29 | 30 | 31 | typedef union 32 | { 33 | uint8_t raw_data[64]; 34 | struct 35 | { 36 | xyz_f_t Accel; 37 | xyz_f_t Gyro; 38 | xyz_f_t Mag; 39 | xyz_f_t vec_3d_cali; 40 | uint32_t mpu_flag; 41 | float Acc_Temperature; 42 | float Gyro_Temperature; 43 | }Offset; 44 | }sensor_setup_t; //__attribute__((packed)) 45 | 46 | typedef struct{ 47 | pid_t roll; 48 | pid_t pitch; 49 | pid_t yaw; 50 | }pid_group_t; 51 | 52 | typedef union 53 | { 54 | uint8_t raw_data[192]; 55 | struct 56 | { 57 | pid_group_t ctrl1; 58 | pid_group_t ctrl2; 59 | ///////////////////// 60 | pid_t hc_sp; 61 | pid_t hc_height; 62 | pid_t ctrl3; 63 | pid_t ctrl4; 64 | 65 | }groups; 66 | 67 | }pid_setup_t; 68 | 69 | extern sensor_setup_t sensor_setup; 70 | extern pid_setup_t pid_setup; 71 | 72 | void Senser_Calibrat_Read(void); 73 | void PID_Para_Read(void); 74 | void Para_Init(void); 75 | 76 | void Para_ResetToFactorySetup(void); 77 | void Param_SavePID(void); 78 | void Param_SaveAccelOffset(xyz_f_t *offset); 79 | void Param_SaveGyroOffset(xyz_f_t *offset); 80 | void Param_SaveMagOffset(xyz_f_t *offset); 81 | void Param_Save_3d_offset(xyz_f_t *offset); 82 | void Parameter_Save(void); 83 | void PID_Para_Init(void); 84 | 85 | #endif 86 | 87 | -------------------------------------------------------------------------------- /applications/rc.h: -------------------------------------------------------------------------------- 1 | #ifndef _RC_H 2 | #define _RC_H 3 | 4 | #include "stm32f4xx.h" 5 | 6 | void Fly_Ready(float T,float height_speed_mm); 7 | void RC_Duty(float , u16 * ); 8 | void Feed_Rc_Dog(u8 ch_mode); 9 | void Mode(void); 10 | 11 | extern float CH_filter[]; 12 | extern s16 CH[]; 13 | extern u8 fly_ready,NS,thr_stick_low ; 14 | extern u8 height_ctrl_mode ; 15 | extern u16 RX_CH[]; 16 | extern u8 rc_lose; 17 | 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /applications/scheduler.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCHEDULER_H_ 2 | #define _SCHEDULER_H_ 3 | 4 | #include "stm32f4xx.h" 5 | 6 | typedef struct 7 | { 8 | u8 check_flag; 9 | u8 err_flag; 10 | s16 cnt_1ms; 11 | s16 cnt_2ms; 12 | s16 cnt_5ms; 13 | s16 cnt_10ms; 14 | s16 cnt_20ms; 15 | s16 cnt_50ms; 16 | u16 time; 17 | }loop_t; 18 | 19 | void Loop_check(void); 20 | 21 | void Duty_Loop(void); 22 | 23 | void Inner_Loop(float); 24 | 25 | void Outer_Loop(float); 26 | 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /applications/stm32f4xx_it.c: -------------------------------------------------------------------------------- 1 | #include "include.h" 2 | 3 | void NMI_Handler(void) 4 | { 5 | } 6 | 7 | void MemManage_Handler(void) 8 | { 9 | /* Go to infinite loop when Memory Manage exception occurs */ 10 | while (1) 11 | { 12 | } 13 | } 14 | 15 | void BusFault_Handler(void) 16 | { 17 | /* Go to infinite loop when Bus Fault exception occurs */ 18 | while (1) 19 | { 20 | } 21 | } 22 | 23 | void UsageFault_Handler(void) 24 | { 25 | /* Go to infinite loop when Usage Fault exception occurs */ 26 | while (1) 27 | { 28 | } 29 | } 30 | 31 | void SVC_Handler(void) 32 | { 33 | } 34 | 35 | void DebugMon_Handler(void) 36 | { 37 | } 38 | 39 | void SysTick_Handler(void) 40 | { 41 | sysTickUptime++; 42 | sys_time(); 43 | } 44 | 45 | void TIM3_IRQHandler(void) 46 | { 47 | _TIM3_IRQHandler(); 48 | 49 | } 50 | 51 | void TIM4_IRQHandler(void) 52 | { 53 | _TIM4_IRQHandler(); 54 | 55 | } 56 | 57 | void USART2_IRQHandler(void) 58 | { 59 | Usart2_IRQ(); 60 | } 61 | 62 | void UART5_IRQHandler(void) 63 | { 64 | Uart5_IRQ(); 65 | } 66 | -------------------------------------------------------------------------------- /applications/usbd_user_hid.h: -------------------------------------------------------------------------------- 1 | #ifndef _USBD_USER_HID_H 2 | #define _USBD_USER_HID_H 3 | 4 | #include "stm32f4xx.h" 5 | 6 | extern void Usb_Hid_Init(void) ; 7 | void Usb_Hid_Adddata(u8 *dataToSend , u8 length); 8 | void Usb_Hid_Send(void); 9 | 10 | #endif 11 | 12 | -------------------------------------------------------------------------------- /applications/version.c: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "string.h" 17 | #include "version.h" 18 | 19 | 20 | extern uint8_t BlockBuf[]; 21 | 22 | // Pointers to substitution strings 23 | const char *fw_version = (const char *)FW_BUILD; 24 | 25 | 26 | uint8_t string_auth[25 + 4]; 27 | uint8_t string_auth_descriptor[2+25*2]; 28 | 29 | 30 | uint8_t get_len_string_interface(void) { 31 | return 2 + strlen((const char *)(string_auth+4))*2; 32 | } 33 | 34 | uint8_t * get_uid_string_interface(void) { 35 | return string_auth_descriptor; 36 | } 37 | 38 | const uint8_t board_secret[9] = "k4flu5fs"; 39 | -------------------------------------------------------------------------------- /applications/version.h: -------------------------------------------------------------------------------- 1 | /* CMSIS-DAP Interface Firmware 2 | * Copyright (c) 2009-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef VERSION_H 17 | #define VERSION_H 18 | 19 | #include "stdint.h" 20 | 21 | #define FW_BUILD "0202" 22 | 23 | uint8_t update_html_file(void); 24 | uint8_t get_len_string_interface(void); 25 | uint8_t *get_uid_string_interface(void); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /build/F407_FC.sct: -------------------------------------------------------------------------------- 1 | ; ************************************************************* 2 | ; *** Scatter-Loading Description File generated by uVision *** 3 | ; ************************************************************* 4 | 5 | LR_IROM1 0x08000000 0x00100000 { ; load region size_region 6 | ER_IROM1 0x08000000 0x00100000 { ; load address = execution address 7 | *.o (RESET, +First) 8 | *(InRoot$$Sections) 9 | .ANY (+RO) 10 | } 11 | RW_IRAM1 0x20000000 0x00020000 { ; RW data 12 | .ANY (+RW +ZI) 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /clear编译完的东西.bat: -------------------------------------------------------------------------------- 1 | del build\*.* /q 2 | del *.bak /q 3 | -------------------------------------------------------------------------------- /doc/note.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | APB1 42m 4 | APB2 84m 5 | 6 | TIMx clk = APBx *2 7 | 8 | 中断优先级: 9 | 10 | 第0组:所有4位用于指定响应优先级; 11 | 第1组:最高1位用于指定抢占式优先级,最低3位用于指定响应优先级; 12 | 第2组:最高2位用于指定抢占式优先级,最低2位用于指定响应优先级; 13 | 第3组:最高3位用于指定抢占式优先级,最低1位用于指定响应优先级; 14 | 第4组:所有4位用于指定抢占式优先级。 15 | |先抢占,再响应| 16 | 1)如果指定的抢占式优先级别或响应优先级别超出了选定的优先级分组所限定的范围,将可能得到意想不到的结果; 17 | 2)抢占式优先级别相同的中断源之间没有嵌套关系; 18 | 3)如果某个中断源被指定为某个抢占式优先级别,又没有其它中断源处于同一个抢占式优先级别,则可以为这个中断源指定任意有效的响应优先级别。 19 | 20 | 21 | 22 | 23 | wz_acc_mms2 = (wz_acc/4096.0f) *10000 + hc_acc_i; 24 | 25 | hc_acc_i += 0.4f *T *( (wz_speed - wz_speed_old)/T - wz_acc_mms2 ); 26 | 27 | 28 | wz_acc_mms2 = (wz_acc/4096.0f) *10000 + (hc_acc_lpf - wz_acc_mms2); 29 | 30 | hc_acc_lpf += 0.4f *T *( (wz_speed - wz_speed_old)/T - hc_acc_lpf ); 31 | 32 | 把hc_acc_i代成(hc_acc_lpf - wz_acc_mms2),然后后边等效,就有了。 33 | 注意wz_speed里边包含hc_acc_i的积分,两次wz_speed做差后,又得到hc_acc_i单次的值。 -------------------------------------------------------------------------------- /doc/record.txt: -------------------------------------------------------------------------------- 1 |  2 | 事件记录,beta0.4开始。 3 | 4 | 5 | 2015.5.18 6 | beta 0.4 修复各种bug。 7 | 8 | 9 | 10 | 2015.5.19 11 | beta 0.5 完善摇杆识别。 12 | 13 | 14 | beta 0.6 pwm_in优化 15 | 16 | 17 | beta 0.7 修复bug,优化rc,添加mapping 18 | 19 | 20 | beta 0.9 起飞成功 21 | beta 1.0 修复控制周期bug 22 | 23 | 24 | beta 1.1 添加部分注释 25 | 26 | beta 1.2 优化整定参数,修改bug 27 | 28 | beta 1.3 完成flash存储,上位机HID通信 29 | 30 | beta 1.35 增加磁力计纠正航向 31 | 32 | beta 1.36 增加磁力计校准时灯管提示 33 | 34 | beta 1.37 增加mpu6050,ak8975,ms5611自检,未通过的LED状态分别是:间隔连续闪烁1次;间隔连续闪烁2次;间隔连续闪烁3次 35 | 36 | beta 1.37.1 增加滑动窗口平均滤波函数,增加ks103超声波读取,该版备份。 37 | 38 | beta 1.37.2 添加user数据,上位机显示波形,串口超声波改发送中断。 39 | 40 | beta 1.37.3 添加部分注释,修改部分变量名,增加ano_private.lib。 41 | 42 | beta 1.38 添加超声波控制代码(注意!暂未测试),修改磁力计纠正算法(重要更新),消除磁力计纠正YAW时对姿态的干扰。删除ano_pribate.lib 43 | 44 | beta 1.39 修复上一版数据传输一个小bug,添加环形缓存。 45 | 46 | beta 1.39.1 超声波直接控制高度,还有问题。 47 | 48 | beta 1.40 超声波定高ok,暂没优化参数,没加上位机调参。可改惯导竖直方向速率控制。 49 | 50 | beta 1.40.1 51 | #define CTRL_HEIGHT 1 //0失能,1使能 52 | #define HEIGHT_MODE 1 //0,无,1惯性控制高度,2气压计控制(空),3超声波控制高度 53 | 54 | beta 1.41 修复磁力计纠正的一个bug。 55 | 56 | beta 1.42 us100超声波定高稳定 57 | 58 | beta 1.43 59 | 1.模式0(呼吸白,解锁绿长),普通,油门直接输出。模式1(呼吸浅绿,解锁浅绿长),垂直速率控制(下一步改为气压定高)。模式2(呼吸紫,解锁紫长),超声波定高。 60 | 2.飞行时,只能向模式0切换,其他切换无效。 61 | 3.只有插上超声波,模式3才有效。(这个未优化,比如临时拔下超声波,也能进入该模式。) 62 | 63 | 64 | beta 1.44 65 | 修复定高控制中积分的bug,优化超声波定高,优化高度设定值调节速度。增加超声波最大高度,可达到到1.5米比较稳定(高度越低越稳定)。 66 | 67 | beta 1.46 68 | 气压计定高,测试版(无高度静差修正)。 69 | 70 | beta 1.47 71 | 气压计定高,测试版(无高度静差修正)。改进磁力计纠正算法,解决磁力计纠正时对姿态的干扰,修正磁力计纠正中180度的一个错误。 72 | 73 | beta 1.48 74 | 修复气压计速率的一个bug,并调整可控制的速率。 75 | 76 | beta 1.48.1 77 | 注释掉while(1); 78 | 79 | beta 1.49 电赛版本,完善通信协议中串口接收通道数据部分。 80 | 81 | beta 1.49.2 修改气压计定高速率环积分部分,优化定高效果。 82 | 83 | beta 1.49.3 滤波算法测试。 84 | 85 | beta 1.50 修改磁力计纠正方法 86 | 87 | beta 1.50.2 增加罗盘倾斜纠正,修复数据传输一个bug。 88 | 89 | beta 1.51 修改气压计融合,定高控制等几处小bug 90 | 91 | beta 1.52 修改超声波定高一个小bug 92 | 93 | beta 1.6 细节优化&新参数 94 | 95 | beta 1.6.2 修正罗盘原始数据的一个错误。 96 | 97 | beta 1.6.2_fix 上版漏掉一句代码,导致解锁后yaw混乱,I'm sorry。。。 98 | 99 | beta 1.6.3 新融合策略,解决加速度零点漂移(水平姿态)。 100 | 101 | beta 1.6.4 修复连接usb后,复位单片机偶尔卡死的问题;修复上版气压速度融合的小错误;修复LED的GPID初始化结构体未给初值造成可能出错的问题。 102 | 103 | beta 1.6.5 小更新,增加加速度计判断,解决6050不同批次量程问题。 104 | 105 | beta 1.6.6 小更新,解决pid数据通信不稳定问题。 106 | 107 | beta 1.6.7 小更新,适配新版领航者的RGB灯 108 | -------------------------------------------------------------------------------- /drivers/ak8975.h: -------------------------------------------------------------------------------- 1 | #ifndef _AK8975_H_ 2 | #define _AK8975_H_ 3 | 4 | #include "stm32f4xx.h" 5 | #include "stdbool.h" 6 | #include "include.h" 7 | 8 | #define CALIBRATING_MAG_CYCLES 2000 //校准时间持续20s 9 | 10 | #define AK8975_ADDRESS 0x0c // 0x18 11 | 12 | #define AK8975_WIA 0x00 13 | #define AK8975_HXL 0x03 14 | #define AK8975_HXH 0x04 15 | #define AK8975_HYL 0x05 16 | #define AK8975_HYH 0x06 17 | #define AK8975_HZL 0x07 18 | #define AK8975_HZH 0x08 19 | #define AK8975_CNTL 0x0A 20 | 21 | typedef struct 22 | { 23 | xyz_s16_t Mag_Adc; //采样值 24 | xyz_f_t Mag_Offset; //偏移值 25 | xyz_f_t Mag_Gain; //比例缩放 26 | xyz_f_t Mag_Val; //纠正后的值 27 | }ak8975_t; 28 | 29 | extern ak8975_t ak8975; 30 | 31 | bool ANO_AK8975_Run(void); 32 | void ANO_AK8975_CalOffset_Mag(void); 33 | void ANO_AK8975_Read(void); 34 | 35 | 36 | extern u8 Mag_CALIBRATED; 37 | extern u8 ak8975_ok; 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /drivers/drv_w25qxx.h: -------------------------------------------------------------------------------- 1 | #ifndef __DRIVER_AT45DB_H 2 | #define __DRIVER_AT45DB_H 3 | #include "stm32f4xx.h" 4 | 5 | #ifdef USE_SPI1 6 | #define SPI1_CLOCK RCC_APB2Periph_SPI1 7 | #define SPI1_AF GPIO_AF_SPI1 8 | #define SPI1_GPIO_CLOCK RCC_AHB1Periph_GPIOA 9 | #define SPI1_SCK_PORT GPIOA 10 | #define SPI1_MISO_PORT GPIOA 11 | #define SPI1_MOSI_PORT GPIOA 12 | #define SPI1_SCK_PIN GPIO_Pin_5 13 | #define SPI1_MISO_PIN GPIO_Pin_6 14 | #define SPI1_MOSI_PIN GPIO_Pin_7 15 | #define SPI1_SCK_SOURCE GPIO_PinSource5 16 | #define SPI1_MISO_SOURCE GPIO_PinSource6 17 | #define SPI1_MOSI_SOURCE GPIO_PinSource7 18 | #define SPI1_DMA_RX_ST DMA1_Stream3 19 | #define SPI1_DMA_RX_CHANNEL DMA_Channel_0 20 | #define SPI1_DMA_RX_FLAGS (DMA_IT_TEIF3 | DMA_IT_DMEIF3 | DMA_IT_FEIF3 | DMA_IT_TCIF3 | DMA_IT_HTIF3) 21 | #define SPI1_DMA_RX_IRQ DMA1_Stream3_IRQn 22 | #define SPI1_DMA_RX_HANDLER DMA1_Stream3_IRQHandler 23 | #define SPI1_DMA_TX_ST DMA1_Stream4 24 | #define SPI1_DMA_TX_CHANNEL DMA_Channel_0 25 | #define SPI1_DMA_TX_FLAGS (DMA_IT_TEIF4 | DMA_IT_DMEIF4 | DMA_IT_FEIF4 | DMA_IT_TCIF4 | DMA_IT_HTIF4) 26 | #endif 27 | 28 | /* Jedec Flash Information structure */ 29 | typedef struct 30 | { 31 | uint8_t initialized; 32 | uint16_t sector_size; 33 | uint16_t sector_count; 34 | uint32_t capacity; 35 | } flash_info_t; 36 | 37 | 38 | void Flash_Init(void); 39 | void Flash_SectorErase(uint32_t address,uint8_t state); 40 | void Flash_PageRead(uint32_t address,uint8_t* buffer, uint32_t lenght); 41 | void Flash_PageWrite(uint32_t address,uint8_t* buffer, uint32_t lenght); 42 | void Flash_SectorsRead(uint32_t address,uint8_t *buffer,uint16_t count); 43 | void Flash_SectorsWrite(uint32_t address,uint8_t *buffer,uint16_t count); 44 | flash_info_t *Flash_GetInfo(void); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /drivers/i2c_soft.h: -------------------------------------------------------------------------------- 1 | #ifndef _I2C_SOFT_H 2 | #define _I2C_SOFT_H 3 | 4 | #include "stm32f4xx.h" 5 | #include "time.h" 6 | 7 | #define SCL_H ANO_GPIO_I2C->BSRRL = I2C_Pin_SCL 8 | #define SCL_L ANO_GPIO_I2C->BSRRH = I2C_Pin_SCL 9 | #define SDA_H ANO_GPIO_I2C->BSRRL = I2C_Pin_SDA 10 | #define SDA_L ANO_GPIO_I2C->BSRRH = I2C_Pin_SDA 11 | #define SCL_read ANO_GPIO_I2C->IDR & I2C_Pin_SCL 12 | #define SDA_read ANO_GPIO_I2C->IDR & I2C_Pin_SDA 13 | 14 | /***************I2C GPIO定义******************/ 15 | #define ANO_GPIO_I2C GPIOB 16 | #define I2C_Pin_SCL GPIO_Pin_6 17 | #define I2C_Pin_SDA GPIO_Pin_7 18 | #define ANO_RCC_I2C RCC_AHB1Periph_GPIOB 19 | /*********************************************/ 20 | extern volatile u8 I2C_FastMode; 21 | 22 | void I2c_Soft_Init(void); 23 | void I2c_Soft_SendByte(u8 SendByte); 24 | u8 I2c_Soft_ReadByte(u8); 25 | 26 | //int I2c_Soft_Single_Write(u8 SlaveAddress,u8 REG_Address,u8 REG_data); 27 | //int I2c_Soft_Single_Read(u8 SlaveAddress,u8 REG_Address); 28 | //int I2c_Soft_Mult_Read(u8 SlaveAddress,u8 REG_Address,u8 * ptChar,u8 size); 29 | 30 | u8 IIC_Write_1Byte(u8 SlaveAddress,u8 REG_Address,u8 REG_data); 31 | u8 IIC_Read_1Byte(u8 SlaveAddress,u8 REG_Address,u8 *REG_data); 32 | u8 IIC_Write_nByte(u8 SlaveAddress, u8 REG_Address, u8 len, u8 *buf); 33 | u8 IIC_Read_nByte(u8 SlaveAddress, u8 REG_Address, u8 len, u8 *buf); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /drivers/led.h: -------------------------------------------------------------------------------- 1 | #ifndef _LED_H_ 2 | #define _LED_H_ 3 | 4 | #include "stm32f4xx.h" 5 | 6 | #define NEW_ANOPILOT 7 | 8 | #ifndef NEW_ANOPILOT 9 | //旧版 10 | 11 | #define LED1_OFF ANO_GPIO_LED->BSRRL = ANO_Pin_LED1 //H 12 | #define LED1_ON ANO_GPIO_LED->BSRRH = ANO_Pin_LED1 //L 13 | #define LED2_OFF ANO_GPIO_LED->BSRRL = ANO_Pin_LED2 14 | #define LED2_ON ANO_GPIO_LED->BSRRH = ANO_Pin_LED2 15 | #define LED3_OFF ANO_GPIO_LED->BSRRL = ANO_Pin_LED3 16 | #define LED3_ON ANO_GPIO_LED->BSRRH = ANO_Pin_LED3 17 | #define LED4_OFF ANO_GPIO_LED->BSRRL = ANO_Pin_LED4 18 | #define LED4_ON ANO_GPIO_LED->BSRRH = ANO_Pin_LED4 19 | 20 | #else 21 | //新版 22 | 23 | #define LED1_OFF ANO_GPIO_LED->BSRRL = ANO_Pin_LED1 //H 24 | #define LED1_ON ANO_GPIO_LED->BSRRH = ANO_Pin_LED1 //L 25 | #define LED2_ON ANO_GPIO_LED->BSRRL = ANO_Pin_LED2 26 | #define LED2_OFF ANO_GPIO_LED->BSRRH = ANO_Pin_LED2 27 | #define LED3_ON ANO_GPIO_LED->BSRRL = ANO_Pin_LED3 28 | #define LED3_OFF ANO_GPIO_LED->BSRRH = ANO_Pin_LED3 29 | #define LED4_ON ANO_GPIO_LED->BSRRL = ANO_Pin_LED4 30 | #define LED4_OFF ANO_GPIO_LED->BSRRH = ANO_Pin_LED4 31 | 32 | #endif 33 | 34 | /***************LED GPIO定义******************/ 35 | #define ANO_RCC_LED RCC_AHB1Periph_GPIOE 36 | #define ANO_GPIO_LED GPIOE 37 | #define ANO_Pin_LED1 GPIO_Pin_3 38 | #define ANO_Pin_LED2 GPIO_Pin_2 39 | #define ANO_Pin_LED3 GPIO_Pin_1 40 | #define ANO_Pin_LED4 GPIO_Pin_0 41 | /*********************************************/ 42 | /* 43 | //RGB_Info == 0,蓝色连续双闪1次:当前模式为3轴飞行器。 44 | //RGB_Info == 1,蓝色连续双闪2次:当前模式为4轴飞行器。 45 | //RGB_Info == 2,蓝色连续双闪3次:当前模式为6轴飞行器。 46 | //RGB_Info == 3,蓝色连续双闪4次:当前模式为8轴飞行器。 47 | //RGB_Info == 4,红色连续1次间隔闪烁:惯性传感器异常。 48 | //RGB_Info == 5,红色连续2次间隔闪烁:电子罗盘异常。 49 | //RGB_Info == 6,红色连续3次闪烁:气压计异常。 50 | //RGB_Info == 7,绿色快速闪烁:传感器正常,自检校准中。 51 | //RGB_Info == 8,开机红色常亮:自检失败,需重启。 52 | 53 | //RGB_Info == 9, 呼吸白色:手动模式上锁(或姿态模式)。 54 | //RGB_Info == 10,呼吸绿色:自动模式上锁(定点定高)。 55 | //RGB_Info == 11,呼吸绿红色:GPS信号弱上锁(自动模式)。 56 | //RGB_Info == 12,呼吸绿黄色:罗盘信号干扰上锁(自动模式)。 57 | 58 | //RGB_Info == 13,双闪白白色:手动模式解锁(或姿态模式)。 59 | //RGB_Info == 14,双闪绿绿色:自动模式解锁(定点定高)。 60 | //RGB_Info == 15,双闪绿红色:GPS信号弱解锁(自动模式)。 61 | //RGB_Info == 16,双闪绿黄色:罗盘信号干扰解锁(自动模式)。 62 | 63 | //RGB_Info == 17,双闪蓝蓝色:返航模式。 64 | 65 | //RGB_Info == 18,红色连续三闪:电量低。 66 | //RGB_Info == 19,天蓝色快闪:罗盘校准中。 67 | //RGB_Info == 20,深蓝色快闪:加速度计校准中。 68 | //RGB_Info == 21,绿色快闪:陀螺校准中。 69 | //RGB_Info == 22,红色常亮:校准失败。 70 | 71 | 72 | RGB_Info == 9, 白色呼吸:手动油门模式上锁 73 | RGB_Info == 23, 绿色常亮:手动油门模式解锁 74 | RGB_Info == 24, 黄色呼吸:气压定高上锁 75 | RGB_Info == 25, 黄色常亮:气压定高解锁 76 | RGB_Info == 26, 紫色呼吸:超声波定高上锁 77 | RGB_Info == 27, 紫色常亮:超声波定高解锁 78 | …………………… 79 | LED_Info == 待定 80 | */ 81 | enum //led编号 82 | { 83 | X=0, 84 | B, 85 | R, 86 | G, 87 | LED_NUM, 88 | 89 | }; 90 | 91 | typedef struct 92 | { 93 | u8 RGB_Info; 94 | u8 LED_Info; 95 | 96 | u8 RGB_Info_old; 97 | }LED_state; 98 | extern LED_state light; 99 | 100 | void LED_Init(void); 101 | void LED_1ms_DRV(void ); 102 | void LED_Duty(void); 103 | 104 | void LED_MPU_Err(void); 105 | void LED_Mag_Err(void); 106 | void LED_MS5611_Err(void); 107 | void aircraft_mode_led(u8 maxmotors); 108 | 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /drivers/ms5611.h: -------------------------------------------------------------------------------- 1 | #ifndef _MS5611_H 2 | #define _MS5611_H 3 | 4 | #include "stm32f4xx.h" 5 | #include "i2c_soft.h" 6 | #include "mpu6050.h" 7 | 8 | #define MS5611_ADDR 0x77 //0xee // 9 | 10 | #define CMD_RESET 0x1E // ADC reset command 11 | #define CMD_ADC_READ 0x00 // ADC read command 12 | #define CMD_ADC_CONV 0x40 // ADC conversion command 13 | #define CMD_ADC_D1 0x00 // ADC D1 conversion 14 | #define CMD_ADC_D2 0x10 // ADC D2 conversion 15 | #define CMD_ADC_256 0x00 // ADC OSR=256 16 | #define CMD_ADC_512 0x02 // ADC OSR=512 17 | #define CMD_ADC_1024 0x04 // ADC OSR=1024 18 | #define CMD_ADC_2048 0x06 // ADC OSR=2048 19 | #define CMD_ADC_4096 0x08 // ADC OSR=4096 20 | #define CMD_PROM_RD 0xA0 // Prom read command 21 | #define PROM_NB 8 22 | #define MS5611_OSR 0x08 //CMD_ADC_4096 23 | 24 | typedef struct 25 | { 26 | s32 height;//cm 27 | 28 | float relative_height; 29 | float h_delta; 30 | float h_dt; 31 | 32 | u8 measure_ok; 33 | u8 measure_ot_cnt; 34 | }_height_st; 35 | 36 | extern _height_st baro; 37 | 38 | //气压计初始化 39 | void MS5611_Init(void); 40 | //读取气压计数据 41 | int MS5611_Update(void); 42 | //返回气压高度 43 | 44 | int32_t MS5611_Get_BaroAlt(void); 45 | 46 | void MS5611_Reset(void); 47 | u8 MS5611_Read_Prom(void); 48 | void MS5611_Start_T(void); 49 | void MS5611_Start_P(void); 50 | void MS5611_Read_Adc_T(void); 51 | void MS5611_Read_Adc_P(void); 52 | void MS5611_BaroAltCalculate(void); 53 | 54 | extern u8 ms5611_ok; 55 | 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /drivers/pwm_in.h: -------------------------------------------------------------------------------- 1 | #ifndef _PWM_IN_H_ 2 | #define _PWM_IN_H_ 3 | 4 | #include "stm32f4xx.h" 5 | 6 | void PWM_IN_Init(void); 7 | void _TIM3_IRQHandler(void); 8 | void _TIM4_IRQHandler(void); 9 | 10 | extern u16 Rc_Pwm_In[8]; 11 | #endif 12 | -------------------------------------------------------------------------------- /drivers/pwm_out.h: -------------------------------------------------------------------------------- 1 | #ifndef _PWM_OUT_H_ 2 | #define _PWM_OUT_H_ 3 | 4 | #include "stm32f4xx.h" 5 | 6 | u8 PWM_Out_Init(uint16_t hz); 7 | void SetPwm(int16_t pwm[],s16 min,s16 max); 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /drivers/time.h: -------------------------------------------------------------------------------- 1 | #ifndef _TIME_H_ 2 | #define _TIME_H_ 3 | 4 | #include "stm32f4xx.h" 5 | 6 | void TIM_INIT(void); 7 | void sys_time(void); 8 | 9 | u16 Get_Time(u8,u16,u16); 10 | 11 | u32 Get_Cycle_T(u8 ); 12 | 13 | void Cycle_Time_Init(void); 14 | 15 | extern volatile uint32_t sysTickUptime; 16 | extern int time_1h,time_1m,time_1s,time_1ms; 17 | 18 | void Delay_us(uint32_t); 19 | void Delay_ms(uint32_t); 20 | void SysTick_Configuration(void); 21 | uint32_t GetSysTime_us(void); 22 | #endif 23 | -------------------------------------------------------------------------------- /drivers/ultrasonic.c: -------------------------------------------------------------------------------- 1 | #include "include.h" 2 | #include "ultrasonic.h" 3 | #include "usart.h" 4 | 5 | 6 | void Ultrasonic_Init() 7 | { 8 | Uart5_Init(9600); //串口5初始化,函数参数为波特率 9 | 10 | } 11 | 12 | s8 ultra_start_f; 13 | 14 | void Ultra_Duty() 15 | { 16 | u8 temp[3]; 17 | 18 | ultra.h_dt = 0.05f; //50ms一次 19 | /*////////////////////////////////////////////// 20 | UART5->DR = 0xe8; //ks103地址(可设置) 21 | while( (UART5->SR & USART_FLAG_TXE) == 0 ); 22 | 23 | UART5->DR = 0x02; //++++ 24 | while( (UART5->SR & USART_FLAG_TXE) == 0 ); 25 | 26 | UART5->DR = 0xbc; //70ms,带温度补偿 27 | while( (UART5->SR & USART_FLAG_TXE) == 0 ); 28 | //////////////////////////////////////////////*/ 29 | #if defined(USE_KS103) 30 | temp[0] = 0xe8; 31 | temp[1] = 0x02; 32 | temp[2] = 0xbc; 33 | Uart5_Send(temp ,3); 34 | #elif defined(USE_US100) 35 | temp[0] = 0x55; 36 | Uart5_Send(temp ,1); 37 | //Usart1_Send(temp ,1); 38 | #endif 39 | /////////////////////////////////////////////// 40 | ultra_start_f = 1; 41 | 42 | if(ultra.measure_ot_cnt<200) //200ms 43 | { 44 | ultra.measure_ot_cnt += ultra.h_dt *1000; 45 | } 46 | else 47 | { 48 | ultra.measure_ok = 0;//超时,复位 49 | } 50 | } 51 | 52 | u16 ultra_distance_old; 53 | 54 | _height_st ultra; 55 | 56 | void Ultra_Get(u8 com_data) 57 | { 58 | static u8 ultra_tmp; 59 | 60 | if( ultra_start_f == 1 ) 61 | { 62 | ultra_tmp = com_data; 63 | ultra_start_f = 2; 64 | } 65 | else if( ultra_start_f == 2 ) 66 | { 67 | ultra.height = ((ultra_tmp<<8) + com_data)/10; 68 | 69 | if(ultra.height < 500) // 5米范围内认为有效,跳变值约10米. 70 | { 71 | ultra.relative_height = ultra.height; 72 | ultra.measure_ok = 1; 73 | } 74 | else 75 | { 76 | ultra.measure_ok = 2; //数据超范围 77 | } 78 | 79 | ultra_start_f = 0; 80 | } 81 | ultra.measure_ot_cnt = 0; //清除超时计数(喂狗) 82 | 83 | ultra.h_delta = ultra.relative_height - ultra_distance_old; 84 | 85 | ultra_distance_old = ultra.relative_height; 86 | 87 | } 88 | 89 | -------------------------------------------------------------------------------- /drivers/ultrasonic.h: -------------------------------------------------------------------------------- 1 | #ifndef _ULTRASONIC_H 2 | #define _ULTRASONIC_H 3 | 4 | #include "stm32f4xx.h" 5 | #include "ms5611.h" 6 | 7 | 8 | void Ultrasonic_Init(void); 9 | void Ultra_Duty(void); 10 | void Ultra_Get(u8); 11 | 12 | extern s8 ultra_start_f; 13 | 14 | extern _height_st ultra; 15 | 16 | #endif 17 | 18 | 19 | -------------------------------------------------------------------------------- /drivers/usart.h: -------------------------------------------------------------------------------- 1 | #ifndef _USART_H 2 | #define _USART_H 3 | 4 | #include "stm32f4xx.h" 5 | 6 | extern u8 Rx_Buf[]; 7 | void Usart2_Init(u32 br_num); 8 | void Usart2_IRQ(void); 9 | void Usart2_Send(unsigned char *DataToSend ,u8 data_num); 10 | 11 | void Uart5_Init(u32 br_num); 12 | void Uart5_IRQ(void); 13 | void Uart5_Send(unsigned char *DataToSend ,u8 data_num); 14 | #endif 15 | --------------------------------------------------------------------------------