├── .cproject ├── .gitignore ├── .mxproject ├── .project ├── .settings └── language.settings.xml ├── ANN_Robot.ioc ├── Drivers ├── CMSIS │ ├── Device │ │ └── ST │ │ │ └── STM32F4xx │ │ │ ├── Include │ │ │ ├── stm32f401xc.h │ │ │ ├── stm32f401xe.h │ │ │ ├── stm32f405xx.h │ │ │ ├── stm32f407xx.h │ │ │ ├── stm32f410cx.h │ │ │ ├── stm32f410rx.h │ │ │ ├── stm32f410tx.h │ │ │ ├── stm32f411xe.h │ │ │ ├── stm32f412cx.h │ │ │ ├── stm32f412rx.h │ │ │ ├── stm32f412vx.h │ │ │ ├── stm32f412zx.h │ │ │ ├── stm32f415xx.h │ │ │ ├── stm32f417xx.h │ │ │ ├── stm32f427xx.h │ │ │ ├── stm32f429xx.h │ │ │ ├── stm32f437xx.h │ │ │ ├── stm32f439xx.h │ │ │ ├── stm32f446xx.h │ │ │ ├── stm32f469xx.h │ │ │ ├── stm32f479xx.h │ │ │ ├── stm32f4xx.h │ │ │ └── system_stm32f4xx.h │ │ │ └── Source │ │ │ └── Templates │ │ │ ├── gcc │ │ │ └── startup_stm32f407xx.s │ │ │ └── system_stm32f4xx.c │ └── Include │ │ ├── arm_common_tables.h │ │ ├── arm_const_structs.h │ │ ├── arm_math.h │ │ ├── cmsis_armcc.h │ │ ├── cmsis_armcc_V6.h │ │ ├── cmsis_gcc.h │ │ ├── core_cm0.h │ │ ├── core_cm0plus.h │ │ ├── core_cm3.h │ │ ├── core_cm4.h │ │ ├── core_cm7.h │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ ├── core_cmSimd.h │ │ ├── core_sc000.h │ │ └── core_sc300.h └── STM32F4xx_HAL_Driver │ ├── Inc │ ├── Legacy │ │ └── stm32_hal_legacy.h │ ├── stm32f4xx_hal.h │ ├── stm32f4xx_hal_adc.h │ ├── stm32f4xx_hal_adc_ex.h │ ├── stm32f4xx_hal_cortex.h │ ├── stm32f4xx_hal_def.h │ ├── stm32f4xx_hal_dma.h │ ├── stm32f4xx_hal_dma_ex.h │ ├── stm32f4xx_hal_flash.h │ ├── stm32f4xx_hal_flash_ex.h │ ├── stm32f4xx_hal_flash_ramfunc.h │ ├── stm32f4xx_hal_gpio.h │ ├── stm32f4xx_hal_gpio_ex.h │ ├── stm32f4xx_hal_pwr.h │ ├── stm32f4xx_hal_pwr_ex.h │ ├── stm32f4xx_hal_rcc.h │ ├── stm32f4xx_hal_rcc_ex.h │ ├── stm32f4xx_hal_tim.h │ ├── stm32f4xx_hal_tim_ex.h │ └── stm32f4xx_hal_uart.h │ └── Src │ ├── stm32f4xx_hal.c │ ├── stm32f4xx_hal_adc.c │ ├── stm32f4xx_hal_adc_ex.c │ ├── stm32f4xx_hal_cortex.c │ ├── stm32f4xx_hal_dma.c │ ├── stm32f4xx_hal_dma_ex.c │ ├── stm32f4xx_hal_flash.c │ ├── stm32f4xx_hal_flash_ex.c │ ├── stm32f4xx_hal_flash_ramfunc.c │ ├── stm32f4xx_hal_gpio.c │ ├── stm32f4xx_hal_pwr.c │ ├── stm32f4xx_hal_pwr_ex.c │ ├── stm32f4xx_hal_rcc.c │ ├── stm32f4xx_hal_rcc_ex.c │ ├── stm32f4xx_hal_tim.c │ ├── stm32f4xx_hal_tim_ex.c │ └── stm32f4xx_hal_uart.c ├── Inc ├── HC_SR04.h ├── adc.h ├── ann.h ├── files │ ├── ann_files.h │ └── original │ │ ├── neues_system.ann │ │ ├── robi_ann_backward.ann │ │ └── robi_ann_forward.ann ├── flash_fs.h ├── gpio.h ├── mxconstants.h ├── stm32f4xx_hal_conf.h ├── stm32f4xx_it.h ├── tim.h └── usart.h ├── LICENSE ├── README.md ├── STM32F407VGTx_FLASH.ld ├── Src ├── HC_SR04.c ├── adc.c ├── ann.c ├── flash_fs.c ├── gpio.c ├── main.c ├── stm32f4xx_hal_msp.c ├── stm32f4xx_it.c ├── syscalls.c ├── tim.c └── usart.c ├── fann ├── include │ ├── config.h │ ├── doublefann.h │ ├── fann.h │ ├── fann_activation.h │ ├── fann_cascade.h │ ├── fann_cpp.h │ ├── fann_data.h │ ├── fann_data_cpp.h │ ├── fann_error.h │ ├── fann_internal.h │ ├── fann_io.h │ ├── fann_train.h │ ├── fann_training_data_cpp.h │ ├── fixedfann.h │ ├── floatfann.h │ ├── parallel_fann.h │ └── parallel_fann.hpp └── lib │ └── libfannfloat_cortexM4lf.a └── servo ├── servo.c └── servo.h /.cproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ -------------------------------------------------------------------------------- /.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousGenFiles] 2 | HeaderPath=C:/Users/Basti/Documents/workspace/ANN_Robot/Inc 3 | SourcePath=C:/Users/Basti/Documents/workspace/ANN_Robot/Src 4 | SourceFiles=gpio.h;adc.h;tim.h;usart.h;stm32f4xx_it.h;stm32f4xx_hal_conf.h;mxconstants.h;gpio.c;adc.c;tim.c;usart.c;stm32f4xx_it.c;stm32f4xx_hal_msp.c;main.c; 5 | HeaderFiles=gpio.h;adc.h;tim.h;usart.h;stm32f4xx_it.h;stm32f4xx_hal_conf.h;mxconstants.h; 6 | 7 | [PreviousLibFiles] 8 | LibFiles=Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_adc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_adc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_armcc_V6.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f401xc.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f401xe.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f405xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f407xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f410cx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f410rx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f410tx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f411xe.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f412cx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f412rx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f412vx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f412zx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f415xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f417xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f427xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f429xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f437xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f439xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f446xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f469xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f479xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h; 9 | 10 | [PreviousUsedRideFiles] 11 | HeaderPath=..\Drivers\STM32F4xx_HAL_Driver\Inc;..\Drivers\STM32F4xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Include;..\Drivers\CMSIS\Device\ST\STM32F4xx\Include; 12 | SourceFiles=../Src/main.c;../Src/gpio.c;../Src/adc.c;../Src/tim.c;../Src/usart.c;../Src/stm32f4xx_it.c;../Src/stm32f4xx_hal_msp.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;../Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;../Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f407xx.s; 13 | 14 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ANN_Robot 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | fr.ac6.mcu.ide.core.MCUProjectNature 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f401xc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f401xc.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f401xe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f401xe.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f405xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f405xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f407xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f407xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f410cx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f410cx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f410rx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f410rx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f410tx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f410tx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f411xe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f411xe.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f412cx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f412cx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f412rx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f412rx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f412vx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f412vx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f412zx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f412zx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f415xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f415xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f417xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f417xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f427xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f427xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f429xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f429xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f437xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f437xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f439xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f439xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f446xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f446xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f469xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f469xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f479xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f479xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f4xx.h 4 | * @author MCD Application Team 5 | * @version V2.5.0 6 | * @date 22-April-2016 7 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /** @addtogroup CMSIS 39 | * @{ 40 | */ 41 | 42 | /** @addtogroup stm32f4xx_system 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @brief Define to prevent recursive inclusion 48 | */ 49 | #ifndef __SYSTEM_STM32F4XX_H 50 | #define __SYSTEM_STM32F4XX_H 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | /** @addtogroup STM32F4xx_System_Includes 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | /** @addtogroup STM32F4xx_System_Exported_types 66 | * @{ 67 | */ 68 | /* This variable is updated in three ways: 69 | 1) by calling CMSIS function SystemCoreClockUpdate() 70 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 71 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 72 | Note: If you use this function to configure the system clock; then there 73 | is no need to call the 2 first functions listed above, since SystemCoreClock 74 | variable is updated automatically. 75 | */ 76 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 77 | 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @addtogroup STM32F4xx_System_Exported_Constants 84 | * @{ 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @addtogroup STM32F4xx_System_Exported_Macros 92 | * @{ 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | /** @addtogroup STM32F4xx_System_Exported_Functions 100 | * @{ 101 | */ 102 | 103 | extern void SystemInit(void); 104 | extern void SystemCoreClockUpdate(void); 105 | /** 106 | * @} 107 | */ 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | #endif /*__SYSTEM_STM32F4XX_H */ 114 | 115 | /** 116 | * @} 117 | */ 118 | 119 | /** 120 | * @} 121 | */ 122 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 123 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/arm_common_tables.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. October 2015 5 | * $Revision: V.1.4.5 a 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 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions 16 | * are met: 17 | * - Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * - Redistributions in binary form must reproduce the above copyright 20 | * notice, this list of conditions and the following disclaimer in 21 | * the documentation and/or other materials provided with the 22 | * distribution. 23 | * - Neither the name of ARM LIMITED nor the names of its contributors 24 | * may be used to endorse or promote products derived from this 25 | * software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * -------------------------------------------------------------------- */ 40 | 41 | #ifndef _ARM_COMMON_TABLES_H 42 | #define _ARM_COMMON_TABLES_H 43 | 44 | #include "arm_math.h" 45 | 46 | extern const uint16_t armBitRevTable[1024]; 47 | extern const q15_t armRecipTableQ15[64]; 48 | extern const q31_t armRecipTableQ31[64]; 49 | /* extern const q31_t realCoefAQ31[1024]; */ 50 | /* extern const q31_t realCoefBQ31[1024]; */ 51 | extern const float32_t twiddleCoef_16[32]; 52 | extern const float32_t twiddleCoef_32[64]; 53 | extern const float32_t twiddleCoef_64[128]; 54 | extern const float32_t twiddleCoef_128[256]; 55 | extern const float32_t twiddleCoef_256[512]; 56 | extern const float32_t twiddleCoef_512[1024]; 57 | extern const float32_t twiddleCoef_1024[2048]; 58 | extern const float32_t twiddleCoef_2048[4096]; 59 | extern const float32_t twiddleCoef_4096[8192]; 60 | #define twiddleCoef twiddleCoef_4096 61 | extern const q31_t twiddleCoef_16_q31[24]; 62 | extern const q31_t twiddleCoef_32_q31[48]; 63 | extern const q31_t twiddleCoef_64_q31[96]; 64 | extern const q31_t twiddleCoef_128_q31[192]; 65 | extern const q31_t twiddleCoef_256_q31[384]; 66 | extern const q31_t twiddleCoef_512_q31[768]; 67 | extern const q31_t twiddleCoef_1024_q31[1536]; 68 | extern const q31_t twiddleCoef_2048_q31[3072]; 69 | extern const q31_t twiddleCoef_4096_q31[6144]; 70 | extern const q15_t twiddleCoef_16_q15[24]; 71 | extern const q15_t twiddleCoef_32_q15[48]; 72 | extern const q15_t twiddleCoef_64_q15[96]; 73 | extern const q15_t twiddleCoef_128_q15[192]; 74 | extern const q15_t twiddleCoef_256_q15[384]; 75 | extern const q15_t twiddleCoef_512_q15[768]; 76 | extern const q15_t twiddleCoef_1024_q15[1536]; 77 | extern const q15_t twiddleCoef_2048_q15[3072]; 78 | extern const q15_t twiddleCoef_4096_q15[6144]; 79 | extern const float32_t twiddleCoef_rfft_32[32]; 80 | extern const float32_t twiddleCoef_rfft_64[64]; 81 | extern const float32_t twiddleCoef_rfft_128[128]; 82 | extern const float32_t twiddleCoef_rfft_256[256]; 83 | extern const float32_t twiddleCoef_rfft_512[512]; 84 | extern const float32_t twiddleCoef_rfft_1024[1024]; 85 | extern const float32_t twiddleCoef_rfft_2048[2048]; 86 | extern const float32_t twiddleCoef_rfft_4096[4096]; 87 | 88 | 89 | /* floating-point bit reversal tables */ 90 | #define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 ) 91 | #define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 ) 92 | #define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 ) 93 | #define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 ) 94 | #define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 ) 95 | #define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 ) 96 | #define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800) 97 | #define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808) 98 | #define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032) 99 | 100 | extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH]; 101 | extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH]; 102 | extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH]; 103 | extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH]; 104 | extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH]; 105 | extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH]; 106 | extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH]; 107 | extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH]; 108 | extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH]; 109 | 110 | /* fixed-point bit reversal tables */ 111 | #define ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH ((uint16_t)12 ) 112 | #define ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH ((uint16_t)24 ) 113 | #define ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH ((uint16_t)56 ) 114 | #define ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH ((uint16_t)112 ) 115 | #define ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH ((uint16_t)240 ) 116 | #define ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH ((uint16_t)480 ) 117 | #define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992 ) 118 | #define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984) 119 | #define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032) 120 | 121 | extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH]; 122 | extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH]; 123 | extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH]; 124 | extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH]; 125 | extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH]; 126 | extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH]; 127 | extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH]; 128 | extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH]; 129 | extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH]; 130 | 131 | /* Tables for Fast Math Sine and Cosine */ 132 | extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1]; 133 | extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1]; 134 | extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1]; 135 | 136 | #endif /* ARM_COMMON_TABLES_H */ 137 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 58 | 59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 68 | 69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/core_cmSimd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmSimd.h 3 | * @brief CMSIS Cortex-M SIMD Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMSIMD_H 42 | #define __CORE_CMSIMD_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | 49 | /* ################### Compiler specific Intrinsics ########################### */ 50 | /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics 51 | Access to dedicated SIMD instructions 52 | @{ 53 | */ 54 | 55 | /*------------------ RealView Compiler -----------------*/ 56 | #if defined ( __CC_ARM ) 57 | #include "cmsis_armcc.h" 58 | 59 | /*------------------ ARM Compiler V6 -------------------*/ 60 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 61 | #include "cmsis_armcc_V6.h" 62 | 63 | /*------------------ GNU Compiler ----------------------*/ 64 | #elif defined ( __GNUC__ ) 65 | #include "cmsis_gcc.h" 66 | 67 | /*------------------ ICC Compiler ----------------------*/ 68 | #elif defined ( __ICCARM__ ) 69 | #include 70 | 71 | /*------------------ TI CCS Compiler -------------------*/ 72 | #elif defined ( __TMS470__ ) 73 | #include 74 | 75 | /*------------------ TASKING Compiler ------------------*/ 76 | #elif defined ( __TASKING__ ) 77 | /* 78 | * The CMSIS functions have been implemented as intrinsics in the compiler. 79 | * Please use "carm -?i" to get an up to date list of all intrinsics, 80 | * Including the CMSIS ones. 81 | */ 82 | 83 | /*------------------ COSMIC Compiler -------------------*/ 84 | #elif defined ( __CSMC__ ) 85 | #include 86 | 87 | #endif 88 | 89 | /*@} end of group CMSIS_SIMD_intrinsics */ 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __CORE_CMSIMD_H */ 97 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_def.h 4 | * @author MCD Application Team 5 | * @version V1.5.0 6 | * @date 06-May-2016 7 | * @brief This file contains HAL common defines, enumeration, macros and 8 | * structures definitions. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT(c) 2016 STMicroelectronics

13 | * 14 | * Redistribution and use in source and binary forms, with or without modification, 15 | * are permitted provided that the following conditions are met: 16 | * 1. Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 22 | * may be used to endorse or promote products derived from this software 23 | * without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | ****************************************************************************** 37 | */ 38 | 39 | /* Define to prevent recursive inclusion -------------------------------------*/ 40 | #ifndef __STM32F4xx_HAL_DEF 41 | #define __STM32F4xx_HAL_DEF 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /* Includes ------------------------------------------------------------------*/ 48 | #include "stm32f4xx.h" 49 | #include "Legacy/stm32_hal_legacy.h" 50 | #include 51 | 52 | /* Exported types ------------------------------------------------------------*/ 53 | 54 | /** 55 | * @brief HAL Status structures definition 56 | */ 57 | typedef enum 58 | { 59 | HAL_OK = 0x00U, 60 | HAL_ERROR = 0x01U, 61 | HAL_BUSY = 0x02U, 62 | HAL_TIMEOUT = 0x03U 63 | } HAL_StatusTypeDef; 64 | 65 | /** 66 | * @brief HAL Lock structures definition 67 | */ 68 | typedef enum 69 | { 70 | HAL_UNLOCKED = 0x00U, 71 | HAL_LOCKED = 0x01U 72 | } HAL_LockTypeDef; 73 | 74 | /* Exported macro ------------------------------------------------------------*/ 75 | #define HAL_MAX_DELAY 0xFFFFFFFFU 76 | 77 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET) 78 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET) 79 | 80 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ 81 | do{ \ 82 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ 83 | (__DMA_HANDLE__).Parent = (__HANDLE__); \ 84 | } while(0) 85 | 86 | #define UNUSED(x) ((void)(x)) 87 | 88 | /** @brief Reset the Handle's State field. 89 | * @param __HANDLE__: specifies the Peripheral Handle. 90 | * @note This macro can be used for the following purpose: 91 | * - When the Handle is declared as local variable; before passing it as parameter 92 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 93 | * to set to 0 the Handle's "State" field. 94 | * Otherwise, "State" field may have any random value and the first time the function 95 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed 96 | * (i.e. HAL_PPP_MspInit() will not be executed). 97 | * - When there is a need to reconfigure the low level hardware: instead of calling 98 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 99 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function 100 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. 101 | * @retval None 102 | */ 103 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U) 104 | 105 | #if (USE_RTOS == 1) 106 | /* Reserved for future use */ 107 | #error "USE_RTOS should be 0 in the current HAL release" 108 | #else 109 | #define __HAL_LOCK(__HANDLE__) \ 110 | do{ \ 111 | if((__HANDLE__)->Lock == HAL_LOCKED) \ 112 | { \ 113 | return HAL_BUSY; \ 114 | } \ 115 | else \ 116 | { \ 117 | (__HANDLE__)->Lock = HAL_LOCKED; \ 118 | } \ 119 | }while (0) 120 | 121 | #define __HAL_UNLOCK(__HANDLE__) \ 122 | do{ \ 123 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 124 | }while (0) 125 | #endif /* USE_RTOS */ 126 | 127 | #if defined ( __GNUC__ ) 128 | #ifndef __weak 129 | #define __weak __attribute__((weak)) 130 | #endif /* __weak */ 131 | #ifndef __packed 132 | #define __packed __attribute__((__packed__)) 133 | #endif /* __packed */ 134 | #endif /* __GNUC__ */ 135 | 136 | 137 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 138 | #if defined (__GNUC__) /* GNU Compiler */ 139 | #ifndef __ALIGN_END 140 | #define __ALIGN_END __attribute__ ((aligned (4))) 141 | #endif /* __ALIGN_END */ 142 | #ifndef __ALIGN_BEGIN 143 | #define __ALIGN_BEGIN 144 | #endif /* __ALIGN_BEGIN */ 145 | #else 146 | #ifndef __ALIGN_END 147 | #define __ALIGN_END 148 | #endif /* __ALIGN_END */ 149 | #ifndef __ALIGN_BEGIN 150 | #if defined (__CC_ARM) /* ARM Compiler */ 151 | #define __ALIGN_BEGIN __align(4) 152 | #elif defined (__ICCARM__) /* IAR Compiler */ 153 | #define __ALIGN_BEGIN 154 | #endif /* __CC_ARM */ 155 | #endif /* __ALIGN_BEGIN */ 156 | #endif /* __GNUC__ */ 157 | 158 | 159 | /** 160 | * @brief __RAM_FUNC definition 161 | */ 162 | #if defined ( __CC_ARM ) 163 | /* ARM Compiler 164 | ------------ 165 | RAM functions are defined using the toolchain options. 166 | Functions that are executed in RAM should reside in a separate source module. 167 | Using the 'Options for File' dialog you can simply change the 'Code / Const' 168 | area of a module to a memory space in physical RAM. 169 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' 170 | dialog. 171 | */ 172 | #define __RAM_FUNC HAL_StatusTypeDef 173 | 174 | #elif defined ( __ICCARM__ ) 175 | /* ICCARM Compiler 176 | --------------- 177 | RAM functions are defined using a specific toolchain keyword "__ramfunc". 178 | */ 179 | #define __RAM_FUNC __ramfunc HAL_StatusTypeDef 180 | 181 | #elif defined ( __GNUC__ ) 182 | /* GNU Compiler 183 | ------------ 184 | RAM functions are defined using a specific toolchain attribute 185 | "__attribute__((section(".RamFunc")))". 186 | */ 187 | #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc"))) 188 | 189 | #endif 190 | 191 | /** 192 | * @brief __NOINLINE definition 193 | */ 194 | #if defined ( __CC_ARM ) || defined ( __GNUC__ ) 195 | /* ARM & GNUCompiler 196 | ---------------- 197 | */ 198 | #define __NOINLINE __attribute__ ( (noinline) ) 199 | 200 | #elif defined ( __ICCARM__ ) 201 | /* ICCARM Compiler 202 | --------------- 203 | */ 204 | #define __NOINLINE _Pragma("optimize = no_inline") 205 | 206 | #endif 207 | 208 | #ifdef __cplusplus 209 | } 210 | #endif 211 | 212 | #endif /* ___STM32F4xx_HAL_DEF */ 213 | 214 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 215 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_dma_ex.h 4 | * @author MCD Application Team 5 | * @version V1.5.0 6 | * @date 06-May-2016 7 | * @brief Header file of DMA HAL extension module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32F4xx_HAL_DMA_EX_H 40 | #define __STM32F4xx_HAL_DMA_EX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32f4xx_hal_def.h" 48 | 49 | /** @addtogroup STM32F4xx_HAL_Driver 50 | * @{ 51 | */ 52 | 53 | /** @addtogroup DMAEx 54 | * @{ 55 | */ 56 | 57 | /* Exported types ------------------------------------------------------------*/ 58 | /** @defgroup DMAEx_Exported_Types DMAEx Exported Types 59 | * @brief DMAEx Exported types 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @brief HAL DMA Memory definition 65 | */ 66 | typedef enum 67 | { 68 | MEMORY0 = 0x00U, /*!< Memory 0 */ 69 | MEMORY1 = 0x01U /*!< Memory 1 */ 70 | }HAL_DMA_MemoryTypeDef; 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /* Exported functions --------------------------------------------------------*/ 77 | /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions 78 | * @brief DMAEx Exported functions 79 | * @{ 80 | */ 81 | 82 | /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions 83 | * @brief Extended features functions 84 | * @{ 85 | */ 86 | 87 | /* IO operation functions *******************************************************/ 88 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 89 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 90 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory); 91 | 92 | /** 93 | * @} 94 | */ 95 | /** 96 | * @} 97 | */ 98 | 99 | /* Private functions ---------------------------------------------------------*/ 100 | /** @defgroup DMAEx_Private_Functions DMAEx Private Functions 101 | * @brief DMAEx Private functions 102 | * @{ 103 | */ 104 | /** 105 | * @} 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | 120 | #endif /*__STM32F4xx_HAL_DMA_EX_H*/ 121 | 122 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 123 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_flash_ramfunc.h 4 | * @author MCD Application Team 5 | * @version V1.5.0 6 | * @date 06-May-2016 7 | * @brief Header file of FLASH RAMFUNC driver. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32F4xx_FLASH_RAMFUNC_H 40 | #define __STM32F4xx_FLASH_RAMFUNC_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\ 46 | defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) 47 | 48 | /* Includes ------------------------------------------------------------------*/ 49 | #include "stm32f4xx_hal_def.h" 50 | 51 | /** @addtogroup STM32F4xx_HAL_Driver 52 | * @{ 53 | */ 54 | 55 | /** @addtogroup FLASH_RAMFUNC 56 | * @{ 57 | */ 58 | 59 | /* Exported types ------------------------------------------------------------*/ 60 | /* Exported macro ------------------------------------------------------------*/ 61 | /* Exported functions --------------------------------------------------------*/ 62 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions 63 | * @{ 64 | */ 65 | 66 | /** @addtogroup FLASH_RAMFUNC_Exported_Functions_Group1 67 | * @{ 68 | */ 69 | __RAM_FUNC HAL_FLASHEx_StopFlashInterfaceClk(void); 70 | __RAM_FUNC HAL_FLASHEx_StartFlashInterfaceClk(void); 71 | __RAM_FUNC HAL_FLASHEx_EnableFlashSleepMode(void); 72 | __RAM_FUNC HAL_FLASHEx_DisableFlashSleepMode(void); 73 | /** 74 | * @} 75 | */ 76 | 77 | /** 78 | * @} 79 | */ 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | /** 86 | * @} 87 | */ 88 | 89 | #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | 95 | #endif /* __STM32F4xx_FLASH_RAMFUNC_H */ 96 | 97 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 98 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_dma_ex.c 4 | * @author MCD Application Team 5 | * @version V1.5.0 6 | * @date 06-May-2016 7 | * @brief DMA Extension HAL module driver 8 | * This file provides firmware functions to manage the following 9 | * functionalities of the DMA Extension peripheral: 10 | * + Extended features functions 11 | * 12 | @verbatim 13 | ============================================================================== 14 | ##### How to use this driver ##### 15 | ============================================================================== 16 | [..] 17 | The DMA Extension HAL driver can be used as follows: 18 | (#) Start a multi buffer transfer using the HAL_DMA_MultiBufferStart() function 19 | for polling mode or HAL_DMA_MultiBufferStart_IT() for interrupt mode. 20 | 21 | -@- In Memory-to-Memory transfer mode, Multi (Double) Buffer mode is not allowed. 22 | -@- When Multi (Double) Buffer mode is enabled the, transfer is circular by default. 23 | -@- In Multi (Double) buffer mode, it is possible to update the base address for 24 | the AHB memory port on the fly (DMA_SxM0AR or DMA_SxM1AR) when the stream is enabled. 25 | 26 | @endverbatim 27 | ****************************************************************************** 28 | * @attention 29 | * 30 | *

© COPYRIGHT(c) 2016 STMicroelectronics

31 | * 32 | * Redistribution and use in source and binary forms, with or without modification, 33 | * are permitted provided that the following conditions are met: 34 | * 1. Redistributions of source code must retain the above copyright notice, 35 | * this list of conditions and the following disclaimer. 36 | * 2. Redistributions in binary form must reproduce the above copyright notice, 37 | * this list of conditions and the following disclaimer in the documentation 38 | * and/or other materials provided with the distribution. 39 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 40 | * may be used to endorse or promote products derived from this software 41 | * without specific prior written permission. 42 | * 43 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 44 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 45 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 46 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 47 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 48 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 49 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 50 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 51 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 52 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53 | * 54 | ****************************************************************************** 55 | */ 56 | 57 | /* Includes ------------------------------------------------------------------*/ 58 | #include "stm32f4xx_hal.h" 59 | 60 | /** @addtogroup STM32F4xx_HAL_Driver 61 | * @{ 62 | */ 63 | 64 | /** @defgroup DMAEx DMAEx 65 | * @brief DMA Extended HAL module driver 66 | * @{ 67 | */ 68 | 69 | #ifdef HAL_DMA_MODULE_ENABLED 70 | 71 | /* Private types -------------------------------------------------------------*/ 72 | /* Private variables ---------------------------------------------------------*/ 73 | /* Private Constants ---------------------------------------------------------*/ 74 | /* Private macros ------------------------------------------------------------*/ 75 | /* Private functions ---------------------------------------------------------*/ 76 | /** @addtogroup DMAEx_Private_Functions 77 | * @{ 78 | */ 79 | static void DMA_MultiBufferSetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength); 80 | /** 81 | * @} 82 | */ 83 | 84 | /* Exported functions ---------------------------------------------------------*/ 85 | 86 | /** @addtogroup DMAEx_Exported_Functions 87 | * @{ 88 | */ 89 | 90 | 91 | /** @addtogroup DMAEx_Exported_Functions_Group1 92 | * 93 | @verbatim 94 | =============================================================================== 95 | ##### Extended features functions ##### 96 | =============================================================================== 97 | [..] This section provides functions allowing to: 98 | (+) Configure the source, destination address and data length and 99 | Start MultiBuffer DMA transfer 100 | (+) Configure the source, destination address and data length and 101 | Start MultiBuffer DMA transfer with interrupt 102 | (+) Change on the fly the memory0 or memory1 address. 103 | 104 | @endverbatim 105 | * @{ 106 | */ 107 | 108 | 109 | /** 110 | * @brief Starts the multi_buffer DMA Transfer. 111 | * @param hdma : pointer to a DMA_HandleTypeDef structure that contains 112 | * the configuration information for the specified DMA Stream. 113 | * @param SrcAddress: The source memory Buffer address 114 | * @param DstAddress: The destination memory Buffer address 115 | * @param SecondMemAddress: The second memory Buffer address in case of multi buffer Transfer 116 | * @param DataLength: The length of data to be transferred from source to destination 117 | * @retval HAL status 118 | */ 119 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength) 120 | { 121 | HAL_StatusTypeDef status = HAL_OK; 122 | 123 | /* Check the parameters */ 124 | assert_param(IS_DMA_BUFFER_SIZE(DataLength)); 125 | 126 | /* Memory-to-memory transfer not supported in double buffering mode */ 127 | if (hdma->Init.Direction == DMA_MEMORY_TO_MEMORY) 128 | { 129 | hdma->ErrorCode = HAL_DMA_ERROR_NOT_SUPPORTED; 130 | status = HAL_ERROR; 131 | } 132 | else 133 | { 134 | /* Process Locked */ 135 | __HAL_LOCK(hdma); 136 | 137 | if(HAL_DMA_STATE_READY == hdma->State) 138 | { 139 | /* Change DMA peripheral state */ 140 | hdma->State = HAL_DMA_STATE_BUSY; 141 | 142 | /* Enable the double buffer mode */ 143 | hdma->Instance->CR |= (uint32_t)DMA_SxCR_DBM; 144 | 145 | /* Configure DMA Stream destination address */ 146 | hdma->Instance->M1AR = SecondMemAddress; 147 | 148 | /* Configure the source, destination address and the data length */ 149 | DMA_MultiBufferSetConfig(hdma, SrcAddress, DstAddress, DataLength); 150 | 151 | /* Enable the peripheral */ 152 | __HAL_DMA_ENABLE(hdma); 153 | } 154 | else 155 | { 156 | /* Return error status */ 157 | status = HAL_BUSY; 158 | } 159 | } 160 | return status; 161 | } 162 | 163 | /** 164 | * @brief Starts the multi_buffer DMA Transfer with interrupt enabled. 165 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains 166 | * the configuration information for the specified DMA Stream. 167 | * @param SrcAddress: The source memory Buffer address 168 | * @param DstAddress: The destination memory Buffer address 169 | * @param SecondMemAddress: The second memory Buffer address in case of multi buffer Transfer 170 | * @param DataLength: The length of data to be transferred from source to destination 171 | * @retval HAL status 172 | */ 173 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength) 174 | { 175 | HAL_StatusTypeDef status = HAL_OK; 176 | 177 | /* Check the parameters */ 178 | assert_param(IS_DMA_BUFFER_SIZE(DataLength)); 179 | 180 | /* Memory-to-memory transfer not supported in double buffering mode */ 181 | if (hdma->Init.Direction == DMA_MEMORY_TO_MEMORY) 182 | { 183 | hdma->ErrorCode = HAL_DMA_ERROR_NOT_SUPPORTED; 184 | return HAL_ERROR; 185 | } 186 | 187 | /* Check callback functions */ 188 | if ((NULL == hdma->XferCpltCallback) || (NULL == hdma->XferM1CpltCallback) || (NULL == hdma->XferErrorCallback)) 189 | { 190 | hdma->ErrorCode = HAL_DMA_ERROR_PARAM; 191 | return HAL_ERROR; 192 | } 193 | 194 | /* Process locked */ 195 | __HAL_LOCK(hdma); 196 | 197 | if(HAL_DMA_STATE_READY == hdma->State) 198 | { 199 | /* Change DMA peripheral state */ 200 | hdma->State = HAL_DMA_STATE_BUSY; 201 | 202 | /* Initialize the error code */ 203 | hdma->ErrorCode = HAL_DMA_ERROR_NONE; 204 | 205 | /* Enable the Double buffer mode */ 206 | hdma->Instance->CR |= (uint32_t)DMA_SxCR_DBM; 207 | 208 | /* Configure DMA Stream destination address */ 209 | hdma->Instance->M1AR = SecondMemAddress; 210 | 211 | /* Configure the source, destination address and the data length */ 212 | DMA_MultiBufferSetConfig(hdma, SrcAddress, DstAddress, DataLength); 213 | 214 | /* Clear all flags */ 215 | __HAL_DMA_CLEAR_FLAG (hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma)); 216 | __HAL_DMA_CLEAR_FLAG (hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma)); 217 | __HAL_DMA_CLEAR_FLAG (hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma)); 218 | __HAL_DMA_CLEAR_FLAG (hdma, __HAL_DMA_GET_DME_FLAG_INDEX(hdma)); 219 | __HAL_DMA_CLEAR_FLAG (hdma, __HAL_DMA_GET_FE_FLAG_INDEX(hdma)); 220 | 221 | /* Enable Common interrupts*/ 222 | hdma->Instance->CR |= DMA_IT_TC | DMA_IT_TE | DMA_IT_DME; 223 | hdma->Instance->FCR |= DMA_IT_FE; 224 | 225 | if((hdma->XferHalfCpltCallback != NULL) || (hdma->XferM1HalfCpltCallback != NULL)) 226 | { 227 | hdma->Instance->CR |= DMA_IT_HT; 228 | } 229 | 230 | /* Enable the peripheral */ 231 | __HAL_DMA_ENABLE(hdma); 232 | } 233 | else 234 | { 235 | /* Process unlocked */ 236 | __HAL_UNLOCK(hdma); 237 | 238 | /* Return error status */ 239 | status = HAL_BUSY; 240 | } 241 | return status; 242 | } 243 | 244 | /** 245 | * @brief Change the memory0 or memory1 address on the fly. 246 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains 247 | * the configuration information for the specified DMA Stream. 248 | * @param Address: The new address 249 | * @param memory: the memory to be changed, This parameter can be one of 250 | * the following values: 251 | * MEMORY0 / 252 | * MEMORY1 253 | * @note The MEMORY0 address can be changed only when the current transfer use 254 | * MEMORY1 and the MEMORY1 address can be changed only when the current 255 | * transfer use MEMORY0. 256 | * @retval HAL status 257 | */ 258 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory) 259 | { 260 | if(memory == MEMORY0) 261 | { 262 | /* change the memory0 address */ 263 | hdma->Instance->M0AR = Address; 264 | } 265 | else 266 | { 267 | /* change the memory1 address */ 268 | hdma->Instance->M1AR = Address; 269 | } 270 | 271 | return HAL_OK; 272 | } 273 | 274 | /** 275 | * @} 276 | */ 277 | 278 | /** 279 | * @} 280 | */ 281 | 282 | /** @addtogroup DMAEx_Private_Functions 283 | * @{ 284 | */ 285 | 286 | /** 287 | * @brief Set the DMA Transfer parameter. 288 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains 289 | * the configuration information for the specified DMA Stream. 290 | * @param SrcAddress: The source memory Buffer address 291 | * @param DstAddress: The destination memory Buffer address 292 | * @param DataLength: The length of data to be transferred from source to destination 293 | * @retval HAL status 294 | */ 295 | static void DMA_MultiBufferSetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength) 296 | { 297 | /* Configure DMA Stream data length */ 298 | hdma->Instance->NDTR = DataLength; 299 | 300 | /* Peripheral to Memory */ 301 | if((hdma->Init.Direction) == DMA_MEMORY_TO_PERIPH) 302 | { 303 | /* Configure DMA Stream destination address */ 304 | hdma->Instance->PAR = DstAddress; 305 | 306 | /* Configure DMA Stream source address */ 307 | hdma->Instance->M0AR = SrcAddress; 308 | } 309 | /* Memory to Peripheral */ 310 | else 311 | { 312 | /* Configure DMA Stream source address */ 313 | hdma->Instance->PAR = SrcAddress; 314 | 315 | /* Configure DMA Stream destination address */ 316 | hdma->Instance->M0AR = DstAddress; 317 | } 318 | } 319 | 320 | /** 321 | * @} 322 | */ 323 | 324 | #endif /* HAL_DMA_MODULE_ENABLED */ 325 | /** 326 | * @} 327 | */ 328 | 329 | /** 330 | * @} 331 | */ 332 | 333 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 334 | -------------------------------------------------------------------------------- /Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_hal_flash_ramfunc.c 4 | * @author MCD Application Team 5 | * @version V1.5.0 6 | * @date 06-May-2016 7 | * @brief FLASH RAMFUNC module driver. 8 | * This file provides a FLASH firmware functions which should be 9 | * executed from internal SRAM 10 | * + Stop/Start the flash interface while System Run 11 | * + Enable/Disable the flash sleep while System Run 12 | @verbatim 13 | ============================================================================== 14 | ##### APIs executed from Internal RAM ##### 15 | ============================================================================== 16 | [..] 17 | *** ARM Compiler *** 18 | -------------------- 19 | [..] RAM functions are defined using the toolchain options. 20 | Functions that are be executed in RAM should reside in a separate 21 | source module. Using the 'Options for File' dialog you can simply change 22 | the 'Code / Const' area of a module to a memory space in physical RAM. 23 | Available memory areas are declared in the 'Target' tab of the 24 | Options for Target' dialog. 25 | 26 | *** ICCARM Compiler *** 27 | ----------------------- 28 | [..] RAM functions are defined using a specific toolchain keyword "__ramfunc". 29 | 30 | *** GNU Compiler *** 31 | -------------------- 32 | [..] RAM functions are defined using a specific toolchain attribute 33 | "__attribute__((section(".RamFunc")))". 34 | 35 | @endverbatim 36 | ****************************************************************************** 37 | * @attention 38 | * 39 | *

© COPYRIGHT(c) 2016 STMicroelectronics

40 | * 41 | * Redistribution and use in source and binary forms, with or without modification, 42 | * are permitted provided that the following conditions are met: 43 | * 1. Redistributions of source code must retain the above copyright notice, 44 | * this list of conditions and the following disclaimer. 45 | * 2. Redistributions in binary form must reproduce the above copyright notice, 46 | * this list of conditions and the following disclaimer in the documentation 47 | * and/or other materials provided with the distribution. 48 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 49 | * may be used to endorse or promote products derived from this software 50 | * without specific prior written permission. 51 | * 52 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 53 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 54 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 55 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 56 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 57 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 58 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 59 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 60 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 61 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 62 | * 63 | ****************************************************************************** 64 | */ 65 | 66 | /* Includes ------------------------------------------------------------------*/ 67 | #include "stm32f4xx_hal.h" 68 | 69 | /** @addtogroup STM32F4xx_HAL_Driver 70 | * @{ 71 | */ 72 | 73 | /** @defgroup FLASH_RAMFUNC FLASH RAMFUNC 74 | * @brief FLASH functions executed from RAM 75 | * @{ 76 | */ 77 | #ifdef HAL_FLASH_MODULE_ENABLED 78 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \ 79 | defined(STM32F412Rx) || defined(STM32F412Cx) 80 | 81 | /* Private typedef -----------------------------------------------------------*/ 82 | /* Private define ------------------------------------------------------------*/ 83 | /* Private macro -------------------------------------------------------------*/ 84 | /* Private variables ---------------------------------------------------------*/ 85 | /* Private function prototypes -----------------------------------------------*/ 86 | /* Exported functions --------------------------------------------------------*/ 87 | /** @defgroup FLASH_RAMFUNC_Exported_Functions FLASH RAMFUNC Exported Functions 88 | * @{ 89 | */ 90 | 91 | /** @defgroup FLASH_RAMFUNC_Exported_Functions_Group1 Peripheral features functions executed from internal RAM 92 | * @brief Peripheral Extended features functions 93 | * 94 | @verbatim 95 | 96 | =============================================================================== 97 | ##### ramfunc functions ##### 98 | =============================================================================== 99 | [..] 100 | This subsection provides a set of functions that should be executed from RAM 101 | transfers. 102 | 103 | @endverbatim 104 | * @{ 105 | */ 106 | 107 | /** 108 | * @brief Stop the flash interface while System Run 109 | * @note This mode is only available for STM32F41xxx/STM32F446xx devices. 110 | * @note This mode couldn't be set while executing with the flash itself. 111 | * It should be done with specific routine executed from RAM. 112 | * @retval None 113 | */ 114 | __RAM_FUNC HAL_FLASHEx_StopFlashInterfaceClk(void) 115 | { 116 | /* Enable Power ctrl clock */ 117 | __HAL_RCC_PWR_CLK_ENABLE(); 118 | /* Stop the flash interface while System Run */ 119 | SET_BIT(PWR->CR, PWR_CR_FISSR); 120 | 121 | return HAL_OK; 122 | } 123 | 124 | /** 125 | * @brief Start the flash interface while System Run 126 | * @note This mode is only available for STM32F411xx/STM32F446xx devices. 127 | * @note This mode couldn't be set while executing with the flash itself. 128 | * It should be done with specific routine executed from RAM. 129 | * @retval None 130 | */ 131 | __RAM_FUNC HAL_FLASHEx_StartFlashInterfaceClk(void) 132 | { 133 | /* Enable Power ctrl clock */ 134 | __HAL_RCC_PWR_CLK_ENABLE(); 135 | /* Start the flash interface while System Run */ 136 | CLEAR_BIT(PWR->CR, PWR_CR_FISSR); 137 | 138 | return HAL_OK; 139 | } 140 | 141 | /** 142 | * @brief Enable the flash sleep while System Run 143 | * @note This mode is only available for STM32F41xxx/STM32F446xx devices. 144 | * @note This mode could n't be set while executing with the flash itself. 145 | * It should be done with specific routine executed from RAM. 146 | * @retval None 147 | */ 148 | __RAM_FUNC HAL_FLASHEx_EnableFlashSleepMode(void) 149 | { 150 | /* Enable Power ctrl clock */ 151 | __HAL_RCC_PWR_CLK_ENABLE(); 152 | /* Enable the flash sleep while System Run */ 153 | SET_BIT(PWR->CR, PWR_CR_FMSSR); 154 | 155 | return HAL_OK; 156 | } 157 | 158 | /** 159 | * @brief Disable the flash sleep while System Run 160 | * @note This mode is only available for STM32F41xxx/STM32F446xx devices. 161 | * @note This mode couldn't be set while executing with the flash itself. 162 | * It should be done with specific routine executed from RAM. 163 | * @retval None 164 | */ 165 | __RAM_FUNC HAL_FLASHEx_DisableFlashSleepMode(void) 166 | { 167 | /* Enable Power ctrl clock */ 168 | __HAL_RCC_PWR_CLK_ENABLE(); 169 | /* Disable the flash sleep while System Run */ 170 | CLEAR_BIT(PWR->CR, PWR_CR_FMSSR); 171 | 172 | return HAL_OK; 173 | } 174 | 175 | /** 176 | * @} 177 | */ 178 | 179 | /** 180 | * @} 181 | */ 182 | 183 | #endif /* STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 184 | #endif /* HAL_FLASH_MODULE_ENABLED */ 185 | /** 186 | * @} 187 | */ 188 | 189 | /** 190 | * @} 191 | */ 192 | 193 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 194 | -------------------------------------------------------------------------------- /Inc/HC_SR04.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Inc/HC_SR04.h -------------------------------------------------------------------------------- /Inc/adc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : ADC.h 4 | * Description : This file provides code for the configuration 5 | * of the ADC instances. 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2016 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | /* Define to prevent recursive inclusion -------------------------------------*/ 35 | #ifndef __adc_H 36 | #define __adc_H 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /* Includes ------------------------------------------------------------------*/ 42 | #include "stm32f4xx_hal.h" 43 | 44 | /* USER CODE BEGIN Includes */ 45 | 46 | /* USER CODE END Includes */ 47 | 48 | extern ADC_HandleTypeDef hadc1; 49 | 50 | /* USER CODE BEGIN Private defines */ 51 | 52 | /* USER CODE END Private defines */ 53 | 54 | extern void Error_Handler(void); 55 | 56 | void MX_ADC1_Init(void); 57 | 58 | /* USER CODE BEGIN Prototypes */ 59 | 60 | /* USER CODE END Prototypes */ 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #endif /*__ adc_H */ 66 | 67 | /** 68 | * @} 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 76 | -------------------------------------------------------------------------------- /Inc/ann.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Inc/ann.h -------------------------------------------------------------------------------- /Inc/flash_fs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Inc/flash_fs.h -------------------------------------------------------------------------------- /Inc/gpio.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : gpio.h 4 | * Description : This file contains all the functions prototypes for 5 | * the gpio 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2016 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | 35 | /* Define to prevent recursive inclusion -------------------------------------*/ 36 | #ifndef __gpio_H 37 | #define __gpio_H 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* Includes ------------------------------------------------------------------*/ 43 | #include "stm32f4xx_hal.h" 44 | 45 | /* USER CODE BEGIN Includes */ 46 | 47 | /* USER CODE END Includes */ 48 | 49 | /* USER CODE BEGIN Private defines */ 50 | 51 | /* USER CODE END Private defines */ 52 | 53 | void MX_GPIO_Init(void); 54 | 55 | /* USER CODE BEGIN Prototypes */ 56 | 57 | /* USER CODE END Prototypes */ 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | #endif /*__ pinoutConfig_H */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 73 | -------------------------------------------------------------------------------- /Inc/mxconstants.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : mxconstants.h 4 | * Description : This file contains the common defines of the application 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2016 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | /* Define to prevent recursive inclusion -------------------------------------*/ 34 | #ifndef __MXCONSTANT_H 35 | #define __MXCONSTANT_H 36 | /* Includes ------------------------------------------------------------------*/ 37 | 38 | /* USER CODE BEGIN Includes */ 39 | 40 | /* USER CODE END Includes */ 41 | 42 | /* Private define ------------------------------------------------------------*/ 43 | 44 | #define CS_I2C_SPI_Pin GPIO_PIN_3 45 | #define CS_I2C_SPI_GPIO_Port GPIOE 46 | #define PC14_OSC32_IN_Pin GPIO_PIN_14 47 | #define PC14_OSC32_IN_GPIO_Port GPIOC 48 | #define PC15_OSC32_OUT_Pin GPIO_PIN_15 49 | #define PC15_OSC32_OUT_GPIO_Port GPIOC 50 | #define PH0_OSC_IN_Pin GPIO_PIN_0 51 | #define PH0_OSC_IN_GPIO_Port GPIOH 52 | #define PH1_OSC_OUT_Pin GPIO_PIN_1 53 | #define PH1_OSC_OUT_GPIO_Port GPIOH 54 | #define OTG_FS_PowerSwitchOn_Pin GPIO_PIN_0 55 | #define OTG_FS_PowerSwitchOn_GPIO_Port GPIOC 56 | #define PDM_OUT_Pin GPIO_PIN_3 57 | #define PDM_OUT_GPIO_Port GPIOC 58 | #define B1_Pin GPIO_PIN_0 59 | #define B1_GPIO_Port GPIOA 60 | #define BOOT1_Pin GPIO_PIN_2 61 | #define BOOT1_GPIO_Port GPIOB 62 | #define CLK_IN_Pin GPIO_PIN_10 63 | #define CLK_IN_GPIO_Port GPIOB 64 | #define ECHO_SIGNAL_Pin GPIO_PIN_15 65 | #define ECHO_SIGNAL_GPIO_Port GPIOB 66 | #define LD4_Pin GPIO_PIN_12 67 | #define LD4_GPIO_Port GPIOD 68 | #define LD3_Pin GPIO_PIN_13 69 | #define LD3_GPIO_Port GPIOD 70 | #define LD5_Pin GPIO_PIN_14 71 | #define LD5_GPIO_Port GPIOD 72 | #define LD6_Pin GPIO_PIN_15 73 | #define LD6_GPIO_Port GPIOD 74 | #define B2_Pin GPIO_PIN_6 75 | #define B2_GPIO_Port GPIOC 76 | #define VBUS_FS_Pin GPIO_PIN_9 77 | #define VBUS_FS_GPIO_Port GPIOA 78 | #define OTG_FS_ID_Pin GPIO_PIN_10 79 | #define OTG_FS_ID_GPIO_Port GPIOA 80 | #define OTG_FS_DM_Pin GPIO_PIN_11 81 | #define OTG_FS_DM_GPIO_Port GPIOA 82 | #define OTG_FS_DP_Pin GPIO_PIN_12 83 | #define OTG_FS_DP_GPIO_Port GPIOA 84 | #define SWDIO_Pin GPIO_PIN_13 85 | #define SWDIO_GPIO_Port GPIOA 86 | #define SWCLK_Pin GPIO_PIN_14 87 | #define SWCLK_GPIO_Port GPIOA 88 | #define I2S3_SCK_Pin GPIO_PIN_10 89 | #define I2S3_SCK_GPIO_Port GPIOC 90 | #define Audio_RST_Pin GPIO_PIN_4 91 | #define Audio_RST_GPIO_Port GPIOD 92 | #define OTG_FS_OverCurrent_Pin GPIO_PIN_5 93 | #define OTG_FS_OverCurrent_GPIO_Port GPIOD 94 | #define SWO_Pin GPIO_PIN_3 95 | #define SWO_GPIO_Port GPIOB 96 | #define Audio_SCL_Pin GPIO_PIN_6 97 | #define Audio_SCL_GPIO_Port GPIOB 98 | #define Audio_SDA_Pin GPIO_PIN_9 99 | #define Audio_SDA_GPIO_Port GPIOB 100 | #define MEMS_INT2_Pin GPIO_PIN_1 101 | #define MEMS_INT2_GPIO_Port GPIOE 102 | /* USER CODE BEGIN Private defines */ 103 | 104 | /* USER CODE END Private defines */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** 111 | * @} 112 | */ 113 | 114 | #endif /* __MXCONSTANT_H */ 115 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 116 | -------------------------------------------------------------------------------- /Inc/stm32f4xx_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_it.h 4 | * @brief This file contains the headers of the interrupt handlers. 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2016 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | 34 | /* Define to prevent recursive inclusion -------------------------------------*/ 35 | #ifndef __STM32F4xx_IT_H 36 | #define __STM32F4xx_IT_H 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /* Includes ------------------------------------------------------------------*/ 43 | /* Exported types ------------------------------------------------------------*/ 44 | /* Exported constants --------------------------------------------------------*/ 45 | /* Exported macro ------------------------------------------------------------*/ 46 | /* Exported functions ------------------------------------------------------- */ 47 | 48 | void NMI_Handler(void); 49 | void HardFault_Handler(void); 50 | void MemManage_Handler(void); 51 | void BusFault_Handler(void); 52 | void UsageFault_Handler(void); 53 | void SVC_Handler(void); 54 | void DebugMon_Handler(void); 55 | void PendSV_Handler(void); 56 | void SysTick_Handler(void); 57 | void TIM1_UP_TIM10_IRQHandler(void); 58 | void EXTI15_10_IRQHandler(void); 59 | void TIM8_BRK_TIM12_IRQHandler(void); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif /* __STM32F4xx_IT_H */ 66 | 67 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 68 | -------------------------------------------------------------------------------- /Inc/tim.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : TIM.h 4 | * Description : This file provides code for the configuration 5 | * of the TIM instances. 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2016 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | /* Define to prevent recursive inclusion -------------------------------------*/ 35 | #ifndef __tim_H 36 | #define __tim_H 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /* Includes ------------------------------------------------------------------*/ 42 | #include "stm32f4xx_hal.h" 43 | 44 | /* USER CODE BEGIN Includes */ 45 | 46 | /* USER CODE END Includes */ 47 | 48 | extern TIM_HandleTypeDef htim1; 49 | extern TIM_HandleTypeDef htim12; 50 | 51 | /* USER CODE BEGIN Private defines */ 52 | 53 | /* USER CODE END Private defines */ 54 | 55 | extern void Error_Handler(void); 56 | 57 | void MX_TIM1_Init(void); 58 | void MX_TIM12_Init(void); 59 | 60 | void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); 61 | 62 | 63 | /* USER CODE BEGIN Prototypes */ 64 | 65 | /* USER CODE END Prototypes */ 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | #endif /*__ tim_H */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 81 | -------------------------------------------------------------------------------- /Inc/usart.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : USART.h 4 | * Description : This file provides code for the configuration 5 | * of the USART instances. 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2016 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | /* Define to prevent recursive inclusion -------------------------------------*/ 35 | #ifndef __usart_H 36 | #define __usart_H 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /* Includes ------------------------------------------------------------------*/ 42 | #include "stm32f4xx_hal.h" 43 | 44 | /* USER CODE BEGIN Includes */ 45 | 46 | /* USER CODE END Includes */ 47 | 48 | extern UART_HandleTypeDef huart2; 49 | 50 | /* USER CODE BEGIN Private defines */ 51 | 52 | /* USER CODE END Private defines */ 53 | 54 | extern void Error_Handler(void); 55 | 56 | void MX_USART2_UART_Init(void); 57 | 58 | /* USER CODE BEGIN Prototypes */ 59 | 60 | /* USER CODE END Prototypes */ 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #endif /*__ usart_H */ 66 | 67 | /** 68 | * @} 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 76 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) Sebastian Foerster 2 | Q-Leaning walking robot with ANN 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Artificial Neural Network and reinforcement learning (Q-Learning) walking robot C-Project 2 | ============== 3 | 4 | Thats an example with an robot "dog" with just 4 servo motors. 5 | The HC-SR04 will measure the distance to the wall. 6 | An ANN will be trained by an Q-Learning algorithm. 7 | reward: distance to the wall gets smaller 8 | 9 | Hardware 10 | -------------- 11 | STM32F4 Discovery Board -> CortexM4 with FPU 12 | 13 | License 14 | -------------- 15 | GPLv2 16 | 17 | Libs 18 | -------------- 19 | fann (LGPL see http://leenissen.dk/) (added as static library to this project) 20 | STM32 HAL 21 | 22 | Software 23 | -------------- 24 | System Workbench (Eclipse based) 25 | STM CubeMX 26 | 27 | Introduction 28 | -------------- 29 | Press the blue Discovery button and the learnphase is starting. 30 | If the distance to the wall gets to small or to large at the training phase the robot starts flashing an LED. Put the robot in the middle of the training stage and press the button to go on. 31 | After the learn phase all LEDs goes on. Press blue button again to execute the learned ann. -------------------------------------------------------------------------------- /STM32F407VGTx_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ***************************************************************************** 3 | ** 4 | 5 | ** File : LinkerScript.ld 6 | ** 7 | ** Abstract : Linker script for STM32F407VGTx Device with 8 | ** 1024KByte FLASH, 128KByte RAM 9 | ** 10 | ** Set heap size, stack size and stack location according 11 | ** to application requirements. 12 | ** 13 | ** Set memory bank area and size if external memory is used. 14 | ** 15 | ** Target : STMicroelectronics STM32 16 | ** 17 | ** 18 | ** Distribution: The file is distributed as is, without any warranty 19 | ** of any kind. 20 | ** 21 | ***************************************************************************** 22 | ** @attention 23 | ** 24 | **

© COPYRIGHT(c) 2014 Ac6

25 | ** 26 | ** Redistribution and use in source and binary forms, with or without modification, 27 | ** are permitted provided that the following conditions are met: 28 | ** 1. Redistributions of source code must retain the above copyright notice, 29 | ** this list of conditions and the following disclaimer. 30 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 31 | ** this list of conditions and the following disclaimer in the documentation 32 | ** and/or other materials provided with the distribution. 33 | ** 3. Neither the name of Ac6 nor the names of its contributors 34 | ** may be used to endorse or promote products derived from this software 35 | ** without specific prior written permission. 36 | ** 37 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 38 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 39 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 40 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 41 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 42 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 43 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 44 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 45 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 46 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 47 | ** 48 | ***************************************************************************** 49 | */ 50 | 51 | /* Entry Point */ 52 | ENTRY(Reset_Handler) 53 | 54 | /* Highest address of the user mode stack */ 55 | _estack = 0x20020000; /* end of RAM */ 56 | /* Generate a link error if heap and stack don't fit into RAM */ 57 | _Min_Heap_Size = 0xA000; /* required amount of heap */ 58 | _Min_Stack_Size = 0x400; /* required amount of stack */ 59 | 60 | /* Specify the memory areas */ 61 | MEMORY 62 | { 63 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K 64 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K 65 | CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K 66 | } 67 | 68 | /* Define output sections */ 69 | SECTIONS 70 | { 71 | /* The startup code goes first into FLASH */ 72 | .isr_vector : 73 | { 74 | . = ALIGN(4); 75 | KEEP(*(.isr_vector)) /* Startup code */ 76 | . = ALIGN(4); 77 | } >FLASH 78 | 79 | /* The program code and other data goes into FLASH */ 80 | .text : 81 | { 82 | . = ALIGN(4); 83 | *(.text) /* .text sections (code) */ 84 | *(.text*) /* .text* sections (code) */ 85 | *(.glue_7) /* glue arm to thumb code */ 86 | *(.glue_7t) /* glue thumb to arm code */ 87 | *(.eh_frame) 88 | 89 | KEEP (*(.init)) 90 | KEEP (*(.fini)) 91 | 92 | . = ALIGN(4); 93 | _etext = .; /* define a global symbols at end of code */ 94 | } >FLASH 95 | 96 | /* Constant data goes into FLASH */ 97 | .rodata : 98 | { 99 | . = ALIGN(4); 100 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 101 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 102 | . = ALIGN(4); 103 | } >FLASH 104 | 105 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 106 | .ARM : { 107 | __exidx_start = .; 108 | *(.ARM.exidx*) 109 | __exidx_end = .; 110 | } >FLASH 111 | 112 | .preinit_array : 113 | { 114 | PROVIDE_HIDDEN (__preinit_array_start = .); 115 | KEEP (*(.preinit_array*)) 116 | PROVIDE_HIDDEN (__preinit_array_end = .); 117 | } >FLASH 118 | .init_array : 119 | { 120 | PROVIDE_HIDDEN (__init_array_start = .); 121 | KEEP (*(SORT(.init_array.*))) 122 | KEEP (*(.init_array*)) 123 | PROVIDE_HIDDEN (__init_array_end = .); 124 | } >FLASH 125 | .fini_array : 126 | { 127 | PROVIDE_HIDDEN (__fini_array_start = .); 128 | KEEP (*(SORT(.fini_array.*))) 129 | KEEP (*(.fini_array*)) 130 | PROVIDE_HIDDEN (__fini_array_end = .); 131 | } >FLASH 132 | 133 | /* used by the startup to initialize data */ 134 | _sidata = LOADADDR(.data); 135 | 136 | /* Initialized data sections goes into RAM, load LMA copy after code */ 137 | .data : 138 | { 139 | . = ALIGN(4); 140 | _sdata = .; /* create a global symbol at data start */ 141 | *(.data) /* .data sections */ 142 | *(.data*) /* .data* sections */ 143 | 144 | . = ALIGN(4); 145 | _edata = .; /* define a global symbol at data end */ 146 | } >RAM AT> FLASH 147 | 148 | _siccmram = LOADADDR(.ccmram); 149 | 150 | /* CCM-RAM section 151 | * 152 | * IMPORTANT NOTE! 153 | * If initialized variables will be placed in this section, 154 | * the startup code needs to be modified to copy the init-values. 155 | */ 156 | .ccmram : 157 | { 158 | . = ALIGN(4); 159 | _sccmram = .; /* create a global symbol at ccmram start */ 160 | *(.ccmram) 161 | *(.ccmram*) 162 | 163 | . = ALIGN(4); 164 | _eccmram = .; /* create a global symbol at ccmram end */ 165 | } >CCMRAM AT> FLASH 166 | 167 | 168 | /* Uninitialized data section */ 169 | . = ALIGN(4); 170 | .bss : 171 | { 172 | /* This is used by the startup in order to initialize the .bss secion */ 173 | _sbss = .; /* define a global symbol at bss start */ 174 | __bss_start__ = _sbss; 175 | *(.bss) 176 | *(.bss*) 177 | *(COMMON) 178 | 179 | . = ALIGN(4); 180 | _ebss = .; /* define a global symbol at bss end */ 181 | __bss_end__ = _ebss; 182 | } >RAM 183 | 184 | /* User_heap_stack section, used to check that there is enough RAM left */ 185 | ._user_heap_stack : 186 | { 187 | . = ALIGN(8); 188 | PROVIDE ( end = . ); 189 | PROVIDE ( _end = . ); 190 | . = . + _Min_Heap_Size; 191 | . = . + _Min_Stack_Size; 192 | . = ALIGN(8); 193 | } >RAM 194 | 195 | 196 | 197 | /* Remove information from the standard libraries */ 198 | /DISCARD/ : 199 | { 200 | libc.a ( * ) 201 | libm.a ( * ) 202 | libgcc.a ( * ) 203 | } 204 | 205 | .ARM.attributes 0 : { *(.ARM.attributes) } 206 | } 207 | 208 | 209 | -------------------------------------------------------------------------------- /Src/HC_SR04.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Src/HC_SR04.c -------------------------------------------------------------------------------- /Src/adc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : ADC.c 4 | * Description : This file provides code for the configuration 5 | * of the ADC instances. 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2016 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | 35 | /* Includes ------------------------------------------------------------------*/ 36 | #include "adc.h" 37 | 38 | #include "gpio.h" 39 | 40 | /* USER CODE BEGIN 0 */ 41 | 42 | /* USER CODE END 0 */ 43 | 44 | ADC_HandleTypeDef hadc1; 45 | 46 | /* ADC1 init function */ 47 | void MX_ADC1_Init(void) 48 | { 49 | ADC_ChannelConfTypeDef sConfig; 50 | 51 | /**Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) 52 | */ 53 | hadc1.Instance = ADC1; 54 | hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2; 55 | hadc1.Init.Resolution = ADC_RESOLUTION_12B; 56 | hadc1.Init.ScanConvMode = DISABLE; 57 | hadc1.Init.ContinuousConvMode = DISABLE; 58 | hadc1.Init.DiscontinuousConvMode = DISABLE; 59 | hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; 60 | hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; 61 | hadc1.Init.NbrOfConversion = 1; 62 | hadc1.Init.DMAContinuousRequests = DISABLE; 63 | hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV; 64 | if (HAL_ADC_Init(&hadc1) != HAL_OK) 65 | { 66 | Error_Handler(); 67 | } 68 | 69 | /**Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. 70 | */ 71 | sConfig.Channel = ADC_CHANNEL_1; 72 | sConfig.Rank = 1; 73 | sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES; 74 | if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) 75 | { 76 | Error_Handler(); 77 | } 78 | 79 | } 80 | 81 | void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle) 82 | { 83 | 84 | GPIO_InitTypeDef GPIO_InitStruct; 85 | if(adcHandle->Instance==ADC1) 86 | { 87 | /* USER CODE BEGIN ADC1_MspInit 0 */ 88 | 89 | /* USER CODE END ADC1_MspInit 0 */ 90 | /* Peripheral clock enable */ 91 | __HAL_RCC_ADC1_CLK_ENABLE(); 92 | 93 | /**ADC1 GPIO Configuration 94 | PA1 ------> ADC1_IN1 95 | */ 96 | GPIO_InitStruct.Pin = GPIO_PIN_1; 97 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; 98 | GPIO_InitStruct.Pull = GPIO_NOPULL; 99 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 100 | 101 | /* USER CODE BEGIN ADC1_MspInit 1 */ 102 | 103 | /* USER CODE END ADC1_MspInit 1 */ 104 | } 105 | } 106 | 107 | void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle) 108 | { 109 | 110 | if(adcHandle->Instance==ADC1) 111 | { 112 | /* USER CODE BEGIN ADC1_MspDeInit 0 */ 113 | 114 | /* USER CODE END ADC1_MspDeInit 0 */ 115 | /* Peripheral clock disable */ 116 | __HAL_RCC_ADC1_CLK_DISABLE(); 117 | 118 | /**ADC1 GPIO Configuration 119 | PA1 ------> ADC1_IN1 120 | */ 121 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1); 122 | 123 | } 124 | /* USER CODE BEGIN ADC1_MspDeInit 1 */ 125 | 126 | /* USER CODE END ADC1_MspDeInit 1 */ 127 | } 128 | 129 | /* USER CODE BEGIN 1 */ 130 | 131 | /* USER CODE END 1 */ 132 | 133 | /** 134 | * @} 135 | */ 136 | 137 | /** 138 | * @} 139 | */ 140 | 141 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 142 | -------------------------------------------------------------------------------- /Src/ann.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Src/ann.c -------------------------------------------------------------------------------- /Src/flash_fs.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Src/flash_fs.c -------------------------------------------------------------------------------- /Src/gpio.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : gpio.c 4 | * Description : This file provides code for the configuration 5 | * of all used GPIO pins. 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2016 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | 35 | /* Includes ------------------------------------------------------------------*/ 36 | #include "gpio.h" 37 | /* USER CODE BEGIN 0 */ 38 | 39 | /* USER CODE END 0 */ 40 | 41 | /*----------------------------------------------------------------------------*/ 42 | /* Configure GPIO */ 43 | /*----------------------------------------------------------------------------*/ 44 | /* USER CODE BEGIN 1 */ 45 | 46 | /* USER CODE END 1 */ 47 | 48 | /** Configure pins as 49 | * Analog 50 | * Input 51 | * Output 52 | * EVENT_OUT 53 | * EXTI 54 | PC3 ------> I2S2_SD 55 | PA4 ------> I2S3_WS 56 | PA5 ------> SPI1_SCK 57 | PA6 ------> SPI1_MISO 58 | PA7 ------> SPI1_MOSI 59 | PB10 ------> I2S2_CK 60 | PC7 ------> I2S3_MCK 61 | PA9 ------> USB_OTG_FS_VBUS 62 | PA10 ------> USB_OTG_FS_ID 63 | PA11 ------> USB_OTG_FS_DM 64 | PA12 ------> USB_OTG_FS_DP 65 | PC10 ------> I2S3_CK 66 | PC12 ------> I2S3_SD 67 | PB6 ------> I2C1_SCL 68 | PB9 ------> I2C1_SDA 69 | */ 70 | void MX_GPIO_Init(void) 71 | { 72 | 73 | GPIO_InitTypeDef GPIO_InitStruct; 74 | 75 | /* GPIO Ports Clock Enable */ 76 | __HAL_RCC_GPIOE_CLK_ENABLE(); 77 | __HAL_RCC_GPIOC_CLK_ENABLE(); 78 | __HAL_RCC_GPIOH_CLK_ENABLE(); 79 | __HAL_RCC_GPIOA_CLK_ENABLE(); 80 | __HAL_RCC_GPIOB_CLK_ENABLE(); 81 | __HAL_RCC_GPIOD_CLK_ENABLE(); 82 | 83 | /*Configure GPIO pin Output Level */ 84 | HAL_GPIO_WritePin(CS_I2C_SPI_GPIO_Port, CS_I2C_SPI_Pin, GPIO_PIN_RESET); 85 | 86 | /*Configure GPIO pin Output Level */ 87 | HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin, GPIO_PIN_RESET); 88 | 89 | /*Configure GPIO pin Output Level */ 90 | HAL_GPIO_WritePin(GPIOD, LD4_Pin|LD3_Pin|LD5_Pin|LD6_Pin 91 | |Audio_RST_Pin, GPIO_PIN_RESET); 92 | 93 | /*Configure GPIO pin : PtPin */ 94 | GPIO_InitStruct.Pin = CS_I2C_SPI_Pin; 95 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 96 | GPIO_InitStruct.Pull = GPIO_NOPULL; 97 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 98 | HAL_GPIO_Init(CS_I2C_SPI_GPIO_Port, &GPIO_InitStruct); 99 | 100 | /*Configure GPIO pin : PtPin */ 101 | GPIO_InitStruct.Pin = OTG_FS_PowerSwitchOn_Pin; 102 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 103 | GPIO_InitStruct.Pull = GPIO_NOPULL; 104 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 105 | HAL_GPIO_Init(OTG_FS_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct); 106 | 107 | /*Configure GPIO pin : PtPin */ 108 | GPIO_InitStruct.Pin = PDM_OUT_Pin; 109 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 110 | GPIO_InitStruct.Pull = GPIO_NOPULL; 111 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 112 | GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; 113 | HAL_GPIO_Init(PDM_OUT_GPIO_Port, &GPIO_InitStruct); 114 | 115 | /*Configure GPIO pin : PtPin */ 116 | GPIO_InitStruct.Pin = B1_Pin; 117 | GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; 118 | GPIO_InitStruct.Pull = GPIO_NOPULL; 119 | HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct); 120 | 121 | /*Configure GPIO pin : PA4 */ 122 | GPIO_InitStruct.Pin = GPIO_PIN_4; 123 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 124 | GPIO_InitStruct.Pull = GPIO_NOPULL; 125 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 126 | GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; 127 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 128 | 129 | /*Configure GPIO pins : PA5 PA6 PA7 */ 130 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; 131 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 132 | GPIO_InitStruct.Pull = GPIO_NOPULL; 133 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 134 | GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; 135 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 136 | 137 | /*Configure GPIO pin : PtPin */ 138 | GPIO_InitStruct.Pin = BOOT1_Pin; 139 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 140 | GPIO_InitStruct.Pull = GPIO_NOPULL; 141 | HAL_GPIO_Init(BOOT1_GPIO_Port, &GPIO_InitStruct); 142 | 143 | /*Configure GPIO pin : PtPin */ 144 | GPIO_InitStruct.Pin = CLK_IN_Pin; 145 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 146 | GPIO_InitStruct.Pull = GPIO_NOPULL; 147 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 148 | GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; 149 | HAL_GPIO_Init(CLK_IN_GPIO_Port, &GPIO_InitStruct); 150 | 151 | /*Configure GPIO pin : PtPin */ 152 | GPIO_InitStruct.Pin = ECHO_SIGNAL_Pin; 153 | GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; 154 | GPIO_InitStruct.Pull = GPIO_PULLDOWN; 155 | HAL_GPIO_Init(ECHO_SIGNAL_GPIO_Port, &GPIO_InitStruct); 156 | 157 | /*Configure GPIO pins : PDPin PDPin PDPin PDPin 158 | PDPin */ 159 | GPIO_InitStruct.Pin = LD4_Pin|LD3_Pin|LD5_Pin|LD6_Pin 160 | |Audio_RST_Pin; 161 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 162 | GPIO_InitStruct.Pull = GPIO_NOPULL; 163 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 164 | HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); 165 | 166 | /*Configure GPIO pin : PtPin */ 167 | GPIO_InitStruct.Pin = B2_Pin; 168 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 169 | GPIO_InitStruct.Pull = GPIO_NOPULL; 170 | HAL_GPIO_Init(B2_GPIO_Port, &GPIO_InitStruct); 171 | 172 | /*Configure GPIO pins : PC7 PCPin PC12 */ 173 | GPIO_InitStruct.Pin = GPIO_PIN_7|I2S3_SCK_Pin|GPIO_PIN_12; 174 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 175 | GPIO_InitStruct.Pull = GPIO_NOPULL; 176 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 177 | GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; 178 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 179 | 180 | /*Configure GPIO pin : PtPin */ 181 | GPIO_InitStruct.Pin = VBUS_FS_Pin; 182 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 183 | GPIO_InitStruct.Pull = GPIO_NOPULL; 184 | HAL_GPIO_Init(VBUS_FS_GPIO_Port, &GPIO_InitStruct); 185 | 186 | /*Configure GPIO pins : PAPin PAPin PAPin */ 187 | GPIO_InitStruct.Pin = OTG_FS_ID_Pin|OTG_FS_DM_Pin|OTG_FS_DP_Pin; 188 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 189 | GPIO_InitStruct.Pull = GPIO_NOPULL; 190 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 191 | GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; 192 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 193 | 194 | /*Configure GPIO pin : PtPin */ 195 | GPIO_InitStruct.Pin = OTG_FS_OverCurrent_Pin; 196 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 197 | GPIO_InitStruct.Pull = GPIO_NOPULL; 198 | HAL_GPIO_Init(OTG_FS_OverCurrent_GPIO_Port, &GPIO_InitStruct); 199 | 200 | /*Configure GPIO pins : PBPin PBPin */ 201 | GPIO_InitStruct.Pin = Audio_SCL_Pin|Audio_SDA_Pin; 202 | GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; 203 | GPIO_InitStruct.Pull = GPIO_PULLUP; 204 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 205 | GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; 206 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 207 | 208 | /*Configure GPIO pin : PtPin */ 209 | GPIO_InitStruct.Pin = MEMS_INT2_Pin; 210 | GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; 211 | GPIO_InitStruct.Pull = GPIO_NOPULL; 212 | HAL_GPIO_Init(MEMS_INT2_GPIO_Port, &GPIO_InitStruct); 213 | 214 | /* EXTI interrupt init*/ 215 | HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0); 216 | HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); 217 | 218 | } 219 | 220 | /* USER CODE BEGIN 2 */ 221 | 222 | /* USER CODE END 2 */ 223 | 224 | /** 225 | * @} 226 | */ 227 | 228 | /** 229 | * @} 230 | */ 231 | 232 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 233 | -------------------------------------------------------------------------------- /Src/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : main.c 4 | * Description : Main program body 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2016 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | /* Includes ------------------------------------------------------------------*/ 34 | #include "stm32f4xx_hal.h" 35 | #include "adc.h" 36 | #include "tim.h" 37 | #include "usart.h" 38 | #include "gpio.h" 39 | 40 | /* USER CODE BEGIN Includes */ 41 | #include 42 | #include 43 | #include "fann.h" 44 | #include "servo.h" 45 | #include "ann.h" 46 | #include "HC_SR04.h" 47 | //#include "flash_fs.h" 48 | 49 | /* USER CODE END Includes */ 50 | 51 | /* Private variables ---------------------------------------------------------*/ 52 | 53 | /* USER CODE BEGIN PV */ 54 | /* Private variables ---------------------------------------------------------*/ 55 | 56 | /* USER CODE END PV */ 57 | 58 | /* Private function prototypes -----------------------------------------------*/ 59 | void SystemClock_Config(void); 60 | void Error_Handler(void); 61 | 62 | /* USER CODE BEGIN PFP */ 63 | /* Private function prototypes -----------------------------------------------*/ 64 | 65 | /* USER CODE END PFP */ 66 | 67 | /* USER CODE BEGIN 0 */ 68 | 69 | /* USER CODE END 0 */ 70 | 71 | int main(void) 72 | { 73 | 74 | /* USER CODE BEGIN 1 */ 75 | 76 | /* USER CODE END 1 */ 77 | 78 | /* MCU Configuration----------------------------------------------------------*/ 79 | 80 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ 81 | HAL_Init(); 82 | 83 | /* Configure the system clock */ 84 | SystemClock_Config(); 85 | 86 | /* Initialize all configured peripherals */ 87 | MX_GPIO_Init(); 88 | MX_USART2_UART_Init(); 89 | MX_ADC1_Init(); 90 | MX_TIM1_Init(); 91 | MX_TIM12_Init(); 92 | 93 | /* USER CODE BEGIN 2 */ 94 | 95 | /* USER CODE END 2 */ 96 | 97 | 98 | 99 | /* Infinite loop */ 100 | /* USER CODE BEGIN WHILE */ 101 | 102 | servo_init(&htim1); 103 | 104 | //include if ANN execute from file is desired 105 | //include also #include "flash_fs.h" in syscalls.c or the file loading will fail 106 | //flash_fs_init(); 107 | 108 | //start timer and distance measurement 109 | hcsr04_startMeasure(); 110 | 111 | //test distance 112 | /*while(1) 113 | { 114 | printf("Distance: %d\n", (int)hcsr04_getLastDistance_mm()); 115 | HAL_Delay(200); 116 | 117 | }*/ 118 | 119 | //wait for user key 120 | while(!HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin)); 121 | 122 | /*struct fann *ann; 123 | //Execute trained networks 124 | while(1) 125 | { 126 | ann = fann_create_from_file("robi_ann_forward_ann"); 127 | HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, 1); 128 | ann_executing(ann, 100); 129 | fann_destroy(ann); 130 | 131 | HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, 0); 132 | HAL_GPIO_WritePin(LD6_GPIO_Port, LD6_Pin, 1); 133 | 134 | ann = fann_create_from_file("robi_ann_backward_ann"); 135 | ann_executing(ann, 100); 136 | fann_destroy(ann); 137 | 138 | HAL_GPIO_WritePin(LD6_GPIO_Port, LD6_Pin, 0); 139 | }*/ 140 | 141 | ann_start_qlearning(700, 0.8, 1.0, 50); 142 | 143 | 144 | while (1) 145 | { 146 | /* USER CODE END WHILE */ 147 | 148 | /* USER CODE BEGIN 3 */ 149 | 150 | } 151 | /* USER CODE END 3 */ 152 | 153 | } 154 | 155 | /** System Clock Configuration 156 | */ 157 | void SystemClock_Config(void) 158 | { 159 | 160 | RCC_OscInitTypeDef RCC_OscInitStruct; 161 | RCC_ClkInitTypeDef RCC_ClkInitStruct; 162 | 163 | __HAL_RCC_PWR_CLK_ENABLE(); 164 | 165 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); 166 | 167 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; 168 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 169 | RCC_OscInitStruct.HSICalibrationValue = 16; 170 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 171 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; 172 | RCC_OscInitStruct.PLL.PLLM = 8; 173 | RCC_OscInitStruct.PLL.PLLN = 168; 174 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; 175 | RCC_OscInitStruct.PLL.PLLQ = 7; 176 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 177 | { 178 | Error_Handler(); 179 | } 180 | 181 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 182 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 183 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 184 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 185 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; 186 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV4; 187 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) 188 | { 189 | Error_Handler(); 190 | } 191 | 192 | HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); 193 | 194 | HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); 195 | 196 | /* SysTick_IRQn interrupt configuration */ 197 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 198 | } 199 | 200 | /* USER CODE BEGIN 4 */ 201 | 202 | /* USER CODE END 4 */ 203 | 204 | /** 205 | * @brief This function is executed in case of error occurrence. 206 | * @param None 207 | * @retval None 208 | */ 209 | void Error_Handler(void) 210 | { 211 | /* USER CODE BEGIN Error_Handler */ 212 | /* User can add his own implementation to report the HAL error return state */ 213 | while(1) 214 | { 215 | } 216 | /* USER CODE END Error_Handler */ 217 | } 218 | 219 | #ifdef USE_FULL_ASSERT 220 | 221 | /** 222 | * @brief Reports the name of the source file and the source line number 223 | * where the assert_param error has occurred. 224 | * @param file: pointer to the source file name 225 | * @param line: assert_param error line source number 226 | * @retval None 227 | */ 228 | void assert_failed(uint8_t* file, uint32_t line) 229 | { 230 | /* USER CODE BEGIN 6 */ 231 | /* User can add his own implementation to report the file name and line number, 232 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 233 | /* USER CODE END 6 */ 234 | 235 | } 236 | 237 | #endif 238 | 239 | /** 240 | * @} 241 | */ 242 | 243 | /** 244 | * @} 245 | */ 246 | 247 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 248 | -------------------------------------------------------------------------------- /Src/stm32f4xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : stm32f4xx_hal_msp.c 4 | * Description : This file provides code for the MSP Initialization 5 | * and de-Initialization codes. 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2016 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | /* Includes ------------------------------------------------------------------*/ 35 | #include "stm32f4xx_hal.h" 36 | 37 | extern void Error_Handler(void); 38 | /* USER CODE BEGIN 0 */ 39 | 40 | /* USER CODE END 0 */ 41 | 42 | /** 43 | * Initializes the Global MSP. 44 | */ 45 | void HAL_MspInit(void) 46 | { 47 | /* USER CODE BEGIN MspInit 0 */ 48 | 49 | /* USER CODE END MspInit 0 */ 50 | 51 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0); 52 | 53 | /* System interrupt init*/ 54 | /* MemoryManagement_IRQn interrupt configuration */ 55 | HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); 56 | /* BusFault_IRQn interrupt configuration */ 57 | HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); 58 | /* UsageFault_IRQn interrupt configuration */ 59 | HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); 60 | /* SVCall_IRQn interrupt configuration */ 61 | HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0); 62 | /* DebugMonitor_IRQn interrupt configuration */ 63 | HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0); 64 | /* PendSV_IRQn interrupt configuration */ 65 | HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0); 66 | /* SysTick_IRQn interrupt configuration */ 67 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 68 | 69 | /* USER CODE BEGIN MspInit 1 */ 70 | 71 | /* USER CODE END MspInit 1 */ 72 | } 73 | 74 | /* USER CODE BEGIN 1 */ 75 | 76 | /* USER CODE END 1 */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 87 | -------------------------------------------------------------------------------- /Src/stm32f4xx_it.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f4xx_it.c 4 | * @brief Interrupt Service Routines. 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2016 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | /* Includes ------------------------------------------------------------------*/ 34 | #include "stm32f4xx_hal.h" 35 | #include "stm32f4xx.h" 36 | #include "stm32f4xx_it.h" 37 | 38 | /* USER CODE BEGIN 0 */ 39 | #include "servo.h" 40 | #include "HC_SR04.h" 41 | /* USER CODE END 0 */ 42 | 43 | /* External variables --------------------------------------------------------*/ 44 | extern TIM_HandleTypeDef htim1; 45 | extern TIM_HandleTypeDef htim12; 46 | 47 | /******************************************************************************/ 48 | /* Cortex-M4 Processor Interruption and Exception Handlers */ 49 | /******************************************************************************/ 50 | 51 | /** 52 | * @brief This function handles Non maskable interrupt. 53 | */ 54 | void NMI_Handler(void) 55 | { 56 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 57 | 58 | /* USER CODE END NonMaskableInt_IRQn 0 */ 59 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 60 | 61 | /* USER CODE END NonMaskableInt_IRQn 1 */ 62 | } 63 | 64 | /** 65 | * @brief This function handles Hard fault interrupt. 66 | */ 67 | void HardFault_Handler(void) 68 | { 69 | /* USER CODE BEGIN HardFault_IRQn 0 */ 70 | 71 | /* USER CODE END HardFault_IRQn 0 */ 72 | while (1) 73 | { 74 | } 75 | /* USER CODE BEGIN HardFault_IRQn 1 */ 76 | 77 | /* USER CODE END HardFault_IRQn 1 */ 78 | } 79 | 80 | /** 81 | * @brief This function handles Memory management fault. 82 | */ 83 | void MemManage_Handler(void) 84 | { 85 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */ 86 | 87 | /* USER CODE END MemoryManagement_IRQn 0 */ 88 | while (1) 89 | { 90 | } 91 | /* USER CODE BEGIN MemoryManagement_IRQn 1 */ 92 | 93 | /* USER CODE END MemoryManagement_IRQn 1 */ 94 | } 95 | 96 | /** 97 | * @brief This function handles Pre-fetch fault, memory access fault. 98 | */ 99 | void BusFault_Handler(void) 100 | { 101 | /* USER CODE BEGIN BusFault_IRQn 0 */ 102 | 103 | /* USER CODE END BusFault_IRQn 0 */ 104 | while (1) 105 | { 106 | } 107 | /* USER CODE BEGIN BusFault_IRQn 1 */ 108 | 109 | /* USER CODE END BusFault_IRQn 1 */ 110 | } 111 | 112 | /** 113 | * @brief This function handles Undefined instruction or illegal state. 114 | */ 115 | void UsageFault_Handler(void) 116 | { 117 | /* USER CODE BEGIN UsageFault_IRQn 0 */ 118 | 119 | /* USER CODE END UsageFault_IRQn 0 */ 120 | while (1) 121 | { 122 | } 123 | /* USER CODE BEGIN UsageFault_IRQn 1 */ 124 | 125 | /* USER CODE END UsageFault_IRQn 1 */ 126 | } 127 | 128 | /** 129 | * @brief This function handles System service call via SWI instruction. 130 | */ 131 | void SVC_Handler(void) 132 | { 133 | /* USER CODE BEGIN SVCall_IRQn 0 */ 134 | 135 | /* USER CODE END SVCall_IRQn 0 */ 136 | /* USER CODE BEGIN SVCall_IRQn 1 */ 137 | 138 | /* USER CODE END SVCall_IRQn 1 */ 139 | } 140 | 141 | /** 142 | * @brief This function handles Debug monitor. 143 | */ 144 | void DebugMon_Handler(void) 145 | { 146 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */ 147 | 148 | /* USER CODE END DebugMonitor_IRQn 0 */ 149 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */ 150 | 151 | /* USER CODE END DebugMonitor_IRQn 1 */ 152 | } 153 | 154 | /** 155 | * @brief This function handles Pendable request for system service. 156 | */ 157 | void PendSV_Handler(void) 158 | { 159 | /* USER CODE BEGIN PendSV_IRQn 0 */ 160 | 161 | /* USER CODE END PendSV_IRQn 0 */ 162 | /* USER CODE BEGIN PendSV_IRQn 1 */ 163 | 164 | /* USER CODE END PendSV_IRQn 1 */ 165 | } 166 | 167 | /** 168 | * @brief This function handles System tick timer. 169 | */ 170 | void SysTick_Handler(void) 171 | { 172 | /* USER CODE BEGIN SysTick_IRQn 0 */ 173 | 174 | /* USER CODE END SysTick_IRQn 0 */ 175 | HAL_IncTick(); 176 | HAL_SYSTICK_IRQHandler(); 177 | /* USER CODE BEGIN SysTick_IRQn 1 */ 178 | 179 | /* USER CODE END SysTick_IRQn 1 */ 180 | } 181 | 182 | /******************************************************************************/ 183 | /* STM32F4xx Peripheral Interrupt Handlers */ 184 | /* Add here the Interrupt Handlers for the used peripherals. */ 185 | /* For the available peripheral interrupt handler names, */ 186 | /* please refer to the startup file (startup_stm32f4xx.s). */ 187 | /******************************************************************************/ 188 | 189 | /** 190 | * @brief This function handles TIM1 update interrupt and TIM10 global interrupt. 191 | */ 192 | void TIM1_UP_TIM10_IRQHandler(void) 193 | { 194 | /* USER CODE BEGIN TIM1_UP_TIM10_IRQn 0 */ 195 | servo_overflow_IT(); 196 | /* USER CODE END TIM1_UP_TIM10_IRQn 0 */ 197 | HAL_TIM_IRQHandler(&htim1); 198 | /* USER CODE BEGIN TIM1_UP_TIM10_IRQn 1 */ 199 | 200 | /* USER CODE END TIM1_UP_TIM10_IRQn 1 */ 201 | } 202 | 203 | /** 204 | * @brief This function handles EXTI line[15:10] interrupts. 205 | */ 206 | void EXTI15_10_IRQHandler(void) 207 | { 208 | /* USER CODE BEGIN EXTI15_10_IRQn 0 */ 209 | 210 | /* USER CODE END EXTI15_10_IRQn 0 */ 211 | HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_15); 212 | /* USER CODE BEGIN EXTI15_10_IRQn 1 */ 213 | hcsr04_cb_pin_fallingedge(); 214 | /* USER CODE END EXTI15_10_IRQn 1 */ 215 | } 216 | 217 | /** 218 | * @brief This function handles TIM8 break interrupt and TIM12 global interrupt. 219 | */ 220 | void TIM8_BRK_TIM12_IRQHandler(void) 221 | { 222 | /* USER CODE BEGIN TIM8_BRK_TIM12_IRQn 0 */ 223 | 224 | /* USER CODE END TIM8_BRK_TIM12_IRQn 0 */ 225 | HAL_TIM_IRQHandler(&htim12); 226 | /* USER CODE BEGIN TIM8_BRK_TIM12_IRQn 1 */ 227 | hcsr04_cb_timeroverflow(); 228 | /* USER CODE END TIM8_BRK_TIM12_IRQn 1 */ 229 | } 230 | 231 | /* USER CODE BEGIN 1 */ 232 | 233 | /* USER CODE END 1 */ 234 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 235 | -------------------------------------------------------------------------------- /Src/syscalls.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/Src/syscalls.c -------------------------------------------------------------------------------- /Src/tim.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : TIM.c 4 | * Description : This file provides code for the configuration 5 | * of the TIM instances. 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2016 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | 35 | /* Includes ------------------------------------------------------------------*/ 36 | #include "tim.h" 37 | 38 | /* USER CODE BEGIN 0 */ 39 | 40 | /* USER CODE END 0 */ 41 | 42 | TIM_HandleTypeDef htim1; 43 | TIM_HandleTypeDef htim12; 44 | 45 | /* TIM1 init function */ 46 | void MX_TIM1_Init(void) 47 | { 48 | TIM_ClockConfigTypeDef sClockSourceConfig; 49 | TIM_MasterConfigTypeDef sMasterConfig; 50 | TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig; 51 | TIM_OC_InitTypeDef sConfigOC; 52 | 53 | htim1.Instance = TIM1; 54 | htim1.Init.Prescaler = 84; 55 | htim1.Init.CounterMode = TIM_COUNTERMODE_UP; 56 | htim1.Init.Period = 20000; 57 | htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; 58 | htim1.Init.RepetitionCounter = 0; 59 | if (HAL_TIM_Base_Init(&htim1) != HAL_OK) 60 | { 61 | Error_Handler(); 62 | } 63 | 64 | sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; 65 | if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK) 66 | { 67 | Error_Handler(); 68 | } 69 | 70 | if (HAL_TIM_PWM_Init(&htim1) != HAL_OK) 71 | { 72 | Error_Handler(); 73 | } 74 | 75 | sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; 76 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; 77 | if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK) 78 | { 79 | Error_Handler(); 80 | } 81 | 82 | sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE; 83 | sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE; 84 | sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF; 85 | sBreakDeadTimeConfig.DeadTime = 0; 86 | sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE; 87 | sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH; 88 | sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE; 89 | if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK) 90 | { 91 | Error_Handler(); 92 | } 93 | 94 | sConfigOC.OCMode = TIM_OCMODE_PWM1; 95 | sConfigOC.Pulse = 5000; 96 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; 97 | sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH; 98 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; 99 | sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; 100 | sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; 101 | if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) 102 | { 103 | Error_Handler(); 104 | } 105 | 106 | if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) 107 | { 108 | Error_Handler(); 109 | } 110 | 111 | if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_3) != HAL_OK) 112 | { 113 | Error_Handler(); 114 | } 115 | 116 | if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_4) != HAL_OK) 117 | { 118 | Error_Handler(); 119 | } 120 | 121 | HAL_TIM_MspPostInit(&htim1); 122 | 123 | } 124 | /* TIM12 init function */ 125 | void MX_TIM12_Init(void) 126 | { 127 | TIM_ClockConfigTypeDef sClockSourceConfig; 128 | TIM_OC_InitTypeDef sConfigOC; 129 | 130 | htim12.Instance = TIM12; 131 | htim12.Init.Prescaler = 84; 132 | htim12.Init.CounterMode = TIM_COUNTERMODE_UP; 133 | htim12.Init.Period = 20000; 134 | htim12.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; 135 | if (HAL_TIM_Base_Init(&htim12) != HAL_OK) 136 | { 137 | Error_Handler(); 138 | } 139 | 140 | sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; 141 | if (HAL_TIM_ConfigClockSource(&htim12, &sClockSourceConfig) != HAL_OK) 142 | { 143 | Error_Handler(); 144 | } 145 | 146 | if (HAL_TIM_PWM_Init(&htim12) != HAL_OK) 147 | { 148 | Error_Handler(); 149 | } 150 | 151 | sConfigOC.OCMode = TIM_OCMODE_PWM1; 152 | sConfigOC.Pulse = 10000; 153 | sConfigOC.OCPolarity = TIM_OCPOLARITY_LOW; 154 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; 155 | if (HAL_TIM_PWM_ConfigChannel(&htim12, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) 156 | { 157 | Error_Handler(); 158 | } 159 | 160 | HAL_TIM_MspPostInit(&htim12); 161 | 162 | } 163 | 164 | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle) 165 | { 166 | 167 | if(tim_baseHandle->Instance==TIM1) 168 | { 169 | /* USER CODE BEGIN TIM1_MspInit 0 */ 170 | 171 | /* USER CODE END TIM1_MspInit 0 */ 172 | /* Peripheral clock enable */ 173 | __HAL_RCC_TIM1_CLK_ENABLE(); 174 | 175 | /* Peripheral interrupt init */ 176 | HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn, 0, 0); 177 | HAL_NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn); 178 | /* USER CODE BEGIN TIM1_MspInit 1 */ 179 | 180 | /* USER CODE END TIM1_MspInit 1 */ 181 | } 182 | else if(tim_baseHandle->Instance==TIM12) 183 | { 184 | /* USER CODE BEGIN TIM12_MspInit 0 */ 185 | 186 | /* USER CODE END TIM12_MspInit 0 */ 187 | /* Peripheral clock enable */ 188 | __HAL_RCC_TIM12_CLK_ENABLE(); 189 | 190 | /* Peripheral interrupt init */ 191 | HAL_NVIC_SetPriority(TIM8_BRK_TIM12_IRQn, 0, 0); 192 | HAL_NVIC_EnableIRQ(TIM8_BRK_TIM12_IRQn); 193 | /* USER CODE BEGIN TIM12_MspInit 1 */ 194 | 195 | /* USER CODE END TIM12_MspInit 1 */ 196 | } 197 | } 198 | void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle) 199 | { 200 | 201 | GPIO_InitTypeDef GPIO_InitStruct; 202 | if(timHandle->Instance==TIM1) 203 | { 204 | /* USER CODE BEGIN TIM1_MspPostInit 0 */ 205 | 206 | /* USER CODE END TIM1_MspPostInit 0 */ 207 | /**TIM1 GPIO Configuration 208 | PE9 ------> TIM1_CH1 209 | PE11 ------> TIM1_CH2 210 | PE13 ------> TIM1_CH3 211 | PE14 ------> TIM1_CH4 212 | */ 213 | GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_13|GPIO_PIN_14; 214 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 215 | GPIO_InitStruct.Pull = GPIO_NOPULL; 216 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 217 | GPIO_InitStruct.Alternate = GPIO_AF1_TIM1; 218 | HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); 219 | 220 | /* USER CODE BEGIN TIM1_MspPostInit 1 */ 221 | 222 | /* USER CODE END TIM1_MspPostInit 1 */ 223 | } 224 | else if(timHandle->Instance==TIM12) 225 | { 226 | /* USER CODE BEGIN TIM12_MspPostInit 0 */ 227 | 228 | /* USER CODE END TIM12_MspPostInit 0 */ 229 | 230 | /**TIM12 GPIO Configuration 231 | PB14 ------> TIM12_CH1 232 | */ 233 | GPIO_InitStruct.Pin = GPIO_PIN_14; 234 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 235 | GPIO_InitStruct.Pull = GPIO_NOPULL; 236 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 237 | GPIO_InitStruct.Alternate = GPIO_AF9_TIM12; 238 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 239 | 240 | /* USER CODE BEGIN TIM12_MspPostInit 1 */ 241 | 242 | /* USER CODE END TIM12_MspPostInit 1 */ 243 | } 244 | 245 | } 246 | 247 | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle) 248 | { 249 | 250 | if(tim_baseHandle->Instance==TIM1) 251 | { 252 | /* USER CODE BEGIN TIM1_MspDeInit 0 */ 253 | 254 | /* USER CODE END TIM1_MspDeInit 0 */ 255 | /* Peripheral clock disable */ 256 | __HAL_RCC_TIM1_CLK_DISABLE(); 257 | 258 | /* Peripheral interrupt Deinit*/ 259 | HAL_NVIC_DisableIRQ(TIM1_UP_TIM10_IRQn); 260 | 261 | /* USER CODE BEGIN TIM1_MspDeInit 1 */ 262 | 263 | /* USER CODE END TIM1_MspDeInit 1 */ 264 | } 265 | else if(tim_baseHandle->Instance==TIM12) 266 | { 267 | /* USER CODE BEGIN TIM12_MspDeInit 0 */ 268 | 269 | /* USER CODE END TIM12_MspDeInit 0 */ 270 | /* Peripheral clock disable */ 271 | __HAL_RCC_TIM12_CLK_DISABLE(); 272 | 273 | /* Peripheral interrupt Deinit*/ 274 | HAL_NVIC_DisableIRQ(TIM8_BRK_TIM12_IRQn); 275 | 276 | /* USER CODE BEGIN TIM12_MspDeInit 1 */ 277 | 278 | /* USER CODE END TIM12_MspDeInit 1 */ 279 | } 280 | } 281 | 282 | /* USER CODE BEGIN 1 */ 283 | 284 | /* USER CODE END 1 */ 285 | 286 | /** 287 | * @} 288 | */ 289 | 290 | /** 291 | * @} 292 | */ 293 | 294 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 295 | -------------------------------------------------------------------------------- /Src/usart.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : USART.c 4 | * Description : This file provides code for the configuration 5 | * of the USART instances. 6 | ****************************************************************************** 7 | * 8 | * COPYRIGHT(c) 2016 STMicroelectronics 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 1. Redistributions of source code must retain the above copyright notice, 13 | * this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, 15 | * this list of conditions and the following disclaimer in the documentation 16 | * and/or other materials provided with the distribution. 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | ****************************************************************************** 33 | */ 34 | 35 | /* Includes ------------------------------------------------------------------*/ 36 | #include "usart.h" 37 | 38 | #include "gpio.h" 39 | 40 | /* USER CODE BEGIN 0 */ 41 | 42 | /* USER CODE END 0 */ 43 | 44 | UART_HandleTypeDef huart2; 45 | 46 | /* USART2 init function */ 47 | 48 | void MX_USART2_UART_Init(void) 49 | { 50 | 51 | huart2.Instance = USART2; 52 | huart2.Init.BaudRate = 256000; 53 | huart2.Init.WordLength = UART_WORDLENGTH_8B; 54 | huart2.Init.StopBits = UART_STOPBITS_1; 55 | huart2.Init.Parity = UART_PARITY_NONE; 56 | huart2.Init.Mode = UART_MODE_TX_RX; 57 | huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; 58 | huart2.Init.OverSampling = UART_OVERSAMPLING_16; 59 | if (HAL_UART_Init(&huart2) != HAL_OK) 60 | { 61 | Error_Handler(); 62 | } 63 | 64 | } 65 | 66 | void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) 67 | { 68 | 69 | GPIO_InitTypeDef GPIO_InitStruct; 70 | if(uartHandle->Instance==USART2) 71 | { 72 | /* USER CODE BEGIN USART2_MspInit 0 */ 73 | 74 | /* USER CODE END USART2_MspInit 0 */ 75 | /* Peripheral clock enable */ 76 | __HAL_RCC_USART2_CLK_ENABLE(); 77 | 78 | /**USART2 GPIO Configuration 79 | PA2 ------> USART2_TX 80 | PA3 ------> USART2_RX 81 | */ 82 | GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3; 83 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 84 | GPIO_InitStruct.Pull = GPIO_PULLUP; 85 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; 86 | GPIO_InitStruct.Alternate = GPIO_AF7_USART2; 87 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 88 | 89 | /* USER CODE BEGIN USART2_MspInit 1 */ 90 | 91 | /* USER CODE END USART2_MspInit 1 */ 92 | } 93 | } 94 | 95 | void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) 96 | { 97 | 98 | if(uartHandle->Instance==USART2) 99 | { 100 | /* USER CODE BEGIN USART2_MspDeInit 0 */ 101 | 102 | /* USER CODE END USART2_MspDeInit 0 */ 103 | /* Peripheral clock disable */ 104 | __HAL_RCC_USART2_CLK_DISABLE(); 105 | 106 | /**USART2 GPIO Configuration 107 | PA2 ------> USART2_TX 108 | PA3 ------> USART2_RX 109 | */ 110 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3); 111 | 112 | } 113 | /* USER CODE BEGIN USART2_MspDeInit 1 */ 114 | 115 | /* USER CODE END USART2_MspDeInit 1 */ 116 | } 117 | 118 | /* USER CODE BEGIN 1 */ 119 | 120 | /* USER CODE END 1 */ 121 | 122 | /** 123 | * @} 124 | */ 125 | 126 | /** 127 | * @} 128 | */ 129 | 130 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 131 | -------------------------------------------------------------------------------- /fann/include/config.h: -------------------------------------------------------------------------------- 1 | /* Name of package */ 2 | /* #undef PACKAGE */ 3 | 4 | /* Version number of package */ 5 | #define VERSION "2.2.0" 6 | 7 | /* Define for the x86_64 CPU famyly */ 8 | /* #undef X86_64 */ 9 | -------------------------------------------------------------------------------- /fann/include/doublefann.h: -------------------------------------------------------------------------------- 1 | /* 2 | Fast Artificial Neural Network Library (fann) 3 | Copyright (C) 2003-2016 Steffen Nissen (steffen.fann@gmail.com) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | /* 20 | #ifndef __doublefann_h__ 21 | #define __doublefann_h__ 22 | 23 | typedef double fann_type; 24 | 25 | #undef DOUBLEFANN 26 | #define DOUBLEFANN 27 | #define FANNPRINTF "%.20e" 28 | #define FANNSCANF "%le" 29 | 30 | #define FANN_INCLUDE 31 | #include "fann.h" 32 | 33 | #endif 34 | */ 35 | -------------------------------------------------------------------------------- /fann/include/fann_activation.h: -------------------------------------------------------------------------------- 1 | /* 2 | Fast Artificial Neural Network Library (fann) 3 | Copyright (C) 2003-2016 Steffen Nissen (steffen.fann@gmail.com) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __fann_activation_h__ 21 | #define __fann_activation_h__ 22 | /* internal include file, not to be included directly 23 | */ 24 | 25 | /* Implementation of the activation functions 26 | */ 27 | 28 | /* stepwise linear functions used for some of the activation functions */ 29 | 30 | /* defines used for the stepwise linear functions */ 31 | 32 | #define fann_linear_func(v1, r1, v2, r2, sum) (((((r2)-(r1)) * ((sum)-(v1)))/((v2)-(v1))) + (r1)) 33 | #define fann_stepwise(v1, v2, v3, v4, v5, v6, r1, r2, r3, r4, r5, r6, min, max, sum) (sum < v5 ? (sum < v3 ? (sum < v2 ? (sum < v1 ? min : fann_linear_func(v1, r1, v2, r2, sum)) : fann_linear_func(v2, r2, v3, r3, sum)) : (sum < v4 ? fann_linear_func(v3, r3, v4, r4, sum) : fann_linear_func(v4, r4, v5, r5, sum))) : (sum < v6 ? fann_linear_func(v5, r5, v6, r6, sum) : max)) 34 | 35 | /* FANN_LINEAR */ 36 | /* #define fann_linear(steepness, sum) fann_mult(steepness, sum) */ 37 | #define fann_linear_derive(steepness, value) (steepness) 38 | 39 | /* FANN_SIGMOID */ 40 | /* #define fann_sigmoid(steepness, sum) (1.0f/(1.0f + exp(-2.0f * steepness * sum))) */ 41 | #define fann_sigmoid_real(sum) (1.0f/(1.0f + exp(-2.0f * sum))) 42 | #define fann_sigmoid_derive(steepness, value) (2.0f * steepness * value * (1.0f - value)) 43 | 44 | /* FANN_SIGMOID_SYMMETRIC */ 45 | /* #define fann_sigmoid_symmetric(steepness, sum) (2.0f/(1.0f + exp(-2.0f * steepness * sum)) - 1.0f) */ 46 | #define fann_sigmoid_symmetric_real(sum) (2.0f/(1.0f + exp(-2.0f * sum)) - 1.0f) 47 | #define fann_sigmoid_symmetric_derive(steepness, value) steepness * (1.0f - (value*value)) 48 | 49 | /* FANN_GAUSSIAN */ 50 | /* #define fann_gaussian(steepness, sum) (exp(-sum * steepness * sum * steepness)) */ 51 | #define fann_gaussian_real(sum) (exp(-sum * sum)) 52 | #define fann_gaussian_derive(steepness, value, sum) (-2.0f * sum * value * steepness * steepness) 53 | 54 | /* FANN_GAUSSIAN_SYMMETRIC */ 55 | /* #define fann_gaussian_symmetric(steepness, sum) ((exp(-sum * steepness * sum * steepness)*2.0)-1.0) */ 56 | #define fann_gaussian_symmetric_real(sum) ((exp(-sum * sum)*2.0f)-1.0f) 57 | #define fann_gaussian_symmetric_derive(steepness, value, sum) (-2.0f * sum * (value+1.0f) * steepness * steepness) 58 | 59 | /* FANN_ELLIOT */ 60 | /* #define fann_elliot(steepness, sum) (((sum * steepness) / 2.0f) / (1.0f + fann_abs(sum * steepness)) + 0.5f) */ 61 | #define fann_elliot_real(sum) (((sum) / 2.0f) / (1.0f + fann_abs(sum)) + 0.5f) 62 | #define fann_elliot_derive(steepness, value, sum) (steepness * 1.0f / (2.0f * (1.0f + fann_abs(sum)) * (1.0f + fann_abs(sum)))) 63 | 64 | /* FANN_ELLIOT_SYMMETRIC */ 65 | /* #define fann_elliot_symmetric(steepness, sum) ((sum * steepness) / (1.0f + fann_abs(sum * steepness)))*/ 66 | #define fann_elliot_symmetric_real(sum) ((sum) / (1.0f + fann_abs(sum))) 67 | #define fann_elliot_symmetric_derive(steepness, value, sum) (steepness * 1.0f / ((1.0f + fann_abs(sum)) * (1.0f + fann_abs(sum)))) 68 | 69 | /* FANN_SIN_SYMMETRIC */ 70 | #define fann_sin_symmetric_real(sum) (sin(sum)) 71 | #define fann_sin_symmetric_derive(steepness, sum) (steepness*cos(steepness*sum)) 72 | 73 | /* FANN_COS_SYMMETRIC */ 74 | #define fann_cos_symmetric_real(sum) (cos(sum)) 75 | #define fann_cos_symmetric_derive(steepness, sum) (steepness*-sin(steepness*sum)) 76 | 77 | /* FANN_SIN */ 78 | #define fann_sin_real(sum) (sin(sum)/2.0f+0.5f) 79 | #define fann_sin_derive(steepness, sum) (steepness*cos(steepness*sum)/2.0f) 80 | 81 | /* FANN_COS */ 82 | #define fann_cos_real(sum) (cos(sum)/2.0f+0.5f) 83 | #define fann_cos_derive(steepness, sum) (steepness*-sin(steepness*sum)/2.0f) 84 | 85 | #define fann_activation_switch(activation_function, value, result) \ 86 | switch(activation_function) \ 87 | { \ 88 | case FANN_LINEAR: \ 89 | result = (fann_type)value; \ 90 | break; \ 91 | case FANN_LINEAR_PIECE: \ 92 | result = (fann_type)((value < 0) ? 0 : (value > 1) ? 1 : value); \ 93 | break; \ 94 | case FANN_LINEAR_PIECE_SYMMETRIC: \ 95 | result = (fann_type)((value < -1) ? -1 : (value > 1) ? 1 : value); \ 96 | break; \ 97 | case FANN_SIGMOID: \ 98 | result = (fann_type)fann_sigmoid_real(value); \ 99 | break; \ 100 | case FANN_SIGMOID_SYMMETRIC: \ 101 | result = (fann_type)fann_sigmoid_symmetric_real(value); \ 102 | break; \ 103 | case FANN_SIGMOID_SYMMETRIC_STEPWISE: \ 104 | result = (fann_type)fann_stepwise(-2.64665293693542480469e+00, -1.47221934795379638672e+00, -5.49306154251098632812e-01, 5.49306154251098632812e-01, 1.47221934795379638672e+00, 2.64665293693542480469e+00, -9.90000009536743164062e-01, -8.99999976158142089844e-01, -5.00000000000000000000e-01, 5.00000000000000000000e-01, 8.99999976158142089844e-01, 9.90000009536743164062e-01, -1, 1, value); \ 105 | break; \ 106 | case FANN_SIGMOID_STEPWISE: \ 107 | result = (fann_type)fann_stepwise(-2.64665246009826660156e+00, -1.47221946716308593750e+00, -5.49306154251098632812e-01, 5.49306154251098632812e-01, 1.47221934795379638672e+00, 2.64665293693542480469e+00, 4.99999988824129104614e-03, 5.00000007450580596924e-02, 2.50000000000000000000e-01, 7.50000000000000000000e-01, 9.49999988079071044922e-01, 9.95000004768371582031e-01, 0, 1, value); \ 108 | break; \ 109 | case FANN_THRESHOLD: \ 110 | result = (fann_type)((value < 0) ? 0 : 1); \ 111 | break; \ 112 | case FANN_THRESHOLD_SYMMETRIC: \ 113 | result = (fann_type)((value < 0) ? -1 : 1); \ 114 | break; \ 115 | case FANN_GAUSSIAN: \ 116 | result = (fann_type)fann_gaussian_real(value); \ 117 | break; \ 118 | case FANN_GAUSSIAN_SYMMETRIC: \ 119 | result = (fann_type)fann_gaussian_symmetric_real(value); \ 120 | break; \ 121 | case FANN_ELLIOT: \ 122 | result = (fann_type)fann_elliot_real(value); \ 123 | break; \ 124 | case FANN_ELLIOT_SYMMETRIC: \ 125 | result = (fann_type)fann_elliot_symmetric_real(value); \ 126 | break; \ 127 | case FANN_SIN_SYMMETRIC: \ 128 | result = (fann_type)fann_sin_symmetric_real(value); \ 129 | break; \ 130 | case FANN_COS_SYMMETRIC: \ 131 | result = (fann_type)fann_cos_symmetric_real(value); \ 132 | break; \ 133 | case FANN_SIN: \ 134 | result = (fann_type)fann_sin_real(value); \ 135 | break; \ 136 | case FANN_COS: \ 137 | result = (fann_type)fann_cos_real(value); \ 138 | break; \ 139 | case FANN_GAUSSIAN_STEPWISE: \ 140 | result = 0; \ 141 | break; \ 142 | } 143 | 144 | #endif 145 | -------------------------------------------------------------------------------- /fann/include/fann_data_cpp.h: -------------------------------------------------------------------------------- 1 | /* 2 | Fast Artificial Neural Network Library (fann) 3 | Copyright (C) 2003-2016 Steffen Nissen (steffen.fann@gmail.com) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef FANN_FANN_DATA_CPP_H_H 21 | #define FANN_FANN_DATA_CPP_H_H 22 | 23 | #include 24 | #include 25 | 26 | /* Section: FANN C++ Datatypes 27 | This section includes enums and helper data types used by the two main classes and 28 | */ 29 | 30 | 31 | /* Type: fann_type 32 | fann_type is the type used for the weights, inputs and outputs of the neural network. 33 | 34 | fann_type is defined as a: 35 | float - if you include fann.h or floatfann.h 36 | double - if you include doublefann.h 37 | int - if you include fixedfann.h (please be aware that fixed point usage is 38 | only to be used during execution, and not during training). 39 | */ 40 | 41 | namespace FANN { 42 | /* Enum: error_function_enum 43 | Error function used during training. 44 | 45 | ERRORFUNC_LINEAR - Standard linear error function. 46 | ERRORFUNC_TANH - Tanh error function, usually better 47 | but can require a lower learning rate. This error function aggressively targets outputs that 48 | differ much from the desired, while not targeting outputs that only differ a little that much. 49 | This activation function is not recommended for cascade training and incremental training. 50 | 51 | See also: 52 | , 53 | */ 54 | enum error_function_enum { 55 | ERRORFUNC_LINEAR = FANN_ERRORFUNC_LINEAR, 56 | ERRORFUNC_TANH 57 | }; 58 | 59 | /* Enum: stop_function_enum 60 | Stop criteria used during training. 61 | 62 | STOPFUNC_MSE - Stop criteria is Mean Square Error (MSE) value. 63 | STOPFUNC_BIT - Stop criteria is number of bits that fail. The number of bits; means the 64 | number of output neurons which differ more than the bit fail limit 65 | (see , ). 66 | The bits are counted in all of the training data, so this number can be higher than 67 | the number of training data. 68 | 69 | See also: 70 | , 71 | */ 72 | enum stop_function_enum { 73 | STOPFUNC_MSE = FANN_STOPFUNC_MSE, 74 | STOPFUNC_BIT 75 | }; 76 | 77 | /* Enum: training_algorithm_enum 78 | The Training algorithms used when training on with functions like 79 | or . The incremental training 80 | looks alters the weights after each time it is presented an input pattern, while batch 81 | only alters the weights once after it has been presented to all the patterns. 82 | 83 | TRAIN_INCREMENTAL - Standard backpropagation algorithm, where the weights are 84 | updated after each training pattern. This means that the weights are updated many 85 | times during a single epoch. For this reason some problems, will train very fast with 86 | this algorithm, while other more advanced problems will not train very well. 87 | TRAIN_BATCH - Standard backpropagation algorithm, where the weights are updated after 88 | calculating the mean square error for the whole training set. This means that the weights 89 | are only updated once during an epoch. For this reason some problems, will train slower with 90 | this algorithm. But since the mean square error is calculated more correctly than in 91 | incremental training, some problems will reach a better solutions with this algorithm. 92 | TRAIN_RPROP - A more advanced batch training algorithm which achieves good results 93 | for many problems. The RPROP training algorithm is adaptive, and does therefore not 94 | use the learning_rate. Some other parameters can however be set to change the way the 95 | RPROP algorithm works, but it is only recommended for users with insight in how the RPROP 96 | training algorithm works. The RPROP training algorithm is described by 97 | [Riedmiller and Braun, 1993], but the actual learning algorithm used here is the 98 | iRPROP- training algorithm which is described by [Igel and Husken, 2000] which 99 | is a variant of the standard RPROP training algorithm. 100 | TRAIN_QUICKPROP - A more advanced batch training algorithm which achieves good results 101 | for many problems. The quickprop training algorithm uses the learning_rate parameter 102 | along with other more advanced parameters, but it is only recommended to change these 103 | advanced parameters, for users with insight in how the quickprop training algorithm works. 104 | The quickprop training algorithm is described by [Fahlman, 1988]. 105 | FANN_TRAIN_SARPROP - THE SARPROP ALGORITHM: A SIMULATED ANNEALING ENHANCEMENT TO RESILIENT BACK PROPAGATION 106 | http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.47.8197&rep=rep1&type=pdf 107 | 108 | 109 | See also: 110 | , 111 | */ 112 | enum training_algorithm_enum { 113 | TRAIN_INCREMENTAL = FANN_TRAIN_INCREMENTAL, 114 | TRAIN_BATCH, 115 | TRAIN_RPROP, 116 | TRAIN_QUICKPROP, 117 | TRAIN_SARPROP 118 | }; 119 | 120 | /* Enum: activation_function_enum 121 | 122 | The activation functions used for the neurons during training. The activation functions 123 | can either be defined for a group of neurons by 124 | and or it can be defined for a single neuron by 125 | . 126 | 127 | The steepness of an activation function is defined in the same way by 128 | , 129 | and . 130 | 131 | The functions are described with functions where: 132 | * x is the input to the activation function, 133 | * y is the output, 134 | * s is the steepness and 135 | * d is the derivation. 136 | 137 | FANN_LINEAR - Linear activation function. 138 | * span: -inf < y < inf 139 | * y = x*s, d = 1*s 140 | * Can NOT be used in fixed point. 141 | 142 | FANN_THRESHOLD - Threshold activation function. 143 | * x < 0 -> y = 0, x >= 0 -> y = 1 144 | * Can NOT be used during training. 145 | 146 | FANN_THRESHOLD_SYMMETRIC - Threshold activation function. 147 | * x < 0 -> y = 0, x >= 0 -> y = 1 148 | * Can NOT be used during training. 149 | 150 | FANN_SIGMOID - Sigmoid activation function. 151 | * One of the most used activation functions. 152 | * span: 0 < y < 1 153 | * y = 1/(1 + exp(-2*s*x)) 154 | * d = 2*s*y*(1 - y) 155 | 156 | FANN_SIGMOID_STEPWISE - Stepwise linear approximation to sigmoid. 157 | * Faster than sigmoid but a bit less precise. 158 | 159 | FANN_SIGMOID_SYMMETRIC - Symmetric sigmoid activation function, aka. tanh. 160 | * One of the most used activation functions. 161 | * span: -1 < y < 1 162 | * y = tanh(s*x) = 2/(1 + exp(-2*s*x)) - 1 163 | * d = s*(1-(y*y)) 164 | 165 | FANN_SIGMOID_SYMMETRIC - Stepwise linear approximation to symmetric sigmoid. 166 | * Faster than symmetric sigmoid but a bit less precise. 167 | 168 | FANN_GAUSSIAN - Gaussian activation function. 169 | * 0 when x = -inf, 1 when x = 0 and 0 when x = inf 170 | * span: 0 < y < 1 171 | * y = exp(-x*s*x*s) 172 | * d = -2*x*s*y*s 173 | 174 | FANN_GAUSSIAN_SYMMETRIC - Symmetric gaussian activation function. 175 | * -1 when x = -inf, 1 when x = 0 and 0 when x = inf 176 | * span: -1 < y < 1 177 | * y = exp(-x*s*x*s)*2-1 178 | * d = -2*x*s*(y+1)*s 179 | 180 | FANN_ELLIOT - Fast (sigmoid like) activation function defined by David Elliott 181 | * span: 0 < y < 1 182 | * y = ((x*s) / 2) / (1 + |x*s|) + 0.5 183 | * d = s*1/(2*(1+|x*s|)*(1+|x*s|)) 184 | 185 | FANN_ELLIOT_SYMMETRIC - Fast (symmetric sigmoid like) activation function defined by David Elliott 186 | * span: -1 < y < 1 187 | * y = (x*s) / (1 + |x*s|) 188 | * d = s*1/((1+|x*s|)*(1+|x*s|)) 189 | 190 | FANN_LINEAR_PIECE - Bounded linear activation function. 191 | * span: 0 < y < 1 192 | * y = x*s, d = 1*s 193 | 194 | FANN_LINEAR_PIECE_SYMMETRIC - Bounded Linear activation function. 195 | * span: -1 < y < 1 196 | * y = x*s, d = 1*s 197 | 198 | FANN_SIN_SYMMETRIC - Periodical sinus activation function. 199 | * span: -1 <= y <= 1 200 | * y = sin(x*s) 201 | * d = s*cos(x*s) 202 | 203 | FANN_COS_SYMMETRIC - Periodical cosinus activation function. 204 | * span: -1 <= y <= 1 205 | * y = cos(x*s) 206 | * d = s*-sin(x*s) 207 | 208 | See also: 209 | , 210 | 211 | */ 212 | enum activation_function_enum { 213 | LINEAR = FANN_LINEAR, 214 | THRESHOLD, 215 | THRESHOLD_SYMMETRIC, 216 | SIGMOID, 217 | SIGMOID_STEPWISE, 218 | SIGMOID_SYMMETRIC, 219 | SIGMOID_SYMMETRIC_STEPWISE, 220 | GAUSSIAN, 221 | GAUSSIAN_SYMMETRIC, 222 | GAUSSIAN_STEPWISE, 223 | ELLIOT, 224 | ELLIOT_SYMMETRIC, 225 | LINEAR_PIECE, 226 | LINEAR_PIECE_SYMMETRIC, 227 | SIN_SYMMETRIC, 228 | COS_SYMMETRIC 229 | }; 230 | 231 | /* Enum: network_type_enum 232 | 233 | Definition of network types used by 234 | 235 | LAYER - Each layer only has connections to the next layer 236 | SHORTCUT - Each layer has connections to all following layers 237 | 238 | See Also: 239 | , 240 | 241 | This enumeration appears in FANN >= 2.1.0 242 | */ 243 | enum network_type_enum { 244 | LAYER = FANN_NETTYPE_LAYER, 245 | SHORTCUT 246 | }; 247 | 248 | /* Type: connection 249 | 250 | Describes a connection between two neurons and its weight 251 | 252 | from_neuron - Unique number used to identify source neuron 253 | to_neuron - Unique number used to identify destination neuron 254 | weight - The numerical value of the weight 255 | 256 | See Also: 257 | , 258 | 259 | This structure appears in FANN >= 2.1.0 260 | */ 261 | typedef struct fann_connection connection; 262 | 263 | /* Forward declaration of class neural_net and training_data */ 264 | class neural_net; 265 | 266 | class training_data; 267 | 268 | /* Type: callback_type 269 | This callback function can be called during training when using , 270 | or . 271 | 272 | >typedef int (*callback_type) (neural_net &net, training_data &train, 273 | > unsigned int max_epochs, unsigned int epochs_between_reports, 274 | > float desired_error, unsigned int epochs, void *user_data); 275 | 276 | The callback can be set by using and is very useful for doing custom 277 | things during training. It is recommended to use this function when implementing custom 278 | training procedures, or when visualizing the training in a GUI etc. The parameters which the 279 | callback function takes is the parameters given to the , plus an epochs 280 | parameter which tells how many epochs the training have taken so far. 281 | 282 | The callback function should return an integer, if the callback function returns -1, the training 283 | will terminate. 284 | 285 | Example of a callback function that prints information to cout: 286 | >int print_callback(FANN::neural_net &net, FANN::training_data &train, 287 | > unsigned int max_epochs, unsigned int epochs_between_reports, 288 | > float desired_error, unsigned int epochs, void *user_data) 289 | >{ 290 | > cout << "Epochs " << setw(8) << epochs << ". " 291 | > << "Current Error: " << left << net.get_MSE() << right << endl; 292 | > return 0; 293 | >} 294 | 295 | See also: 296 | , 297 | */ 298 | typedef int (*callback_type)(neural_net &net, training_data &train, 299 | unsigned int max_epochs, unsigned int epochs_between_reports, 300 | float desired_error, unsigned int epochs, void *user_data); 301 | } 302 | 303 | #endif //FANN_FANN_DATA_CPP_H_H 304 | -------------------------------------------------------------------------------- /fann/include/fann_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | Fast Artificial Neural Network Library (fann) 3 | Copyright (C) 2003-2016 Steffen Nissen (steffen.fann@gmail.com) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __fann_error_h__ 21 | #define __fann_error_h__ 22 | 23 | #include 24 | 25 | #define FANN_ERRSTR_MAX 128 26 | struct fann_error; 27 | 28 | /* Section: FANN Error Handling 29 | 30 | Errors from the fann library are usually reported on stderr. 31 | It is however possible to redirect these error messages to a file, 32 | or completely ignore them by the function. 33 | 34 | It is also possible to inspect the last error message by using the 35 | and functions. 36 | */ 37 | 38 | /* Enum: fann_errno_enum 39 | Used to define error events on and . 40 | 41 | See also: 42 | , , 43 | 44 | FANN_E_NO_ERROR - No error 45 | FANN_E_CANT_OPEN_CONFIG_R - Unable to open configuration file for reading 46 | FANN_E_CANT_OPEN_CONFIG_W - Unable to open configuration file for writing 47 | FANN_E_WRONG_CONFIG_VERSION - Wrong version of configuration file 48 | FANN_E_CANT_READ_CONFIG - Error reading info from configuration file 49 | FANN_E_CANT_READ_NEURON - Error reading neuron info from configuration file 50 | FANN_E_CANT_READ_CONNECTIONS - Error reading connections from configuration file 51 | FANN_E_WRONG_NUM_CONNECTIONS - Number of connections not equal to the number expected 52 | FANN_E_CANT_OPEN_TD_W - Unable to open train data file for writing 53 | FANN_E_CANT_OPEN_TD_R - Unable to open train data file for reading 54 | FANN_E_CANT_READ_TD - Error reading training data from file 55 | FANN_E_CANT_ALLOCATE_MEM - Unable to allocate memory 56 | FANN_E_CANT_TRAIN_ACTIVATION - Unable to train with the selected activation function 57 | FANN_E_CANT_USE_ACTIVATION - Unable to use the selected activation function 58 | FANN_E_TRAIN_DATA_MISMATCH - Irreconcilable differences between two structures 59 | FANN_E_CANT_USE_TRAIN_ALG - Unable to use the selected training algorithm 60 | FANN_E_TRAIN_DATA_SUBSET - Trying to take subset which is not within the training set 61 | FANN_E_INDEX_OUT_OF_BOUND - Index is out of bound 62 | FANN_E_SCALE_NOT_PRESENT - Scaling parameters not present 63 | FANN_E_INPUT_NO_MATCH - The number of input neurons in the ann and data don't match 64 | FANN_E_OUTPUT_NO_MATCH - The number of output neurons in the ann and data don't match 65 | FANN_E_WRONG_PARAMETERS_FOR_CREATE - The parameters for create_standard are wrong, either too few parameters provided or a negative/very high value provided 66 | */ 67 | enum fann_errno_enum 68 | { 69 | FANN_E_NO_ERROR = 0, 70 | FANN_E_CANT_OPEN_CONFIG_R, 71 | FANN_E_CANT_OPEN_CONFIG_W, 72 | FANN_E_WRONG_CONFIG_VERSION, 73 | FANN_E_CANT_READ_CONFIG, 74 | FANN_E_CANT_READ_NEURON, 75 | FANN_E_CANT_READ_CONNECTIONS, 76 | FANN_E_WRONG_NUM_CONNECTIONS, 77 | FANN_E_CANT_OPEN_TD_W, 78 | FANN_E_CANT_OPEN_TD_R, 79 | FANN_E_CANT_READ_TD, 80 | FANN_E_CANT_ALLOCATE_MEM, 81 | FANN_E_CANT_TRAIN_ACTIVATION, 82 | FANN_E_CANT_USE_ACTIVATION, 83 | FANN_E_TRAIN_DATA_MISMATCH, 84 | FANN_E_CANT_USE_TRAIN_ALG, 85 | FANN_E_TRAIN_DATA_SUBSET, 86 | FANN_E_INDEX_OUT_OF_BOUND, 87 | FANN_E_SCALE_NOT_PRESENT, 88 | FANN_E_INPUT_NO_MATCH, 89 | FANN_E_OUTPUT_NO_MATCH, 90 | FANN_E_WRONG_PARAMETERS_FOR_CREATE 91 | }; 92 | 93 | /* Group: Error Handling */ 94 | 95 | /* Function: fann_set_error_log 96 | 97 | Change where errors are logged to. Both and can be 98 | casted to , so this function can be used to set either of these. 99 | 100 | If log_file is NULL, no errors will be printed. 101 | 102 | If errdat is NULL, the default log will be set. The default log is the log used when creating 103 | and . This default log will also be the default for all new structs 104 | that are created. 105 | 106 | The default behavior is to log them to stderr. 107 | 108 | See also: 109 | 110 | 111 | This function appears in FANN >= 1.1.0. 112 | */ 113 | FANN_EXTERNAL void FANN_API fann_set_error_log(struct fann_error *errdat, FILE * log_file); 114 | 115 | 116 | /* Function: fann_get_errno 117 | 118 | Returns the last error number. 119 | 120 | See also: 121 | , 122 | 123 | This function appears in FANN >= 1.1.0. 124 | */ 125 | FANN_EXTERNAL enum fann_errno_enum FANN_API fann_get_errno(struct fann_error *errdat); 126 | 127 | 128 | /* Function: fann_reset_errno 129 | 130 | Resets the last error number. 131 | 132 | This function appears in FANN >= 1.1.0. 133 | */ 134 | FANN_EXTERNAL void FANN_API fann_reset_errno(struct fann_error *errdat); 135 | 136 | 137 | /* Function: fann_reset_errstr 138 | 139 | Resets the last error string. 140 | 141 | This function appears in FANN >= 1.1.0. 142 | */ 143 | FANN_EXTERNAL void FANN_API fann_reset_errstr(struct fann_error *errdat); 144 | 145 | 146 | /* Function: fann_get_errstr 147 | 148 | Returns the last errstr. 149 | 150 | This function calls and 151 | 152 | This function appears in FANN >= 1.1.0. 153 | */ 154 | FANN_EXTERNAL char *FANN_API fann_get_errstr(struct fann_error *errdat); 155 | 156 | 157 | /* Function: fann_print_error 158 | 159 | Prints the last error to stderr. 160 | 161 | This function appears in FANN >= 1.1.0. 162 | */ 163 | FANN_EXTERNAL void FANN_API fann_print_error(struct fann_error *errdat); 164 | 165 | FANN_EXTERNAL extern FILE * fann_default_error_log; 166 | 167 | #endif 168 | -------------------------------------------------------------------------------- /fann/include/fann_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Fast Artificial Neural Network Library (fann) 3 | Copyright (C) 2003-2016 Steffen Nissen (steffen.fann@gmail.com) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __fann_internal_h__ 21 | #define __fann_internal_h__ 22 | /* internal include file, not to be included directly 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include "fann_data.h" 29 | 30 | #define FANN_FIX_VERSION "FANN_FIX_2.0" 31 | #define FANN_FLO_VERSION "FANN_FLO_2.1" 32 | 33 | #ifdef FIXEDFANN 34 | #define FANN_CONF_VERSION FANN_FIX_VERSION 35 | #else 36 | #define FANN_CONF_VERSION FANN_FLO_VERSION 37 | #endif 38 | 39 | #define FANN_GET(type, name) \ 40 | FANN_EXTERNAL type FANN_API fann_get_ ## name(struct fann *ann) \ 41 | { \ 42 | return ann->name; \ 43 | } 44 | 45 | #define FANN_SET(type, name) \ 46 | FANN_EXTERNAL void FANN_API fann_set_ ## name(struct fann *ann, type value) \ 47 | { \ 48 | ann->name = value; \ 49 | } 50 | 51 | #define FANN_GET_SET(type, name) \ 52 | FANN_GET(type, name) \ 53 | FANN_SET(type, name) 54 | 55 | 56 | struct fann_train_data; 57 | 58 | struct fann *fann_allocate_structure(unsigned int num_layers); 59 | void fann_allocate_neurons(struct fann *ann); 60 | 61 | void fann_allocate_connections(struct fann *ann); 62 | 63 | int fann_save_internal(struct fann *ann, const char *configuration_file, 64 | unsigned int save_as_fixed); 65 | int fann_save_internal_fd(struct fann *ann, FILE * conf, const char *configuration_file, 66 | unsigned int save_as_fixed); 67 | int fann_save_train_internal(struct fann_train_data *data, const char *filename, 68 | unsigned int save_as_fixed, unsigned int decimal_point); 69 | int fann_save_train_internal_fd(struct fann_train_data *data, FILE * file, const char *filename, 70 | unsigned int save_as_fixed, unsigned int decimal_point); 71 | 72 | void fann_update_stepwise(struct fann *ann); 73 | void fann_seed_rand(); 74 | 75 | void fann_error(struct fann_error *errdat, const enum fann_errno_enum errno_f, ...); 76 | void fann_init_error_data(struct fann_error *errdat); 77 | 78 | struct fann *fann_create_from_fd(FILE * conf, const char *configuration_file); 79 | struct fann_train_data *fann_read_train_from_fd(FILE * file, const char *filename); 80 | 81 | void fann_compute_MSE(struct fann *ann, fann_type * desired_output); 82 | void fann_update_output_weights(struct fann *ann); 83 | void fann_backpropagate_MSE(struct fann *ann); 84 | void fann_update_weights(struct fann *ann); 85 | void fann_update_slopes_batch(struct fann *ann, struct fann_layer *layer_begin, 86 | struct fann_layer *layer_end); 87 | void fann_update_weights_quickprop(struct fann *ann, unsigned int num_data, 88 | unsigned int first_weight, unsigned int past_end); 89 | void fann_update_weights_batch(struct fann *ann, unsigned int num_data, unsigned int first_weight, 90 | unsigned int past_end); 91 | void fann_update_weights_irpropm(struct fann *ann, unsigned int first_weight, 92 | unsigned int past_end); 93 | void fann_update_weights_sarprop(struct fann *ann, unsigned int epoch, unsigned int first_weight, 94 | unsigned int past_end); 95 | 96 | void fann_clear_train_arrays(struct fann *ann); 97 | 98 | fann_type fann_activation(struct fann * ann, unsigned int activation_function, fann_type steepness, 99 | fann_type value); 100 | 101 | fann_type fann_activation_derived(unsigned int activation_function, 102 | fann_type steepness, fann_type value, fann_type sum); 103 | 104 | int fann_desired_error_reached(struct fann *ann, float desired_error); 105 | 106 | /* Some functions for cascade */ 107 | int fann_train_outputs(struct fann *ann, struct fann_train_data *data, float desired_error); 108 | 109 | float fann_train_outputs_epoch(struct fann *ann, struct fann_train_data *data); 110 | 111 | int fann_train_candidates(struct fann *ann, struct fann_train_data *data); 112 | 113 | fann_type fann_train_candidates_epoch(struct fann *ann, struct fann_train_data *data); 114 | 115 | void fann_install_candidate(struct fann *ann); 116 | int fann_check_input_output_sizes(struct fann *ann, struct fann_train_data *data); 117 | 118 | int fann_initialize_candidates(struct fann *ann); 119 | 120 | void fann_set_shortcut_connections(struct fann *ann); 121 | 122 | int fann_allocate_scale(struct fann *ann); 123 | 124 | FANN_EXTERNAL void FANN_API fann_scale_data_to_range(fann_type ** data, unsigned int num_data, unsigned int num_elem, 125 | fann_type old_min, fann_type old_max, fann_type new_min, fann_type new_max); 126 | 127 | /* called fann_max, in order to not interferre with predefined versions of max */ 128 | #define fann_max(x, y) (((x) > (y)) ? (x) : (y)) 129 | #define fann_min(x, y) (((x) < (y)) ? (x) : (y)) 130 | #define fann_safe_free(x) {if(x) { free(x); x = NULL; }} 131 | #define fann_clip(x, lo, hi) (((x) < (lo)) ? (lo) : (((x) > (hi)) ? (hi) : (x))) 132 | #define fann_exp2(x) exp(0.69314718055994530942*(x)) 133 | /*#define fann_clip(x, lo, hi) (x)*/ 134 | 135 | #define fann_rand(min_value, max_value) (((float)(min_value))+(((float)(max_value)-((float)(min_value)))*rand()/(RAND_MAX+1.0f))) 136 | 137 | #define fann_abs(value) (((value) > 0) ? (value) : -(value)) 138 | 139 | #ifdef FIXEDFANN 140 | 141 | #define fann_mult(x,y) ((unsigned int)(x*y) >> (unsigned int)decimal_point) 142 | #define fann_div(x,y) (((unsigned int)(x) << (unsigned int)decimal_point)/y) 143 | #define fann_random_weight() (fann_type)(fann_rand(0,multiplier/10)) 144 | #define fann_random_bias_weight() (fann_type)(fann_rand((0-multiplier)/10,multiplier/10)) 145 | 146 | #else 147 | 148 | #define fann_mult(x,y) (x*y) 149 | #define fann_div(x,y) (x/y) 150 | #define fann_random_weight() (fann_rand(-0.1f,0.1f)) 151 | #define fann_random_bias_weight() (fann_rand(-0.1f,0.1f)) 152 | 153 | #endif 154 | 155 | #endif 156 | -------------------------------------------------------------------------------- /fann/include/fann_io.h: -------------------------------------------------------------------------------- 1 | /* 2 | Fast Artificial Neural Network Library (fann) 3 | Copyright (C) 2003-2016 Steffen Nissen (steffen.fann@gmail.com) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __fann_io_h__ 21 | #define __fann_io_h__ 22 | 23 | /* Section: FANN File Input/Output 24 | 25 | It is possible to save an entire ann to a file with for future loading with . 26 | */ 27 | 28 | /* Group: File Input and Output */ 29 | 30 | /* Function: fann_create_from_file 31 | 32 | Constructs a backpropagation neural network from a configuration file, which has been saved by . 33 | 34 | See also: 35 | , 36 | 37 | This function appears in FANN >= 1.0.0. 38 | */ 39 | FANN_EXTERNAL struct fann *FANN_API fann_create_from_file(const char *configuration_file); 40 | 41 | 42 | /* Function: fann_save 43 | 44 | Save the entire network to a configuration file. 45 | 46 | The configuration file contains all information about the neural network and enables 47 | to create an exact copy of the neural network and all of the 48 | parameters associated with the neural network. 49 | 50 | These three parameters (, , 51 | ) are *NOT* saved to the file because they cannot safely be 52 | ported to a different location. Also temporary parameters generated during training 53 | like are not saved. 54 | 55 | Return: 56 | The function returns 0 on success and -1 on failure. 57 | 58 | See also: 59 | , 60 | 61 | This function appears in FANN >= 1.0.0. 62 | */ 63 | FANN_EXTERNAL int FANN_API fann_save(struct fann *ann, const char *configuration_file); 64 | 65 | 66 | /* Function: fann_save_to_fixed 67 | 68 | Saves the entire network to a configuration file. 69 | But it is saved in fixed point format no matter which 70 | format it is currently in. 71 | 72 | This is useful for training a network in floating points, 73 | and then later executing it in fixed point. 74 | 75 | The function returns the bit position of the fix point, which 76 | can be used to find out how accurate the fixed point network will be. 77 | A high value indicates high precision, and a low value indicates low 78 | precision. 79 | 80 | A negative value indicates very low precision, and a very 81 | strong possibility for overflow. 82 | (the actual fix point will be set to 0, since a negative 83 | fix point does not make sense). 84 | 85 | Generally, a fix point lower than 6 is bad, and should be avoided. 86 | The best way to avoid this, is to have less connections to each neuron, 87 | or just less neurons in each layer. 88 | 89 | The fixed point use of this network is only intended for use on machines that 90 | have no floating point processor, like an iPAQ. On normal computers the floating 91 | point version is actually faster. 92 | 93 | See also: 94 | , 95 | 96 | This function appears in FANN >= 1.0.0. 97 | */ 98 | FANN_EXTERNAL int FANN_API fann_save_to_fixed(struct fann *ann, const char *configuration_file); 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /fann/include/fixedfann.h: -------------------------------------------------------------------------------- 1 | /* 2 | Fast Artificial Neural Network Library (fann) 3 | Copyright (C) 2003-2016 Steffen Nissen (steffen.fann@gmail.com) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __fixedfann_h__ 21 | #define __fixedfann_h__ 22 | 23 | typedef int fann_type; 24 | 25 | #undef FIXEDFANN 26 | #define FIXEDFANN 27 | #define FANNPRINTF "%d" 28 | #define FANNSCANF "%d" 29 | 30 | #define FANN_INCLUDE 31 | #include "fann.h" 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /fann/include/floatfann.h: -------------------------------------------------------------------------------- 1 | /* 2 | Fast Artificial Neural Network Library (fann) 3 | Copyright (C) 2003-2016 Steffen Nissen (steffen.fann@gmail.com) 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __floatfann_h__ 21 | #define __floatfann_h__ 22 | 23 | typedef float fann_type; 24 | 25 | #undef FLOATFANN 26 | #define FLOATFANN 27 | #define FANNPRINTF "%.20e" 28 | #define FANNSCANF "%f" 29 | 30 | #define FANN_INCLUDE 31 | #include "fann.h" 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /fann/include/parallel_fann.h: -------------------------------------------------------------------------------- 1 | /* 2 | * parallel_FANN.h 3 | * 4 | * Author: Alessandro Pietro Bardelli 5 | */ 6 | #ifndef DISABLE_PARALLEL_FANN 7 | #ifndef PARALLEL_FANN_H_ 8 | #define PARALLEL_FANN_H_ 9 | 10 | #include "fann.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" 14 | { 15 | 16 | #ifndef __cplusplus 17 | } /* to fool automatic indention engines */ 18 | #endif 19 | #endif /* __cplusplus */ 20 | 21 | #ifndef FIXEDFANN 22 | FANN_EXTERNAL float FANN_API fann_train_epoch_batch_parallel(struct fann *ann, struct fann_train_data *data, const unsigned int threadnumb); 23 | 24 | FANN_EXTERNAL float FANN_API fann_train_epoch_irpropm_parallel(struct fann *ann, struct fann_train_data *data, const unsigned int threadnumb); 25 | 26 | FANN_EXTERNAL float FANN_API fann_train_epoch_quickprop_parallel(struct fann *ann, struct fann_train_data *data, const unsigned int threadnumb); 27 | 28 | FANN_EXTERNAL float FANN_API fann_train_epoch_sarprop_parallel(struct fann *ann, struct fann_train_data *data, const unsigned int threadnumb); 29 | 30 | FANN_EXTERNAL float FANN_API fann_train_epoch_incremental_mod(struct fann *ann, struct fann_train_data *data); 31 | 32 | FANN_EXTERNAL float FANN_API fann_test_data_parallel(struct fann *ann, struct fann_train_data *data, const unsigned int threadnumb); 33 | #endif /* FIXEDFANN */ 34 | 35 | #ifdef __cplusplus 36 | #ifndef __cplusplus 37 | /* to fool automatic indention engines */ 38 | { 39 | 40 | #endif 41 | } 42 | #endif /* __cplusplus */ 43 | 44 | #endif /* PARALLEL_FANN_H_ */ 45 | #endif /* DISABLE_PARALLEL_FANN */ 46 | -------------------------------------------------------------------------------- /fann/include/parallel_fann.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * parallel_FANN.hpp 3 | * Author: Alessandro Pietro Bardelli 4 | */ 5 | #ifndef DISABLE_PARALLEL_FANN 6 | #ifndef PARALLEL_FANN_HPP_ 7 | #define PARALLEL_FANN_HPP_ 8 | #include 9 | #include 10 | #include "fann.h" 11 | 12 | #ifndef FIXEDFANN 13 | namespace parallel_fann { 14 | float train_epoch_batch_parallel(struct fann *ann, struct fann_train_data *data, const unsigned int threadnumb); 15 | 16 | float train_epoch_irpropm_parallel(struct fann *ann, struct fann_train_data *data, const unsigned int threadnumb); 17 | 18 | float train_epoch_quickprop_parallel(struct fann *ann, struct fann_train_data *data, const unsigned int threadnumb); 19 | 20 | float train_epoch_sarprop_parallel(struct fann *ann, struct fann_train_data *data, const unsigned int threadnumb); 21 | 22 | float train_epoch_incremental_mod(struct fann *ann, struct fann_train_data *data); 23 | 24 | float train_epoch_batch_parallel(struct fann *ann, struct fann_train_data *data, const unsigned int threadnumb,std::vector< std::vector >& predicted_outputs); 25 | 26 | float train_epoch_irpropm_parallel(struct fann *ann, struct fann_train_data *data, const unsigned int threadnumb, std::vector< std::vector >& predicted_outputs); 27 | 28 | float train_epoch_quickprop_parallel(struct fann *ann, struct fann_train_data *data, const unsigned int threadnumb, std::vector< std::vector >& predicted_outputs); 29 | 30 | float train_epoch_sarprop_parallel(struct fann *ann, struct fann_train_data *data, const unsigned int threadnumb, std::vector< std::vector >& predicted_outputs); 31 | 32 | float train_epoch_incremental_mod(struct fann *ann, struct fann_train_data *data, std::vector< std::vector >& predicted_outputs); 33 | 34 | float test_data_parallel(struct fann *ann, struct fann_train_data *data, const unsigned int threadnumb); 35 | float test_data_parallel(struct fann *ann, struct fann_train_data *data, const unsigned int threadnumb, std::vector< std::vector >& predicted_outputs); 36 | } 37 | #endif /* FIXEDFANN */ 38 | #endif /* PARALLEL_FANN_HPP_ */ 39 | #endif /* DISABLE_PARALLEL_FANN */ 40 | -------------------------------------------------------------------------------- /fann/lib/libfannfloat_cortexM4lf.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/fann/lib/libfannfloat_cortexM4lf.a -------------------------------------------------------------------------------- /servo/servo.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/servo/servo.c -------------------------------------------------------------------------------- /servo/servo.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Counterfeiter/Q-LearningRobot/707c9cd7d04364997a36479439ca966edae6762a/servo/servo.h --------------------------------------------------------------------------------