From 1282b9b77ef6b7182da9fc53f6d917da17f9008a Mon Sep 17 00:00:00 2001 From: FinleyHsu <152379270+FinleyHsu@users.noreply.github.com> Date: Tue, 28 Jul 2026 11:01:55 +0800 Subject: [PATCH] feat: add STM32 four-channel weighing firmware --- STM32_4路称重_Git提交精简工程/.gitignore | 22 + STM32_4路称重_Git提交精简工程/README.md | 26 + .../Release/V2.1_260709_4CH.hex | 5704 +++++++++++ .../gcc_build/Makefile | 76 + .../gcc_build/extract_sources.pl | 13 + .../gcc_build/gcc_compat.h | 12 + .../gcc_build/gcc_syscalls.c | 17 + .../gcc_build/startup_stm32f10x_hd_gcc.S | 201 + .../gcc_build/stm32f103rc.ld | 95 + .../src/CMSIS/Startup/startup_stm32f10x_cl.s | 368 + .../src/CMSIS/Startup/startup_stm32f10x_hd.s | 358 + .../CMSIS/Startup/startup_stm32f10x_hd_vl.s | 346 + .../src/CMSIS/Startup/startup_stm32f10x_ld.s | 297 + .../CMSIS/Startup/startup_stm32f10x_ld_vl.s | 304 + .../src/CMSIS/Startup/startup_stm32f10x_md.s | 307 + .../CMSIS/Startup/startup_stm32f10x_md_vl.s | 315 + .../src/CMSIS/Startup/startup_stm32f10x_xl.s | 358 + .../src/CMSIS/core_cm3.c | 784 ++ .../src/CMSIS/core_cm3.h | 1818 ++++ .../src/CMSIS/stm32f10x.h | 8336 +++++++++++++++++ .../src/CMSIS/system_stm32f10x.c | 1094 +++ .../src/CMSIS/system_stm32f10x.h | 98 + .../src/HARDWARE/AUDIO/bsp_WM8978.h | 79 + .../src/HARDWARE/AUDIO/bsp_i2c_gpio.c | 232 + .../src/HARDWARE/AUDIO/bsp_i2c_gpio.h | 44 + .../src/HARDWARE/AUDIO/bsp_wm8978.c | 1103 +++ .../src/HARDWARE/AUDIO/sound.c | 198 + .../src/HARDWARE/AUDIO/sound.h | 28 + .../src/HARDWARE/AUDIO/soundfilelists.h | 15 + .../src/HARDWARE/BUZZER/buzzer.c | 669 ++ .../src/HARDWARE/BUZZER/buzzer.h | 26 + .../src/HARDWARE/DEVICE/device.c | 1387 +++ .../src/HARDWARE/DEVICE/device.h | 72 + .../src/HARDWARE/DEVICE/deviceSet.c | 1694 ++++ .../src/HARDWARE/DEVICE/deviceSet.h | 36 + .../src/HARDWARE/DEVICE/distancer.c | 387 + .../src/HARDWARE/DEVICE/distancer.h | 47 + .../src/HARDWARE/DEVICE/m_s_comm.c | 492 + .../src/HARDWARE/DEVICE/m_s_comm.h | 16 + .../src/HARDWARE/Disinfection/disinfection.c | 308 + .../src/HARDWARE/Disinfection/disinfection.h | 28 + .../src/HARDWARE/EXTI/exti.c | 55 + .../src/HARDWARE/EXTI/exti.h | 21 + .../HARDWARE/ElectronicLock/ElectronicLock.c | 270 + .../HARDWARE/ElectronicLock/ElectronicLock.h | 29 + .../src/HARDWARE/FLASH/flash.c | 257 + .../src/HARDWARE/FLASH/flash.h | 81 + .../src/HARDWARE/GPS/gps.c | 265 + .../src/HARDWARE/GPS/gps.h | 54 + .../src/HARDWARE/GSM/at_proc.c | 544 ++ .../src/HARDWARE/GSM/at_proc.h | 126 + .../src/HARDWARE/GSM/ec200x.c | 1569 ++++ .../src/HARDWARE/GSM/ec200x.h | 37 + .../src/HARDWARE/GSM/gsm_gprs.c | 1356 +++ .../src/HARDWARE/GSM/gsm_gprs.h | 33 + .../src/HARDWARE/GSM/gsm_uart.c | 170 + .../src/HARDWARE/GSM/gsm_uart.h | 20 + .../src/HARDWARE/GSM/gsm_uart_conf.c | 23 + .../src/HARDWARE/GSM/gsm_uart_conf.h | 58 + .../src/HARDWARE/GSM/netwer_appcall.c | 341 + .../src/HARDWARE/GSM/netwer_appcall.h | 26 + .../src/HARDWARE/IR_Distancer/IR_Distancer.c | 421 + .../src/HARDWARE/IR_Distancer/IR_Distancer.h | 25 + .../src/HARDWARE/KEY/key.c | 648 ++ .../src/HARDWARE/KEY/key.h | 62 + .../src/HARDWARE/KEY/sw_key.c | 117 + .../src/HARDWARE/KEY/sw_key.h | 26 + .../src/HARDWARE/LCD/BMP.h | 216 + .../src/HARDWARE/LCD/SDWe_LCD.c | 302 + .../src/HARDWARE/LCD/SDWe_LCD.h | 20 + .../src/HARDWARE/LCD/display.c | 1082 +++ .../src/HARDWARE/LCD/display.h | 33 + .../src/HARDWARE/LCD/icon.h | 192 + .../src/HARDWARE/LCD/lcd.c | 136 + .../src/HARDWARE/LCD/lcd.h | 25 + .../src/HARDWARE/LCD/lcd12864.c | 523 ++ .../src/HARDWARE/LCD/lcd12864.h | 43 + .../src/HARDWARE/LED/led.c | 137 + .../src/HARDWARE/LED/led.h | 24 + .../src/HARDWARE/MOTOR/door_ctrl.c | 1469 +++ .../src/HARDWARE/MOTOR/door_ctrl.h | 26 + .../src/HARDWARE/MOTOR/motor.c | 474 + .../src/HARDWARE/MOTOR/motor.h | 39 + .../src/HARDWARE/NTC_ADC/adc.c | 113 + .../src/HARDWARE/NTC_ADC/adc.h | 17 + .../src/HARDWARE/NTC_ADC/ntc.c | 149 + .../src/HARDWARE/NTC_ADC/ntc.h | 26 + .../src/HARDWARE/NTC_ADC/ntc_10K_tab.h | 31 + .../src/HARDWARE/OPTO_SWITCH/opto_sw_key.c | 367 + .../src/HARDWARE/OPTO_SWITCH/opto_sw_key.h | 30 + .../src/HARDWARE/QR_Code/qr_code.c | 202 + .../src/HARDWARE/QR_Code/qr_code.h | 29 + .../src/HARDWARE/RFID/RFID_IC.c | 331 + .../src/HARDWARE/RFID/RFID_IC.h | 47 + .../src/HARDWARE/RFID/rfid_decode_yhk.c | 127 + .../src/HARDWARE/RFID/rfid_decode_yhk.h | 16 + .../src/HARDWARE/RFID/rfid_decode_yn.c | 259 + .../src/HARDWARE/RFID/rfid_decode_yn.h | 19 + .../src/HARDWARE/RFID/rfid_decode_zl.c | 72 + .../src/HARDWARE/RFID/rfid_decode_zl.h | 18 + .../src/HARDWARE/RS485/RS485.c | 672 ++ .../src/HARDWARE/RS485/RS485.h | 44 + .../src/HARDWARE/SCALE/scale.c | 177 + .../src/HARDWARE/SCALE/scale.h | 53 + .../src/HARDWARE/SPI/spi.c | 87 + .../src/HARDWARE/SPI/spi.h | 10 + .../src/HARDWARE/STMFLASH/stmflash.c | 459 + .../src/HARDWARE/STMFLASH/stmflash.h | 32 + .../src/HARDWARE/TIMER/timer.c | 353 + .../src/HARDWARE/TIMER/timer.h | 35 + .../src/HARDWARE/USART/RS485.c | 453 + .../src/HARDWARE/USART/UsarInterface.c | 17 + .../src/HARDWARE/USART/UsarInterface.h | 19 + .../src/HARDWARE/USART/crc16.c | 77 + .../src/HARDWARE/USART/crc16.h | 9 + .../src/HARDWARE/USART/printf.c | 65 + .../src/HARDWARE/USART/rs485.h | 37 + .../src/HARDWARE/USART/usart1.c | 125 + .../src/HARDWARE/USART/usart1.h | 25 + .../src/HARDWARE/USART/usart2.c | 220 + .../src/HARDWARE/USART/usart2.h | 26 + .../src/HARDWARE/USART/usart3.c | 156 + .../src/HARDWARE/USART/usart3.h | 19 + .../src/HARDWARE/USART/usart4.c | 227 + .../src/HARDWARE/USART/usart4.h | 26 + .../src/HARDWARE/USART/usart5.c | 141 + .../src/HARDWARE/USART/usart5.h | 27 + .../HARDWARE/UltrasonicWave/UltrasonicWave.c | 518 + .../HARDWARE/UltrasonicWave/UltrasonicWave.h | 28 + .../src/HARDWARE/WDG/wdg.c | 75 + .../src/HARDWARE/WDG/wdg.h | 18 + .../src/Project/Project.uvprojx | 751 ++ .../src/Project/stm32f10x_conf.h | 77 + .../src/STM32F10x_FWLib/inc/misc.h | 220 + .../src/STM32F10x_FWLib/inc/stm32f10x_adc.h | 483 + .../src/STM32F10x_FWLib/inc/stm32f10x_bkp.h | 195 + .../src/STM32F10x_FWLib/inc/stm32f10x_can.h | 697 ++ .../src/STM32F10x_FWLib/inc/stm32f10x_cec.h | 210 + .../src/STM32F10x_FWLib/inc/stm32f10x_crc.h | 94 + .../src/STM32F10x_FWLib/inc/stm32f10x_dac.h | 317 + .../STM32F10x_FWLib/inc/stm32f10x_dbgmcu.h | 119 + .../src/STM32F10x_FWLib/inc/stm32f10x_dma.h | 439 + .../src/STM32F10x_FWLib/inc/stm32f10x_exti.h | 184 + .../src/STM32F10x_FWLib/inc/stm32f10x_flash.h | 426 + .../src/STM32F10x_FWLib/inc/stm32f10x_fsmc.h | 733 ++ .../src/STM32F10x_FWLib/inc/stm32f10x_gpio.h | 385 + .../src/STM32F10x_FWLib/inc/stm32f10x_i2c.h | 684 ++ .../src/STM32F10x_FWLib/inc/stm32f10x_iwdg.h | 140 + .../src/STM32F10x_FWLib/inc/stm32f10x_pwr.h | 156 + .../src/STM32F10x_FWLib/inc/stm32f10x_rcc.h | 727 ++ .../src/STM32F10x_FWLib/inc/stm32f10x_rtc.h | 135 + .../src/STM32F10x_FWLib/inc/stm32f10x_sdio.h | 531 ++ .../src/STM32F10x_FWLib/inc/stm32f10x_spi.h | 487 + .../src/STM32F10x_FWLib/inc/stm32f10x_tim.h | 1164 +++ .../src/STM32F10x_FWLib/inc/stm32f10x_usart.h | 412 + .../src/STM32F10x_FWLib/inc/stm32f10x_wwdg.h | 115 + .../src/STM32F10x_FWLib/src/misc.c | 225 + .../src/STM32F10x_FWLib/src/stm32f10x_adc.c | 1307 +++ .../src/STM32F10x_FWLib/src/stm32f10x_bkp.c | 308 + .../src/STM32F10x_FWLib/src/stm32f10x_can.c | 1415 +++ .../src/STM32F10x_FWLib/src/stm32f10x_cec.c | 433 + .../src/STM32F10x_FWLib/src/stm32f10x_crc.c | 160 + .../src/STM32F10x_FWLib/src/stm32f10x_dac.c | 571 ++ .../STM32F10x_FWLib/src/stm32f10x_dbgmcu.c | 162 + .../src/STM32F10x_FWLib/src/stm32f10x_dma.c | 714 ++ .../src/STM32F10x_FWLib/src/stm32f10x_exti.c | 269 + .../src/STM32F10x_FWLib/src/stm32f10x_flash.c | 1684 ++++ .../src/STM32F10x_FWLib/src/stm32f10x_fsmc.c | 866 ++ .../src/STM32F10x_FWLib/src/stm32f10x_gpio.c | 650 ++ .../src/STM32F10x_FWLib/src/stm32f10x_i2c.c | 1331 +++ .../src/STM32F10x_FWLib/src/stm32f10x_iwdg.c | 190 + .../src/STM32F10x_FWLib/src/stm32f10x_pwr.c | 307 + .../src/STM32F10x_FWLib/src/stm32f10x_rcc.c | 1470 +++ .../src/STM32F10x_FWLib/src/stm32f10x_rtc.c | 339 + .../src/STM32F10x_FWLib/src/stm32f10x_sdio.c | 799 ++ .../src/STM32F10x_FWLib/src/stm32f10x_spi.c | 908 ++ .../src/STM32F10x_FWLib/src/stm32f10x_tim.c | 2890 ++++++ .../src/STM32F10x_FWLib/src/stm32f10x_usart.c | 1058 +++ .../src/STM32F10x_FWLib/src/stm32f10x_wwdg.c | 224 + .../src/SYSTEM/debug/debug_conf.c | 36 + .../src/SYSTEM/debug/debug_conf.h | 16 + .../src/SYSTEM/delay/delay.c | 54 + .../src/SYSTEM/delay/delay.h | 10 + .../src/USER/data_typedef.c | 371 + .../src/USER/data_typedef.h | 412 + .../src/USER/date_time.c | 102 + .../src/USER/date_time.h | 42 + STM32_4路称重_Git提交精简工程/src/USER/main.c | 259 + .../src/USER/message.c | 85 + .../src/USER/message.h | 60 + .../src/USER/my_math.c | 241 + .../src/USER/my_math.h | 26 + .../src/USER/over_flow.c | 739 ++ .../src/USER/over_flow.h | 22 + .../src/USER/pc_protocol.c | 909 ++ .../src/USER/pc_protocol.h | 16 + .../src/USER/stm32f10x_conf.h | 77 + .../src/USER/stm32f10x_it.c | 87 + .../src/USER/stm32f10x_it.h | 46 + .../src/USER/tcp_protocol.c | 1381 +++ .../src/USER/tcp_protocol.h | 26 + .../src/USER/user_app.c | 1661 ++++ .../src/USER/user_app.h | 31 + .../src/USER/user_manag.c | 207 + .../src/USER/user_manag.h | 31 + 205 files changed, 80376 insertions(+) create mode 100644 STM32_4路称重_Git提交精简工程/.gitignore create mode 100644 STM32_4路称重_Git提交精简工程/README.md create mode 100644 STM32_4路称重_Git提交精简工程/Release/V2.1_260709_4CH.hex create mode 100644 STM32_4路称重_Git提交精简工程/gcc_build/Makefile create mode 100644 STM32_4路称重_Git提交精简工程/gcc_build/extract_sources.pl create mode 100644 STM32_4路称重_Git提交精简工程/gcc_build/gcc_compat.h create mode 100644 STM32_4路称重_Git提交精简工程/gcc_build/gcc_syscalls.c create mode 100644 STM32_4路称重_Git提交精简工程/gcc_build/startup_stm32f10x_hd_gcc.S create mode 100644 STM32_4路称重_Git提交精简工程/gcc_build/stm32f103rc.ld create mode 100755 STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_cl.s create mode 100755 STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_hd.s create mode 100755 STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_hd_vl.s create mode 100755 STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_ld.s create mode 100755 STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_ld_vl.s create mode 100755 STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_md.s create mode 100755 STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_md_vl.s create mode 100755 STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_xl.s create mode 100755 STM32_4路称重_Git提交精简工程/src/CMSIS/core_cm3.c create mode 100755 STM32_4路称重_Git提交精简工程/src/CMSIS/core_cm3.h create mode 100755 STM32_4路称重_Git提交精简工程/src/CMSIS/stm32f10x.h create mode 100755 STM32_4路称重_Git提交精简工程/src/CMSIS/system_stm32f10x.c create mode 100755 STM32_4路称重_Git提交精简工程/src/CMSIS/system_stm32f10x.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_WM8978.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_i2c_gpio.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_i2c_gpio.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_wm8978.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/sound.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/sound.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/soundfilelists.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/BUZZER/buzzer.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/BUZZER/buzzer.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/device.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/device.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/deviceSet.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/deviceSet.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/distancer.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/distancer.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/m_s_comm.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/m_s_comm.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/Disinfection/disinfection.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/Disinfection/disinfection.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/EXTI/exti.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/EXTI/exti.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/ElectronicLock/ElectronicLock.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/ElectronicLock/ElectronicLock.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/FLASH/flash.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/FLASH/flash.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/GPS/gps.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/GPS/gps.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/at_proc.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/at_proc.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/ec200x.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/ec200x.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_gprs.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_gprs.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart_conf.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart_conf.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/netwer_appcall.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/netwer_appcall.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/IR_Distancer/IR_Distancer.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/IR_Distancer/IR_Distancer.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/key.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/key.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/sw_key.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/sw_key.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/BMP.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/SDWe_LCD.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/SDWe_LCD.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/display.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/display.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/icon.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd12864.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd12864.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/LED/led.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/LED/led.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/door_ctrl.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/door_ctrl.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/motor.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/motor.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/NTC_ADC/adc.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/NTC_ADC/adc.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/NTC_ADC/ntc.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/NTC_ADC/ntc.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/NTC_ADC/ntc_10K_tab.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/OPTO_SWITCH/opto_sw_key.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/OPTO_SWITCH/opto_sw_key.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/QR_Code/qr_code.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/QR_Code/qr_code.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/RFID_IC.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/RFID_IC.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yhk.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yhk.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yn.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yn.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_zl.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_zl.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/RS485/RS485.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/RS485/RS485.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/SCALE/scale.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/SCALE/scale.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/SPI/spi.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/SPI/spi.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/STMFLASH/stmflash.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/STMFLASH/stmflash.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/TIMER/timer.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/TIMER/timer.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/RS485.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/UsarInterface.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/UsarInterface.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/crc16.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/crc16.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/printf.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/rs485.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart1.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart1.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart2.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart2.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart3.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart3.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart4.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart4.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart5.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart5.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/UltrasonicWave/UltrasonicWave.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/UltrasonicWave/UltrasonicWave.h create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/WDG/wdg.c create mode 100755 STM32_4路称重_Git提交精简工程/src/HARDWARE/WDG/wdg.h create mode 100755 STM32_4路称重_Git提交精简工程/src/Project/Project.uvprojx create mode 100755 STM32_4路称重_Git提交精简工程/src/Project/stm32f10x_conf.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/misc.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_adc.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_bkp.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_can.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_cec.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_crc.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_dac.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_dbgmcu.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_dma.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_exti.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_flash.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_fsmc.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_gpio.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_i2c.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_iwdg.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_pwr.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_rcc.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_rtc.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_sdio.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_spi.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_tim.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_usart.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_wwdg.h create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/misc.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_adc.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_bkp.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_can.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_cec.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_crc.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_dac.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_dbgmcu.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_dma.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_exti.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_flash.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_fsmc.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_gpio.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_i2c.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_iwdg.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_pwr.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_rcc.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_rtc.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_sdio.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_spi.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_tim.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_usart.c create mode 100755 STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_wwdg.c create mode 100755 STM32_4路称重_Git提交精简工程/src/SYSTEM/debug/debug_conf.c create mode 100755 STM32_4路称重_Git提交精简工程/src/SYSTEM/debug/debug_conf.h create mode 100755 STM32_4路称重_Git提交精简工程/src/SYSTEM/delay/delay.c create mode 100755 STM32_4路称重_Git提交精简工程/src/SYSTEM/delay/delay.h create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/data_typedef.c create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/data_typedef.h create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/date_time.c create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/date_time.h create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/main.c create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/message.c create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/message.h create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/my_math.c create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/my_math.h create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/over_flow.c create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/over_flow.h create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/pc_protocol.c create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/pc_protocol.h create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/stm32f10x_conf.h create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/stm32f10x_it.c create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/stm32f10x_it.h create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/tcp_protocol.c create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/tcp_protocol.h create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/user_app.c create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/user_app.h create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/user_manag.c create mode 100755 STM32_4路称重_Git提交精简工程/src/USER/user_manag.h diff --git a/STM32_4路称重_Git提交精简工程/.gitignore b/STM32_4路称重_Git提交精简工程/.gitignore new file mode 100644 index 0000000..d65edea --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/.gitignore @@ -0,0 +1,22 @@ +# Keil build outputs and user-local settings +Output/ +Listing/ +Objects/ +*.o +*.d +*.crf +*.axf +*.elf +*.map +*.lst +*.dep +*.uvgui* +*.uvopt* +JLinkLog.txt + +# GCC build outputs +gcc_build/build/ + +# macOS metadata +.DS_Store +._* diff --git a/STM32_4路称重_Git提交精简工程/README.md b/STM32_4路称重_Git提交精简工程/README.md new file mode 100644 index 0000000..b6e8dd9 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/README.md @@ -0,0 +1,26 @@ +# STM32 四投口四路称重固件 + +这是用于 Git 提交的精简工程包,保留了重新编译所需的源码、头文件、Keil 工程、STM32 标准外设库、CMSIS 和 GCC 构建配置。 + +## 目录 + +- `src/Project/Project.uvprojx`:Keil MDK 工程入口 +- `src/USER/`:主程序与业务逻辑 +- `src/HARDWARE/`:硬件驱动 +- `src/CMSIS/`:CMSIS 与启动文件 +- `src/STM32F10x_FWLib/`:STM32F10x 标准外设库 +- `src/SYSTEM/`:系统基础模块 +- `gcc_build/`:ARM GCC 构建脚本与链接脚本 +- `Release/V2.1_260709_4CH.hex`:可烧录固件 + +## 构建 + +Keil MDK:打开 `src/Project/Project.uvprojx`。 + +ARM GCC: + +```sh +make -C gcc_build +``` + +版本标识:`V2.1_260709_4CH`。 diff --git a/STM32_4路称重_Git提交精简工程/Release/V2.1_260709_4CH.hex b/STM32_4路称重_Git提交精简工程/Release/V2.1_260709_4CH.hex new file mode 100644 index 0000000..f512da6 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/Release/V2.1_260709_4CH.hex @@ -0,0 +1,5704 @@ +:020000040800F2 +:1000000000C0002065BB00081104000813040008AC +:100010001504000817040008190400080000000077 +:100020000000000000000000000000001B040008A9 +:100030001D040008000000001F040008210400083F +:10004000B1BB0008B1BB0008B1BB0008B1BB0008E0 +:10005000B1BB0008B1BB0008B1BB0008B1BB0008D0 +:10006000B1BB0008B1BB0008B1BB0008B1BB0008C0 +:10007000B1BB0008B1BB0008B1BB0008B1BB0008B0 +:10008000B1BB0008B1BB0008B1BB0008B1BB0008A0 +:10009000B1BB0008B1BB0008B1BB0008B1BB000890 +:1000A000B1BB0008B1BB0008B1BB0008B1BB000880 +:1000B000B9290008352A0008D52A0008B1BB000874 +:1000C000B1BB0008B1BB0008B1BB0008B1BB000860 +:1000D000B1BB00080D2C0008492E00085D2F000858 +:1000E000B1BB0008B1BB0008B1BB0008B1BB000840 +:1000F000B1BB0008B1BB0008B1BB0008B1BB000830 +:10010000B1BB0008B1BB0008492B0008B1BB000817 +:100110006131000811320008B1BB0008B1BB000812 +:10012000B1BB0008B1BB0008B1BB0008B1BB0008FF +:100130000348044B834202D0034B03B11847704776 +:10014000B80D0020B80D0020000000000548064B47 +:100150001B1AD90F01EBA301491002D0034B03B1C5 +:1001600018477047B80D0020B80D002000000000AF +:1001700010B5064C237843B9FFF7DAFF044B13B1EF +:100180000448AFF300800123237010BDB80D002098 +:10019000000000003001000808B5054B1BB10549FF +:1001A0000548AFF30080BDE80840FFF7CFBF00BFB0 +:1001B00000000000BC0D00203001000810B52C4BE1 +:1001C0001A7882B901224FF496712A481A7002F007 +:1001D000A3FB4FF49661284802F09EFB4FF4167182 +:1001E000264802F099FB264C2278012A06D1254B9D +:1001F000197819B931201A7000F0C0FF224B1A7813 +:1002000072B9224A1278012A0AD1214A1278012AA7 +:1002100006D120481A700CF0C3FA672000F0AEFF38 +:10022000154802F087FB40B1134802F07DFB2378AC +:10023000012B02D1312000F0A1FF0E4802F07AFB21 +:1002400040B10C4802F070FB134B1B7813B96220CD +:1002500000F094FF094802F06DFB38B1074802F046 +:1002600063FBBDE81040672000F088BF10BD00BFF1 +:10027000F00D0020E80D0020E00D0020D80D00203A +:1002800058380020D50D0020D40D0020DE0E0020AF +:10029000DD0E00207C200108890E00204FF4A060B4 +:1002A0000BF05EB808B54FF49661504802F034FB8D +:1002B0000BF004F8FFF7F2FF4FF4165002F060FC69 +:1002C0004FF4164002F0F0FC4FF4165002F06AFEB4 +:1002D0004FF4E13002F05AFF41F61F414FF47A70BB +:1002E00002F040FB41F61F41642002F079FB41F629 +:1002F0001F4141F2883002F0C3FB41F61F416420E8 +:1003000002F0F8FB3A480CF04BFA07F01DFD07F03D +:1003100061FD38480CF044FA05F08AFB01200AF030 +:1003200061FB40F27121052002F0C8FA902000F034 +:1003300025FF314D314C02F0B3FF03F009FA04F010 +:1003400017FD07F001FE01F055F801F00FFC07F072 +:100350003BFE07F055FF07F063FC05F02FFC06F0AD +:100360002DF900F013FF0AF053FE0AF045FB01F0EF +:10037000C7F908F02DFC02F059F82B782BB90AF0D8 +:1003800033F901F047FB01F075FB00F04FF9FFF77F +:1003900015FF0AF0FDF802F0CBF802F059F908F069 +:1003A0006FFC08F0AFFC08F0E9FC02F09BFA0F4884 +:1003B00002F0C0FA10B10D4802F0B6FA2378012B12 +:1003C00006D1002323700E4B0E4819880CF0E8F973 +:1003D0000D4B1A78012A04BF00221A700B4B1A78B1 +:1003E000012AA8D100221A70A5E700BFF40D002051 +:1003F00092200108C3200108890E0020010F00206F +:10040000020F0020DC200108000E0020CD0E00208D +:100410007047FEE7FEE7FEE7FEE77047704770476C +:1004200070470000374B82B01A6842F001021A6030 +:100430005968354A0A405A601A6822F0847222F4D8 +:1004400080321A601A6822F480221A605A6822F4F4 +:10045000FE025A604FF41F029A600022009201923D +:100460001A6842F480321A601A6802F4003201926B +:10047000009A01320092019A1AB9009AB2F5A06F5F +:10048000F2D11A6812F4003218BF01220192019AC7 +:10049000012A30D11D4A116841F010011160116824 +:1004A00021F003011160116841F0020111605A68E6 +:1004B0005A605A685A605A6842F480625A605A68B0 +:1004C00022F47C125A605A6842F4E8125A601A68A0 +:1004D00042F080721A601A689201FCD55A6822F0C4 +:1004E00003025A605A6842F002025A605A6802F0E7 +:1004F0000C02082AFAD14FF00062054B9A6002B054 +:10050000704700BF001002400000FFF800200240CA +:1005100000ED00E07FB501AC84E80E00F42250430A +:100520000D4C21184A78132A14D8561C4E701421E9 +:10053000255C2A44B2FBF1F501FB15220C2101FBDD +:1005400002000444043401AA07CA84E80B00012015 +:1005500004B070BD0020FBE778190020F423F0B54B +:1005600003FB00F20A4CA518697879B10C26A35C4C +:10057000101D06FB030014260133B3FBF6F706FB40 +:10058000173301392044A3546970F0BD0846FCE7D5 +:10059000781900200B460122002110B50BB9104636 +:1005A00010BD00FB01F4A2FB0021013BDBB22144A2 +:1005B000F4E7000000B5174B8DB01A8803A8A2F22B +:1005C0006C7208929A78013A0792DA7806921A7950 +:1005D00005925A799B79049203930CF065FB0E4BBC +:1005E000C3E9000110F5E14041F10001CDE900014E +:1005F00068460CF07BF9094A034610601421084A4A +:1006000008480DF083FA074907480CF0C9F80DB007 +:1006100000BD00BF541C0020F80E00205C1C002010 +:10062000EC200108681C0020FE20010813B5194BBE +:100630001A782AB901220A2117481A7002F06CF9B7 +:10064000154802F077F910B3134802F06DF9134B17 +:100650001B7813B912480CF0A3F81249D1E9003203 +:100660005C1C42F10000C1E9004047F281015B18C7 +:1006700042F100026846CDE900320CF037F90A4A2F +:10068000034610601421094A09480DF03FFA02B0F0 +:1006900010BD00BFF40E0020EC0E0020000F002063 +:1006A0000F210108F80E00205C1C0020EC2001083E +:1006B000681C002041F23113984264D02FD840F6D4 +:1006C000A173984256D014D840F2D173984208D002 +:1006D0000CD840F2E933984248D040F2EB339842CC +:1006E00014D1814214BF00200120704740F2D3731F +:1006F000F5E741F26903984242D009D840F6AB735E +:1007000098423AD041F20F0398423FD00020704700 +:1007100041F2CD039842F9D141F2CE0328E041F2F3 +:100720008A339842DDD012D841F225339842D8D08E +:100730000AD841F25D2398422ED041F2C12398425B +:10074000E4D141F2C22313E041F28933C7E741F219 +:100750007B7398421DD041F285739842C1D041F21B +:1007600074739842D2D14EF6892301E042F21B7392 +:100770009942B7E740F6A273FAE740F6B673F7E797 +:1007800041F26A03F4E741F23213F1E741F27E03EA +:10079000EEE74EF66B23EBE741F25E23E8E700005D +:1007A00030B503780246482B89B03AD14378452BBF +:1007B00037D18378522B34D1C3784F2B31D10125D7 +:1007C000814BC48981481D7063BA038099B2804B04 +:1007D0001888FFF76FFF08B17E4B1D7041F6273375 +:1007E0009C427BD042F21B7399422FD84CF6106387 +:1007F0009C4200F0A18041F2CE03994219D84AF2FE +:100800000F239C4271D040F6A173994209D94BF253 +:100810000F639C4200F0908046F610239C4200F04B +:100820008B804FF4806200216B480BF0CBFF09B046 +:1008300030BD43F211239C427ED045F612639C42A8 +:10084000EFD1664B127C1A70654B4BE046F6EA33EB +:100850009C4200F0B38048F6EA139C42E1D1137C3D +:1008600060490B70591E0329DBD8507C5E49012B6F +:100870000870907C5D490870D07C5D490870107DDF +:100880005C49087028D0507D5B49022B0870907D30 +:100890005A490870D07D5A490870107E594908702D +:1008A0001AD0507E5849042B0870907E5749087022 +:1008B000D07E57490870107F564908700CD1517F7F +:1008C000554B1970917F554B1970D17F544B92F84D +:1008D00020201970534B1A70534B03E0534B127C7A +:1008E0001A70534B01221A709BE7117C514B02F195 +:1008F0001A041970D2F811304F491BBA0B60D2F8A4 +:100900001530527E4D494E4D1BBA402A0B602A705D +:1009100003D94C480BF044FF402221464A480DF0D1 +:100920000BFC2B784949E218E35812791BBA0B608B +:10093000474B1A70474BD5E7117C3E4B02F11A0426 +:100940001970D2F811303C491BBA0B60D2F815303F +:10095000527E3A493A4D1BBA402A0B602A7003D99D +:1009600038480BF01DFF4022214637480DF0E4FBCC +:100970002A783649A318A2589D1D12BA0A6019791F +:10098000334A354C5B791170684620220021237070 +:100990000BF018FF2278202A03D92A480BF000FF19 +:1009A0002022294668460DF0C7FB6A462B492C4891 +:1009B0000BF06AFD237806332370BBE71369294ADD +:1009C0001BBA1360284B8DE7010F0020020F002097 +:1009D000040F0020A9100020502800208A0E0020BB +:1009E0008B0E0020300E00202F0E00201D0E002048 +:1009F0001C0E00201B0E00202E0E00201A0E0020C0 +:100A0000190E0020180E00202D0E0020170E0020B9 +:100A1000160E0020150E00202C0E0020140E0020B3 +:100A2000130E0020120E0020990E0020010E00204F +:100A3000980E002045190020281600204819002093 +:100A400078160020232101088B160020940E002028 +:100A50008A1600209C0E00208C0E002035210108F3 +:100A6000EC170020900E00209A0E00206821F0B5AF +:100A7000184BC1B000938DF8051003784178847845 +:100A80008DF804300B448DF80610303B10F8031F2E +:100A900023448DF807408DF808100B446A4641EA5C +:100AA0000421092401F10A06B6B225460134A4B294 +:100AB000B44209D1535516230B31104689B2135550 +:100AC00002F0C0FA41B0F0BD10F8017F57553B4429 +:100AD000EBE700BFFEFEFE68F7B500230546A14C1C +:100AE00001466070A0482370A370E3700BF058FEBD +:100AF000312D4DD81F2D08D8013DEBB2082B2FD931 +:100B00009A480BF04DFE04256FE0203D112DF7D8DB +:100B100001A353F825F000BF750C0008FD0C000878 +:100B2000C10D0008470E0008010B0008010B00086A +:100B3000010B0008010B0008010B0008010B000865 +:100B4000010B0008010B0008010B0008010B000855 +:100B5000010B0008010B0008530E00086F0E00087F +:100B6000082DCDD801A353F825F000BFCF0B000806 +:100B7000010C00085D0C0008650C0008010B000862 +:100B8000010B0008010B0008070B0008070B000809 +:100B9000672D10D85F2DB3D90120613D2071062D3E +:100BA00000F26F81DFE815F07201FB014D02550282 +:100BB00058029802BA02902DA2D101236C482371E9 +:100BC0000DF0C8FA6A4982B2451D601D4BE1012350 +:100BD000684D2371684B2A781B78684968486371AF +:100BE000A2710DF0A9FA2D78073529462B1F5D4813 +:100BF0001A0AA270E37003B0BDE8F040FFF736BFF9 +:100C00000122604B22711B78FF2B15D1A2715E4A25 +:100C1000042312786371E271022222725B4A237309 +:100C200012785B4B62720322A2725A4A1278E27205 +:100C30001B780E256373D8E7A371013B6271032B08 +:100C400014D8DFE803F0020507094F4B1B780EE0CC +:100C50004E4BFBE74F4BF9E74D4BF7E70123237171 +:100C60000525C2E7012323716371A37100230825C1 +:100C7000E371BAE70123484A23711278042A09D89C +:100C8000002AEDD0023A6371022A23D8DFE802F08D +:100C90002A2E3200FF2AE3D1A371404B04221B8885 +:100CA0006271190A2372022363723D4BE1711B8842 +:100CB000E273190AE372032323733A4BA1721B8870 +:100CC0001225190AA373384B61731B881A0A227400 +:100CD00063748AE7A371314B1B8809251A0AE271F4 +:100CE000237282E70223A3712D4BF5E70323A3713F +:100CF0002C4BF1E70423A3712B4BEDE701232B4A87 +:100D000023711278042A09D8002AA9D0023A637103 +:100D1000022A18D8DFE802F01A1E2200FF2A9FD10B +:100D2000A371234B04221B786271E37102232372A7 +:100D3000204B22731B7863720323A3721E4B1B7814 +:100D4000E3721E4B74E7A371194B7FE70223A37173 +:100D5000184B7BE70323A371174B77E70423A37199 +:100D6000164B73E77C1D00203E210108B0210108CD +:100D7000A8210108A60E0020A70E00200D180020B3 +:100D8000831D0020A30E0020CB0E0020CA0E0020E1 +:100D9000C80E0020C90E0020A20E0020A0100020C6 +:100DA0009E1000209C1000209A100020A10E002010 +:100DB000840B0020830B0020820B0020810B00207D +:100DC0000123A74A23711278042A0BD8002A3FF482 +:100DD00047AF023AA3496371022A24D8DFE802F040 +:100DE000222F3100FF2A7FF43BAF0225002104208F +:100DF000A5720325A3719B4BA5731B78162503EBE6 +:100E00008303DA095B006071E17122726372E1723F +:100E100022736373E17322746374A074E1742275A6 +:100E20006375E2E60223A3710023E3710B780A25C0 +:100E300003EB83035A00DB0923726272D5E60323B6 +:100E4000F1E70423EFE7012323716371A371864B5C +:100E5000FCE60123854823710DF07CF9834960711C +:100E600082B2851D82480DF067F9ADB2BDE601235F +:100E70000F2280497E482371627115250DF05CF9BF +:100E8000B3E67D4B06251B786371AEE67B4B7C4E4B +:100E90001D787C4B022D19787B4B36781A787B4B6A +:100EA0001B7807D0052D2AD00525794800960BF030 +:100EB00077FC9AE6A071774865710088A573070AE8 +:100EC00020727548E77100886173070AA072734841 +:100ED000677200886275070A20737148E77200889C +:100EE000050A20746F48E5730088050AA0746E48EF +:100EF00065740088050AE57420751625D5E7A0718C +:100F00006448042500886571070A20726248E77109 +:100F100000886173070AA072604867720088627572 +:100F2000070A20730220A0735D48E7720088070A51 +:100F300020745C48E7730088070AA0745A486774F5 +:100F40000088070A20750320A0755848E7740088B8 +:100F5000070A20765648E7750088070AA0765548A4 +:100F600067760088070AE77620775348A5770088D8 +:100F70006377050A84F820005048E577008884F8F4 +:100F80002560050A84F822004D4884F82150008825 +:100F9000050A84F8235084F82400262585E7374B7A +:100FA000374E1D78374B022D1978374B37781A7822 +:100FB000364B1B7805D0052D1AD0052541480097E2 +:100FC00075E74FF0000CA071264865710078E57256 +:100FD00000EB8000C6094000102584F807C0267287 +:100FE0006072A17284F80CC06673A073E273E5E7C7 +:100FF0001C4DA0712D784FF0000C05EB8505EE0916 +:10100000680002254FF0040EE572032584F805E020 +:10101000257484F807C01A2526726072A17284F8BC +:101020000CC06673A073E27384F811C0A674E074F8 +:10103000237584F815E084F816C0E6752076677687 +:10104000BCE7214B1B786371204B1B780725A371EC +:10105000CBE51F4B6071F8E71E4B6071A071F5E5A1 +:10106000A00E0020F4110020E20E00205021010803 +:10107000821D002059380020700E00201D00002025 +:10108000810B0020840B0020830B0020820B0020AA +:1010900060210108C60E0020BE0E0020BC0E0020FC +:1010A000C40E0020BA0E0020B80E0020C20E002090 +:1010B000B60E0020B40E0020C00E0020B20E00209C +:1010C000B00E00208B21010808100020071000201E +:1010D00005100020E10E002000221F490B78012B93 +:1010E00005BF0A701D4A1346127804BF0825E27135 +:1010F0001B4A18BF0625117808BFA37101290BD11F +:101100000021117002216A1C61550D44154992B2EB +:101110000978ADB2A1540133637166E5124B102515 +:101120001B786371114B1B78A371114B1B681A0E4E +:10113000E2711A0C2272A3721A0A0E4B62721B78A9 +:10114000E3720D4B1B681A0E22731A0C62731A0A93 +:10115000A273E37349E500BFE50E0020E00E002016 +:10116000E40E0020DF0E0020DD0E0020DC0E00204B +:10117000D80E0020D40E0020D00E0020024B188084 +:101180000ECB0220FFF7C6B96019002070B5774E6C +:101190003378FD2B19D1764D76486C7821460BF0CB +:1011A000FFFA312C4ED81F2C22D8032C00F08C8053 +:1011B000042C00F08E80022C55D04FF48072002158 +:1011C0006B480BF0FFFA002333706B4B1A782AB987 +:1011D0000122022169481A7001F09EFB684C2378B5 +:1011E000002B00F0AE80012B00F0B8800023B3E0AC +:1011F000203C112CE1D801A353F824F0D7120008A9 +:10120000E7120008F712000807130008BB110008D6 +:10121000BB110008BB110008BB110008BB1100087E +:10122000BB110008BB110008BB110008BB1100086E +:10123000BB110008BB110008BB1100080B1300080C +:101240000F130008912C64D0922CB6D1B5F805305C +:10125000B3F5807F6FD0B3F5007FAED1B5F807301E +:10126000484A5BBA6BE06B794749484A0B70ABB9A7 +:10127000FF230B701370464B1B7843B1454B1B7813 +:101280002BB1454B1B7813B1444B1B7813B901228A +:10129000434B1A700220FFF771FF8EE71370013B7A +:1012A000032BF7D801A252F823F000BFBD120008AB +:1012B000C1120008C512000889120008344BE4E787 +:1012C000344BE2E7344BE0E7364B012220461A70FC +:1012D000E1E7354BF9E76B79344A002B08BFFF2370 +:1012E00020201370D7E76B79314A002B08BFFF230A +:1012F00021201370CFE76B792E4A002B08BFFF2304 +:1013000022201370C7E72320C5E73020C3E7312030 +:10131000C1E7AB7969791B0443EA0163E979287A6B +:10132000254A43EA0123D9170343C2E900310122C8 +:10133000224B1A7041E7B5F80730214A5BBA138097 +:101340003BE70220FFF70AF970B10078FFF7C4FB12 +:101350000A4801F0E9FA0123237005E0074801F08B +:10136000E9FA00287FF442AF70BD00BFD60F00201D +:101370004C270020BF210108100F0020080F00207B +:10138000060F0020FC0D0020A40E0020A30E00205C +:10139000CB0E0020CA0E0020C90E0020C80E00206F +:1013A000A50E00209F0E0020610E0020A20E00203E +:1013B000A10E0020A00E0020F80E0020000F00203B +:1013C000FE0D002038B5044608480D190BF0E8F969 +:1013D000AC4204D1BDE8384004480BF0E1B914F840 +:1013E000011B03480BF0DCF9F2E700BFE92001081C +:1013F000D12101082DE9F0410025304A304C137805 +:101400002570012B44D12F48157023700CF0A2FEDB +:101410002D4E4FF48072294630702C480BF0D2F9D3 +:101420003278284929480CF087FE2378002B43D0D6 +:10143000DFF8948098F80030002B3DD00021012780 +:10144000234E244D244B4FF4807224481F7031707A +:1014500029700BF0B7F9237898F800201B491F4832 +:1014600033702A700CF068FE1D480BF099F9317842 +:101470001C480BF095F929781B480BF091F9174996 +:101480001A480BF08DF93846BDE8F041FFF776BEFB +:10149000174B1A78012A0FD11D7002232370154BA8 +:1014A000094E1B784FF480722946084833700BF0C0 +:1014B00089F932781049B5E7BDE8F081861100203E +:1014C000A90E002088110020A80E0020CB160020B5 +:1014D000A70E0020A60E0020921000200D1800205C +:1014E000D9210108EC210108F72101080122010896 +:1014F000DE110020D9110020AE380020214B1A78CF +:10150000012A03D1002204201A7070471E4B1F4984 +:101510001A78012A02D00878012804D1002201207B +:101520001A700A7070471A490878012803D10023FD +:1015300002200B70704717490878012803D1002357 +:1015400003200B70704714490878012803D1002349 +:1015500005200B707047032A07D1104A107800222B +:101560000A2818BF07201A707047042A4FF000009D +:1015700002D1187008207047052A04BF187009208E +:10158000704700BF870E002086110020DB1100206D +:10159000DE110020DD110020DC1100208711002069 +:1015A00010B5044686B01122002101A80BF00AF9FB +:1015B000601E092818D8DFE800F005191927191747 +:1015C0002B17442B0924224B2246224922481C7007 +:1015D0000CF0B2FD22461F4920480CF0ADFD11224F +:1015E0001F4920480CF0A8FD06B010BD1E4B1F4936 +:1015F0001A78174B18481A700CF09EFD2322002110 +:101600001A480BF0DFF8EFE70022114B1A70EBE7F6 +:10161000174B0F4C1A7817490F4822700CF08CFDAD +:1016200023781549062219440DF10F000CF084FDB2 +:1016300011220C4801A90CF07FFD212200210D4848 +:10164000DFE71822024B0B4903481A70F3E700BF8B +:10165000A80E0020C9110020CB1600204E19002032 +:10166000A911002058160020D9110020AE38002002 +:101670008711002088110020A311002010B500243C +:10168000124B21461C70124B21221C70114B124828 +:101690001C70124B1C70124B1C70124B1C70124BA6 +:1016A0001C70124B1C70124B1C70124B1C700BF0F8 +:1016B00089F82146092210480BF084F82146BDE83C +:1016C000104011220D480BF07DB800BF870E00209E +:1016D00086110020DB110020CB160020DE11002037 +:1016E000DD110020DC11002006100020890E0020F2 +:1016F000A90E0020A80E00204E1900205816002028 +:1017000070B59D4B1A786AB901220A219B481A705C +:1017100001F002F964219A4801F0FEF81421994879 +:1017200001F0FAF8984C2378042B08D8013B032BDE +:101730000DD8DFE813F063008900B800BE00202B4D +:1017400000F0BD80212B00F0DF8000232EE08F4BC6 +:101750001A78022A3BD1002201251A708C4B8D4E3B +:101760001D708D4B32781D7073781B0243EA024363 +:10177000B2781343894A1360894A126893421CD194 +:1017800088480BF00DF83146092287480CF0D4FC4C +:1017900086480BF005F8844801F018F8014638B186 +:1017A000834B84481D700AF0FBFF2023237003E065 +:1017B00081480AF0F5FF257070BD7D4B7F481D7094 +:1017C0000AF0EEFF6D4801F0AFF80423EEE77C4A23 +:1017D0001378012BF0D1002111706F4A1370794BEF +:1017E0001D78012D06D178480AF0DAFF0222684BF5 +:1017F0001A70E0E775480AF0D3FFE6E7644E744DCF +:101800003378012B1BD1734A624913700922724845 +:101810002A700CF091FC3278704B6F491A702A785C +:101820006F4B70481A7021220CF086FC6E4B1B78AF +:10183000002BCAD0534801F077F80323B6E7022BF8 +:101840001CBF04232370E6E74D4801F073F808B18C +:101850006648D0E7664B1A78012AADD11870654BFF +:101860001D78012D07D0022D0FD0002DE2D1624846 +:101870000AF096FFDEE761480AF092FF444B1B78BE +:10188000022BD7D1534B1D70D4E7414B1B78012B52 +:1018900005D1454800F0BCFF00F07AFFCAE7022BF3 +:1018A000C8D15748E4E7374801F044F800288CD104 +:1018B00082E70023354A1370464A137076E70922FF +:1018C000434D344944482A700CF036FC304B4249B1 +:1018D0001A78424B43481A702A78414B1A702122D9 +:1018E0000CF02AFC41F25D22464B00201A800ECB00 +:1018F000FEF710FE44480AF053FF212323702048CE +:10190000BDE8704001F010B81D4801F013F8002840 +:101910007FF45BAF364B1A78012A7FF44DAF187015 +:10192000344B1D78012D06D0022D1AD0002D7FF4E6 +:101930004CAF31485FE731480AF032FF144B1B7857 +:10194000012B08D131480AF02BFF174800F084FF23 +:1019500000F01EFF39E7022B7FF437AF1D4B1D70DF +:1019600033E70B4B1B78012B01D1294843E7022BAE +:101970007FF42BAF22483EE7700F0020680F002055 +:10198000600F0020580F0020540F00208611002007 +:10199000530F0020C911002092100020200E0020BB +:1019A0005C0E00200F220108BC2400202022010828 +:1019B0008F1000202D2201084E220108612201080B +:1019C000600E0020560E0020742201088D220108AE +:1019D000A80E0020610E0020CB1600209E0E0020D5 +:1019E0009D0E0020221900207B110020B02201084A +:1019F0008B0E00208A0E0020C3220108DE2201087F +:101A0000F12201086C19002006230108182301089F +:101A10002B23010838B5114B1A78012A1AD100225C +:101A20000F4C104821781A700AF0BAFE23780E4C39 +:101A3000002B14BF0123002323700CD104F0EEFA15 +:101A40000A4D22782B789A4204D009480AF0A8FE61 +:101A500023782B7038BD04F0A5FAF1E7980E00202A +:101A6000010E002042230108050000200400002090 +:101A70005323010870B5174B1A78012A28D1164C48 +:101A800023789BB10F2B88BF0222144D144E88BFC0 +:101A900003F00F0311202B703270FFF76FFB3278C9 +:101AA000297810480AF07CFE002323700E4C23781E +:101AB000012B0DD103230A4D11202B70FFF75EFB84 +:101AC000064B2A78197807480AF06AFE002323702B +:101AD00070BD00BF230000204C280020081000200B +:101AE000071000206C2301080910002010B5154BC9 +:101AF000154C1978154B1A788A4207D001222270AA +:101B0000134A1448117019700AF04AFE124B1978E2 +:101B1000124B1A788A4208D00120114A19701070AD +:101B2000104A114811700AF03BFE2378012B03D0B4 +:101B30000B4B1B78012B04D1BDE810406620FFF74A +:101B40001DBB10BDE70E0020E50E0020520F002047 +:101B5000E00E00208D230108E60E0020510F00202A +:101B6000E40E0020DF0E0020AB2301082DE9F04732 +:101B70008C4B86B01A781ABB01220A218A481A7047 +:101B800000F0CAFE0F21894800F0C6FE4FF4FA614A +:101B9000874800F0C1FE1E21864800F0BDFE64218A +:101BA000854800F0B9FE1421844800F0B5FE1E21DE +:101BB000834800F0B1FE40F6B831824800F0ACFE38 +:101BC000814C2378112B15D8112B1DD8DFE813F089 +:101BD00031006000B802E0022C032E0342031C0017 +:101BE0001C001C001C001C001C001C001C001C0015 +:101BF0004B034803302B00F0768307D8202B00F0EE +:101C00003D83212B00F053830023B6E2312B00F0FB +:101C10007683662BF8D1674800F08CFE002800F030 +:101C20001F836A480AF0BCFD04F0BCF9FFF726FDEB +:101C3000EAE7674A1578012D40F0128300231370FC +:101C4000644A28461570644A1370644A1370644AE3 +:101C50001370644A1370644A1370644A137008F076 +:101C6000C1FE04F005FA62480AF09AFD614B624831 +:101C70001D70624B1D700AF093FD4C4800F054FE3D +:101C80004B4800F051FE4E4800F04EFE2570E7E252 +:101C9000474800F04FFE58B100232370FFF7EEFCD9 +:101CA00004F080F9564806B0BDE8F0470AF078BD68 +:101CB0004E4D2B786BB9424800F03CFE48B1514B79 +:101CC0001B78012B0CBF0220062008F08BFE01239D +:101CD0002B704D4B1A78012A04D1002234481A7017 +:101CE00000F022FE494B1A78012A0ED10022484DFD +:101CF0001A70287804F06EFA6020FFF73FFA2B780C +:101D0000062B02D1032008F06DFE424B1A78012AFF +:101D100009D100221A7005232370284806B0BDE8B7 +:101D2000F04700F001BE2C4B1A78012A40F098824F +:101D3000002239481A700AF033FDFFF7D7FE612000 +:101D4000FFF71CFA35480AF02BFD354B354D197855 +:101D500035480AF025FD297834480AF021FD344B36 +:101D60001B78012B18D133480AF01AFD2978324824 +:101D7000FFF728FB314B1B78042B67D0052B00F0B5 +:101D8000F7802F480AF00CFD01222E4B1A700B48E9 +:101D900000F0CAFD0523F0E127492B480AF000FDB9 +:101DA000E8E700BFB40F0020AC0F0020A40F002014 +:101DB0009C0F0020940F00208C0F0020840F002027 +:101DC0007C0F0020740F0020720F00202E260108C7 +:101DD000A50E002092100020720E0020730E00202D +:101DE0009C0E00209A0E00209B0E0020710F0020F8 +:101DF000C9230108880E0020EF230108890E002066 +:101E00000A24010822000020750E0020710E002017 +:101E1000700E0020620E00202324010844240108D3 +:101E2000A70E0020A60E00206124010870240108DE +:101E3000A90E00207E2401080D1800201D0000209E +:101E40007C250108E90F00208B240108A74D288874 +:101E50000FF02EFDA6490FF037FE0FF043F9A54B0A +:101E6000064618780F460FF023FD0FF03BF9CDE939 +:101E70000401A14B18880FF01BFD9D490FF024FEB3 +:101E80000FF030F9CDE902019C4B18880FF010FDDE +:101E900097490FF019FE0FF025F93246984E3B4650 +:101EA000CDE9000197480AF07BFC30880FF000FD77 +:101EB0008F490FF009FE0FF015F9934B8046187803 +:101EC00089460FF0F5FC0FF00DF9CDE904018F4BB9 +:101ED0008F4F18880FF0ECFC85490FF0F5FD0FF0DF +:101EE00001F9CDE902018B4B18880FF0E1FC804924 +:101EF0000FF0EAFD0FF0F6F842464B46CDE900013F +:101F000085480AF04DFC38880FF0D2FC78490FF074 +:101F1000DBFD0FF0E7F8814B8046187889460FF01B +:101F2000C7FC0FF0DFF8CDE904017D4B18880FF0F6 +:101F3000BFFC6F490FF0C8FD0FF0D4F8CDE90201E6 +:101F4000784B18880FF0B4FC69490FF0BDFD0FF015 +:101F5000C9F84B46CDE90001424673480AF020FC1F +:101F6000724B1B883A883188288804F053F908E7B7 +:101F70005E4DDFF8B8A128880FF09AFC5C490FF09D +:101F8000A3FD0FF0AFF85B4B064618780F460FF035 +:101F90008FFC0FF0A7F8CDE90401574B18880FF01C +:101FA00087FC53490FF090FD0FF09CF8CDE902013A +:101FB000524B18880FF07CFC4D490FF085FD0FF057 +:101FC00091F832464E4E3B46CDE900014D480AF0AD +:101FD000E7FB30880FF06CFC45490FF075FD0FF002 +:101FE00081F8494B8046187889460FF061FC0FF064 +:101FF00079F8CDE90401454B454F18880FF058FC9E +:102000003B490FF061FD0FF06DF8CDE90201414B46 +:1020100018880FF04DFC36490FF056FD0FF062F8AE +:1020200042464B46CDE900013B480AF0B9FB3888EF +:102030000FF03EFC2E490FF047FD0FF053F8374BE1 +:102040008046187889460FF033FC0FF04BF8CDE945 +:102050000401334B18880FF02BFC25490FF034FD99 +:102060000FF040F8CDE902012E4B18880FF020FC4C +:102070001F490FF029FD0FF035F842464B46CDE9D8 +:10208000000129480AF08CFBBAF800000FF010FCA0 +:1020900017490FF019FD0FF025F8254B80461878E9 +:1020A00089460FF005FC0FF01DF8CDE90401214B26 +:1020B00018880FF0FDFB0E490FF006FD0FF012F827 +:1020C000CDE902011C4B18880FF0F2FB08490FF014 +:1020D000FBFC0FF007F84B46CDE9000142461748DC +:1020E0000AF05EFBBAF800303CE700BFC60E0020E5 +:1020F0000000C84221000020BC0E0020BE0E0020BF +:10210000C40E00209C24010820000020B80E0020EE +:10211000C20E0020BA0E0020D42401081F000020A7 +:10212000B40E0020B60E00200C250108C00E0020C1 +:102130001E000020B00E0020B20E00204425010831 +:10214000904800F0F7FB002800F08A808E4B8F4A01 +:102150001B88128813438E4A128813438D4A1288B3 +:1021600013438D4A128813439BB243B18B480AF044 +:1021700017FB8B4800F0D8FB0323237070E004208A +:1021800008F030FC04F040F986480AF009FBFEE54F +:10219000854B1A78012A3AD10022844D1A7028689A +:1021A0000FF086FB82490FF08FFC0EF09BFF814EF3 +:1021B00002460B4680480AF0F3FA30680FF078FBCD +:1021C0007B490FF081FC0EF08DFF02460B467B48E9 +:1021D0000AF0E6FA31682868814213D304F0C0F8A7 +:1021E0000520FEF7CBFF2B683068C01A0FF060FBAC +:1021F0006F490FF069FC0EF075FF02460B46704800 +:102200000AF0CEFA04235F48237000F08DFB644887 +:1022100000F090FB20B3042008F0E4FB04F0F4F895 +:1022200068480AF0BDFA76E55648F1E7664800F0DE +:1022300081FBA8B165480AF0B3FA03F0B3FE0920A8 +:10224000FEF79CFFFFF71AFA0023614A1370614AF8 +:10225000137092E75C4800F06DFB00287FF4D4AC6B +:1022600006B0BDE8F08700225B4B1046197804F0F9 +:10227000FDF83020FEF782FF11237EE700250320C2 +:102280002B462A462946009503F00EFF41F2CD0267 +:10229000524B28461A800ECBFEF73CF950480AF004 +:1022A0007FFA21233E48237000F03EFB35E53C4891 +:1022B00000F040FB00287FF46DAD4A4B1A78012AEC +:1022C000CED11870484B1B78012B08D147480AF033 +:1022D00067FA474800F0C0FA00F05AFA5AE5454854 +:1022E0000AF05EFA56E541F231123C4B00201A80AA +:1022F0000ECBFEF70FF931233F4823700EE5394F1F +:102300003B78012B04D1002302203B70FEF736FFFF +:10231000FFF7F4F80546F0B10021384B384E19604C +:10232000314B092230703748197039700AF04AFA77 +:102330003078FFF735F93278334B34491A70344B23 +:1023400034481A78344B1A7021220BF0F5FE3023F2 +:1023500032482370A7E4324E377837B931480AF053 +:102360001FFAFFF78BF927707AE7234800F0E2FAAB +:1023700000283FF475AF2C480AF012FAFFF77EF9F7 +:10238000357083E4940F0020C60E0020C40E002098 +:10239000C20E0020C00E0020AE0E00209A250108BB +:1023A0008C0F0020BB2501089A0E0020940E0020FF +:1023B0000000C842900E0020DC250108F12501082C +:1023C000062601081B260108840F00202E2601087E +:1023D000890E0020A50E0020630E00206C1900203D +:1023E000062301089C0E002045190020182301082F +:1023F000BC2400202B230108740F00204819002062 +:10240000A90E00204E190020A70E0020CB16002098 +:10241000A80E00200D180020A60E00203B26010863 +:102420006F0E00205026010863260108F8B52C4BDA +:102430001A7852B901224FF496712A481A7000F0A6 +:102440006BFA1421284800F067FA284B284D1E78B3 +:102450002B78284C1BB1012B2ED0002307E0264BF4 +:102460001B78B34204D0204800F05EFA01232B70A1 +:10247000224D23782A789A4208D063BB20480AF07C +:102480008FF9237823202B70FEF778FE1D4D2B78D3 +:102490002BBB144800F04EFA08B301231A482B70E6 +:1024A0000AF07EF92378C3B915480AF079F9BDE836 +:1024B000F8402320FEF762BE0B4800F03BFA0028EC +:1024C000D6D00D4F3B78B342C7D010480AF068F918 +:1024D00026703E70C1E70E48D1E70D48E5E7F8BD2C +:1024E000500F0020480F0020400F0020E30E002076 +:1024F0003C0F0020E20E00203B0F00203A0F00208E +:102500008F260108390F0020B12601087626010820 +:10251000A0260108054B1B685A6822B91868B0FA52 +:1025200080F0400970470020704700BF5C1C00200D +:1025300070B5394B1A784AB901220A2137481A7006 +:1025400000F0EAF91421364800F0E6F9354C23781A +:10255000022B50D026D843BB334B1B78012B23D101 +:10256000FFF7D8FF01281FD1304B1B689A6803235F +:1025700092FBF3F303EB43039A4215D12C492D4808 +:102580000AF00EF92C4B1B78022B05D02B4B1B7835 +:10259000012B01D008F072FE214800F0C5F901239B +:1025A000237001E0102B2ED070BD1D4800F0C2F941 +:1025B000064630B122480AF0F3F808F06FFE002317 +:1025C000EEE71E4B1B78012B06D11E480AF0E8F8F7 +:1025D00008F064FE0223E3E7174D2B78022BE3D1CA +:1025E00019480AF0DDF808F059FE0C482E7000F08A +:1025F0009BF91023D4E7114B1B78002BD4D113483F +:102600000AF0CEF8C6E7054800F094F90028CBD0D0 +:102610000023094A1370C3E7380F0020300F002051 +:10262000280F0020250F0020000F00205C1C002038 +:10263000681C0020D6260108A8140020890E00205E +:10264000F326010810270108312701084E27010849 +:1026500038B5364B1A7852B901220A2134481A701B +:1026600000F05AF941F27071324800F055F9324CDD +:102670002378022B46D01BD8EBB9304B1B78012BAB +:1026800018D1FFF747FF012814D12D492D480AF032 +:1026900087F82D4B1B78022B05D02C4B1B78012B78 +:1026A00001D008F0CBFD234800F03EF9012317E0EC +:1026B000102B31D038BD1F4800F03CF930B1244810 +:1026C0000AF06EF808F0CAFD002323701F4B1B7838 +:1026D000012B07D11F480AF063F808F0BFFD022361 +:1026E0002370E7E7184D2B78022BE3D11A480AF044 +:1026F00057F808F0B3FD00230D482B7000F014F9D3 +:102700001023EDE7114B1B78002BD3D113480AF0AF +:1027100047F808F093FDC9E7054800F00BF90028D9 +:10272000C8D00023084A1370DAE700BF240F002046 +:102730001C0F0020140F0020110F0020000F00209C +:10274000681C00206B270108AA140020890E0020B5 +:1027500086270108A1270108C0270108DB270108F7 +:1027600038B5044608480D190AF01AF8AC4204D1ED +:10277000BDE8384004480AF013B814F8011B0348B8 +:102780000AF00EF8F2E700BFE9200108D1210108A4 +:1027900070B50A4B0A4D1A7829780A480AF000F8F1 +:1027A0000024094E2B78E0B2834200D870BD10217E +:1027B00006EB0010FFF7D4FF0134F3E7B60F00205B +:1027C000B50F0020F62701087C1E0020F0B50E4B47 +:1027D0001A787AB100230D494C1E451E01F10F06EF +:1027E00014F801CF15F8017FBC4505D1B442F7D1EB +:1027F0000133DAB21046F0BD0133DCB2A24201F17E +:102800001001E9D80022F5E7B50F00207C1E00205A +:1028100038B50E4C014625780D48102200EB051006 +:102820000BF08AFC22780B490132D2B2632A227063 +:1028300088BF00220B7888BF22700133DBB2632B84 +:102840000B7084BF64230B7038BD00BFB60F00202F +:102850007C1E0020B50F0020F0B5044685B0102284 +:10286000FF21684609F0AEFF2046FFF7AFFFA0B199 +:1028700001380F4EC4B20F4D06EB04102B78013B0C +:10288000A3420CDC102206EB031069460BF054FC4B +:102890002B78094A013B2B70137005B0F0BD00F195 +:1028A0001007102239460BF047FC01343846E5E7A3 +:1028B0007C1E0020B50F0020B60F002038B505465D +:1028C0000C4645F2555009F09FF8284609F0A2F849 +:1028D000204609F0A5F809F0A9F8BDE8384009F04C +:1028E000ADB8000008B50A4B1A782AB901220521B3 +:1028F00008481A7000F010F8064800F01BF830B1D4 +:10290000044800F011F8BDE8084009F08FB808BD90 +:10291000C00F0020B80F0020024B41601B6803600D +:10292000704700BFC40F0020014B1B680360704755 +:10293000C40F0020044B02681B6840689B1A834246 +:1029400034BF002001207047C40F0020044B1A68D8 +:10295000D0E90030184490428CBF801A00207047A4 +:10296000C40F002030B50C46012185B0054608464D +:1029700008F020FE002301A94FF08040ADF80A3096 +:10298000ADF80630ADF80850ADF8044008F02CFF63 +:10299000012241214FF0804008F077FF01214FF0E4 +:1029A000804008F069FF034B6846009308F0E2FCA2 +:1029B00005B030BD1C00030108B501214FF0804077 +:1029C00008F06EFF18B1054A136801331360012146 +:1029D000BDE808404FF0804008F06EBFC40F0020F3 +:1029E00030B5054685B00C460220012108F0E2FD15 +:1029F000002301A90D48ADF80A30ADF80630ADF856 +:102A00000850ADF8044008F0EFFE012241210748CC +:102A100008F03BFF0121054808F02EFF044B6846F3 +:102A2000009308F0A7FC05B030BD00BF00040040D3 +:102A30001D02020108B501210D4808F031FF58B10F +:102A40000C4B1B78012B07D10B4B1B7853B900F0B3 +:102A50000BFD08B1094B18700121BDE8084004487E +:102A600008F02ABF012BF7D100F09AFDF1E700BF73 +:102A700000040040E80E0020230000204C28002025 +:102A800030B50C4685B005460121042008F092FDC2 +:102A9000ADF80440002401A90C48ADF80850ADF889 +:102AA0000A40ADF8064008F09FFE01224121074888 +:102AB00008F0EBFE064B6846009308F05BFC2146ED +:102AC000024808F0D9FE05B030BD00BF0008004044 +:102AD0001E02020108B50121054808F0E1FE28B1F7 +:102AE000BDE808400121024808F0E6BE08BD00BF6D +:102AF0000008004030B50C4685B00546012108208D +:102B000008F058FDADF80440002401A90C48ADF8C8 +:102B10000850ADF80A40ADF8064008F065FE012205 +:102B20000748114608F0B1FE064B6846009308F0CE +:102B300021FC2146024808F09FFE05B030BD00BFD1 +:102B4000000C00403203020108B501210A4808F0D8 +:102B5000A7FE80B1094A0121138807486FEA434361 +:102B60006FEA5343138008F0A7FEBDE80840002138 +:102B7000014808F081BE08BD000C0040C80F0020CD +:102B800010B5012186B0044644F2040008F006FDA9 +:102B9000194808F033FD194B69461948009308F0AD +:102BA00026FC4FF48063ADF80030042369461448D6 +:102BB0008DF8033008F01BFC4FF4402302940024EE +:102BC00002A90D48CDE90343ADF8144008F064FDB7 +:102BD0000C4B01A8019308F0CDFB012240F22551D6 +:102BE000054808F0AEFD0121034808F0A1FD064BA1 +:102BF0001C8006B010BD00BF003801400002031861 +:102C00000008014025010201C80F002038B540F23C +:102C10002551114808F0C8FDB0B10F4808F0B7FDC4 +:102C20000E4C054623887F2B0FD800210C4808F056 +:102C300035FE23881BB90121094808F01DFE2388B1 +:102C40005A1C2280074AD55438BD6FEA43436FEAC5 +:102C500053432380F8E700BF00380140C80F00202D +:102C6000000C0040CC240020014608B5044808F0C0 +:102C70008AFD4021024808F08EFD0128F9D108BDE7 +:102C80000038014038B50D1804464021054808F0C9 +:102C900088FDAC4200D138BD14F8010BFFF7E4FF0A +:102CA000F7E700BF0038014010B5012186B00446A7 +:102CB000042008F073FC01214FF4003008F07AFC86 +:102CC000164B69461648009308F091FB0823ADF8AF +:102CD00000300423694612488DF8033008F087FB62 +:102CE00000234FF4402202A90E48CDE90332ADF88B +:102CF0001430029408F0D0FC0B4B01A8019308F0AB +:102D000039FB012240F22551064808F01AFD012145 +:102D1000044808F00DFD06B010BD00BF0400031804 +:102D2000000801400044004026000001014608B5AB +:102D3000044808F028FD4021024808F02CFD012835 +:102D4000F9D108BD0044004038B50D1804464021B3 +:102D5000054808F026FDAC4200D138BD14F8010B3F +:102D6000FFF7E4FFF7E700BF00440040F0B5304B49 +:102D70001A78092A5AD8DFE802F0050A59131B24E9 +:102D80002C394E54FE280AD101221A7007E0FE2881 +:102D900005D068284AD103221A70264B1870F0BD5E +:102DA000254A244910700A7802440A700422ECE78C +:102DB00068283BD105221A701E4A137868331370B5 +:102DC000EDE71D4A1B4950700A7802440A7006223A +:102DD000DBE7194A174990700A7802440A70174ACB +:102DE000107008B90822D0E70722CEE7134E144C22 +:102DF000104D367822782978013EB2420E4E02F10B +:102E000003070144F055297002DA01322270C6E747 +:102E100000222270E6E7074A1278824206D1092290 +:102E2000B3E7162802BFFD21064A11700022ACE765 +:102E3000CD0F0020CC0F00204C250020CB0F002010 +:102E4000CA0F0020CE0F002008B540F225510648D9 +:102E500008F0AAFC38B1044808F099FCBDE8084025 +:102E6000C0B2FFF783BF08BD0044004030B5012168 +:102E700091B00446082008F091FB01214FF4802016 +:102E800008F098FB2C4808F0B9FB2C4B69462C48FD +:102E9000009308F0ACFA4FF40063ADF8003004235F +:102EA000694627488DF8033008F0A1FA4FF4402313 +:102EB0000194002401A92048CDE90243ADF8104057 +:102EC00008F0EAFB0121084608F05CFB052008F049 +:102ED00013FA1C4808F0F4FC1B4B802505931B4B90 +:102EE00005A90693102307934FF480531548CDE9A5 +:102EF0000E34CDE90A54CDE90C44099408F05AFD8A +:102F0000294601220C4808F035FC114B05A8059311 +:102F100008F030FA012240F22551074808F011FC70 +:102F20000121054808F004FC0A4B21460A481C8090 +:102F300008F0A2FC11B030BD0048004000040318A6 +:102F4000000C01401C0002400448004058300020A2 +:102F500027000001503000200008004008B540F272 +:102F60002551064808F020FC38B1044808F00FFC51 +:102F7000BDE80840C0B200F087BE08BD0048004070 +:102F800010B504460021064808F030FD21460448EB +:102F900008F037FDBDE810400121014808F026BDCA +:102FA0001C00024010B5012186B00446102008F034 +:102FB000F5FA01214FF4002008F0FCFA164B69469F +:102FC0001648009308F013FA4FF40063ADF8003090 +:102FD0000423694611488DF8033008F008FA0023ED +:102FE0004FF4402202A90E48CDE90332ADF8143067 +:102FF000029408F051FB0B4B01A8019308F0BAF9B9 +:10300000012240F22551064808F09BFB01210448AB +:1030100008F08EFB06B010BD00040318001001403C +:10302000004C004034010101014608B5044808F095 +:10303000AAFB4021024808F0AEFB0128F9D108BDE7 +:10304000004C004038B50D1804464021054808F0F2 +:10305000A8FBAC4200D138BD14F8010BFFF7E4FF28 +:10306000F7E700BF004C0040F0B5384B1A78092A4A +:1030700008D8092A08D8DFE802F0090E07171E272A +:103080002E475C623E2A2DD0002202E0FE290AD1A2 +:1030900001221A7007E0FE2905D06829F4D1032225 +:1030A0001A702B4B1970F0BD0170294802780A4440 +:1030B00002700422EDE76829E6D105221A70244A3D +:1030C000137868331370EEE74170214802780A44A0 +:1030D00002700622DDE781701D4802780A44027002 +:1030E0003E22D6E71A4CC17022780A4422708278B8 +:1030F00041EA022217490A800AB90822C9E70021D9 +:10310000154A11800722C4E7124F114E124D3F8815 +:103110002A883478013F0C4402F1040CBA4200F8CA +:103120000C10347002DA01322A80BCE700222A80B7 +:10313000E3E7074A12788A42A6D10922A9E71629AD +:1031400002BFFD21054A11709EE700BFD50F002088 +:10315000D40F0020D20F0020D00F0020D60F002067 +:1031600008B540F22551074808F01EFB40B105485C +:1031700008F00DFBBDE80840C1B20348FFF774BF7B +:1031800008BD00BF004C00404C27002010B50121B5 +:1031900086B00446302008F001FA01214FF4801077 +:1031A00008F008FA154B69461548009308F01FF916 +:1031B000042369461348ADF800308DF8033008F059 +:1031C00016F900234FF4402202A90F48CDE903323B +:1031D000ADF81430029408F05FFA0C4B01A801938B +:1031E00008F0C8F8012240F22551074808F0A9FA72 +:1031F0000121054808F09CFA06B010BD0010031824 +:10320000001001400014014000500040350201014F +:1032100008B540F22551054808F0C6FA20B1BDE8CE +:103220000840024808F0B3BA08BD00BF0050004093 +:1032300007B50121092008F0B1F90121074808F07C +:103240002FF9074B01A90748019308F0D0F8102186 +:10325000044808F021F903B000BD00BF00023000AF +:1032600010000310000C014008B51021034808F0BD +:1032700015F90122024B1A7008BD00BF000C014075 +:10328000EA0F002008B51021034808F005F90022D4 +:10329000024B1A7008BD00BF000C0140EA0F00206D +:1032A00010B5154B1A7842B9012114481970FFF76F +:1032B00033FB13211248FFF72FFB124C23781BB16D +:1032C000012B0DD0002309E0FFF7DCFF0C48FFF7CE +:1032D00031FB20B10948FFF727FB0123237010BD04 +:1032E000FFF7C2FF0548FFF725FB0028F7D0044889 +:1032F000FFF71AFBE6E700BFE80F0020E00F002011 +:10330000D80F0020D70F002073B5482420250121B5 +:10331000042008F043F90121042008F03FF90121BD +:10332000102008F03BF90121082008F037F90121AD +:10333000042008F033F90121042008F02FF90121BD +:10334000102008F02BF90121082008F027F90121AD +:10335000082008F023F90121082008F01FF90121B5 +:10336000102008F01BF90121102008F017F901A91D +:103370003748ADF804508DF8074008F038F880233E +:1033800001A93348ADF804308DF8074008F02FF854 +:10339000ADF80450022501A92E482F4E8DF80740A4 +:1033A00008F025F801A92D48ADF804508DF8074024 +:1033B00008F01DF801A92648019608F018F8102118 +:1033C000234808F069F8264B01A92148019308F029 +:1033D0000EF840211E4808F05FF801A91D4801962B +:1033E00008F005F810211B4808F056F81D4B01A9FC +:1033F0001A48019307F0FBFF0121184808F04CF828 +:103400004FF4807301A91548ADF804308DF80740DA +:1034100007F0EDFF4FF4007301A91048ADF8043038 +:103420008DF8074007F0E3FF012301A90948ADF833 +:1034300004308DF8074007F0DAFF064801A9ADF81F +:1034400004508DF8074007F0D2FF02B070BD00BFF6 +:10345000000801400010014010000310000C014062 +:10346000400003100100031070B5454B1A782AB9CB +:103470000122142143481A70FFF74EFA424E347865 +:10348000032C0CD8DFE804F002274D5E20213F48D2 +:1034900007F0FCFF3E4C20B9012323703370002558 +:1034A00039E08021394807F0F1FF18B90223237071 +:1034B0000123F3E72021374807F0E8FF08B9032389 +:1034C000F5E70221344807F0E1FF08B90423EEE7ED +:1034D00000232370E3E720212C4807F0D7FF88B1B1 +:1034E00080212A4807F0D2FFB8B12021294807F0EF +:1034F000CDFFA0B10221284807F0C8FFB0FA80F440 +:103500006409A400224B1D78A54236D102231D4830 +:103510003370FFF709FA284670BD0224F2E703244E +:10352000F0E71848FFF706FA60B1194B1D786B1EDB +:10353000032B4FF0030396BF05EB05150025EDB2F5 +:103540003370E8E72021114807F0A0FF0128A6D139 +:1035500080210E4807F09AFF0128A0D120210D48B4 +:1035600007F094FF01289AD102210B4807F08EFF43 +:10357000012894D10122094B1A7000238EE700BF65 +:1035800004100020FC0F0020FA0F0020000801406A +:10359000F90F002000100140000C0140091000202C +:1035A00038B5344B1A782AB90122142132481A70DE +:1035B000FFF7B2F92021314807F068FF8021054666 +:1035C0002F4807F063FF202144002D4807F05EFFDD +:1035D00044EA85042B4D20432B782B4CC0B220703D +:1035E000032B13D8DFE803F002142842274A60B106 +:1035F000411E042904D8DFE801F004040404040097 +:103600001846012310702B7000E0107000240DE0AC +:103610001E4B68B1421E042A00D900201C78844247 +:1036200008D1022314482B70FFF77EF9204638BDDD +:103630001870F2E70023E6E70F48FFF77BF960B167 +:10364000124B1C78631E042B4FF0030396BF04EB50 +:1036500004140024E4B22B70E8E72378002BD5D1C2 +:10366000002301222B700A4B1A70CFE70028F7D0F5 +:10367000CCE700BFF80F0020F00F00200010014041 +:1036800000080140EC0F00200A100020EB0F002082 +:1036900009100020013803280FD8DFE800F00206E7 +:1036A000080B1021054807F0F9BE4021FAE7102168 +:1036B0000348F8E701210348F5E770470008014097 +:1036C00000100140000C0140013803280FD8DFE84A +:1036D00000F00206080B1021054807F0DDBE40216E +:1036E000FAE710210348F8E701210348F5E770479E +:1036F0000008014000100140000C01400421014875 +:1037000007F0CABE000C014007B50121082007F0F0 +:1037100045FF074B01A90748019307F068FE042104 +:10372000044807F0BBFE0122034B1A7003B000BD32 +:1037300004000310000C01409310002008B1FFF7B3 +:10374000DDBF0421014807F0A9BE00BF000C014005 +:1037500038B5954B1A784AB90122022193481A705C +:10376000FFF7DAF808219248FFF7D6F8914C237852 +:10377000012B40D0022B53D0002B4DD18E4B1D7806 +:10378000012D05D1FFF7BAFF8848FFF7CDF8257066 +:103790008A4B1A7842B9012189481970FFF7BCF8A1 +:1037A00002218848FFF7B8F8874C2378012B3ED0D8 +:1037B000022B51D0002B4BD1844B1D78012D05D10C +:1037C000FFF79CFF7E48FFF7AFF82570804B1A7813 +:1037D0002AB9012202217F481A70FFF79DF87E4C1A +:1037E0002378002B3FD0012B5CD00020FFF7A6FFF1 +:1037F0000023237042E06D48FFF79CF840B10020A1 +:10380000FFF79CFF6A48FFF78FF802232370BFE79A +:10381000694B1B78002BBBD10020FFF78FFF04E022 +:103820006348FFF787F80028F2D00023EEE76448EA +:10383000FFF780F840B10020FFF780FF6148FFF7F5 +:1038400073F802232370C1E7604B1B78002BBDD1B6 +:103850000020FFF773FF04E05A48FFF76BF80028D9 +:10386000F2D00023EEE75D4A1578012D06D11370E2 +:10387000FFF744FF5748FFF757F82570584B1A7861 +:103880002AB90122142157481A70FFF745F8564CFF +:1038900023786BB1012B35D00020FFF74FFF0023B9 +:1038A000237010E04B48FFF745F80028E6D09CE76E +:1038B0004E4A1578012D06D11370FFF71FFF4948B6 +:1038C000FFF732F825704A4B1A788AB90124494823 +:1038D00021461C70FFF720F802214748FFF71CF82B +:1038E00021464648FFF718F802214548FFF714F82B +:1038F000444C2378052B00F2A880DFE803F00B2D61 +:103900003B478D993748FFF715F80028C4D1FFF7DA +:10391000F5FED8E73C4B1D78012D07D100221A7027 +:10392000FFF7ECFE3348FEF7FFFF2570374B1A78A0 +:103930002AB90122052136481A70FEF7EDFF354CF1 +:103940002378052B00F2EA80DFE813F08400A90059 +:10395000B700C300D000DC002648FEF7EBFF0028CC +:10396000E4D00020FFF7EAFE2448FEF7DDFF022343 +:103970002370DBE72148FEF7DDFF0028D6D0FFF7F4 +:10398000BDFE1D48FEF7D0FF0323F1E71A48FEF7FE +:10399000D1FF0028CAD00020FFF7D0FE1848FEF75C +:1039A000C3FF0423E4E700BF8C1000208410002034 +:1039B0007C100020791000208E100020781000204C +:1039C0007010002068100020651000208D1000206D +:1039D000641000205C10002059100020921000207C +:1039E00058100020501000204D1000209110002091 +:1039F0004C100020441000203C1000203410002007 +:103A00002C100020291000209310002028100020E6 +:103A1000201000201D1000208248FEF78BFF002898 +:103A200084D0FFF76BFE8048FEF77EFF05239FE7FB +:103A30007D48FEF77FFF00283FF478AF0020FFF7B6 +:103A40007DFE0023794A137092E70020FFF776FE8F +:103A500000238DE7764B1D78012D07D100221A70C7 +:103A6000FFF74CFE7348FEF75FFF2570724B1A7824 +:103A70004AB90122022171481A70FEF74DFF022156 +:103A80006F48FEF749FF6F4C2378092B00F2C28084 +:103A9000DFE803F0495664707D8996A2AFBB6548A4 +:103AA000FEF748FF0028E1D00020FFF747FE6148FD +:103AB000FEF73AFF02232370D8E75E48FEF73AFF8D +:103AC0000028D3D0FFF71AFE5A48FEF72DFF032334 +:103AD000F1E75848FEF72EFF0028C7D00020FFF777 +:103AE0002DFE5448FEF720FF0423E4E75148FEF77B +:103AF00021FF0028BAD0FFF701FE4E48FEF714FF61 +:103B00000523D8E74B48FEF715FF0028AED000206C +:103B1000FFF714FE0023464A1370CCE70020FFF79E +:103B20000DFE0023C7E7484B1D78012D07D1002269 +:103B30001A70FFF7E3FD4148FEF7F6FE257038BD29 +:103B40003E48FEF7F7FE0028F9D00020FFF7F6FD0B +:103B50003A48FEF7E9FE02232370F0E73748FEF704 +:103B6000E9FE0028EBD0FFF7C9FD3448FEF7DCFE84 +:103B70000323F1E73148FEF7DDFE0028DFD0002007 +:103B8000FFF7DCFD2D48FEF7CFFE0423E4E72B48CA +:103B9000FEF7D0FE0028D2D0FFF7B0FD2748FEF791 +:103BA000C3FE0523D8E72548FEF7C4FE0028C6D08B +:103BB0000020FFF7C3FD2148FEF7B6FE0623CBE742 +:103BC0001E48FEF7B7FE0028B9D0FFF797FD1B4847 +:103BD000FEF7AAFE0723BFE71848FEF7ABFE002852 +:103BE000ADD00020FFF7AAFD1448FEF79DFE082384 +:103BF000B2E71248FEF79EFE0028A0D0FFF77EFD38 +:103C00000E48FEF791FE0923A6E70C48FEF792FE48 +:103C1000002894D00020FFF791FD00230A4A13707A +:103C20009AE700BF2C1000203C10002093100020C9 +:103C300090100020201000201C10002014100020E4 +:103C40000C1000200B1000208F1000204FF4E130EA +:103C5000FFF70CB90846FFF793B900000FB407B59A +:103C600004AA52F8041B0748019208F0EBFC05482F +:103C70000AF070FA80B2FFF783F903B05DF804EB45 +:103C800004B0704758300020F8B5234D234E2B88E0 +:103C9000B3F5806F38D2224C591C327889B2298012 +:103CA000E05422BB631813F8013C0A2B0DD11D48C8 +:103CB0000329037803F10103037004D962542046F9 +:103CC000C9B201F0B5F800232B80174B1B78102BDD +:103CD0000CD12988631813F8013C3E2B06D100262D +:103CE0000F486654C9B201F0A3F82E80F8BD0F4BFF +:103CF0001B888B42FAD8002720466754C9B2FCF7CC +:103D00004FFD2F803770F1E700232B803370084878 +:103D1000BDE8F84008F044BDA6100020A81000201F +:103D200050280020A21000207E110020A4100020A6 +:103D30001A28010801220C4B0C491A700C4B1A70FE +:103D400000230B700B490B700B490A700B4A137060 +:103D50000B4A13700B4A13700B4A13700B4A137003 +:103D60000B4A1370704700BF7211002073110020BE +:103D700070110020711100206F1100207B110020B4 +:103D80005838002074110020751100207611002091 +:103D90007A11002007B50121082007F0FFFB094B2D +:103DA00001A90948019307F022FB4FF4805106480E +:103DB00007F074FBFFF74AFF0022044B1A7003B0B0 +:103DC00000BD00BF00100310000C01405838002057 +:103DD0000123024A1370024A1370704772110020C7 +:103DE0007011002010B51D4B1A784AB901221E210E +:103DF0001B481A70FEF790FD50211A48FEF78CFD03 +:103E0000194C2378012B11D0022B1ED063B917480F +:103E100008F0C6FC4FF48051154807F03DFB1048F0 +:103E2000FEF782FD01232370002010BD0C48FEF731 +:103E300081FD0028F8D04FF480510D4807F02EFB8B +:103E40000848FEF771FD0223EDE70648FEF772FD14 +:103E50000028E9D0002301202370E6E76C11002040 +:103E6000641100205C11002059110020272801084E +:103E7000000C014038B5594B1A782AB90122642147 +:103E800057481A70FEF748FD564C23780A2B13D872 +:103E9000DFE803F006131D7780353E555E969E00E1 +:103EA000514A1578012D07D1002313704F4A50480D +:103EB000137008F075FC257038BD0B214D4800F0DB +:103EC00073FF4748FEF730FD02232370F4E74A4BA7 +:103ED00093F81F34012B04D1484808F061FC0523F6 +:103EE000F3E7642B04D1464808F05AFC0A23ECE7B8 +:103EF0003B48FEF71FFD0028DED04248F4E71321BF +:103F0000414800F051FF3648FEF70EFD0623DCE77E +:103F1000394B93F81F37012B04D13C4808F040FC83 +:103F20000723D2E7642B03D1394808F039FC1BE0A2 +:103F30002B48FEF7FFFC0028BED03648F5E71421D9 +:103F4000354800F031FF2648FEF7EEFC0823BCE7B9 +:103F5000294B93F87F37012B08D13048FCF72AFB17 +:103F60002F49304808F01CFC0323AEE7642B01D135 +:103F70002D48DAE71A48FEF7DDFC00289CD02B48D4 +:103F8000D3E70C212A4800F00FFF1548FEF7CCFCC0 +:103F900004239AE7184B93F87F34012B04D125486A +:103FA00008F0FEFB092390E7642B01D122489BE730 +:103FB0000B48FEF7BFFC00283FF47EAF1F4893E795 +:103FC00000250122084B1E481D70084B1A7070E72F +:103FD0000023054A1370054A137076E75811002034 +:103FE000501100204D1100206E1100206D11002095 +:103FF00091280108A728010824000020B228010800 +:10400000C1280108D3280108ED2801080B2901085F +:104010001A2901082D29010848290108541C0020EB +:10402000681C0020512901085D2901087029010838 +:104030008B29010898290108A9290108BD2901082F +:10404000D9290108F8B59D4B1A784AB90122642193 +:104050009B481A70FEF760FC14219A48FEF75CFC3E +:10406000994C9A4D2378172B1BD8013B162B1CD843 +:10407000DFE813F02A0036004900550063006C00A9 +:104080008300A400BF00C800DA00EF000E016C013D +:104090008B01A001BC01C501E001EB01FF0107029A +:1040A0000C02FF2B7ED016230CE0FFF79BFE0028AE +:1040B00078D00023864A1370864A1370864A82F8A5 +:1040C0004230012323706DE0844808F069FB012130 +:1040D000834800F069FE7A48FEF726FC0223F1E7E8 +:1040E000804B93F85F30012B04D17F4808F058FBD8 +:1040F0000323E7E77248FEF71DFC002852D07B48F7 +:1041000008F04EFBCFE77A4808F04AFB02217948D5 +:1041100000F04AFE6A48FEF707FC0423D2E7714B21 +:1041200093F8BF30012B01D10523CBE76448FEF79C +:1041300001FC002836D07048E2E703216F4800F008 +:1041400033FE5F48FEF7F0FB0623BBE7654B93F8B1 +:104150001F71012F0BD16A4E6A48314608F020FBCF +:104160000022694B06F8017C1A70FF23AAE7544825 +:10417000FEF7E0FBB0B16548C2E7634B1A78052A49 +:1041800007D900221A700422534B614883F8422059 +:10419000B6E76048042100F007FE08234948237071 +:1041A000FEF7C2FB2B78012B07D10026484B5A485B +:1041B0002E701E7008F0F4FA2670F8BD494B93F883 +:1041C0007F31012B0AD1554808F0EAFA544808F02B +:1041D000E7FA00224C4B1A70092373E73948FEF7BF +:1041E000A9FB0028DED0484A137801331370072357 +:1041F00068E705214B4800F0D7FD3148FEF794FBF6 +:104200000A235FE7374B93F8DF31012B05D146498D +:10421000464808F0C5FA0B2354E72948FEF78AFB05 +:104220000028BFD042486BE7374B1A780A2A07D9D3 +:1042300000221A700222284B3E4883F842205FE792 +:1042400006213D4800F0B0FD1E48FEF76DFB0C2333 +:1042500038E7244B93F83F32012B0FD11D4B1978CF +:1042600061B163290AD0354808F09AFA344808F059 +:1042700097FA0022244B1A700D2323E71148FEF70A +:1042800059FB00288ED0204A137801331370C2E7FF +:104290001D4B1A78142A07D900221A7002220E4BDD +:1042A000284883F842202BE70721274800F07CFDAF +:1042B0000448FEF739FB0E2304E700BF4C11002031 +:1042C000441100203C1100203A11002072110020FE +:1042D000731100209B38002058380020F129010874 +:1042E000FE29010824000020012A01080E2A0108E5 +:1042F000232A0108302A0108352A01084C2A01081E +:1043000059380020542A010839110020622A010876 +:10431000772A01089E2A0108352C0108A72A0108DE +:10432000B92A0108C92A010882380020D22A0108C6 +:10433000E12A0108FA2A01083B280108152B010887 +:104340002B2B0108402B0108612B0108564B93F8D9 +:104350009F32012B0AD1554808F022FA544808F040 +:104360001FFA0022534B1A700F23ABE65248FEF798 +:10437000E1FA00283FF416AF4E4B5048197801314E +:10438000C9B2197008F00CFA76E74A4B1A780A2A73 +:1043900007D900221A700322494B4A4883F8422069 +:1043A000AEE60821484800F0FFFC4348FEF7BCFA9F +:1043B000102387E63C4B93F8FF32012B07D1404A8C +:1043C000424882F8423008F0EBF911237AE63A4885 +:1043D000FEF7B0FA00283FF4E5AE364B37481978BF +:1043E0000131C9B2197008F0DBF9BDE7092138487D +:1043F00000F0DAFC3748FEF797FA122362E62A4B00 +:1044000093F85F33012B0DD12D4B93F82930012BFD +:1044100004D1314808F0C4F9132353E6022BFBD131 +:104420002E48F7E72B48FEF785FA00283FF4BAAE8E +:104430002B48EFE701222B4B26481A7000222A4B0B +:104440001A70FEF771FA14233CE6FFF713FD264BB2 +:104450001A78012A03D100221A70152332E61D486A +:10446000FEF768FA00283FF49DAE204808F098F95E +:10447000F3E700220F4B1A7001221D4B1A7017230D +:1044800020E61C4808F08CF900231BE62B78012B52 +:104490007FF488AE0026164B17482E701E7008F069 +:1044A0007FF926707EE600BF240000206A2B0108F9 +:1044B0007B2B0108391100203C110020962B0108AC +:1044C00058380020A32B0108BE2B0108C82B010877 +:1044D000DD2B010844110020E62B0108F32B010815 +:1044E000002C01086E1100206D1100200F2C010816 +:1044F00073110020222C0108352C010870B59F4B48 +:104500001A78CAB901221E219D481A70FEF704FAD2 +:104510001E219C48FEF700FA64219B48FEF7FCF937 +:1045200064219A48FEF7F8F914219948FEF7F4F946 +:10453000C8219848FEF7F0F9974C984E23780D2B38 +:1045400000F21681DFE813F00E00170040007B0038 +:1045500087005800640091009E00B400BF00D500A1 +:10456000F30000018E4B1D78012D19D18D4808F004 +:1045700017F9257014E08C4808F012F98B4B0A21CA +:1045800093F82930022B14BF89488A4800F00CFCAC +:104590007B48FEF7C9F97F48FEF7C6F9022323706E +:1045A0003378012B0FD100258348357008F0F8F8D7 +:1045B000824B25701D70824B1D707C4B1D70814B92 +:1045C0001D70814B1D7070BD804B93F8BF33012B64 +:1045D00004D17F4808F0E4F80523E0E7642B04D118 +:1045E0007C4808F0DDF80C23D9E76548FEF7A2F90E +:1045F0000028D5D07848F4E7784808F0D1F80C21A5 +:10460000774800F0D1FB5E48FEF78EF90623C6E737 +:104610006E4B93F87F24012A04D1724808F0C0F849 +:104620000323BCE793F81F34642B01D16E48D8E70D +:104630005348FEF77FF90028B2D06C48D1E76C48A8 +:1046400008F0AEF80B216B4800F0AEFB4C48FEF7CB +:104650006BF90423A3E75D4B93F81F34012BE3D1DF +:10466000654808F09DF8072399E7644808F098F832 +:1046700063480D2100F098FB082341482370FEF7A2 +:1046800053F98DE7514B93F8DF34012B04D15D488A +:1046900008F086F8092382E7642B01D15A48A0E785 +:1046A0003748FEF747F900283FF47AAF574898E7B4 +:1046B000574808F075F857480E2100F075FB0A239B +:1046C00031482370DBE7414B93F83F35012B04D190 +:1046D000514808F065F80B2361E7642B01D14F487E +:1046E0007FE72948FEF726F900283FF459AF4C48E8 +:1046F00077E70123314A4B481370314A13704A4A15 +:10470000118819444FF6FF7389B299420ABF0223F8 +:104710000B461946138008F043F80023294A13700A +:10472000294A13700122214B1A700D2337E73F48A5 +:1047300008F036F8244B3E4819780131C9B2197097 +:1047400008F02EF800232AE73378012B7FF43BAFE3 +:1047500000251948357008F023F8184B1D70184BC8 +:104760001D70124B1D70174B1D70174B1D7000E70D +:10477000304808F015F8FFF72BFB11E7381100203F +:1047800030110020281100202011002018110020D5 +:1047900010110020081100200511002070110020C8 +:1047A000731100204C2C0108672C01085838002098 +:1047B0007D2C0108972C0108862E01087B11002012 +:1047C00071110020751100207611002024000020B6 +:1047D000B22C0108C12C0108D32C0108F12C0108CE +:1047E0008B290108FC2C0108092D0108202D010846 +:1047F000412D0108A7280108522D0108652D010847 +:10480000742D01087E2D01088F2D0108A82D0108A7 +:10481000C72D0108DE2D01080B2E0108182E0108F6 +:10482000252E0108352E010878110020552E01088B +:104830006A2E01089F2E010870B5994B88B01A782E +:10484000FAB901224FF4167196481A70FEF764F80F +:104850004FF416719448FEF75FF81E219348FEF757 +:104860005BF864219248FEF757F8C8219148FEF79B +:1048700053F832219048FEF74FF80A218F48FEF78F +:104880004BF88F4C2378142B00F2E281DFE813F011 +:104890001500450054007F009400BF00D600ED00D5 +:1048A000E001E001E0017501E001E0018F01D901C3 +:1048B000E0019801A101B501BE018249824B0A784D +:1048C0001B78012A14D1012B04D100220A707F49E0 +:1048D0000A7023707E4B1E78012E07D100257D487B +:1048E0001D7007F05DFF7C4B25701E7008B070BD19 +:1048F000012BEFD16C48FEF71DF820B16A48FEF796 +:1049000013F81323E5E76748FEF714F80028E1D011 +:104910006448FEF709F81123DBE7704B70491A88E9 +:10492000684607F0B1FD1021684600F03DFA5F4887 +:10493000FDF7FAFF0223CCE76A4B93F8FF350A2B09 +:1049400004D1694807F02CFF0323C2E70C2B0CD1DC +:10495000664807F025FF0122654B1A70654B1978F0 +:10496000654807F01DFF0F23B3E70D2B01D1634806 +:10497000EFE74E48FDF7DEFF0028ABD0604807F0B8 +:104980000FFF5C4B19780131C9B21970E8E70022BA +:104990005C4B524D1A705C492A885C4809F0CCFB8C +:1049A00029885A48FFF756F9594807F0F9FE404858 +:1049B000FDF7BAFF04238CE74A4B93F8FF350B2B26 +:1049C00007D1544807F0ECFE3C48FDF7ADFF052346 +:1049D0007FE70C2B0ED1504B5048196807F0E0FED2 +:1049E0004F4807F0DDFE4F4B4F4819780131C9B2EF +:1049F0001970B6E72E48FDF79DFF00283FF46AAF17 +:104A0000454B4648196807F0CBFE4848E9E73D4B5F +:104A10001B78012B07D100223A4B45481A7007F04A +:104A2000BFFE0E2355E72548FDF784FF00283FF41D +:104A300051AF00223F4B1A7006234AE73E4807F069 +:104A4000AFFE3C4B1B78062B01D93C48C9E700233D +:104A50003B4A112113803B4A3B48138000F0A4F9E4 +:104A60001548FDF761FF072333E71E4B93F85F26D8 +:104A7000012A6FD1FF22334D314E83F85F263188F2 +:104A80002A88324807F08CFE32882B889A4261D1FE +:104A90002F4807F085FE0748FDF746FF0B2318E770 +:104AA00004110020FC100020F4100020EC10002065 +:104AB000E4100020DC100020D4100020CC100020D6 +:104AC000CA100020851100207B11002084110020D5 +:104AD0006F110020D73001088311002080110020C1 +:104AE000BC2E010824000020CB2E0108D92E01087D +:104AF0007411002076110020E92E0108002F010812 +:104B00001B2F0108A9100020583400205830002025 +:104B1000332F01084A2F0108C40F00205D2F010820 +:104B20006E2F0108751100207F2F0108952F0108B5 +:104B3000B42F0108C9100020C92F0108E62F010871 +:104B4000AC100020AA100020073001081530010821 +:104B5000323001083F4B1B78012B3FF45CAF3E48DD +:104B6000FDF7E8FE00283FF4B5AE3C4807F018FE1C +:104B70003B4A1378013313705EE7364B1B78012BE9 +:104B80003FF449AF3748FDF7D5FE00283FF4A2AE09 +:104B90000122354B35481A7007F002FE344B354878 +:104BA00019780131C9B2197007F0FAFD23E001222A +:104BB000314B1A700023314A13702D4A137088E666 +:104BC00006212F4800F0F0F82E48FDF7ADFE122325 +:104BD0007FE62D4B93F83F32012B06D12B4B1978F2 +:104BE00019B1632901D02A48DEE72648FDF7A2FE65 +:104BF00000283FF46FAE00236BE61421254800F037 +:104C0000D3F82048FDF790FE142362E61E4B93F87C +:104C10007F37012B07D1204A20481370FBF7CAFCCD +:104C20001F492048C0E7642B03D11F4807F0B8FD97 +:104C3000E1E71448FDF77EFE00283FF44BAE1B4829 +:104C4000F4E71B4807F0ACFD01221A4B1A70D2E7BB +:104C50001948EBE7A9100020D41000204D300108BE +:104C6000C9100020DC1000208211002064300108EF +:104C7000751100207F2F010884110020761100207B +:104C80003B280108EC100020240000209B38002065 +:104C90008730010848290108000F0020541C00201B +:104CA000681C0020512901085D29010870290108AC +:104CB0009930010883110020B030010808B5204B5D +:104CC0001A786AB901221E211E481A70FDF724FEC7 +:104CD00064211D48FDF720FE0A211C48FDF71CFE3B +:104CE0001B4B1A78012A06D100221A481A7007F0C5 +:104CF00057FDFFF71FF8184B1A78022A06D9002231 +:104D000016481A7007F04CFDFFF714F8144B1A7888 +:104D1000022A06D9002213481A7007F041FDFFF756 +:104D200009F8114B1A78012A08D100220F481A708D +:104D300007F036FDBDE80840FEF7FCBF08BD00BF28 +:104D4000C8100020C0100020B8100020B0100020B3 +:104D500074110020EE30010875110020083101089F +:104D6000761100202C3101087A11002055310108FC +:104D700008B5FFF767F9FFF7C1FBFFF75DFDBDE879 +:104D80000840FFF79BBF002330B5DCB2A24201D838 +:104D9000002030BDC55C2DB1CC5C1CB1A54203F137 +:104DA0000103F2D00120F4E76022064B1970064B94 +:104DB000013902FB0133FF220146044883F85F20DA +:104DC000FEF74CBF7E11002024000020972401082C +:104DD0002DE9F843002580460E272E4639460A2045 +:104DE00018F8014BFBF7D6FB303C61434FEAE479FE +:104DF00000FB0911A4FB0040013F64190144FFB20C +:104E000041EB0606FF2F2546E8D1084B320E5A74B7 +:104E1000320C9A74320ADA74220E5A75220C9A7580 +:104E2000220A1E75DA751C76BDE8F8835838002012 +:104E300002292DE9F84F05468B464FD0964E37781C +:104E40001D2F4BD8431813F8022C0D2A03D113F849 +:104E5000013C0A2B07D0102F40D1904B5B4413F834 +:104E6000013C3E2B3AD160230022013F5F438C4C32 +:104E700007F14108A044D3B218F80330924601323A +:104E8000002BF8D150372744DAB2BA5C9946013387 +:104E9000002AF9D12846834907F012FD00283FD0A7 +:104EA0002846814907F00CFDD0B1804809F052F93D +:104EB0007E49C2B22846FFF766FF78B97C4928468A +:104EC00007F0FEFC7A49013007F0FAFC013006F0E9 +:104ED00070FE784B1880784B01221A70BDE8F88F6D +:104EE0002846764907F0ECFC08B1754BF4E72846F4 +:104EF000744907F0E5FC20B17348BDE8F84F07F0AE +:104F00004FBC2846714907F0DBFC08B17048F4E754 +:104F10002846704907F0D4FC0028DFD06E48ECE743 +:104F200033785FFA8AFA013B5FFA89F9132BD5D8F7 +:104F3000DFE813F014003B0047005B0066008100CF +:104F40009200A200E80021014B01360160017501C9 +:104F500018028801C101F1012D0266025F4809F0C3 +:104F6000F9F85E49C2B22846FFF70DFF40B960224A +:104F70003378013B02FB0343012283F85F201EE0EC +:104F8000574809F0E7F85649C2B22846FFF7FBFE3A +:104F90000028ECD0534809F0DDF85349C2B2284646 +:104FA000FFF7F1FE002899D1CCE052462946404651 +:104FB000FFF7E9FE0028EDD1012384F8BF303070FF +:104FC0008CE7BBF1110F89D1012384F81F31002434 +:104FD00029460F224548347009F0AEF8444804745D +:104FE000BDE8F84F0130FFF7F3BE52462946404670 +:104FF000FFF7C9FE0028CDD1012384F87F31DEE719 +:10500000524629464046FFF7BEFE07460028C1D15A +:105010001422384805F1080109F08EF86022344B5B +:1050200083F83E7033783770013B02FB0343012263 +:1050300083F85F2052E7524629464046FFF7A3FE19 +:105040000028A7D101233070A81D84F83F3206F054 +:10505000B0FD294B187041E7524629464046FFF7FC +:1050600092FE18B9012384F89F32A8E72348FFF77E +:105070008AFE0028F6D08DE7524629464046FFF7C3 +:1050800082FE18B9012384F8FF3298E71C48FFF725 +:105090007AFE0028F6D07DE77E11002050280020FF +:1050A00024000020663101086D31010872310108C9 +:1050B00081310108A4100020A810002083310108CC +:1050C0007A1100208A31010898310108AA310108BB +:1050D000B2310108C6310108CF310108FE290108AB +:1050E0002A320108E2310108E8310108593800206C +:1050F00058380020823800209B380020F431010805 +:10510000FF3101082846AC4907F0DAFB18B3012249 +:10511000AA4BA94883F8292009F01CF80246A649A1 +:10512000A74809F009F8524629464046FFF72BFEEA +:1051300000283FF41CAF4A463846FFF724FE0028FB +:105140007FF428AF60223378013B02FB03436422E3 +:1051500083F85F20C2E628469A4907F0B1FB002891 +:10516000E1D00222954B974883F8292008F0F2FFFE +:1051700094490246D4E7524629464046FFF703FECB +:1051800018B9012384F8BF3319E74A463846FFF7B8 +:10519000FAFD00287FF4FEAE642384F8BF339DE659 +:1051A000524629464046FFF7EEFD18B9012384F820 +:1051B0007F3404E74A463846FFF7E5FD00287FF4D0 +:1051C000E9AE642384F87F3488E652462946404697 +:1051D000FFF7D9FD18B9012384F81F34EFE64A46DA +:1051E0003846FFF7D0FD00287FF4D4AE642384F85E +:1051F0001F3473E6524629464046FFF7C4FD18B9EE +:10520000012384F8DF34DAE64A463846FFF7BBFD6F +:1052100000287FF4BFAE642384F8DF345EE6524694 +:1052200029464046FFF7AFFD18B9012384F83F3502 +:10523000C5E64A463846FFF7A6FD00287FF4AAAE29 +:105240006423F3E7012229465F48FFF79CFD18B964 +:105250000A2384F8FF3541E607225C48FFF793FDF7 +:1052600018B90B2384F8FF35A9E609225848FFF73F +:105270008AFD08B90C23F5E705225648FFF783FDA0 +:105280000028F7D006225448FFF77DFD08B90D230A +:10529000E8E7504808F05EFF2946C2B24F48FFF7E2 +:1052A00072FD00287FF41AAE60223378013B02FBC6 +:1052B00003430C2261E6524629464046FFF763FD50 +:1052C000F0B92846464907F0FBFA20B1023006F053 +:1052D00070FC444B18802846434907F0F1FA20B18E +:1052E000013006F066FC414B188060223378013BA8 +:1052F00002FB0343012283F85F2000233370EDE5B6 +:105300004A463846FFF73FFD00287FF443AE64234A +:1053100084F85F36E2E5524629464046FFF733FD02 +:1053200050B93349284607F0CBFA013006F041FC6A +:10533000304B1870304BCFE502223048FFF723FD89 +:1053400028B9012384F8BF362B4B187037E64A463C +:105350003846FFF718FD00287FF41CAE642384F85C +:10536000BF36BBE5524629464046FFF70CFD18B94B +:10537000012384F89F3522E64A463846FFF703FDAD +:1053800000287FF407AE642384F89F35A6E55246D3 +:1053900029464046FFF7F7FC18B9012384F81F3768 +:1053A0000DE64A463846FFF7EEFC00287FF4F2ADE2 +:1053B000642384F81F3791E50B3201085838002028 +:1053C0007138002018320108233201082532010803 +:1053D0002D320108E231010837320108E8310108B5 +:1053E000F2310108AC10002081310108AA10002020 +:1053F000882401087C1100207D1100202A32010838 +:10540000524629464046FFF7BEFC002840D1012302 +:1054100029493070284684F87F3707F051FA4278DE +:105420008178303A254B01F5F46102EB820201EB01 +:1054300042021A8002794179303A303902EB820215 +:1054400001EB42029A70C279017A303A303902EBAC +:10545000820201EB4202DA70827AC17A303A303944 +:1054600002EB820201EB42021A71427B817B303AED +:10547000303902EB820201EB42025A71027C417C1C +:10548000303A02EB8202303901EB42029A7125E593 +:105490000B4808F05FFE0B49C2B22846FFF773FCC9 +:1054A00000287FF41BAD60223378013B02FB0344EC +:1054B000642384F85F3011E57F310108541C00201B +:1054C000E2310108E8310108F8B54B780A788E78A6 +:1054D0001B0204460F4643EA024305210A201E43ED +:1054E000FBF758F802460B46304600210CF0D8FB7B +:1054F000042120700A20FBF74DF802460B46304687 +:1055000000210CF0CDFB0A2200230CF0C9FB032183 +:1055100062700A20FBF73EF802460B463046002137 +:105520000CF0BEFB0A2200230CF0BAFB0221A27091 +:105530000A20FBF72FF802460B46304600210CF0FC +:10554000AFFB0A2200230CF0ABFB0121E2700A2022 +:10555000FBF720F80A2502460B46304600210CF0E6 +:105560009FFB0A2200230CF09BFBB6FBF5F305FB27 +:1055700013662271667107212846D7F80360FBF78E +:1055800009F836BA02460B46304600210CF088FB7B +:105590000621A0712846FAF7FDFF02460B46304669 +:1055A00000210CF07DFB0A2200230CF079FB052181 +:1055B000E2712846FAF7EEFF02460B46304600211C +:1055C0000CF06EFB0A2200230CF06AFB042122720D +:1055D0002846FAF7DFFF02460B46304600210CF062 +:1055E0005FFB0A2200230CF05BFB0321627228465A +:1055F000FAF7D0FF02460B46304600210CF050FB74 +:105600000A2200230CF04CFB0221A2722846FAF772 +:10561000C1FF02460B46304600210CF041FB0A2236 +:1056200000230CF03DFB0121E2722846FAF7B2FF9D +:1056300002460B46304600210CF032FB0A220023C2 +:105640000CF02EFBB6FBF5F305FB136622736673B5 +:10565000FB79B3FBF5F3A373FB79B3FBF5F205FB21 +:105660001233E3733B7AB3FBF5F205FB1233237479 +:10567000F8BD000010B5044686B00A4601A80749E7 +:1056800006F002FF621E01AB0F3413F8011B303924 +:1056900002F8011FA242F8D106B010BDB53B0108C7 +:1056A000002330B5421E01390F3012F8015F11F8A6 +:1056B000014F904205FB04339BB2F6D10B22B3FBA2 +:1056C000F2F102FB113080B20A2802D018B1C0B248 +:1056D00030BD0020FCE70520FAE70000F8B51F4CBC +:1056E0001F492046FFF7F0FE1E491F48FFF7C2FF83 +:1056F00020461D49FFF7D4FF237C83422CD11B4851 +:1057000007F04EF827461125194E17F8011B1948C6 +:1057100001F1300306F8013B013D07F041F815F0B7 +:10572000FF05F2D1144807F03BF8A27B134B42B9B6 +:10573000E27B012A0ED112481A7007F031F80120DD +:10574000F8BD052A06D1E27B052A03D102220D48C5 +:105750001A70F2E700221A700020F1E7A911002068 +:10576000C91100203E3201089D3800205E32010838 +:10577000881100206D240108E9200108861100200D +:10578000693201088432010838B5044608480D1909 +:1057900007F006F8AC4204D1BDE83840044806F0F2 +:1057A000FFBF14F8011B034806F0FAFFF2E700BF41 +:1057B000E9200108D32101082DE9F0438BB002AFA5 +:1057C00020220021384606F0FDFFDFF81891212243 +:1057D0000021444806F0F6FF20220021424806F04E +:1057E000F1FF4D464FF00008404E3F4C32782846BE +:1057F0003F49120906F048FE16F8012B681C1309F0 +:1058000023703B4902F00F0206F03EFE16F8013C01 +:1058100008F1020803F00F03B8F1200F637005F1DF +:10582000020504F10204E1D1002399F80020462A80 +:1058300038D1304A13702F4C2F48217806F0B0FF32 +:1058400021782948FFF7A0FF26492C4806F0A8FF39 +:105850002278A2F10A030A2B42D8002438462149B3 +:1058600008F06AFC3846ADF8044008F073FC431EAB +:1058700003F0010348BF5B421D464FF00A08C6B261 +:105880003744AEB90A2394FBF3F203FB124424BB62 +:1058900003221B4B1B481A7006F082FF01200BB03D +:1058A000BDE8F0830133202B09F10109BDD1C2E726 +:1058B00017F8013D01A88DF8043006F07AF906F0DA +:1058C00001039D4208BF400090FBF8F208FB120064 +:1058D00014440444701EC6B2D3E70B4806F060FFC0 +:1058E0000020DCE788110020A9110020C911002048 +:1058F0009F32010887110020A4320108B13201084B +:1059000086110020BD320108CE3201082DE9F04198 +:10591000254C23787A2B45D163786C2B42D12122F8 +:1059200000212248224D06F04DFF20220021204870 +:1059300006F048FF0027A8461C4E227830461D4935 +:10594000120906F0A1FD14F8012B701C13092B702D +:10595000184902F00F0206F097FD14F8013C0237D7 +:1059600003F00F03202F6B7006F1020605F102050C +:10597000E3D10A2198F8043098F805200E4801FB7D +:10598000032203320D4B5200D2B208491A7006F0BE +:1059900007FF03220A4B0B481A7006F001FF012093 +:1059A000BDE8F0810020FBE7C9110020881100202C +:1059B000A91100209F320108DD3201088711002063 +:1059C00086110020F332010807B50121052005F0FA +:1059D000E5FD064B01A90648019305F008FD4FF4CB +:1059E0000041034805F058FD03B000BD00800310DE +:1059F0000008014008B5FFF771FE20B10848BDE876 +:105A0000084006F0CDBEFFF7D7FE08B10548F6E71F +:105A1000FFF77CFF08B10448F1E70448EFE700BF57 +:105A20000A33010819330108263301083533010808 +:105A300008B5C82005F07AFC08210748FDF722F9CF +:105A4000C82005F073FC05481521FDF71BF9BDE8DA +:105A50000840C82005F06ABC790B0020640B0020C8 +:105A600038B506F02DFF08B9002038BD0F4906F003 +:105A700027FF0028F8D0441C204608F06BFB431E8B +:105A80001B06F1D40A4D802200212870094806F037 +:105A900099FE21462A78074808F04EFB054A2978E6 +:105AA000054806F07DFE0120DFE700BF4233010814 +:105AB000D9110020AE38002044330108F8B504465F +:105AC00008F048FB234685B2002061198B4219D1AA +:105AD000204608F03FFB294682B22B4806F060FEC4 +:105AE0002A49204606F0ECFE0646204608F032FB26 +:105AF0007F280FD9264806F053FEBDE8F840254818 +:105B000006F04EBE1A780D2A01D00A2A00D118706C +:105B10000133DBE7DEB1304608F01CFB01221E4BEF +:105B20001E4FC5B231461A7038702A461C4808F01C +:105B300003FB00231A4A1B48535506F031FE18494F +:105B4000194806F02DFE3978184806F029FE20463F +:105B50001749FFF785FF174D074628B1164806F08D +:105B60001FFE01232B70F8BD204608F0F3FA0B4E00 +:105B70003946307080220A4806F024FE21463278E9 +:105B8000074808F0D9FAECE75833010869330108EF +:105B90007133010880330108DA110020D911002087 +:105BA000AE38002095330108A6330108B43301084C +:105BB000C5330108DE110020E733010810B51B4B87 +:105BC0001A7852B90122642119481A70FCF7A4FE10 +:105BD0004FF496711748FCF79FFE1548FCF7AAFE94 +:105BE00010B11348FCF7A0FE134B144C1A78144B59 +:105BF00010481B789A4238BF1A46124B1B789342C2 +:105C000038BF13462370FCF795FE70B10948FCF7C6 +:105C10008BFE20780BF04CFE0BF064FABDE81040D0 +:105C200002460B46084806F0BBBD10BDF01100202F +:105C3000E8110020E0110020F3110020F4110020F1 +:105C4000F2110020F1110020FC33010808B50021F9 +:105C500001200C4A00F02AFD00210220094A00F030 +:105C600025FD00210320074A00F020FD0021064AFF +:105C7000084600F01BFDBDE8084000210220034A51 +:105C800000F014BD13340108243401083534010830 +:105C90001E2903460A4614D8B9B101391D2914D862 +:105CA000DFE801F01513191B1D131F211323131314 +:105CB0002527292B192D1313131313131313131340 +:105CC000132F3F291FD0402921D0124901E0124A49 +:105CD0001249184619E0124AFAE7124AF8E7124A3E +:105CE000F6E7124AF4E7124AF2E7124AF0E7124ADC +:105CF000EEE7124AECE7124AEAE7124AE8E7124AEC +:105D0000E6E7124AE4E7124A044906F0BDBB114A2D +:105D1000FAE700BF6D340108A0340108B53B010863 +:105D200046340108493401084C3401084F34010855 +:105D30005234010855340108583401085B34010815 +:105D40005E3401086134010864340108AA34010892 +:105D5000673401086A3401081E29034614D8B9B112 +:105D600001391D2914D8DFE801F01513191B1D1383 +:105D70001F21232323132527292B192D1313131335 +:105D8000131313131313132F3F291FD0402921D0AE +:105D9000114A00E0114A1846114919E0114AFAE780 +:105DA000114AF8E7114AF6E7114AF4E7114AF2E717 +:105DB000114AF0E7114AEEE7114AECE7114AEAE727 +:105DC000114AE8E7114AE6E7114AE4E7114A0449B3 +:105DD00006F05ABB104AFAE71F3401087134010873 +:105DE000B53B0108763401087B3401088034010892 +:105DF000853401088A340108EC4001088F34010819 +:105E000094340108993401089E340108A334010830 +:105E1000A8340108673401086A34010870B50E46D9 +:105E200014461D469CB000210120214A00F03EFC92 +:105E3000002102201E4A00F039FC1D4A00210320E7 +:105E400000F034FC314608A8FFF722FF21460DA8D8 +:105E500012ACFFF71DFF2946204617ADFFF718FFCC +:105E600028469DF88010FFF713FF124B1B78042B78 +:105E70000DD0052B13D0022100200F4A00F016FC94 +:105E8000002102200D4A00F011FC1CB070BD0C492D +:105E900000940DAB08AA03A806F0F6FAEBE7CDE9EB +:105EA000004508490DAB08AA03A806F0EDFAE2E7A1 +:105EB000133401081D000020C93401081019002006 +:105EC000AD340108BA34010838B52B4B1C78F4B94D +:105ED00001250A2129481D70FCF71EFD2146284690 +:105EE000274A00F0E3FB21460220254A00F0DEFBB2 +:105EF00021460320224A00F0D9FB02212046214AF4 +:105F000000F0D4FB214602201F4A00F0CFFB1F4BBC +:105F10001A7822BB1E4A19481278012A08BF1A7043 +:105F2000FCF708FDD8B11B4C1448FCF7FDFC2378A6 +:105F3000032B0DD8DFE803F002141618104A0021D5 +:105F4000022000F0B3FB144A0021022000F0AEFB57 +:105F500023780133DBB2032B88BF0023237038BDC5 +:105F60000E4AF1E70E4AEFE7054A0021022000F051 +:105F70009DFB054AE8E700BF201200201812002010 +:105F800013340108D2340108DB3401081612002052 +:105F90005838002015120020EC340108FD340108A7 +:105FA0000E35010808B500F07DFB0021164A0846B1 +:105FB00000F07CFB00210120134A00F077FB002158 +:105FC0000220114A00F072FB002103200E4A00F06B +:105FD0006DFB012100200D4A00F068FB002102202A +:105FE0000B4A00F063FB032000210A4A00F05EFB2D +:105FF000094B1878431E1F2B05D8BDE80840033015 +:10600000C00800F055BB08BD133401082634010850 +:106010001F350108303501089B38002008B50021E4 +:1060200001200F4A00F042FB002102200C4A00F040 +:106030003DFB002103200A4A00F038FB022100202A +:10604000084A00F033FB00210220074A00F02EFB33 +:10605000BDE8084000210320044A00F027BB00BF30 +:1060600013340108413501084A3501085B35010840 +:1060700008B5002101200A4A00F018FB0021022087 +:10608000074A00F013FB00210320054A00F00EFB35 +:10609000BDE8084000210220024A00F007BB00BF13 +:1060A000133401086C3501082DE9F043002406463D +:1060B0008DB00120894615462146364A98460094FF +:1060C000149FCDF8034000F0F1FA21460220314A36 +:1060D00000F0ECFA032021462E4A00F0E7FA701E89 +:1060E000042840D8DFE800F0033742474C00B9F1FC +:1060F000000F2DD0694605F10A03103513F8012F62 +:106100003032AB4201F8012BF8D16A46224902A88D +:1061100006F0BAF938460BF0CBFB20490BF0D4FC63 +:106120000AF0E0FF0B4602461D4907A806F0ACF94D +:106130001C4B197819B901201B4A00F0B7FA02AAC2 +:106140000021022000F0B2FA07AA0021032008E093 +:1061500042461649DBE7164806F022FB154A0021A5 +:10616000022000F0A3FA0DB0BDE8F083124806F05B +:1061700017FB124AF3E7124806F012FB114AEEE74A +:10618000114806F00DFB114A0021022000F08EFAA2 +:106190000F4ADAE7133401087D3501080000C842D0 +:1061A0008A350108220000209E3501089535010836 +:1061B000AF350108BC350108CD350108DC350108D3 +:1061C000ED350108FA3501080B36010818360108CB +:1061D0002936010810B5044686B0002103200A4A7A +:1061E00000F064FA5CB12246084901A806F04CF9B7 +:1061F0000021032001AA00F059FA06B010BD04499D +:1062000001A806F041F9F3E7133401083A36010812 +:106210004B360108F0B507469DB000201C460E46DF +:10622000154600F041FA0021454A084600F03EFAC2 +:1062300000210120424A00F039FA00210220404AA0 +:1062400000F034FA3E4A0021032000F02FFA3D4BC3 +:1062500003A81978FFF780FD38460BF029FB3A496F +:106260000BF032FC0AF03EFF03AACDE900013749EA +:1062700008A806F009F9364B03A81978FFF76CFD5A +:1062800030460BF015FB30490BF01EFC0AF02AFFDC +:1062900003AACDE900012D490DA806F0F5F82D4B14 +:1062A00003A81978FFF758FD28460BF001FB264993 +:1062B0000BF00AFC0AF016FF03AACDE900012349FE +:1062C00012A806F0E1F8244B03A81978FFF744FD63 +:1062D00020460BF0EDFA1C490BF0F6FB0AF002FF2A +:1062E00003AACDE90001194917A806F0CDF81B4B08 +:1062F0001B78042B03D0052B11D01DB0F0BD00215D +:10630000012008AA00F0D2F90DAA0021022000F015 +:10631000CDF912AA0021032000F0C8F9EDE7002111 +:1063200008AA084600F0C2F9002101200DAA00F0D9 +:10633000BDF912AA0021022000F0B8F917AAE9E776 +:10634000133401081B0000200000C8425C3601081D +:106350001A00002019000020180000201D00002055 +:1063600010B588428AB094BF081A00200C460BF082 +:106370009FFA20490BF0A8FB0AF0B4FE02460B4638 +:1063800068461D4906F080F820460BF091FA19493D +:106390000BF09AFB0AF0A6FE0B460246174905A829 +:1063A00006F072F80021164A084600F07FF9002135 +:1063B0000120134A00F07AF900210220104A00F06F +:1063C00075F9002103200E4A00F070F90221002027 +:1063D0000C4A00F06BF96A460021022000F066F9D1 +:1063E000002105AA032000F061F9012000F05CF90A +:1063F0000AB010BD0000C842693601088A3501089C +:106400001334010841350108002108B50846134A34 +:1064100000F04CF900210120104A00F047F900215A +:1064200002200E4A00F042F9002103200B4A00F03E +:106430003DF9022100200A4A00F038F9002102202B +:10644000084A00F033F903200021074A00F02EF932 +:10645000BDE80840012000F027B900BF133401084F +:106460004135010874360108853601087FB51346A9 +:106470000A46F0B1114901A806F006F800210120F2 +:106480000F4A00F013F9002102200D4A00F00EF926 +:10649000002103200A4A00F009F900210220094ADC +:1064A00000F004F90021032001AA00F0FFF807B072 +:1064B00000BD054901A805F0E7FFDFE796360108B2 +:1064C00013340108B2360108A63601087FB502462A +:1064D0000F4901A805F0D8FF002101200D4A00F066 +:1064E000E5F8002102200B4A00F0E0F8002103202B +:1064F000084A00F0DBF801AA0021022000F0D6F8DB +:1065000000210320044A00F0D1F807B000BD00BF0D +:10651000C336010813340108D03601087FB502469E +:106520000F4901A805F0B0FF002101200D4A00F03D +:10653000BDF8002102200B4A00F0B8F8002103202A +:10654000084A00F0B3F801AA0021022000F0AEF8DA +:1065500000210320044A00F0A9F807B000BD00BFE5 +:10656000C336010813340108DF3601087FB502463F +:106570000F4901A805F088FF002101200D4A00F015 +:1065800095F8002102200B4A00F090F8002103202A +:10659000084A00F08BF801AA0021022000F086F8DA +:1065A00000210320044A00F081F807B000BD00BFBD +:1065B000C336010813340108F036010870B52F4BBB +:1065C0001A7872B9012232212D481A70FCF7A4F909 +:1065D00032212C48FCF7A0F94FF416712A48FCF739 +:1065E0009BF92A4C2A4E2378012B1DD9022B23D04C +:1065F000284A96F842301178994205D0022B137040 +:1066000033D1052000F054F8234B1878234B1A7827 +:10661000824232D01870431E1F2B2ED8BDE8704026 +:106620000330C00800F044B81548FCF783F900288F +:10663000DED002232370DBE7194D2B78002BD7D156 +:10664000FFF742FC3378012B04D12B70FFF7AAFC33 +:10665000032323700C48FCF76DF90028C8D00123F0 +:106660002B70FFF79FFC0323E4E7032B01D10620E7 +:10667000C8E7042BC8D10720C4E770BD141200205E +:106680000C12002004120020FC110020F811002040 +:1066900058380020F61100209B380020F51100200A +:1066A000F711002000F08EB800F0D2B800F0DCB88E +:1066B00000F0F4B838B50546002405FA04F31B06CB +:1066C0004FF0400109480DD504F0E6FE20210748AF +:1066D00004F0E2FE01342021044804F0DFFE082C1F +:1066E000EBD138BD04F0DAFEF0E700BF000C01404A +:1066F00008B5FC20FFF7DEFF08BD000010B504461A +:1067000080210D4804F0C8FEFFF7F2FFF820FFF7E4 +:10671000D1FF04F0F000FFF7CDFF200100F0F00002 +:10672000FFF7C8FF642004F0E7FDBDE810408021BA +:10673000014804F0B3BE00BF000C014010B5044690 +:1067400080210D4804F0A8FEFFF7D2FFFA20FFF7E2 +:10675000B1FF04F0F000FFF7ADFF200100F0F00002 +:10676000FFF7A8FF642004F0C7FDBDE810408021BA +:10677000014804F093BE00BF000C014038B534203E +:10678000FFF7BCFF3620FFF7B9FF002565F07F005B +:10679000C0B2FFF7B3FF8020FFF7B0FF2024002036 +:1067A000013CFFF7CBFF14F0FF04F8D10135202D99 +:1067B000ECD13620FFF7A2FFBDE838403020FFF7CC +:1067C0009DBF000007B50121082004F0E7FE01216C +:1067D000082004F0E3FE0121082004F0DFFE184B3E +:1067E00001A91848019304F002FE174B01A91548AE +:1067F000019304F0FCFD154B01A91248019304F02C +:10680000F6FD022004F092FD3020FFF777FF05200F +:1068100004F08CFD0C20FFF771FF052004F086FDCD +:106820000120FFF76BFF052004F080FD0620FFF735 +:1068300065FF052004F07AFDFFF7A0FF03B000BD5F +:1068400020000310000C01404000031080000310E2 +:1068500008B501280CBF36203420FFF74FFFBDE8F4 +:1068600008403020FFF74ABF0023032898BF0A4B97 +:1068700010B598BF1B5C14465818C0B2FFF73EFF16 +:10688000013C14F8010F00B910BDFFF757FF32208B +:1068900004F032FDF5E700BF4951010838B5044660 +:1068A000114D3420FFF72AFF362005EB4415FFF782 +:1068B00025FF83242046FFF721FF8020FFF71EFFDE +:1068C00001342878FFF73AFFE4B26878FFF736FF23 +:1068D000932C05F10205EDD13620FFF70FFFBDE83F +:1068E00038403020FFF70ABF4D51010807B501219C +:1068F000102004F053FE0121102004F04FFE01216E +:10690000042004F04BFE0121042004F047FE012185 +:10691000082004F043FE0121082004F03FFE204B34 +:1069200001A92048019304F062FD04211D4804F0F0 +:10693000B5FD1D4B01A91B48019304F058FD08212A +:10694000184804F0ABFD194B01A91948019304F054 +:106950004EFD0121164804F0A1FD164B01A9144873 +:10696000019304F044FD0221114804F097FD124BFD +:1069700001A91248019304F03AFD4FF400510F4869 +:1069800004F08CFD0E4B01A90C48019304F02FFD7F +:106990004FF48041094804F081FD03B000BD00BF01 +:1069A0000400031000100140080003100100031050 +:1069B000000801400200031000200310000C0140F9 +:1069C0000040031008B5431E0146052B2CD8DFE814 +:1069D00003F0030B11171D240421164804F05CFD7D +:1069E000154B01221A7008BD0821124804F054FD0D +:1069F000124BF6E70121124804F04EFD114BF0E76F +:106A000002210F4804F048FD0F4BEAE74FF4005114 +:106A10000E4804F041FD0E4BE3E74FF480410B4874 +:106A200004F03AFD0B4BDCE70B48BDE8084005F0ED +:106A3000B7BE00BF00100140261200202512002022 +:106A4000000801402412002023120020000C014005 +:106A50002212002021120020FD36010808B5431E35 +:106A60000146052B2CD8DFE803F0030B11171D247A +:106A70000421164804F012FD154B00221A7008BDBF +:106A80000821124804F00AFD124BF6E701211248D2 +:106A900004F004FD114BF0E702210F4804F0FEFC66 +:106AA0000F4BEAE74FF400510E4804F0F7FC0E4B91 +:106AB000E3E74FF480410B4804F0F0FC0B4BDCE7BC +:106AC0000B48BDE8084005F06BBE00BF0010014058 +:106AD0002612002025120020000801402412002068 +:106AE00023120020000C014022120020211200205D +:106AF000FD36010813B50121082004F04FFD0121E6 +:106B0000102004F04BFD0121102004F047FD01216D +:106B1000102004F043FD0121102004F03FFD01216D +:106B2000042004F03BFD0121042004F037FD012185 +:106B3000042004F033FD2B4B01A92B48019304F0F2 +:106B400056FC4FF40041284804F0A8FC274B01A94B +:106B50002748019304F04BFC4021254804F09EFC9B +:106B6000244B01A922480193234C04F040FC8021CE +:106B70001F4804F093FC01A91D48019404F037FC60 +:106B80004FF480711A4804F089FC1C4B01A9184885 +:106B9000019304F02CFC4FF40071154804F07EFCC6 +:106BA00001A91748019404F022FC4FF480711448A5 +:106BB00004F074FC134B01A91148019304F017FC75 +:106BC0004FF400610E4804F069FC0F4B01A90C481A +:106BD000019304F00CFC4FF48051094804F05EFC72 +:106BE00002B010BD00800310000C014040000310F3 +:106BF0000010014080000310000103100002031088 +:106C0000000801400008031000100310014610B5F1 +:106C1000441E1C4805F0C4FD032C0FD8DFE804F027 +:106C2000020F1A264FF40041174804F037FC4021A8 +:106C3000164804F031FC164B01221A7010BD802159 +:106C4000124804F02BFC4FF48071104804F024FC2F +:106C5000104BF1E74FF400710C4804F01FFC4FF4A7 +:106C600080710D4804F018FC0C4BE5E74FF400610F +:106C7000094804F013FC4FF48051074804F00CFC61 +:106C8000074BD9E719370108000C014000100140FB +:106C90002A1200202912002000080140281200209A +:106CA00027120020014610B5441E1C4805F078FD4F +:106CB000032C0FD8DFE804F0020F1A264FF400412E +:106CC000174804F0E9FB4021164804F0E7FB164B97 +:106CD00002221A7010BD8021124804F0DDFB4FF42F +:106CE0008071104804F0DAFB104BF1E74FF40071AB +:106CF0000C4804F0D1FB4FF480710D4804F0CEFB3A +:106D00000C4BE5E74FF40061094804F0C5FB4FF474 +:106D10008051074804F0C2FB074BD9E72E37010822 +:106D2000000C0140001001402A120020291200200E +:106D3000000801402812002027120020013810B559 +:106D4000032815D8DFE800F0021524344FF4004181 +:106D50001F48204C04F0A2FB40211F4804F09EFB7A +:106D600023781BB101211D4805F01AFD0023237073 +:106D700010BD802118481A4C04F090FB4FF480712C +:106D8000154804F08BFB2378002BEFD00221EAE7B3 +:106D90004FF400711048134C04F080FB4FF48071E5 +:106DA000114804F07BFB2378002BDFD00321DAE7C6 +:106DB0004FF400610C480D4C04F070FB4FF480510F +:106DC000094804F06BFB2378002BCFD00421CAE7DD +:106DD000000C01402A120020001001404337010836 +:106DE000291200202812002000080140271200204C +:106DF00010B5244B1A782AB90122142122481A709E +:106E0000FBF78AFD214C2378032B38D8DFE803F009 +:106E1000020D172D4FF480711D4804F037FB08B99F +:106E2000032300E00123237007E00120FFF73AFF6E +:106E3000022315482370FBF777FD002010BD124890 +:106E4000FBF778FD18B10120FFF778FFE8E74FF472 +:106E500080710F4804F01AFB10B90120FFF76EFF94 +:106E60000C4B1B78002BDBD0E7E70B4805F098FCB8 +:106E70000120FFF763FF002301202370DEE70748AE +:106E8000F4E700BF5C1200205412002051120020D1 +:106E9000000C01402A120020583701087037010801 +:106EA00070B5964B1A782ABB012195481970FBF7EB +:106EB00033FD03219348FBF72FFD05219248FBF793 +:106EC0002BFD0A219148FBF727FD02219048FBF793 +:106ED00023FD19218F48FBF71FFD10218E48FBF77A +:106EE0001BFD14218D48FBF717FD40F6B8318C4887 +:106EF000FBF712FD8B4C2378092B0FD9A3F130023D +:106F0000042A01D900232CE0313B032B00F2B1808D +:106F1000DFE813F0B700C600D800DF00013B082B04 +:106F200006D8DFE803F01720263650616C839A00FC +:106F30007D4E3578012D45D17C4805F031FC00238C +:106F40007B4A337013707B4A137014227A4B1A7089 +:106F5000257037E06E48FBF7E7FC6E48FBF7E4FC72 +:106F6000022323702EE06A48FBF7E4FC50B30323AE +:106F7000F7E7724805F014FC0120FFF747FE0423F1 +:106F80006F48237005F00CFC6348BDE87040FBF7C8 +:106F9000CBBC6048FBF7CEFC5F48FBF7CBFC68B18D +:106FA0000120FFF7CBFE674805F0FAFB664805F0C5 +:106FB000F7FB5B48FBF7B8FC0523D2E7634B1B7874 +:106FC000002BF3D070BD5A4B1A78012A03D100224E +:106FD0001A700623C5E75248FBF7ACFC0028F1D035 +:106FE0005B4805F0DDFBF4E75A4805F0D9FB0120CA +:106FF000FFF758FE4948FBF797FC0723B1E74748DE +:10700000FBF798FC20B10120FFF798FE0823A8E7C2 +:107010004FF48071504804F039FA10B90120FFF79D +:107020008DFE4A4B1B78002BCCD1ECE74FF48071DE +:10703000494804F02BFA404B60B132221A702022EA +:10704000464B47481A700122464B1A7005F0A8FBC0 +:10705000092386E714221A70FAE700250122324B31 +:1070600041481D70324B1D70324B1A7005F098FB71 +:107070006EE73E4805F094FB2548FBF755FC3123AD +:107080006FE72348FBF756FC00289BD0384805F0F3 +:1070900087FB0120FFF7BAFD32231948237074E7FC +:1070A0001748FBF747FC00288CD0324805F078FBE6 +:1070B0000120FFF743FE332323702F48BDE87040C3 +:1070C00005F06EBBFFF794FE01287FF47BAF3423FD +:1070D00047E74FF48071204804F0D8F9164B38B1D7 +:1070E00032221A7020221D4B1A7001221D4BB2E76A +:1070F000142203481A70FBF717FCA9E78C13002031 +:10710000841300207C130020741300206C130020D3 +:10711000641300205C130020541300204C13002043 +:107120004413002041130020820E00208D370108F7 +:107130007E0E00207A0E0020680E0020A037010885 +:10714000AC370108BE370108D03701082A120020E9 +:10715000DE370108F5370108000C0140640E0020FD +:10716000033801086E0E00201D3801082B38010875 +:1071700038380108453801085A38010810B5244B41 +:107180001A782AB90122142122481A70FBF7C4FB8D +:10719000214C2378032B38D8DFE803F0020D172D9C +:1071A0004FF400711D4804F071F908B9032300E0A1 +:1071B0000123237007E00220FFF774FD0223154826 +:1071C0002370FBF7B1FB002010BD1248FBF7B2FBA8 +:1071D00018B10220FFF7B2FDE8E74FF400710F4845 +:1071E00004F054F910B90220FFF7A8FD0C4B1B78EE +:1071F000002BDBD0E7E70B4805F0D2FA0220FFF7BF +:107200009DFD002301202370DEE70748F4E700BF5F +:10721000501200204812002045120020000C0140AE +:1072200029120020693801088138010870B5964B91 +:107230001A782ABB012195481970FBF76DFB0321D1 +:107240009348FBF769FB05219248FBF765FB0A2190 +:107250009148FBF761FB02219048FBF75DFB192188 +:107260008F48FBF759FB10218E48FBF755FB142183 +:107270008D48FBF751FB40F6B8318C48FBF74CFBCF +:107280008B4C2378092B0FD9A3F13002042A01D9A2 +:1072900000232CE0313B032B00F2B180DFE813F038 +:1072A000B700C600D800DF00013B082B06D8DFE896 +:1072B00003F01720263650616C839A007D4E357896 +:1072C000012D45D17C4805F06BFA00237B4A3370D1 +:1072D00013707B4A137014227A4B1A70257037E0B2 +:1072E0006E48FBF721FB6E48FBF71EFB0223237061 +:1072F0002EE06A48FBF71EFB50B30323F7E7724802 +:1073000005F04EFA0220FFF781FC04236F4823703A +:1073100005F046FA6348BDE87040FBF705BB6048DE +:10732000FBF708FB5F48FBF705FB68B10220FFF79E +:1073300005FD674805F034FA664805F031FA5B4808 +:10734000FBF7F2FA0523D2E7634B1B78002BF3D04F +:1073500070BD5A4B1A78012A03D100221A700623F5 +:10736000C5E75248FBF7E6FA0028F1D05B4805F084 +:1073700017FAF4E75A4805F013FA0220FFF792FCD7 +:107380004948FBF7D1FA0723B1E74748FBF7D2FAA0 +:1073900020B10220FFF7D2FC0823A8E74FF40071C8 +:1073A000504804F073F810B90220FFF7C7FC4A4BAD +:1073B0001B78002BCCD1ECE74FF40071494804F066 +:1073C00065F8404B60B132221A702022464B474884 +:1073D0001A700122464B1A7005F0E2F9092386E77C +:1073E00014221A70FAE700250122324B41481D7021 +:1073F000324B1D70324B1A7005F0D2F96EE73E48E1 +:1074000005F0CEF92548FBF78FFA31236FE72348C3 +:10741000FBF790FA00289BD0384805F0C1F902200C +:10742000FFF7F4FB32231948237074E71748FBF782 +:1074300081FA00288CD0324805F0B2F90220FFF71B +:107440007DFC332323702F48BDE8704005F0A8B9B8 +:10745000FFF794FE01287FF47BAF342347E74FF416 +:107460000071204804F012F8164B38B132221A701D +:1074700020221D4B1A7001221D4BB2E71422034833 +:107480001A70FBF751FAA9E74013002038130020C7 +:107490003013002028130020201300201813002090 +:1074A000101300200813002000130020F812002001 +:1074B000F5120020810E00209E3801087D0E00206C +:1074C000790E0020670E0020B1380108BD38010890 +:1074D000CF380108E138010829120020EF380108EF +:1074E00006390108000C0140640E0020143901081F +:1074F0006D0E00202E3901083C3901084939010878 +:10750000563901086B39010810B5234B1A782AB98E +:107510000122142121481A70FBF7FEF9204C237830 +:10752000032B36D8DFE803F0020C162B01211D488F +:1075300003F0ACFF08B9032300E00123237007E048 +:107540000320FFF7AFFB022314482370FBF7ECF98D +:10755000002010BD1148FBF7EDF918B10320FFF72B +:10756000EDFBE8E701210F4803F090FF10B903207D +:10757000FFF7E4FB0C4B1B78002BDCD0E8E70B4853 +:1075800005F00EF90320FFF7D9FB0023012023703B +:10759000DFE70748F4E700BF441200203C12002058 +:1075A0003912002000100140281200207A39010809 +:1075B0009239010870B5984B1A782ABB0121974877 +:1075C0001970FBF7A9F903219548FBF7A5F90521E7 +:1075D0009448FBF7A1F90A219348FBF79DF90F2185 +:1075E0009248FBF799F919219148FBF795F90F217A +:1075F0009048FBF791F914218F48FBF78DF940F67D +:10760000B8318E48FBF788F98D4C2378092B0FD9B8 +:10761000A3F13002042A01D9002330E0313B032BCF +:1076200000F2AF80DFE813F0B800C700DC00E20032 +:10763000013B082B06D8DFE803F018242B3B5F6FD3 +:107640007A9098007F4E3578012D40F085807E48F5 +:1076500005F0A6F800237D4A337013707C4A13703E +:1076600014227C4B1A70257076E00320FFF7AAF9EC +:107670006E48FBF759F96E48FBF756F90223237061 +:107680006AE06A48FBF756F9002865D00323F6E75D +:10769000714805F085F80320FFF7B8FA04236F4816 +:1076A000237005F07DF86348BDE87040FBF73CB9F6 +:1076B0005F48FBF73FF910B10320FFF7CFF95D48B2 +:1076C000FBF738F980B10320FFF738FB0320FFF701 +:1076D000C5F9634805F064F8624805F061F8574859 +:1076E000FBF722F90523CAE75F4B1B78002B33D148 +:1076F0000320FFF7B3F9EFE7544B1A78012A03D1BF +:1077000000221A700623BAE74C48FBF713F918B3A6 +:10771000564805F045F8F5E7554805F041F80320CF +:10772000FFF7C0FA4448FBF7FFF80723A7E74248F2 +:10773000FBF700F920B10320FFF700FB08239EE7C9 +:1077400001214C4803F0A2FE10B90320FFF7F6FA1E +:10775000454B1B78002BEED070BD0121454803F04E +:1077600095FE002850D0302389E700250122354BB3 +:1077700041481D70354B1D70354B1A7005F010F8DF +:1077800071E73E4805F00CF80320FFF71BF9274886 +:10779000FBF7CAF8312372E72448FBF7CBF800283F +:1077A000DAD0374804F0FCFF0320FFF72FFA32232A +:1077B0001A48237078E71948FBF7BCF80028CBD0AB +:1077C000304804F0EDFF0320FFF748F90320FFF7EE +:1077D000B5FA332323702C48BDE8704004F0E0BFB5 +:1077E000FFF792FE0128B7D1342348E70121214851 +:1077F00003F04CFE174B48B132221A702022234B63 +:107800001A700122224B1A70092338E71422034808 +:107810001A70FBF789F8F7E7F4120020EC12002049 +:10782000E4120020DC120020D4120020CC12002030 +:10783000C4120020BC120020B4120020AC120020A0 +:10784000A9120020800E0020AF3901087C0E002014 +:10785000780E0020660E0020C2390108CE390108DA +:10786000E0390108F239010828120020003A010825 +:10787000173A010800100140253A0108333A01087F +:10788000403A01084D3A0108623A0108640E0020AE +:107890006C0E002010B5234B1A782AB9012214214E +:1078A00021481A70FBF738F8204C2378032B36D880 +:1078B000DFE803F0020C162B02211D4803F0E6FD61 +:1078C00008B9032300E00123237007E00420FFF739 +:1078D000E9F9022314482370FBF726F8002010BDB5 +:1078E0001148FBF727F818B10420FFF727FAE8E75B +:1078F00002210F4803F0CAFD10B90420FFF71EFA59 +:107900000C4B1B78002BDCD0E8E70B4804F048FF59 +:107910000420FFF713FA002301202370DFE7074854 +:10792000F4E700BF38120020301200202F12002090 +:107930000010014027120020713A0108893A01081D +:1079400070B5984B1A782ABB012197481970FAF73D +:10795000E3FF03219548FAF7DFFF05219448FAF782 +:10796000DBFF0A219348FAF7D7FF0F219248FAF775 +:10797000D3FF19219148FAF7CFFF0F219048FAF76A +:10798000CBFF14218F48FAF7C7FF40F6B8318E4875 +:10799000FAF7C2FF8D4C2378092B0FD9A3F13002DF +:1079A000042A01D9002330E0313B032B00F2AF80E1 +:1079B000DFE813F0B800C700DC00E200013B082B51 +:1079C00006D8DFE803F018242B3B5F6F7A9098000D +:1079D0007F4E3578012D40F085807E4804F0E0FE32 +:1079E00000237D4A337013707C4A137014227C4B41 +:1079F0001A70257076E00420FEF7E4FF6E48FAF76F +:107A000093FF6E48FAF790FF022323706AE06A48FA +:107A1000FAF790FF002865D00323F6E7714804F0D9 +:107A2000BFFE0420FFF7F2F804236F48237004F030 +:107A3000B7FE6348BDE87040FAF776BF5F48FAF7D3 +:107A400079FF10B10420FFF709F85D48FAF772FFDB +:107A500080B10420FFF772F90420FEF7FFFF6348AE +:107A600004F09EFE624804F09BFE5748FAF75CFF64 +:107A70000523CAE75F4B1B78002B33D10420FEF7A8 +:107A8000EDFFEFE7544B1A78012A03D100221A7058 +:107A90000623BAE74C48FAF74DFF18B3564804F0EE +:107AA0007FFEF5E7554804F07BFE0420FFF7FAF867 +:107AB0004448FAF739FF0723A7E74248FAF73AFFA5 +:107AC00020B10420FFF73AF908239EE702214C4831 +:107AD00003F0DCFC10B90420FFF730F9454B1B78AC +:107AE000002BEED070BD0221454803F0CFFC0028EA +:107AF00050D0302389E700250122354B41481D70C5 +:107B0000354B1D70354B1A7004F04AFE71E73E4844 +:107B100004F046FE0420FEF755FF2748FAF704FF5D +:107B2000312372E72448FAF705FF0028DAD03748F6 +:107B300004F036FE0420FFF769F832231A48237058 +:107B400078E71948FAF7F6FE0028CBD0304804F061 +:107B500027FE0420FEF782FF0420FFF7EFF833230F +:107B600023702C48BDE8704004F01ABEFFF792FE67 +:107B70000128B7D1342348E70221214803F086FCCD +:107B8000174B48B132221A702022234B1A7001225F +:107B9000224B1A70092338E7142203481A70FAF7A7 +:107BA000C3FEF7E7A8120020A012002098120020C0 +:107BB00090120020881200208012002078120020ED +:107BC0007012002068120020601200205D12002058 +:107BD0007F0E0020A63A01087B0E0020770E0020C1 +:107BE000650E0020B93A0108C53A0108D73A0108E4 +:107BF000E93A010827120020F73A01080E3B010874 +:107C0000001001401C3B01082A3B0108373B0108DA +:107C1000443B0108593B0108640E00206B0E002014 +:107C200008B5FFF73DF9FFF701FBFFF7C3FCBDE81F +:107C30000840FFF785BE0000F8B5134F3B7813B935 +:107C4000FFF7D6F83870114E337813B9FFF796FA6C +:107C500030700F4D2B7813B9FFF756FC28700D4C80 +:107C6000237813B9FFF716FE20703B78012B0AD159 +:107C70003378012B07D12B78012B04D12378012BEA +:107C800004BF054A1370F8BD2E1200202D120020EB +:107C90002C1200202B1200208D13002038B5044632 +:107CA00008480D1904F07CFDAC4204D1BDE8384011 +:107CB000044804F075BD14F8011B034804F070FD7E +:107CC000F2E700BFE9200108D121010808B503F05F +:107CD00007F860B101F0BAF90522084B08491A709B +:107CE00004230B7007490A70074A137008BD074840 +:107CF00004F056FD01F0C8FAEEE700BF1D000020B9 +:107D00001C000020550E0020540E0020683B010886 +:107D1000084B09481978094B1B7859436FF06303E6 +:107D200091FBF3F1064B1B781944064BC9B219704D +:107D300004F036BD11000020853B01081200002030 +:107D400010000020580E002010B51B4804F028FD3C +:107D50001A4A1B491B4804F097FB4FF47A7003F052 +:107D6000E5FAFBF765FAFBF7CFFCFBF7CDFAFEF778 +:107D700099FCFDF76BFFFEF7B9FDFDF725FEFCF75B +:107D800009F802F009FEFEF7B5FEFFF79FFFFFF7C7 +:107D9000BFFF0D4C237863B101F0D0F80020FEF74F +:107DA00087FC0122094B0A481A70BDE8104004F014 +:107DB000F7BCFFF741FFEDE79B3B010850210108AD +:107DC000B03B0108101900208D130020E80E0020A0 +:107DD000B83B010808B5254804F0E2FC244804F04B +:107DE000DFFC03F04BFA4FF47A7003F09FFA03F0D4 +:107DF00055FA4FF47A7003F099FA1E4804F0D0FC5B +:107E00000420FEF74FFF4FF47A7003F08FFA04203E +:107E1000FEF794FF4FF47A7003F088FA164804F0E6 +:107E2000BFFC03F00BFA4FF47A7003F07FFA03F013 +:107E300015FA4FF47A7003F079FA104804F0B0FCA8 +:107E40000320FEF7BFFD0420FEF7BCFD4FF47A705F +:107E500003F06CFA0320FEF701FE0420FEF7FEFD9E +:107E6000BDE80840064804F09BBC00BFD13B0108B8 +:107E7000E03B0108F33B0108063C0108173C010800 +:107E8000283C01080346F0B490B008469E181946F5 +:107E90006C466B46B14209D1034600EB5202934255 +:107EA00049D1102110B0F0BCFFF7F8BE11F8015B0A +:107EB000303D362D1FD8DFE805F01C20222426286F +:107EC0002A2C2E301E1E1E1E1E1E1E323436383A1E +:107ED0003C1E1E1E1E1E1E1E1E1E1E1E1E1E1E1EA4 +:107EE0001E1E1E1E1E1E1E1E1E1E1E323436383A3A +:107EF0003C0000251D700133CCE70125FAE702257F +:107F0000F8E70325F6E70425F4E70525F2E706255B +:107F1000F0E70725EEE70825ECE70925EAE70A255B +:107F2000E8E70B25E6E70C25E4E70D25E2E70E255B +:107F3000E0E70F25DEE714F8025B14F8011C41EAC4 +:107F4000051103F8011BAAE71FB51A4CB4F900206C +:107F50002388002A24DAC3F30E03222B22D1164BE6 +:107F60009A7F302A01D0462A1CD1DB7F302B01D0EA +:107F7000462B17D1114804F013FC202269460E4805 +:107F8000FFF780FF102269460D4806F0D5F8FDF78F +:107F900031FD80220021084804F014FC00232380D6 +:107FA00004B010BD074804F0FBFB0348FDF786FD55 +:107FB000EFE700BFC80F0020CC2400203B3C0108A5 +:107FC000C9110020463C0108F8B55E4B1A7872B919 +:107FD000012264215C481A70FAF79EFC4FF4FA61A2 +:107FE0005A48FAF799FC0A215948FAF795FC594D75 +:107FF0002C78012C1FD0032C00F09580D4B9564F5B +:108000003E78012E16D1554804F0CAFB544B554812 +:108010001C70554B3C701C70544B1C70544B1C70A6 +:10802000544B1C70544B1C7004F0BAFB4748FAF7D1 +:108030007BFC2E70F8BD4548FAF77CFC38B14F4BFD +:108040004F481C7004F0ACFB03232B70F2E74D4B40 +:108050001A78012A06D118703C48FAF765FC4A489C +:1080600004F09EFB494C2378FF2B1BD10023237087 +:108070000123474A1370474A12780AB93A4A1370E3 +:10808000454B1B7813B90122384B1A70434B1B78B0 +:1080900013B90122364B1A70414B1B7813B90122D8 +:1080A000344B1A702378A3B10121394A013B117076 +:1080B000032B0CD8DFE803F00219232D354B1B7876 +:1080C0008BB90122284B37481A7004F069FB002352 +:1080D0002370294A1378012BACD100211170274A53 +:1080E00031481370AEE73148EFE72B4B1B7823B9CB +:1080F00001221E4B2E481A70E7E72E48E5E7274B72 +:108100001B7823B901221A4B2B481A70DDE72B4844 +:10811000DBE7234B1B7823B90122164B28481A7042 +:10812000D3E72848D1E700230B4A1370264A13707F +:108130000D4A13700D4A13700D4A13700D4A1370D7 +:1081400083E700BF5814002050140020481400207A +:10815000401400203D140020880E0020533C0108EC +:10816000620E0020783C0108860E0020850E00205B +:10817000840E0020830E0020760E0020720E002058 +:10818000893C0108740E00209C3C0108A40E0020CC +:1081900092100020CB0E0020CA0E0020C90E002035 +:1081A000C80E0020B93C0108313D0108C93C010856 +:1081B000D73C0108E73C0108F53C0108053D0108F2 +:1081C000133D0108233D01084C2800200023064AE6 +:1081D0001370064A1370064A1370064A1370064A53 +:1081E0001370064A137070474C280020880E002038 +:1081F000860E0020850E0020840E0020830E0020B5 +:108200002DE9F04FA04B89B01A7852BB01219F484D +:108210001970FAF781FB0F219D48FAF77DFB0521C4 +:108220009C48FAF779FB0A219B48FAF775FB102165 +:108230009A48FAF771FB3C219948FAF76DFB4FF425 +:10824000E1619848FAF768FB40F6B8319648FAF7CA +:1082500063FB14219548FAF75FFB0A219448FAF76B +:108260005BFB944C2378212B25D8212B29D8DFE8E0 +:1082700013F02A00C600F9007901420256021503E4 +:108280003E03280028002800280028002800280095 +:1082900028002800F503FA03FC0304040A0428005C +:1082A000280028002800280028002800280028008E +:1082B00028001104C300402B00F09E80502B00F0DA +:1082C0000E830023CCE07C4B1B78012B0CD07B4B26 +:1082D0001B78012B08D07A4B1B78012B04D0794BEB +:1082E0001B78012B40F088800125774804F058FA6C +:1082F000764B774A1D7000231370764ADFF8D8E179 +:108300001370764ADFF8D8811370764A764E137070 +:10831000764A774F1370774ADFF8DCA11370774AFB +:108320001370774A1370774A1370774A1370774A3D +:108330001370774A1370774A1370774A1370774A2D +:108340001370774A1370774A1370774A1380774A0D +:108350001380774A1380774AB2F800C0764AAEF8A5 +:1083600000C01088A8F800C0744ADFF8D4C1118892 +:10837000ACF800003080734A73481288018039805D +:108380007249AAF800200A80714A7248137004F0FA +:1083900007FAB8F8000009F08BFA6F4909F094FB6E +:1083A00008F0A0FE8046BAF80000894609F080FA7D +:1083B000694909F089FB08F095FECDE90401388888 +:1083C00009F076FA644909F07FFB08F08BFECDE9ED +:1083D0000201308809F06CFA5F4909F075FB08F07A +:1083E00081FE4246CDE900014B465C4804F0D8F9D5 +:1083F0002648FAF799FA257009B0BDE8F08F2348AE +:10840000FAF798FA0028F7D02B4A1378012B05D1F8 +:10841000002111702F4A1370364A1370274A1378BF +:10842000012B05D1002111702C4A1370334A1370AF +:10843000234A1378012B05D100211170294A1370AA +:108440002F4A13701F4A1378012B05D10021117098 +:10845000264A13702B4A13701348FAF765FA022361 +:108460002370C9E71048FAF765FA20B13C4804F0D8 +:1084700097F90423F4E70B48FAF756FA0A48FAF793 +:1084800053FA0323ECE700BF3C140020341400200F +:108490002C140020241400201C140020141400208C +:1084A0000C14002004140020FC130020F4130020FE +:1084B000EC130020E8130020860E0020850E00201B +:1084C000840E0020830E0020463D0108CC0E0020C3 +:1084D0009F0E0020820E0020DE130020810E00205F +:1084E000BE0E0020800E0020BA0E00207F0E00205D +:1084F000B60E0020E7130020B20E0020E613002085 +:10850000E5130020E4130020E3130020E213002011 +:10851000E1130020E01300207E0E00207D0E0020DD +:108520007C0E00207B0E0020AE0E0020AC0E002042 +:10853000AA0E0020A01000209E1000209C100020F9 +:10854000DC1300209A100020DA130020D81300203A +:10855000700E00205B3D01080000C842703D01081C +:10856000AD3D01089848FAF7E5F938B1042397487A +:10857000237009B0BDE8F04F04F012B9944B1D7898 +:10858000012D0BD11870934B93481D70934B1D70A8 +:10859000FAF7CAF9924B1D70924B1D70924B1D78E1 +:1085A000012D0CD100221A70904B8B481D70904BFE +:1085B0001D70FAF7B9F98A4B1D708A4B1D708D4BEF +:1085C0001D78012D0CD100221A708B4B82481D7032 +:1085D0008A4B1D70FAF7A8F9814B1D70814B1D70F5 +:1085E000874B1D78012D0CD100221A70854B7A48DB +:1085F0001D70854B1D70FAF797F9794B1D70794BFB +:108600001D70824B82491A880B889A420ED9D31A60 +:10861000042B0BDD70480A80FAF786F90123704AB3 +:108620007C4813706F4A137004F0BAF87A4B7B4998 +:108630001A880B889A420ED9D31A042B0BDD664890 +:108640000A80FAF771F90123654A75481370654A83 +:10865000137004F0A5F8734B73491A880B889A427B +:108660000ED9D31A042B0BDD5B480A80FAF75CF9AC +:1086700001235B4A6D4813705A4A137004F090F856 +:108680006B4B6C491A880B889A420ED9D31A042B6B +:108690000BDD51480A80FAF747F90123504A664832 +:1086A0001370504A137004F07BF84B48FAF74EF9F8 +:1086B0000A23B0FBF3F0614BC0B21870604B1A682C +:1086C000824207D0186001235E4A0328137004BF5A +:1086D0005D4A13704048FAF72DF920B15B4804F069 +:1086E0005FF85B48C3E65B4B1A78012A7FF484AEDF +:1086F00018705948F3E7594804F052F80123584AD2 +:1087000058481370584A1370584A1370584A1370D7 +:108710000523237009B0BDE8F04FFAF705B95148B9 +:10872000FAF708F930B106235248237004F038F8FC +:108730005148EFE7294B514A1B78012B03D1504B8D +:108740001B78012B01D101231370294B1B78012BBE +:1087500003D14C4B1B78012B02D101214A4B1970DC +:10876000264B1B78012B03D1484B1B78012B02D1E0 +:108770000121474B1970244B1B78012B03D1454B2A +:108780001B78012B02D10121434B19701378012B67 +:108790007FF432AE3C4D2B78012B7FF42DAE3C485C +:1087A0000378012B7FF428AE3B490B78012B7FF433 +:1087B00023AE00230370304813702B700B70FAF750 +:1087C000B3F806234CE600BFFC130020AD3D0108C2 +:1087D000860E0020820E002004140020E7130020E3 +:1087E000750E0020740E0020850E0020810E0020E2 +:1087F000E6130020840E0020800E0020E5130020E8 +:10880000830E00207F0E0020E4130020A010002023 +:10881000DE130020C33D01089E100020DC13002061 +:10882000D13D01089C100020DA130020DF3D010833 +:108830009A100020D8130020ED3D0108700E002092 +:10884000D4130020710E002090100020FB3D010881 +:108850000A3E01089F0E0020133E01082A3E01082F +:108860007E0E00200C1400207D0E00207C0E0020C7 +:108870007B0E0020413E0108F4130020E31300208A +:108880007A0E0020790E0020E2130020780E0020DE +:10889000E1130020770E0020E01300208848FAF74B +:1088A00049F800283FF4A8AD864B87481A88874BC3 +:1088B0001A80874B1A88874B1A80874B1A88874BF8 +:1088C0001A80874B1A88874B1A800022864B1A70B1 +:1088D0000122864B1A70FAF727F85023C0E57A4830 +:1088E000FAF728F800283FF487AD0723B8E5804E53 +:1088F000804803F055FF308808F0DAFF7E4909F020 +:10890000E3F808F0EFFB714F80463888894608F09D +:10891000CFFF794909F0D8F808F0E4FBDFF8DCA1D3 +:1089200042464B46CDE90001754803F039FFBAF8DD +:10893000000008F0BDFF704909F0C6F808F0D2FB4E +:10894000644D80462888894608F0B2FF6A4909F0DC +:10895000BBF808F0C7FB4246CDE900014B46694829 +:1089600003F01EFF684BDFF874B1188808F0A0FF11 +:10897000614909F0A9F808F0B5FB8046BBF8000092 +:10898000894608F095FF5C4909F09EF808F0AAFBBB +:108990004B46DFF878914246CDE900015C4803F090 +:1089A000FFFEB9F8000008F083FF534909F08CF886 +:1089B00008F098FB02460B46DFF82881CDE9062334 +:1089C000B8F8000008F074FF4B4909F07DF808F092 +:1089D00089FBDDE90623CDE900014E4803F0E0FE06 +:1089E0003B883288934231D39B1A9BB2092B98BFA4 +:1089F0000023494A13802B88BAF80020934227D3DA +:108A00009B1A9BB2092B98BF0023444A13803E4A0D +:108A1000BBF80030128893421CD39B1A9BB2092BDF +:108A200098BF00233E4A1380B8F80030B9F8002000 +:108A3000934211D39B1A9BB2092B98BF0023394A4A +:108A40003948138003F0ACFE112309E50023D0E779 +:108A50000023DAE70023E5E70023F0E7334803F0DB +:108A60009FFE1223FCE41323FAE4314803F098FE3E +:108A70000122304B1A701423F2E4FFF7A7FB2E48B3 +:108A800003F08EFE1DE42D4803F08AFEF8F7F6FD94 +:108A90002B48F5E72B4803F083FEF8F7EFFD0120A4 +:108AA000FAF712FE0220FAF70FFE0123264A2748A2 +:108AB0001370274A137003F073FE2123D0E400BF24 +:108AC000F4130020A0100020EC130020BC0E0020A6 +:108AD0009E100020B80E00209C100020B40E002034 +:108AE0009A100020B00E0020CC0E00209914002017 +:108AF000BE0E0020543E01080000C842BA0E0020FD +:108B0000693E01088B3E0108B60E0020B20E00201F +:108B1000AD3E0108CF3E0108C60E0020C40E002065 +:108B2000C20E0020C00E0020F13E0108063F0108E1 +:108B3000193F0108760E0020323F01084A3F010824 +:108B40006B3F0108893F0108690E0020A43F01081E +:108B50006A0E002010B5174B1A7832B901224FF473 +:108B6000E16115481A70F9F7D7FE144C237813B158 +:108B7000012B11D010BD124B1B78022B03D0114BCF +:108B80001B78022BF6D1104803F00AFE0A48F9F7C9 +:108B9000CBFE01232370EDE70748F9F7CBFE002851 +:108BA000E8D00A4803F0FCFD0023054A1370054A8B +:108BB0001370EFE7D0130020C8130020C513002066 +:108BC000AA140020A8140020C63F0108ED3F0108A8 +:108BD00010B5234B1A784AB90122022121481A7094 +:108BE000F9F79AFE02212048F9F796FE1F4C2378E8 +:108BF000032B0FD8DFE803F002121D2A1C4A13785A +:108C0000012B07D10021117002221A490A701A495A +:108C10000A702370BDE81040FFF79CBF174803F0AF +:108C2000BFFD0620FDF7CEFE0E48F9F77DFE0223BC +:108C3000EFE70C48F9F77EFE0028EBD00620FDF7A1 +:108C40000DFF0948F9F770FE0323E2E70648F9F73C +:108C500071FE0028DED00023054A1370D9E700BF5B +:108C6000C4130020BC130020B4130020B113002053 +:108C7000610E0020AA140020A81400200240010860 +:108C800038B51A4B1A782AB90122962118481A7059 +:108C9000F9F742FE174C25781DB1012D13D00023A2 +:108CA00022E0154B1D78012D0CD12846FDF78AFED8 +:108CB0000220FDF787FE114803F072FD0C48F9F71A +:108CC00033FE257038BD0A48F9F734FE0028F9D084 +:108CD0002846FDF7C3FE0220FDF7C0FE084803F05A +:108CE0005FFD0023044A13702370EBE7B0130020EC +:108CF000A8130020A5130020E90F0020134001084D +:108D00002440010810B5174B1A782AB901226421B2 +:108D100015481A70F9F700FE144C237813B1012B93 +:108D200010D010BD124B1B78272BFAD9114803F035 +:108D300037FD0320FDF746FE0420FDF743FE012327 +:108D40002370EEE70A4B1B78262BEAD80A4803F07B +:108D500027FD0320FDF782FE0420FDF77FFE0023A0 +:108D6000EEE700BFA41300209C13002099130020FD +:108D7000F4110020354001085240010838B5284B55 +:108D80001A782AB90122642126481A70F9F7C4FD1D +:108D9000254C2378012B23D0022B2AD0A3B9012103 +:108DA000224802F073FB80B9214803F0F9FC04204B +:108DB000FDF778FF01231F4A652013701E4A1370C8 +:108DC000F8F7DCF90223237038BD1C4B1B784F2BBE +:108DD000FAD91B4803F0E4FC0123164A1370F2E7AA +:108DE000164B1B784B2B17D8164803F0D9FC0023E1 +:108DF000E9E701210D4802F049FB01280CD10025CB +:108E0000114803F0CDFC0420FDF798FF0A4B6520C4 +:108E10001D70F8F7B3F925700122064B1A70D3E7DD +:108E200098130020901300208E13002000100140A2 +:108E3000654001088F100020E10E0020F411002091 +:108E40008A400108AA400108C44001081E280146C2 +:108E500014D8D0B1431E1D2B17D8DFE803F01D1620 +:108E60002022241626282C2A2E16303234363A3C5C +:108E700016161616161616161616163E512826D053 +:108E800006D83F282BD040282BD0174803F088BCA9 +:108E90005228FAD1154800E0154803F081BC154866 +:108EA000FBE71548F9E71548F7E71548F5E71548D2 +:108EB000F3E71548F1E71548EFE71548EDE71548E2 +:108EC000EBE71548E9E71548E7E71548E5E71548F2 +:108ED000E3E71548E1E71548DFE71548DDE7154802 +:108EE000DBE71548D9E700BF234101080941010824 +:108EF00071340108763401087B340108803401089C +:108F0000DD4001088A340108E6400108F14001080B +:108F1000FC4001088F340108943401089934010899 +:108F20009E340108034101080F410108A3340108E0 +:108F3000A8340108154101081C410108F7B5324861 +:108F400003F02EFC314803F02BFC3149314803F08B +:108F500027FC314B314C1B78314D013B314E324FA8 +:108F6000042B0DD8DFE803F0031A252738002F481B +:108F700003F016FC2078FFF769FF2D4803F010FC82 +:108F80003B782348009333782A782178FCF746FF12 +:108F9000284803B0BDE8F04003F002BC264803F0C7 +:108FA000FFFB2078FFF752FF244803F0F9FB2878F5 +:108FB000E1E72348F3E7234803F0F2FB2078FFF7CB +:108FC00045FF1E4803F0ECFB2878FFF73FFF1B48E6 +:108FD00003F0E6FB3078CEE71B4803F0E1FB207896 +:108FE000FFF734FF154803F0DBFB2878FFF72EFF6F +:108FF000124803F0D5FB3078FFF728FF0F4803F045 +:10900000CFFB3878B7E700BF2C410108E4410108E5 +:10901000101900203B4101081D0000201B0000200A +:109020001A00002019000020180000204441010807 +:1090300082270108D54101085F4101087A410108F2 +:109040007D4101089F410108BA4101082DE9F74F10 +:10905000594A5A4B12785A491A705A4A5A4B12783E +:109060005A480A705A4A5B4C12785B4D1A705B4A38 +:10907000DFF86CB112785B4E02705B4A5B48127885 +:10908000006822705A4ADFF86CA112785A4F2A7091 +:109090005A4ADFF86CE11268DFF86881CBF80020EB +:1090A000594ADFF86891106059485A4A00785A4C7A +:1090B00010705A485A4D007830705A485A4E00780D +:1090C0008AF800005948007838705948594F00789C +:1090D0008EF800005848007888F800005748DFF8FC +:1090E0006081007889F800005648DFF85C910078CC +:1090F00020705648564C007889F800005548007892 +:1091000030705548007838705448007888F800006E +:10911000534800782070534800782870524803F074 +:109120003FFB524803F03CFB2549244B0978364A63 +:109130000091DBF800101B7812684D4803F030FBFB +:109140009AF80030DFF89CC0324A1F4900939CF81F +:10915000003012780978474803F022FB294BDFF8EA +:10916000A0E01B781948244A00939EF8003001784B +:109170001278414803F014FB99F800301549009328 +:10918000DFF88890244B99F800201B7809783B4839 +:1091900003F006FB98F800300F49009332783B78D3 +:1091A0000978374803F0FCFA2A782178354803B06B +:1091B000BDE8F04F03F0F4BA1D000020550E00206A +:1091C000540E00201C000020530E0020520E0020E0 +:1091D0001B000020510E0020500E00201A0000201D +:1091E0004C0E0020450E0020190000205C0E0020CF +:1091F00018000020440E0020430E00201400002020 +:10920000420E0020410E0020480E0020400E00209B +:1092100011000020460E00203F0E0020100000200C +:10922000390E00200F0000203D0E00200E0000200F +:109230000D0000203C0E00200C0000200B00002040 +:109240003B0E00200A0000203E0E002009000020F6 +:109250003A0E002008000020070000200600002031 +:10926000570E0020560E0020F34101081442010859 +:109270002242010844420108614201087E4201087D +:109280009B420108B84201082DE9F74F594BDFF81E +:1092900068B11B68594ACBF80030594B59481B68D4 +:1092A000594C1360594B5A4A1B785A4D13705A4BFC +:1092B0005A4E1B78DFF868A103705A4B5A481B7846 +:1092C0005A4F23705A4B04241B78DFF868812B70A7 +:1092D000052505705848594B047059481D70007891 +:1092E000584BDFF8649118705848594900780C7051 +:1092F00030705848584C0078584D8AF8000058484B +:10930000584E007838705848584F007888F8000058 +:109310005748DFF86081007889F800005648DFF888 +:109320005C91007820705648564C0078287056485A +:10933000564D007889F8000055480078307055483F +:10934000007838705448007888F800005348007856 +:109350002070534800782870524803F021FA524890 +:1093600003F01EFA3A49354B0978244A0091DBF89C +:1093700000101B7812684D4803F012FA9AF800307A +:10938000DFF898E0DFF8BCC0214900939EF8003078 +:109390009CF800200978464803F002FADFF8A8C0DC +:1093A00018489CF80030214A0093224B01781B7822 +:1093B0001278404803F0F4F999F80030264A0093F7 +:1093C0001149264B12781B7809783B4803F0E8F9DD +:1093D00098F800300F49009332783B780978374885 +:1093E00003F0DEF92A782178354803B0BDE8F04F64 +:1093F00003F0D6B94C0E0020140000205C0E0020B3 +:10940000480E00201A00002019000020530E0020F2 +:109410001B00002018000020520E00201000002029 +:109420000F000020510E0020550E00200E000020DD +:10943000500E00200D000020540E00201D000020C2 +:10944000460E0020110000200C000020450E0020D8 +:109450001C000020440E00200B0000200A00002009 +:10946000430E002008000020420E002007000020CC +:10947000410E002006000020400E002009000020C0 +:109480003F0E0020570E00203E0E0020560E0020FA +:109490003D0E00203C0E00203B0E00203A0E002026 +:1094A000390E0020CA420108E9420108224201089F +:1094B00044420108614201087E4201089B420108C2 +:1094C000B842010838B5044604F044FE092811D812 +:1094D0000A49204603F07EF90546204604F03AFE8C +:1094E000854204D12046BDE8384002F062BB044802 +:1094F00003F056F94FF0FF3038BD00BFF7420108C6 +:109500000243010870B504460D1F00EB0216B44279 +:1095100001D101200CE02046FFF7D4FF431C03D00B +:10952000103445F8040FF2E7024803F039F900203F +:1095300070BD00BF1343010870B54FF4807204463C +:1095400000212D4803F03EF92C4803F029F90023AF +:109550002B4D20462B492B7003F04CF90446264E28 +:109560003CBB2978284803F01BF9234E2B78E1B245 +:109570008B4237D8254803F013F91F48FFF7A2FFA5 +:10958000431C36D0224C234D2070C1B2224803F038 +:1095900007F923782A789A4209D0012B07D00122B3 +:1095A0001E4B1F481A7003F0FBF823782B70012024 +:1095B00070BD204604F0CEFD0F280ED82878214635 +:1095C00006EB001004F0A2FD00200E4903F012F992 +:1095D0002B78044601332B70C2E7124803F0E0F801 +:1095E0000020E5E7104806EB011103F0D9F801343B +:1095F000BCE70E48F2E700BF2E39002026430108E1 +:10960000AD38002081310108504301086D43010845 +:109610003F3A002088140020714301080D0E0020FD +:109620007E43010835430108684301088F43010860 +:109630002DE9F04F9B49BBB003F042F9044680226C +:1096400000211AA803F0BEF8611C1AA804F05EFD00 +:109650001AA8FFF771FF0128044624D1924D9348C0 +:10966000297803F09DF82B780D2B12D8DBB1013B44 +:109670000C2B18D8DFE813F022003C005000D30078 +:109680001700EB0003011700170017001700170061 +:109690007A01382B00F0768208D81E2B00F0448225 +:1096A0001F2B00F059823BB0BDE8F08F642BFAD13C +:1096B0007F4803F075F87F4B1C70F4E77E4803F099 +:1096C0006FF87E497E4803F06BF87C48FFF7FAFE9E +:1096D0000146481C7B4B05D07B4A116001221A7061 +:1096E0007A4867E000227A481A7003F059F8DAE7FE +:1096F000784803F055F87149714803F051F86F4804 +:10970000FFF7E0FE421C0146734B01D0734AE4E7C9 +:10971000002273481A70E8E7724803F041F867497D +:10972000674803F03DF86548FFF7CCFE431C13D0B3 +:109730006D4BC1B218706D4803F032F86C496D483A +:1097400003F02EF86A48FFF7BDFE471C09D100223E +:10975000694B6A481A70C8E70022674B68481A705C +:10976000C3E7684CC1B22070674803F019F80023C2 +:10977000227866480AA9CDE90A33CDE90C33FFF710 +:10978000C1FE012804D000225B4B61481A70ACE78F +:1097900020780C9B0138DDE90A12032883D8DFE822 +:1097A00000F0020C192901225A4B5B481970524BE8 +:1097B000C9B21A7002F0F4FF75E70120554B197019 +:1097C000564BC9B21A704C4BD2B21870544802F0C2 +:1097D000E7FF68E701244F4801705048C9B20270A2 +:1097E0005048D2B203704448DBB204704E4802F0D5 +:1097F000D7FF58E70125474C0D982170474CC9B257 +:109800002270484CD2B22370484CDBB220703A4CE4 +:10981000C0B225700090464802F0C2FF43E74548B9 +:1098200002F0BEFF2549264802F0BAFF2348FFF7A1 +:1098300049FE461C0146404B05D0404A10600122BB +:109840003F481A70B6E700223E481A704DE73E487E +:1098500002F0A6FF19491A4802F0A2FF1748FFF7C5 +:1098600031FE451C394B06D0394A10700122C1B275 +:109870001A7038489EE7002237481A7035E7374893 +:1098800002F08EFF0D490E4802F08AFF0B48FFF7E9 +:1098900019FE441C324B01D0324AE6E7002232481E +:1098A0001A7022E7F23101083F3A00209C43010878 +:1098B000F8470108020E0020AC4301083E390020A1 +:1098C000C74301080C0E0020280E0020D7430108D2 +:1098D000E6430108FF4301080B0E0020240E002080 +:1098E000164401082F440108310E00204A440108A3 +:1098F0004E3900205D440108090E0020A1440108F2 +:109900006D440108300E0020864401085E390020B5 +:10991000224501082F0E0020C24401082E0E00200F +:10992000D44401082D0E0020EA4401082C0E00202A +:10993000044501083F450108080E0020200E0020C4 +:109940005C4501086D45010888450108070E0020A7 +:10995000110E0020B4450108C3450108EE45010879 +:10996000060E0020100E002016460108904802F056 +:1099700017FF9049904802F013FF8E48FFF7A2FDB1 +:10998000411C3FF4E4AE8D4FC1B238708C4802F0F8 +:1099900007FF00233A788B4802EB4202D2B20AA9B1 +:1099A000CDE90A33CDE90C33CDE90E33CDE91033DF +:1099B0001293FFF7A7FD012840F0B180DDE90A12FC +:1099C000DDE90C30DDE90E45DDE9106C3F78DDF8AE +:1099D00048E0013F032F3FF666AEDFE807F00210D4 +:1099E0002C5A0124784801707848C9B2027078482E +:1099F000D2B203707748DBB204707748F7E60127EC +:109A0000714E3170714EC9B23270714ED2B2337034 +:109A1000724EDBB23070724EC0B23470714EE4B22E +:109A200035706C4EEDB237700090029501946E481F +:109A300002F0B6FE37E64FF00108634F3970634F0E +:109A4000C9B23A70624FD2B23B70644FDBB2387029 +:109A5000634FC0B23C70634FE4B23D70634FEDB2F0 +:109A60003E70634FF6B287F800C0624F87F800E09F +:109A7000584F87F800805FFA8EF705975FFA8CF7EA +:109A8000009004970396029501945B4802F088FECB +:109A900009E64FF0010B4C4FDDF84C8039704B4F0D +:109AA000DDF850903A704A4FDDF854A03B704B4FB0 +:109AB000DBB238704A4FC0B23C704A4FE4B23D70DE +:109AC0004A4FEDB23E704A4FF6B287F800C0494F98 +:109AD000D2B287F800E0494FC9B287F80080484FFA +:109AE00087F80090474F87F800A03A4F87F800B0FA +:109AF0005FFA8AF708975FFA89F707975FFA88F79E +:109B000006975FFA8EF705975FFA8CF70090049737 +:109B10000396029501943C4802F042FEC3E5002200 +:109B20003A4B3B481A70E0E53A4802F039FE2149C9 +:109B3000214802F035FE1F48FFF7C4FC421C06D046 +:109B4000354BC1B21870354B35481C7032E60022D7 +:109B5000344B35481A70C8E5344802F021FE1549E7 +:109B6000154802F01DFE1348FFF7ACFC0130304BE6 +:109B700004D01C70284B2F4819781BE600222E4871 +:109B80001A70B2E52D4802F00BFE0A490A4802F0AD +:109B900007FE0848FFF796FC431C0146284B03D0FC +:109BA000284A1C7010609BE5002227481A709CE52B +:109BB0003D4601083E390020C7430108300E002011 +:109BC000864401084E3900201D0E00201C0E002086 +:109BD0001B0E0020050E00205F4601081A0E002013 +:109BE000190E0020180E002073460108170E0020E1 +:109BF000160E0020150E002098460108140E0020B5 +:109C0000130E0020120E0020CE460108090E00207F +:109C100015470108324701080F0E0020040E0020EE +:109C2000494701080C0E00205C47010879470108EC +:109C3000030E002090470108A3470108C047010810 +:109C40000A0E0020240E0020DB47010810B50B4B44 +:109C50001C78012C0FD100221A70094B1A68094B8D +:109C60001B689A4204D1084802F09AFD204610BDB4 +:109C7000064802F095FD0024F8E700BF0C0E002016 +:109C800014000020280E00201B4801082E4801085F +:109C900070B51C4C237813B1012B0BD070BD1A4941 +:109CA0000A78012AFAD10B70184922700B701849F2 +:109CB0000B70F3E7154B1E78012E1AD100251D708D +:109CC000144B1A68144B1B689A420DD1134802F0CA +:109CD00067FD134B13481A68134B1A6002F060FDBE +:109CE000124B25701E70D9E71148BDE8704002F094 +:109CF00057BD074A1378012BD0D100230D481370AC +:109D00002370F2E7871400200B0E00200C0E0020B9 +:109D10000D0E002014000020280E00201B48010812 +:109D2000240E0020414801084C0E00200E0E002099 +:109D30002E4801085448010838B5094D2C7874B9EB +:109D4000084A1378012B0AD11470074A0748116892 +:109D5000074A1160074A137002F022FD2C7038BDCB +:109D6000861400200A0E0020240E00206F480108EF +:109D70004C0E00200E0E002070B5264C237813B137 +:109D8000012B0ED070BD244A1578012DFAD1137025 +:109D9000224A23481370234A137002F001FD2570F4 +:109DA000F0E71E4B1E78012E2AD100251D701E4B98 +:109DB0001A681E4B1B689A421DD11D4802F0F0FC28 +:109DC0001C4B1A781C4B1A701C4B1A781C4B1A70BF +:109DD0001C4B1A781C4B1A701C4B1A781C4B1A70AF +:109DE0001C4B1A781C4B1A701C4B1A781C4B1A709F +:109DF0001C4B1E70D3E71C48BDE8704002F0D0BC7D +:109E0000084A1378012BBDD1002318481370237022 +:109E1000F2E700BF85140020090E00200C0E002080 +:109E2000864801080D0E002014000020280E002096 +:109E30001B480108310E0020550E0020300E002076 +:109E4000540E00202F0E0020530E00202E0E002056 +:109E5000520E00202D0E0020510E00202C0E00204E +:109E6000500E00200E0E00202E4801085448010814 +:109E700070B51C4C237813B1012B0BD070BD1A495F +:109E80000A78012AFAD10B70184922700B70184910 +:109E90000B70F3E7154B1E78012E1AD100251D70AB +:109EA000144B1A68144B1B689A420DD1134802F0E8 +:109EB00077FC134B13481A68134B1A6002F070FCBE +:109EC000124B25701E70D9E71148BDE8704002F0B2 +:109ED00067BC074A1378012BD0D100230D481370BB +:109EE0002370F2E784140020080E00200C0E0020DE +:109EF0000D0E002014000020280E00201B48010831 +:109F0000200E0020A5480108480E00200E0E00205B +:109F10002E4801085448010838B5214C237813B164 +:109F2000012B0BD038BD1F490A78012AFAD10B70DA +:109F30001D4922700B701D490B70F3E71A4B1A78FC +:109F4000012A23D100221A70194B1A68194B1B6879 +:109F50009A4216D1184802F023FC184B184D1B7872 +:109F600018482B7002F01CFC2B78012B0CBF1648F4 +:109F7000164802F015FC0122154B1A7000232370BD +:109F8000D0E71448BDE8384002F00ABC074A13780D +:109F9000012BC7D10023104813702370F2E700BFD4 +:109FA00083140020070E00200C0E00200D0E002050 +:109FB00014000020280E00201B480108110E00206C +:109FC0003A0E0020BA480108E3480108EE480108AB +:109FD0000E0E00202E4801085448010838B5214CC7 +:109FE000237813B1012B0BD038BD1F490A78012A01 +:109FF000FAD10B701D4922700B701D490B70F3E7ED +:10A000001A4B1A78012A23D100221A70194B1A68A8 +:10A01000194B1B689A4216D1184802F0C1FB184B25 +:10A02000184D1B7818482B7002F0BAFB2B78012BC7 +:10A030000CBF1648164802F0B3FB0122154B1A70EC +:10A0400000232370D0E71448BDE8384002F0A8BBD5 +:10A05000074A1378012BC7D10023104813702370CF +:10A06000F2E700BF82140020060E00200C0E002034 +:10A070000D0E002014000020280E00201B480108AF +:10A08000100E0020390E0020F9480108EE480108A2 +:10A09000E34801080E0E00202E480108544801082C +:10A0A00070B5324C237813B1012B0ED070BD304AFD +:10A0B0001578012DFAD113702E4A2F4813702F4AAC +:10A0C000137002F06DFB2570F0E72A4B1E78012E0D +:10A0D00042D100251D702A4B1A682A4B1B689A42F0 +:10A0E00035D1294802F05CFB284B1A78284B1A70AE +:10A0F000284B1A78284B1A70284B1A78284B1A705C +:10A10000284B1A78284B1A70284B1A78284B1A704B +:10A11000284B1A78284B1A70284B1A78284B1A703B +:10A12000284B1A78284B1A70284B1A78284B1A702B +:10A13000284B1A78284B1A70284B1A78284B1A701B +:10A14000284B1A78284B1A70284B1E70BBE72848FA +:10A15000BDE8704002F024BB084A1378012BA5D15A +:10A160000023244813702370F2E700BF81140020FD +:10A17000050E00200C0E0020864801080D0E002060 +:10A1800014000020280E00201B4801081D0E00208E +:10A19000460E00201C0E0020450E00201B0E002045 +:10A1A000440E00201A0E0020430E0020190E00203D +:10A1B000420E0020180E0020410E0020170E002035 +:10A1C000400E0020160E00203F0E0020150E00202D +:10A1D0003E0E0020140E00203D0E0020130E002025 +:10A1E0003C0E0020120E00203B0E00200E0E002020 +:10A1F0002E48010854480108F8B57C4B1A786AB912 +:10A2000001221E217A481A70F8F786FB0A21794844 +:10A21000F8F782FBC8217848F8F77EFB774C237863 +:10A22000112B1ED8DFE813F012001E00410064005D +:10A230009900C7001D001D001D001D001D001D0010 +:10A240001D001D001D001D00D300DB006C490A78B5 +:10A25000012A06D100230B706A4922700B706A49EB +:10A260000B70F8BD674B1A78012A15D100221A70BD +:10A27000664B1A68664B1B689A4208D1654802F023 +:10A280008FFA654802F08CFA02232370E9E76348ED +:10A29000BDE8F84002F084BA5B4A1378012BE0D1A4 +:10A2A00000235F4813702370F2E75E4D2878FCF7B7 +:10A2B0000DF92B7853B95C4B1B78012B03D1FBF7BD +:10A2C00071FE0023E1E7FBF7A9FEFAE7574AA12058 +:10A2D00013700023564A1370564A13700122564BCE +:10A2E0001A7000F075FE4448F8F71EFB0323CCE714 +:10A2F0004148F8F71FFB38B1504802F051FA0022EC +:10A300004D4B1A7010232370464D2B78012B0ED025 +:10A31000022BD6D1474B1E78012EA2D1484802F01D +:10A320003FFA2878FCF7FAF80023464A0BE0404B46 +:10A330001E78012E95D1444802F032FA2878FCF7B5 +:10A34000EDF80023414A13703B4A2B481370404BF1 +:10A350001E70F8F7E9FA042397E72748F8F7EAFAB6 +:10A36000054638B1354802F01BFA0022384B1A7006 +:10A3700010238AE72B4E3378012B08D0022BA0D173 +:10A38000304B1F78012F7FF46CAF324805E02F4B24 +:10A390001F78012F7FF465AF2F4802F001FA307863 +:10A3A000FCF7E4F82A4B12481D702C4B1F70F8F78D +:10A3B000BBFA052369E70E48F8F7BCFA00283FF41A +:10A3C00050AF00231C4A1370214A137073E7A52075 +:10A3D00000F0FEFD0748F8F7A7FA112355E70548F6 +:10A3E000F8F7A8FA00283FF43CAFE2E78014002019 +:10A3F00078140020701400206814002067140020D6 +:10A40000040E00200C0E00200D0E00201400002071 +:10A41000280E00201B4801081E4901082E4801088B +:10A42000544801080F0E002005000020991000205C +:10A4300097100020951000208E100020314901084F +:10A4400062490108941000204C4901089610002030 +:10A450008D1000208E4901087849010891100020D4 +:10A4600038B5074D2C7854B9064A1378012B06D11C +:10A470001470054A0548137002F092F92C7038BD2B +:10A4800066140020030E0020610E0020A44901087C +:10A4900038B5194C2378012B0DD0102B2BD04BB98C +:10A4A00016490A78012A05D10B70154922700B70E4 +:10A4B00014490B7038BDFFF7C9FB012805460CD1C4 +:10A4C000114802F06DF900F01DFD00220F4B1D70C8 +:10A4D0000A4B1A7010232370ECE70A4A1378012BF9 +:10A4E000E8D100231370054A237013700848BDE8B3 +:10A4F000384002F055B9FEE765140020020E002036 +:10A500000C0E00200D0E0020B94901089210002009 +:10A510005448010838B5194B1A782AB90122142178 +:10A5200017481A70F8F7F8F9164C237813B1012B75 +:10A5300013D038BD144A1578012DFAD1137000F0EC +:10A54000A1FAFEF7A1FEFDF7E3FBFEF7F7FC25708D +:10A550000B48BDE83840F8F7E7B90948F8F7EAF9D9 +:10A560000028E6D0094B1B78012B04D1FBF71AFD1C +:10A5700000232370DDE7FBF751FDF9E764140020A9 +:10A580005C140020591400200E0E0020050000204D +:10A5900010B5124C2378012B07D1114802F000F9B5 +:10A5A000002310482370FFF743F8FFF771FBFFF714 +:10A5B000C3FBFFF7E1FBFFF75BFCFFF7ADFCFFF729 +:10A5C0000DFDFFF76DFDFFF717FEFFF749FFFFF7E2 +:10A5D0005FFFBDE81040FFF79DBF00BFDA1100200C +:10A5E000D0490108AE3800202DE9F74FA64B1A7864 +:10A5F0002AB901226421A5481A70F8F78DF9A44BF5 +:10A6000093F800A0BAF1000F00F00581A14BA24A17 +:10A610001B781278934200F201816426D21AD2B2DA +:10A620005643B6FBFAF69D4BF6B21B789246B34200 +:10A630008CBF002301239A4A13709A4A92F8009023 +:10A64000B9F1000F00F0EE80974A98491278097826 +:10A650008A4200F2EA806425891AC9B24D43B5FBEB +:10A66000F9F5934AEDB212788946AA428CBF0022CE +:10A670000122DFF840B28BF800208F4A92F8008068 +:10A68000B8F1000F00F0D5808C4A8D491278097816 +:10A690008A4200F2D1806424891AC9B24C43B4FBC7 +:10A6A000F8F4884AE4B212788846A2428CBF0022AD +:10A6B000012285490A70854A1778002F00F0C08072 +:10A6C000834A8449127809788A4200F2BC80891A48 +:10A6D0006422C9B24A43B2FBF7F2D2B201927E4A77 +:10A6E000019812780F4682428CBF002201227B49DA +:10A6F00001200A707A4A1288022A04D0794A128804 +:10A70000022A40F0A480F8F7DFFF0220F8F7C2FF2A +:10A710000320F8F7D9FF0420F8F7BCFF604B724A1A +:10A720001B7812789A4211D1704A11789BF8002058 +:10A7300091420BD16E4A1178634A1278914205D149 +:10A740006C4A1178654A127891423CD0012B0CBFBB +:10A7500069486A4802F024F8514B4E491A78624B16 +:10A7600009781A7066485246334602F019F89BF889 +:10A770000030012B0CBF6348634802F011F89BF8CE +:10A7800000205A4B48491A7009782B464A465F48C0 +:10A7900002F006F84C4B49491A78554B09781A7063 +:10A7A0004E4B5B481A78534B1A702346424601F0D1 +:10A7B000F7FF47493A46019B0978564801F0F0FFF8 +:10A7C0006220F6F7DBFC3148F8F7B4F8002800F017 +:10A7D000B1802E48F8F7A8F82E493346524609783A +:10A7E0004D4801F0DDFF30492B464A4609784B4879 +:10A7F00001F0D6FF3149234642460978484801F026 +:10A80000CFFF3A463249019B0978464803B0BDE87C +:10A81000F04F01F0C5BF534656460CE700231E46D5 +:10A820009A4608E74A464D4623E7002215469146D8 +:10A830001FE7424644463CE700221446904638E76C +:10A840003A46019753E70022174601924FE7C3B1FA +:10A85000F8F720FF9BF800300220002B64D0F8F7B7 +:10A8600019FF194B03201B78002B60D0F8F712FF5B +:10A870001A4B04201B78002B7FF44EAFF8F724FF0F +:10A880004CE7F8F721FFE5E798140020901400202A +:10A8900011000020840B0020100000200F00002079 +:10A8A000CB0E00200E000020830B00200D000020A6 +:10A8B0000C000020CA0E00200B000020820B00209C +:10A8C0000A00002009000020C90E00200800002016 +:10A8D000810B00200700002006000020C80E002089 +:10A8E000FE0D0020FC0D00208C1400208B14002095 +:10A8F0008A14002089140020EA490108F649010859 +:10A90000044A0108244A0108304A01083E4A010865 +:10A910005E4A01087E4A01089E4A0108C54A0108AC +:10A92000EC4A0108134B0108F8F7CEFE99E7F8F757 +:10A93000CBFE9DE703B0BDE8F08F00BF00B589B046 +:10A9400002460649684601F09FFD684603F002FC96 +:10A9500081B26846F8F796F909B000BD3A4B010894 +:10A9600007B50121092000F019FE0121074800F078 +:10A9700097FD074B01A90748019300F038FD082116 +:10A98000044800F08BFD03B000BD00BF00023000A2 +:10A9900008000310000C014008B5FFF7E1FFBDE817 +:10A9A00008401420FFF7CABF00B589B002460A4923 +:10A9B000684601F069FD0821084800F06DFD01229C +:10A9C000074B68461A7003F0C5FB81B26846F8F77A +:10A9D00059F909B000BD00BF404B0108000C01400F +:10A9E000A51400200122024B1A70024B1870704708 +:10A9F000A7140020A614002038B51A4B1A782AB9DB +:10AA00000122322118481A70F7F786FF174C237875 +:10AA1000012B10D0022B0DD08BB9154A1578012DC2 +:10AA200008D11370134B1878FFF7BEFF0E48F7F7E5 +:10AA30007BFF257038BD0E4B1B78012B01D1002305 +:10AA40000EE00948F7F776FF0028F3D00A4801F036 +:10AA5000A7FE0821094800F021FD0023084A1370D1 +:10AA60002370E7E7A41400209C1400209A1400200F +:10AA7000A7140020A6140020484B0108000C014038 +:10AA8000A5140020F8B55F4D5F48296801F088FEE5 +:10AA90005E4C00F0DBFF5E4801F012F84FF6FF71EC +:10AAA0005B4801F02DF861885A4801F029F82188A7 +:10AAB000594C5A4801F024F86188594801F020F8AF +:10AAC0002188584801F01CF8574B58481978584BC2 +:10AAD000584E1B78584C43EA012101F011F8574BAE +:10AAE00057481978574B584F1B7843EA012101F01A +:10AAF00007F8564B56481978564B1B7843EA012104 +:10AB000000F0FEFF544B55481978554B1B7843EA2B +:10AB1000012100F0F5FF534B53481978534B1B7834 +:10AB200043EA012100F0ECFF514B52481978524B97 +:10AB30001B7843EA012100F0E3FF504B504819789D +:10AB4000504B1B7843EA012100F0DAFF4E4B4F488F +:10AB500019784F4B1B7843EA012100F0D1FF4D4B90 +:10AB60004D4819784D4B1B7843EA012100F0C8FF8E +:10AB70004B4B4C4819784C4B1B7843EA012100F0B1 +:10AB8000BFFF4A4B4A48197800F0BAFF2968494884 +:10AB900001F006FE31787378204643EA0121023441 +:10ABA00000F0AEFFBC4206F10206F3D1296842482C +:10ABB00001F0F6FD414B20461978414B1B7843EAE2 +:10ABC000012100F09DFF3F4B3F4819783F4B1B7818 +:10ABD00043EA012100F094FF3D4B3E48198800F004 +:10ABE0008FFF40F60B210A4800F08AFF00F03AFF81 +:10ABF0002968394801F0D4FDBDE8F840374801F034 +:10AC0000CFBD00BFC40F0020574B01084C0E0020E1 +:10AC100000F8070802F80708480E002004F80708A3 +:10AC200006F8070808F80708550E00200AF8070874 +:10AC3000540E0020CB17002038F80708530E0020D0 +:10AC40000CF80708460E002058F80708450E0020AB +:10AC50000EF80708440E0020520E002010F80708D6 +:10AC6000430E0020420E002012F80708410E00207B +:10AC7000510E002014F80708400E00203F0E00205F +:10AC800016F807083E0E0020500E002018F807089E +:10AC90003D0E00203C0E00201AF807083B0E002055 +:10ACA0003A0E002034F80708390E0020380E002034 +:10ACB00036F80708664B0108754B0108370E00206F +:10ACC000360E0020350E00205AF80708340E0020FA +:10ACD000320E00205CF80708844B0108934B0108F2 +:10ACE00040F60B212DE9F04F634B93B01A8892B2D6 +:10ACF0008A4240F0BB805988604C89B221609A88B2 +:10AD00005F4D92B242EA01422260D9885D4E89B21B +:10AD100029601A895C4F92B242EA01422A605A893C +:10AD2000DFF86881110A31703A709A89DFF8609112 +:10AD3000110A88F8001089F80020DA895549100AAC +:10AD4000087055490A701A8A5449100A0870544903 +:10AD50000A705A8A5349100A087053490A709A8A2D +:10AD60005249100A087052490A70DA8A5149100A89 +:10AD7000087051490A701A8B5049100A08705049DE +:10AD80000A705A8B4F49100A08704F490A709A8E00 +:10AD90004E49100A08704E494E480A70DA8E4E4BE2 +:10ADA0001A704E4B4E4A32F8021B02334FEA112CF6 +:10ADB000824203F802CC03F8011CF4D12E4BDFF8D9 +:10ADC00024A1B3F85820DFF820B1110A8AF8001046 +:10ADD0008BF80020B3F85A00444A010A1170444924 +:10ADE0000870B3F85C00434B1880434801F0D8FC6E +:10ADF000404B3F491B883D4A11930B783F481093C5 +:10AE000013780F939BF800300E939AF800300D934F +:10AE1000324B0C93304B1B780B932D4B1B780A93C2 +:10AE20002A4B1B780993204B1B7808931D4B1B78EA +:10AE300007931B4B1B780693184B1B780593164BF7 +:10AE40001B780493134B1B78039399F800300293FB +:10AE500098F8003001933B78009333782A68216892 +:10AE600001F09EFC002013B0BDE8F08F244801F0F3 +:10AE700097FC0120F7E700BF00F807084C0E002000 +:10AE8000480E0020550E0020540E0020530E0020C6 +:10AE9000460E0020450E0020440E0020520E0020D9 +:10AEA000430E0020420E0020410E0020510E0020D3 +:10AEB000400E00203F0E00203E0E0020500E0020CD +:10AEC0003D0E00203C0E00203B0E00203A0E0020DC +:10AED000390E002058F80708380E0020CB17002044 +:10AEE00038F80708370E0020360E0020350E0020F7 +:10AEF000340E0020320E0020A64B0108B94B010889 +:10AF00004F4C010808B500F0A1FD054800F0D8FD40 +:10AF100000F0A8FDBDE80840024801F041BC00BFB8 +:10AF200000F807086A4C0108FF2810B514D00B4C34 +:10AF30000F3024785C436FF0630394FBF3F440F22A +:10AF4000A3631444A4B2A04288BF1046994202D819 +:10AF50004A2898BF1046C0B210BD00BF12000020A2 +:10AF6000682270B5194BA0B000938DF805200378C6 +:10AF700042788DF804308DF806201344082210F82A +:10AF8000021F303B01F109058DF807100B44EDB2AB +:10AF900014460132D2B28034AA426C440FD104F874 +:10AFA000803C02F180030DEB030216230A31684650 +:10AFB000C9B202F8803CF7F7C7FE20B070BD10F8A8 +:10AFC000016F04F8806C3344E2E700BFFEFEFE68C8 +:10AFD00038B5002305460B4C014660700A482370C3 +:10AFE00001F0DEFBA12D0ABF04210321074B054818 +:10AFF00004BF1B78E370CB1EA370BDE83840FFF799 +:10B00000AFBF00BF5A3A00208D4C010899100020B4 +:10B010002DE9F7435E4D2B78FD2B11D15D4C637804 +:10B02000032B00F08D800ED8012B1BD0022B00F0DB +:10B03000838080220021574801F0C4FB00232B703D +:10B0400003B0BDE8F083A22B00F09280A32BF0D1D7 +:10B05000E378514A012B137000F09780022BE8D15E +:10B060004E4B67E0B4F803304D4A5BBA138099B297 +:10B07000B4F805304B4A5BBA13809EB2B4F807307F +:10B08000494A5BBA13801FFA83F8B4F80930474A7B +:10B090005BBA1FFA83F91380454B1B78002B39D11B +:10B0A000444B454A1B781278E07AFFF73DFF434B4B +:10B0B000434A1870434B07461B7831461278207B71 +:10B0C000FFF732FF404B414A1870414B06461B7850 +:10B0D00041461278607BFFF727FF3E4B3E4A1870CF +:10B0E0003E4B80461B7812784946A07BFFF71CFF39 +:10B0F0003B4B324618703B4B39461F703A4B1E7023 +:10B100003A4B83F800803A4B187000904346394818 +:10B1100001F046FBE27B384B1A70227C374B1A70E9 +:10B12000627C374B1A70A27C364B1A70364BE27C2D +:10B130001A70364B012201E0E278354B1A7078E73D +:10B14000E278344B1A702279334B1A706279334BA0 +:10B150001A70D4F80630324A1BBA1360A27A314B07 +:10B160001A70D4F80B30304A1BBA13602F4BE1E74A +:10B17000E378094A012B137004D0022B7FF459AFF6 +:10B180002B4BD7E72B4A137053E72B4AFBE700BF43 +:10B19000CE0F00204C250020981000209410002095 +:10B1A000A01000209E1000209C1000209A1000206B +:10B1B000CC0E0020110000201000002021000020F3 +:10B1C0000D0000200E000020200000200A000020BA +:10B1D0000B0000201F0000200700002008000020B6 +:10B1E0001E000020840B0020830B0020820B002017 +:10B1F000810B0020A14C0108F1110020E30E00207A +:10B20000F3110020E70E0020E60E0020000E0020C3 +:10B2100006100020DE0E0020DD0E0020DC0E0020D7 +:10B22000D80E0020D40E0020D00E0020CD0E00201D +:10B2300095100020971000209610002008B50520DA +:10B24000FBF7C0FB034801F0ABFA0122024B1A7076 +:10B2500008BD00BFC44C0108AB14002008B5052090 +:10B26000FBF7FCFB034801F09BFA0022024B1A702B +:10B2700008BD00BFD74C0108AB14002008B503205F +:10B28000FBF710FD034801F08BFA0122024B1A7004 +:10B2900008BD00BFEA4C0108A914002008B503202E +:10B2A000FBF74CFD034801F07BFA0022024B1A70B9 +:10B2B00008BD00BF014D0108A914002008B56FF0BA +:10B2C000040000F089F8084B084A1B68B3FBF2F34E +:10B2D000074ADBB21370C3EB431203EB8203054A48 +:10B2E000DB00138008BD00BF0000002000127A00C0 +:10B2F000AE140020AC1400200B4B00221B785843E6 +:10B300004FF0E02358619A611A6942F001021A6114 +:10B310001A69D10701D5D203FAD51A6922F00102C0 +:10B320001A6100229A617047AE1400200B4B002274 +:10B330001B8858434FF0E02358619A611A6942F024 +:10B3400001021A611A69D10701D5D203FAD51A6927 +:10B3500022F001021A6100229A617047AC140020A9 +:10B36000034B40F0BF6040F40030D860704700BF2E +:10B3700000ED00E030B5C2780378EAB1144A0F2539 +:10B38000D1684478C943C1F30221C1F10402944059 +:10B39000827825FA01F10A400E49224312010B443A +:10B3A00083F8002301220378580903F01F0302FAEF +:10B3B00003F341F8203030BD01215A0903F01F0387 +:10B3C000994002F12003034A42F82310F3E700BF3B +:10B3D00000ED00E000E100E04FF0E0231A690428EE +:10B3E0000CBF42F0040222F004021A617047CB78CD +:10B3F000F0B503F00F04DB0644BF8B781C430B78D9 +:10B40000D3B1002201274FF00F0C03680D8807FA13 +:10B4100002F636EA05050BD195000CFA05FE23EA83 +:10B420000E0304FA05F52B43CD78282D2AD1466169 +:10B430000132082AEAD103600B88FF2B21D90023AF +:10B440004FF0010C4FF00F0E46680D8803F1080213 +:10B450000CFA02F232EA05050FD19D000EFA05F74B +:10B4600026EA070604FA05F52E43CD78282D08BFF5 +:10B470004261CD78482D08BF02610133082BE4D129 +:10B480004660F0BD482D08BF0661D1E783681942C8 +:10B4900014BF01200020704701617047416170476F +:10B4A00030B50028164C00F44015B4BFE36963685A +:10B4B000B5F5401F82B212D1656823F0706325F0A4 +:10B4C00070656560440D2401A2401A43002918BF2D +:10B4D00013460B4A0028B4BFD361536030BDC40289 +:10B4E0004DBF0324440D2401C0F303454CBFAC40C1 +:10B4F00002FA04F423EA040343F07063E2E700BFB6 +:10B500000000014010B51A4A536803F00C03082BE1 +:10B510002CD153685168C3F38343CC0303F1020376 +:10B5200002D5516889031FD512494B430360516806 +:10B53000114CC1F30311615CCB4043605168C1F30E +:10B540000221615C23FA01F181605168C1F3C221DB +:10B55000615CCB40C36052680849C2F381328A5CA7 +:10B56000B3FBF2F3036110BD0549DEE7044BDDE7F1 +:10B570000010024000093D00515201084D520108DF +:10B5800000127A00044B5A6911B102435A617047A4 +:10B5900022EA0002FAE700BF00100240044B9A6959 +:10B5A00011B102439A61704722EA0002FAE700BF34 +:10B5B00000100240044BDA6911B10243DA617047AE +:10B5C00022EA0002FAE700BF00100240044BDA68EA +:10B5D00011B10243DA60704722EA0002FAE700BFC5 +:10B5E00000100240044B1A6911B102431A617047FE +:10B5F00022EA0002FAE700BF0010024008B5214B22 +:10B6000098420BD101214FF48040FFF7DFFFBDE8E6 +:10B61000084000214FF48040FFF7D8BF1A4B9842F2 +:10B620000BD101214FF40030FFF7DCFF00214FF474 +:10B630000030BDE80840FFF7D5BF144B984208D151 +:10B6400001214FF48020FFF7CDFF00214FF480202F +:10B65000EFE70F4B984208D101214FF40020FFF78C +:10B66000C1FF00214FF40020E3E70A4B984208D1C4 +:10B6700001214FF48010FFF7B5FF00214FF4801037 +:10B68000D7E708BD003801400044004000480040B2 +:10B69000004C00400050004030B50446038ACA8880 +:10B6A00023F44053134387B0038283898A8823F4A9 +:10B6B000B05323F00C0313430A890D4613434A8900 +:10B6C00013438381838A8A8923F4407313438382DB +:10B6D00001A8FFF717FFDDE9033214498C4208BFC8 +:10B6E00013461922A18953432A680D044CBF520006 +:10B6F00092006421B3FBF2F3B3FBF1F201FB1233CE +:10B70000A08900044BBFDB001B01323332334BBF37 +:10B71000B3FBF1F3B3FBF1F303F0070303F00F0303 +:10B7200043EA0212228107B030BD00BF0038014059 +:10B73000838919B143F400538381704723F4005384 +:10B74000FAE7012310B5C1F34214012C01F01F01E7 +:10B7500003FA01F305D10C3042B1026813430360D0 +:10B7600010BD022C0CBF10301430F5E7026822EA3D +:10B770000303F4E7838A12B119438182704723EAF5 +:10B78000010383827047C1F308018180704780887C +:10B79000C0F3080070470388194214BF012000203D +:10B7A0007047C943018070470123C1F3421210B5AD +:10B7B000012A01F01F0403FA04F30FD1828992B227 +:10B7C000134001220088090A8A4080B21040002BF1 +:10B7D00018BF002814BF0120002010BD022A0CBF92 +:10B7E000028A828AEBE70000214A0388904212D045 +:10B7F00002F5006290420ED0B0F1804F0BD0A2F55E +:10B800009832904207D002F58062904203D002F550 +:10B810008062904203D14A8823F070031343154A93 +:10B82000904207D002F5806290421EBFCA8823F47E +:10B830004073134303808B8883850B8803850C4BEF +:10B8400098420FD003F5006398420BD003F5406394 +:10B85000984207D003F58063984203D003F58063D4 +:10B86000984201D10B7A038601238382704700BF7F +:10B87000002C014000100040038819B143F001037F +:10B880000380704723F00103FAE7838912B119435B +:10B890008181704723EA0103838170478184704767 +:10B8A000038A8289114214BF01200020194200F04E +:10B8B000010008BF00207047C943018270470000A3 +:10B8C000036823F001031B041B0C036000230360C7 +:10B8D00043608360C360294B984204D1284A53686F +:10B8E00043F00F0326E0274B984204D1244A5368C3 +:10B8F00043F0F0031EE0244B984204D1204A5368E1 +:10B9000043F4706316E0214B984204D11C4A5368FB +:10B9100043F470430EE01E4B984204D1184A53681A +:10B9200043F4702306E01B4B984205D1144A536838 +:10B9300043F4700353607047174B984204D1104A88 +:10B94000536843F07063F5E7144B984201D1144AF1 +:10B95000C5E7144B984201D1114AC8E7124B9842EF +:10B9600001D10F4ACBE7114B984201D10C4ACEE7E7 +:10B970000F4B9842DFD10A4AD1E700BF08000240CE +:10B98000000002401C00024030000240440002401F +:10B99000580002406C00024080000240080402404F +:10B9A000000402401C0402403004024044040240EF +:10B9B0005804024010B58B680C6A026823430C6976 +:10B9C0006FF30E1223434C6923438C692343CC69E4 +:10B9D00023434C6A23438C6A234313430360CB689D +:10B9E00043600B6883604B68C36010BD036819B186 +:10B9F00043F001030360704723F001031B041B0C99 +:10BA0000F8E7416070470000014B1860704700BFC5 +:10BA100000300040014B5860704700BF00300040CC +:10BA2000014B9860704700BF003000404AF6AA22E0 +:10BA3000014B1A60704700BF003000404CF6CC420A +:10BA4000014B1A60704700BF00300040034B044AAE +:10BA50005A6002F188325A60704700BF00200240ED +:10BA600023016745024A136943F08003136170475D +:10BA700000200240084BDA68D10709D4DA6852077F +:10BA800008D4DB6813F0100F0CBF042003207047AC +:10BA900001207047022070470020024010B5044684 +:10BAA000FFF7E8FF012806D10CB9052010BDFFF70C +:10BAB000E1FF013CF6E7002C08BF0520F6E7000097 +:10BAC00038B505464FF43020FFF7E8FF042813D1BE +:10BAD0000A4C4FF43020236943F00203236165616F +:10BAE000236943F040032361FFF7D8FF236923F064 +:10BAF0000203DB04DB0C236138BD00BF00200240E1 +:10BB000070B505464FF400500E46FFF7C7FF0428F6 +:10BB10000FD1084C4FF40050236943F00103236117 +:10BB20002E80FFF7BBFF236923F00103DB04DB0C4E +:10BB3000236170BD0020024070B50E4615460024FA +:10BB4000AC4201DB284670BD40210548FFF723FECB +:10BB50000028F9D0315D0248FFF715FE0134EFE708 +:10BB6000005000400D480E490E4A914200D304E0B7 +:10BB700050F8043B41F8043BF7E70B490B4A00231C +:10BB8000914200D302E041F8043BF9E7F4F74AFCA4 +:10BB900001F044FAF4F786FBFEE700005456010872 +:10BBA00000000020B80D0020B80D00205C3B0020F4 +:10BBB000FEE70A22002100F0CBBD002B2DE9F04763 +:10BBC0001D46BBBF03F100431D4600232D2388B053 +:10BBD000149F144627F02007B8BF1446129A462F28 +:10BBE000109EDDF84CA0137004D0452F00D1013613 +:10BBF000022300E0032307AA049206AACDE902A2C9 +:10BC0000CDE9003622462B4602F05EFB472F8046E8 +:10BC10001AD1119BDB070ED500EB06090022002389 +:10BC20002046294605F01EFD08B1CDF81C903022B3 +:10BC3000079B4B451ED34046079B159AA3EB080371 +:10BC4000136008B0BDE8F087462F00EB0609E5D188 +:10BC50000378302B0AD1002200232046294605F024 +:10BC600001FD18B9C6F10106CAF80060DAF8003023 +:10BC70009944D3E7591C07911A70D9E7F7B5002901 +:10BC8000B6BF2D232B2349420929027043702BDDB7 +:10BC90000DF10704A6460A26871CB1FBF6F5A4465B +:10BCA00006FB1512632902F13002294604F1FF3424 +:10BCB0000CF8012CF1DC3031ACF1020204F8011C6B +:10BCC0001446411C72450AD30DF10903A3EB0C0382 +:10BCD000A64538BF00233B44181A03B0F0BD12F844 +:10BCE000013B01F8013FEDE7302330318370C17033 +:10BCF000031DF1E72DE9F04F93B00C46DDF870809D +:10BD000016461F46054602F0F3F9036818460B93E2 +:10BD100002F020FA00231093D8F8003094F818A00D +:10BD2000073323F00703F3E80212D4F800B0CDE99B +:10BD30000812C8F8003013460A46C4E91223DDE9A8 +:10BD4000088323F000490C904FF0FF3240464946EB +:10BD50009A4B05F0B9FC70BB4FF0FF3240464946A4 +:10BD6000964B05F093FC30BBDDE90801002200236F +:10BD700005F082FC10B12D2384F84330904A914B9A +:10BD8000BAF1470F8CBF9046984603234FF0000945 +:10BD900023612BF004032360334621462846009795 +:10BDA00011AA00F0D1F9013040F08F804FF0FF3040 +:10BDB00013B0BDE8F08FDDE908231046194605F001 +:10BDC00083FC40B1099B804A002BBCBF2D2384F823 +:10BDD00043307E4BD4E763680AF0DF095A1C3ED13A +:10BDE0000623636000224BF480632360069210AA4E +:10BDF000CDE904A20FAA03920DF13B02CDE9013275 +:10BE0000636828460093DDE90823FFF7D6FEB9F101 +:10BE1000470F80460F9929D1C81C02DB63688B420B +:10BE200041DAAAF1020A5FFA8AFA5246013904F1AC +:10BE300050000F91FFF722FF109A81461318012A34 +:10BE4000236102DC2268D20701D5013323619DF80A +:10BE50003B30002BA0D02D2384F843309CE7B9F170 +:10BE6000470FBFD1002BBDD10123BAE7BAF1650F4F +:10BE7000DBD9BAF1660F18D1002963680BDD2161A7 +:10BE800013B92268D00702D501330B4423614FF068 +:10BE90000009A165DBE713B92268D20701D5023397 +:10BEA000F4E70123F2E74FF0670A109B8B4205DCB1 +:10BEB00023682161D807EAD54B1CE7E70029CCBFEE +:10BEC0000122C1F102021344E0E723685A0507D4B6 +:10BED0002369424631462846B847013028D165E7F4 +:10BEE000BAF1650F40F2DC80D4E912010022002390 +:10BEF00005F0B8FB90B3012331462846344AB847D1 +:10BF000001303FF453AFDDE90F38434502DB2368CE +:10BF1000D8070DD5DDE90B2331462846B847013057 +:10BF20003FF444AF4FF0000908F1FF38C84509DC81 +:10BF300023689B0700F10581E068119B9842B8BF18 +:10BF4000184635E701233146284604F11A02B8475E +:10BF500001303FF42BAF09F10109E7E70F9B834262 +:10BF600038DC012331462846194AB84701303FF4EE +:10BF70001DAFDDE90F3959EA030302D12368D90760 +:10BF8000D6D5DDE90B2331462846B84701303FF4CA +:10BF90000DAF4FF0000A0F9B5B42534501DC4B464F +:10BFA00097E701233146284604F11A02B8470130C9 +:10BFB0003FF4FCAE0AF1010AEDE700BFFFFFEF7F9F +:10BFC0001C4D0108184D0108244D0108204D0108A1 +:10BFD00013300108A36DDDF840B05B45A8BF5B4698 +:10BFE000002B089337DC4FF0000904F11A02089B7C +:10BFF000D4F858A0002BB4BF5346AAEB03034B451B +:10C0000031DC0F9B9B453ADC2368DA0737D40F9B62 +:10C01000ABEB0309ABEB0A039945A8BF9946B9F10D +:10C02000000F34DC4FF000080F9BB9F1000FABEBB1 +:10C030000303A8BFA3EB090343457FF779AF0123AF +:10C040003146284604F11A02B84701303FF4AEAE3B +:10C0500008F10108E8E7424631462846089BB84700 +:10C060000130C0D1A2E60123314628460D92B847DF +:10C0700001303FF49BAE0D9A09F10109B7E7314653 +:10C08000DDE90B232846B8470130C0D18EE64B4688 +:10C090003146284608EB0A02B8470130C2D185E68E +:10C0A000DDF840A0BAF1010F01DCDB0735D5012333 +:10C0B000424631462846B84701303FF477AEDDE9C5 +:10C0C0000B2331462846B84701303FF46FAED4E920 +:10C0D0001201002200230AF1FF3A05F0C3FAC8B9A1 +:10C0E000534608F1010231462846B84701300DD1C8 +:10C0F0005CE601233146284604F11A02B8470130B4 +:10C100003FF454AE08F10108D045F2DB4B4604F190 +:10C110005002DFE64FF00008F6E701234246E2E76F +:10C1200001233146284604F11902B84701303FF493 +:10C130003DAE08F10108E36811995B1A4345EFDC55 +:10C14000FAE64FF00008F6E72DE9F04791469846E9 +:10C150008A680B6907469342B8BF1346C9F8003096 +:10C1600091F843200C46089E12B10133C9F8003003 +:10C170002368990642BFD9F800300233C9F800306D +:10C18000256815F0060507D104F1190AE368D9F806 +:10C1900000209B1AAB4229DC94F843302268003B14 +:10C1A00018BF012392062ED44146384604F14302BB +:10C1B000B047013021D02368A16803F00603042BA7 +:10C1C00012BF0025E568D9F80030226904BFED1AD6 +:10C1D00025EAE5758B1A2B449142C8BF1D464FF0E6 +:10C1E00000091A344D451AD1002008E001235246B7 +:10C1F00041463846B047013003D14FF0FF30BDE82B +:10C20000F0870135C2E73020E11881F843005A1C5D +:10C2100094F845102244023382F84310C4E7012306 +:10C22000224641463846B0470130E6D009F10109BF +:10C23000D8E700002DE9F04398460B7E85B0782BB7 +:10C24000174606460C460C9A09D8622B01F14301A9 +:10C2500008D8002B00F0DC80582B00F0BD8004F1E2 +:10C26000420539E0A3F163001528F8D801A555F877 +:10C2700020F000BFCDC20008E1C200085FC2000884 +:10C280005FC200085FC200085FC20008E1C2000888 +:10C290005FC200085FC200085FC200085FC20008FA +:10C2A000F1C300080DC300089FC300085FC2000867 +:10C2B0005FC2000819C400085FC200080DC300086F +:10C2C0005FC200085FC20008A7C30008136804F13A +:10C2D0004205191D1B68116084F842300123A8E053 +:10C2E00013682568181D1060280601D51B6803E037 +:10C2F0006A06FBD5B3F90030002B03DA2D225B422E +:10C3000084F843200A22DFF878C113E0256810681A +:10C3100015F0800F50F8043B02D16D0648BF9BB268 +:10C320001060227EDFF858C16F2A5DD108220020FC +:10C3300084F843006568002DA56005DB20681D4377 +:10C3400020F00400206051D00D46B3FBF2F002FB58 +:10C35000103E1CF80EE09A4205F801ED0346F4D9B0 +:10C36000082A0BD12368DA0708D5236962689A4244 +:10C37000DEBF302305F8013C05F1FF35491B216183 +:10C380003B4621463046CDF8008003AAFFF7DCFE8D +:10C39000013053D14FF0FF3005B0BDE8F083236882 +:10C3A00043F0200323607823DFF8D8C084F84530B9 +:10C3B0002068156810F0800F55F8043B03D110F089 +:10C3C000400F18BF9BB21560C50744BF40F0200066 +:10C3D000206023B11022AAE7DFF8A4C0E6E72268B4 +:10C3E00022F020022260F5E70A22A0E70D46B7E717 +:10C3F0001368D4F800C01D1D60691CF0800F156023 +:10C400001B6801D0186003E01CF0400FFAD01880C0 +:10C4100000230D462361B3E71368191D11601D68E1 +:10C4200000212846626801F079FE08B1401B606077 +:10C4300063682361002384F84330A1E72A46394624 +:10C4400030462369C0470130A4D023689B0714D429 +:10C45000E068039B9842B8BF18469DE70123394620 +:10C46000304604F11902C047013093D00135E3682A +:10C4700003995B1AAB42F1DCEAE70025F7E700BF5E +:10C48000284D0108394D01080EB46FF0004110B578 +:10C4900000249DB01FAB02900690079104910948BB +:10C4A000094953F8042B0591006802A901931B94D4 +:10C4B00002F08EFD029B1C701DB0BDE8104003B061 +:10C4C000704700BF9C0B00200802FFFF002310B53F +:10C4D0000446C0E90033C0E90433836081814366C8 +:10C4E000C2818361194608225C3000F06BF90D4B64 +:10C4F000246263620C4BA3620C4BE3620C4B23631C +:10C500000C4B9C4206D003F16802944202D0D03317 +:10C510009C4205D104F15800BDE8104001F0BCBBBD +:10C5200010BD00BF99FD0008BFFD0008F7FD000821 +:10C530001DFE0008B0140020024A0349034800F021 +:10C5400011B900BF880B00201DFF0008A00B0020C0 +:10C5500041680C4B10B59942044601D003F0DEFC53 +:10C56000A168094B994202D0204603F0D7FCE1684C +:10C57000064B994204D02046BDE8104003F0CEBCE3 +:10C5800010BD00BFB0140020181500208015002039 +:10C5900010B50A4B0A4A04211A600A480022FFF724 +:10C5A00095FF012209210848FFF790FFBDE81040E0 +:10C5B000022212210548FFF789BF00BFE8150020BD +:10C5C00039C50008B014002018150020801500207F +:10C5D000014801F063BB00BFEF150020014801F0E6 +:10C5E0005FBB00BFEF15002010B50446FFF7F0FF5A +:10C5F000236A1BB1BDE81040FFF7F0BF044B236274 +:10C60000044B1B68002BF5D1FFF7C2FFF2E700BF18 +:10C6100051C50008E815002010B59AB000910491AA +:10C620006FF000410024059102910549199403918E +:10C63000694602F0CDFC009B1C701AB010BD00BF13 +:10C640000802FFFF13460A46014602480068FFF74A +:10C65000E3BF00BF9C0B0020242B2DE9F047884648 +:10C6600001D8012B06D100F0D3FC16230360002073 +:10C67000BDE8F0870D46344E294615F8014B375D6D +:10C6800017F00807F8D12D2C10D101272C788D1C1C +:10C6900033F0100115D1302C0DD1297801F0DF01D4 +:10C6A000582908D16C78023510230AE02B2C04BFDE +:10C6B0002C788D1CECE7002BF6D1302C14BF0A230C +:10C6C0000823002107F1004E0EF1FF3EBEFBF3F9F7 +:10C6D0000E4603FB19EAA4F1300CBCF1090F10D887 +:10C6E0006446A3421EDDB1F1FF3F07D0B14516D32A +:10C6F00001D1A24513DB012106FB034615F8014BCE +:10C70000E9E7A4F1410CBCF1190F01D8373CE8E787 +:10C71000A4F1610CBCF1190F04D8573CE1E74FF0CC +:10C72000FF31EBE74B1C05D122237646036032B97B +:10C7300030469DE707B17642002AF9D009B105F1EC +:10C74000FF38C2F80080F3E721540108FFF784BFE7 +:10C7500013460A46014602480068FFF77DBF00BF46 +:10C760009C0B00202DE9F84380468946144600269C +:10C77000D4E90175013F05D52468002CF8D1304675 +:10C78000BDE8F883AB89012B07D9B5F90E30013329 +:10C7900003D029464046C84706436835EAE700000B +:10C7A0000FB407B5064904AB086853F8042B816839 +:10C7B000019302F0DBFD03B05DF804EB04B07047B9 +:10C7C0009C0B002003460244934200D1704703F8BB +:10C7D000011BF9E7034670B51C781E4644B10133CE +:10C7E0004A1E01E0A542F7D012F8015F002DF9D1F1 +:10C7F000301A70BD1B4B2DE9F0411C680646656C74 +:10C800000F463DBB502002F0DBFC606428B90246B5 +:10C810005B21154B154801F0A9FC8560626CC0E9ED +:10C820000055C2E90355626C2B46C2E90555626C9E +:10C83000C2E90A55626CC2E90C55626CC2E90E5538 +:10C84000626CC2E91055626CC2E91255626C1577D0 +:10C85000656C6B622A4639463046BDE8F0410123DB +:10C8600000F006B89C0B00204A4D0108614D0108FC +:10C87000F0B5044608B9146844B1204614F8015BC9 +:10C880004F1E17F8016F1EB965B91560002005E04D +:10C89000B542F6D1002BF0D114600370F0BD1C46F8 +:10C8A0000CE01DB9274614F8013B4E1E16F8015F37 +:10C8B000AB42F6D1002BF2D000233B701460EDE7C1 +:10C8C0000A7870B56AB970BD9A4209D10C4605461E +:10C8D00014F8013F002BF6D015F8016F9E42F7D0F7 +:10C8E00001300378002BEFD11846ECE738B50B4B3D +:10C8F00005461C68626B52B9242002F061FC0246B6 +:10C90000606320B93221064B064801F02FFC28460F +:10C91000BDE83840114600F007B800BF9C0B00206E +:10C920004A4D0108C44D01082DE9F0410C46064668 +:10C9300003F034FD21460746304603F033FD4369DA +:10C940000446990703F26C7806D1642298FBF2F34F +:10C9500002FB1383002B6FD14FF4C87398FBF3F5E0 +:10C9600003FB1585B5FA85F56D09644B6D4205F03D +:10C9700030051D4401F07EF901F088F9604B1B6819 +:10C98000002B68D07B68434558D1D6E90023D7E90E +:10C9900008013E68002E59D1824273EB01015CDB35 +:10C9A000012323623B6D4FF4616293FBF2F002FBC3 +:10C9B00010333C2293FBF2F602FB163321686268C7 +:10C9C000C91AA368921B1B1A3B2921606260A360ED +:10C9D0004FDD013262603C3921603B2A4FDD01337B +:10C9E000A3603C3A6260172B4FDDE269183B0132CD +:10C9F000E261A269A3600132072AA8BF0022A261F6 +:10CA0000E26823690132E26055F823108A420EDDA4 +:10CA10000B2BA2EB0102E26003F1010205BF002231 +:10CA200063692261013302BF22616361E26101F047 +:10CA300027F92046BDE8F081012596E7404601F040 +:10CA400067F80028A1D14FF0FF3304E0824273EB76 +:10CA5000010102DA0023236209E0D7E912018242D0 +:10CA60008B41B4BF012300232362002B9AD1BB6A00 +:10CA700099E70029B1DA013A62603C31ACE7002A5B +:10CA8000B1DA013BA3603C32ACE7002BCFDAE269BC +:10CA90001833013AE261A269A360013A48BF062255 +:10CAA000A261E268013AE260002AC0D12369013B39 +:10CAB00004D4236155F82330E360B8E70B232361E6 +:10CAC00063695A1E6261920703F26B7305D1642198 +:10CAD00093FBF1F201FB12326AB94FF4C87293FB77 +:10CAE000F2F102FB1133B3FA83F35B0903F5B6737A +:10CAF000E3610B23DEE70123F8E700BFC45201081E +:10CB000010160020F7B5016804463B2911D93C22D4 +:10CB1000684601F049FB019A63680099002A0B44BA +:10CB20006360BBBF3C3203F1FF3322602260B8BFB9 +:10CB3000636061683B2911D93C22684601F034FBEF +:10CB4000019AA3680099002A0B44A360BBBF3C3242 +:10CB500003F1FF3362606260B8BFA360A168172968 +:10CB600011D91822684601F01FFB019AE368009969 +:10CB7000002A0B44E360BBBF183203F1FF33A2600D +:10CB8000A260B8BFE36021690B2911D90C22684665 +:10CB900001F00AFB019A63690099002A0B44636162 +:10CBA000BBBF0C3203F1FF3322612261B8BF636166 +:10CBB00063699A073FD1642193FBF1F201FB1232C2 +:10CBC000002A3AD14FF4C87203F26C7393FBF2F16E +:10CBD00002FB1133002B0CBF1D231C23E268002A2B +:10CBE0002DDD304D216901290CBF184655F8210073 +:10CBF00082424DDD0131121A0C29E2602161F1D12E +:10CC0000002063692061591C8807616146D1642056 +:10CC100091FBF0F600FB1611002941D14FF4C871C9 +:10CC200003F26D7393FBF1F001FB1033002B0CBF8B +:10CC30001D231C23D6E71C23D0E71D23CEE70B259D +:10CC40006420184E216901392161013116D16369CF +:10CC5000591E8F07C4E904511CD191FBF0F700FB6A +:10CC60001711C9B94FF4C87103F26B7393FBF1F755 +:10CC700001FB1733002B0CBF1D231C232169012945 +:10CC80000CBF194656F821100A44002AE260D9DD8B +:10CC900003B0F0BD1C23F1E71D23EFE71C23A1E740 +:10CCA0001D239FE7945201082DE9F74F074603F033 +:10CCB00075FB81463846FFF725FFD7E90363D7E9BF +:10CCC0000041B448013E50F82300012BBA687D6949 +:10CCD000064411DDA8070FD1642095FBF0F300FB9B +:10CCE000135343B94FF4C87005F26C7393FBF0FC17 +:10CCF00000FB1C3303B9013644F6206005F51C53D4 +:10CD000010338342FE6100F26D813C2303FB01443A +:10CD10004FF46163462D03FB024440F3B180462388 +:10CD200040F26D1C64214FF4C8709A0740F0A28055 +:10CD300093FBF1F201FB1232002A40F09E8003F2D5 +:10CD40006C7292FBF0FE00FB1E22002A0CBF4FF417 +:10CD5000B77262460133AB421644E6D18E4B4FEABE +:10CD6000E478C6FB034800F085FF00F08FFF8B4B93 +:10CD70001B68002B00F04381D7F820A07869534648 +:10CD8000012BA8BF01230193D9F8043000F26C7085 +:10CD9000834240F0B880D9E91221D9F828C0D9F8E7 +:10CDA0005030B2EB0C0B61EBEC7E5C4578EB0E0087 +:10CDB00080F2CC80D9E90812D9F80000C91A62EBD8 +:10CDC000E372002800F0CB808C4278EB0202C0F2C4 +:10CDD00013815C4578EB0E0EB4BF4FF0010B4FF0A2 +:10CDE000000BBAF1000FC0F29580019A82EA0B0A9B +:10CDF000BAF1010F40F08E80BBF1000F00F0BE8051 +:10CE0000ACEB03033A681C191A443A60FA683846D6 +:10CE100048EBE3780192FFF775FEFB68019A9B1AD5 +:10CE200078D0012B00F3AD80B3F1FF3FA8BF9A4645 +:10CE3000FB6956441AEB030340F1B2806B1E99075D +:10CE400040F0A280642293FBF2F102FB1133002B2D +:10CE500040F09D804FF4C87305F26B7595FBF3F2BB +:10CE600003FB1255002D40F26D1318BF4FF4B6733B +:10CE7000FB614FE040F26D126CE74FF4B77269E767 +:10CE80003FF46CAF452340F26D1C64214FF4C87031 +:10CE900012E062BB93FBF1F201FB123252BB03F2D0 +:10CEA0006C7292FBF0FE00FB1E22002A0CBF4FF4B6 +:10CEB000B7726246B61A013BAB4203F00302E8DCEC +:10CEC000DAB9642295FBF2F302FB1353C3B94FF4B2 +:10CED000C87205F26C7393FBF2F102FB1133002B65 +:10CEE00040F26D1308BF4FF4B773F61A36E740F2FD +:10CEF0006D12DFE74FF4B772DCE740F26D13F4E731 +:10CF00004FF4B773F1E700F003FE00287FF443AF5E +:10CF1000DDF804B0BBF1010F73D14FF0010BD9F86C +:10CF200050301C1948EBE37800F0AAFE07230436C2 +:10CF300096FBF3F3C3EBC303F61A51D4C7F820B042 +:10CF4000BE612046414603B0BDE8F08FD21A61EBC6 +:10CF5000E371944278EB0101BFF62CAFD8E78C4225 +:10CF600078EB020242DA5C4578EB0E0EB4BF4FF06C +:10CF7000010B834635E74FF0000B36E7A3EB0C03BC +:10CF800040E74FF0FF3A53E74FF4B67370E740F2D3 +:10CF90006D136DE7645201088051010010160020E6 +:10CFA000AA0717D1642195FBF1F201FB1252A2B935 +:10CFB0004FF4C87205F26C7595FBF2F102FB115546 +:10CFC000002D40F26D1208BF4FF4B7729342A8BF14 +:10CFD0009B1A4DE740F26D12F8E74FF4B772F5E790 +:10CFE0000736ABE74FF0FF34A046AAE7BAF1000FCF +:10CFF00093DB4FF0010BF8E6BAF1000FBBDA4FF00C +:10D00000000BD9F828301C1948EBE3788CE700BFF7 +:10D01000014B1868704700BF9C0B002070B50026BC +:10D020000C4C0D4B1D1BB6EBA50F09D1002608F0CB +:10D03000FDFA0A4C0A4B1D1BB6EBA50F05D170BDBE +:10D0400054F8043B98470136EDE754F8043B984701 +:10D050000136F1E74C5601084C5601084C560108C0 +:10D0600050560108426940F26C73002AA8BF6FF065 +:10D0700063031344920705D1642193FBF1F201FB92 +:10D080001232CAB94FF4C87293FBF2F102FB1133AA +:10D09000B3FA83F35B09D0E90602400000EB02100B +:10D0A000184441F2A263984227D011DC01280ADC1F +:10D0B000C043C00F404270470123ECE7104BC34010 +:10D0C00043F3000070470A381728F7D9002070474B +:10D0D00041F2B463984206DC41F2B1639842D4BF96 +:10D0E000002001207047A0F5B65002381528EDD871 +:10D0F000044BC34003F0010070470120704700BF9C +:10D10000CF00CC001F002A002DE9F04F1E4600235F +:10D1100007460D461C468FB002931378002B00F093 +:10D12000D984252B40F081805378302B00F0878004 +:10D130002B2B00F08480002302F1010898F80020D6 +:10D14000313AD2B2082A7DD840460A2206A9039372 +:10D1500002F0FAFF8146DDF81880039B98F8001072 +:10D16000452901D04F2901D108F1010898F80000A4 +:10D17000A0F12501552900F25081DFE811F0A30448 +:10D180004E014E014E014E014E014E014E014E0127 +:10D190004E014E014E014E014E014E014E014E0117 +:10D1A0004E014E014E014E014E014E014E014E0107 +:10D1B0004E014E014E018500B300EC002F014E01DF +:10D1C0006001D90173027A024E014E014E019202B2 +:10D1D0004E014E019D024E01CD02540375038A0398 +:10D1E00092030004E800160479044E014E014E013A +:10D1F0004E014E014E0166009D00CA00240124012B +:10D200004E0183019D004E018B0273027A028F0250 +:10D2100094024E019D02C602E000D6026D037C031B +:10D22000C903F703E40008043F04691EA14240F269 +:10D23000F480013204F1010A3B5554466DE702F1D6 +:10D2400002087BE74FF0000988E7B369AB4A18335F +:10D2500052F823B0584600F07DFF0BF1FF3B04EB82 +:10D26000000A6B1E544507D198F80030002B00F0DF +:10D27000328408F10102E0E7A34240F2CE801BF8BD +:10D28000012F3A550134EDE7B2699C4B03EB820361 +:10D29000D3F87CB0584600F05DFF0BF1FF3B04EB88 +:10D2A000000A6B1EA245DFD0A34240F2B6801BF8F5 +:10D2B000012F3A550134F5E7904B326953F822B00B +:10D2C000584600F047FF0BF1FF3B04EB000A6B1ED2 +:10D2D0005445C9D0A34240F2A0801BF8012F3A5513 +:10D2E0000134F5E73369854A0C3352F823B05846C8 +:10D2F00000F030FF0BF1FF3B04EB000A6B1EA24570 +:10D30000B2D0A34240F289801BF8012F3A55013474 +:10D31000F5E77A4BD3F8A0A0504600F01BFF9AF82F +:10D320000030002B00F06D8333465246291B38191C +:10D33000FFF7EAFE002870DD04EB000A94E76F4B6C +:10D34000D3F8E4A0E8E76D4BD3F89CA0E4E76B4B7F +:10D35000D3F898A0E0E7D6F814A069498A45ACBF95 +:10D360004FF0000B4FF0010BBAF1000F0BDB642004 +:10D370009AFBF0F0133083B1632801DD2B2B20D012 +:10D38000604B61490BE00AF26C70039300F0EAFE17 +:10D390006421039B90FBF1F0EDE75A4B5B49019050 +:10D3A000B9F1020F2CBFCBEB0900CBF10200584AB8 +:10D3B000009053488245B8BF13460A46291B3819C6 +:10D3C00022E0544BDDE7544A5449F368642818BFFF +:10D3D0000A46291B381902F0E9F817E07069336929 +:10D3E000002803F1010A07EB040BF368A5EB04091D +:10D3F00019DB642290FBF2FC02FB1C00CDE900303B +:10D40000494653465846464A02F0D0F8002804DB05 +:10D4100000EB040A55453FF627AF4FF0000A50468F +:10D420000FB0BDE8F08F00F26C70039300F09AFE2D +:10D43000642290FBF2FC039B0CFB1200DEE725212B +:10D440000DF11A0A8DF818105BB1B9F1050F8DF8BE +:10D45000193013D85046334900F058FE334606AA17 +:10D4600064E72B238DF8193004231E2150462E4AE1 +:10D4700002F09CF80028EDDD5044ECE7B9F106031A +:10D48000E8D0F2E73046FFF7EDFD73698246002BE6 +:10D4900016DB642293FBF2F1B0F1FF3F02FB113384 +:10D4A00040F020830AEB0300642390FBF3F203FBBC +:10D4B00012021A44B2FBF3F103FB1123164A88E768 +:10D4C00003F26C7000F04EFE642390FBF3F2BAF1AD +:10D4D000FF3F02FB130306D17169144A9142E1DA5E +:10D4E0004FF0010ADEE7BAF1010F40F0FE827169E8 +:10D4F000034A9142F4DA4FF0FF3AD3E7245301088C +:10D5000094F8FFFFEB2001082D4E0108264E01087C +:10D5100041510108354E0108414E01086D340108A2 +:10D52000374E01084A4E0108464E010895F8FFFFA4 +:10D53000BE490593736930468B42ACBF002101217F +:10D5400003930491FFF78EFD039B8246002BDDE9D8 +:10D55000041347DB4FF0640B039A92FBFBFB0BF1C8 +:10D56000130B706900284BDB4FF0640C90FBFCFE42 +:10D570000CFB1E00BAF1FF3F51D1AD4AD6F814C0E2 +:10D58000944502DA4FF0010A51468244BAF1FF3F56 +:10D5900055D14FF0630A0BF1FF3B642000FB0BAA4F +:10D5A000002954D12B2B54D142F20F70824550D90F +:10D5B00019468DF8181001210DF1190CB9F1000F61 +:10D5C00001D0A9EB010925218CF80010002B43D1D3 +:10D5D0000CF10100974900F099FD4B46CDF800A0F1 +:10D5E00006AA9DE0CDE90431039B03F26C7000F0C4 +:10D5F000B9FDDDE904314FF0640C90FBFCFBB0E7B2 +:10D6000000F26C70CDE9043100F0ACFDDDE90431CD +:10D610004FF0640C90FBFCFE0EFB1C00AAE7BAF175 +:10D62000010F05D18149039A8A4204DB0021ACE74E +:10D630004FF0000AA9E751464FF0FF3AA5E7BAF1CB +:10D64000640F04BF4FF0000A0BF1010BA5E72D2179 +:10D65000AFE70DF1180CB1E730230CF102008CF8A4 +:10D660000130B7E7744A7549B3686B2818BF0A469A +:10D67000AFE6B36863B10C2B04D00C2193FBF1F23D +:10D6800001FB12336D4A6C49492818BF0A46A0E6CF +:10D690000C23F7E7F3696A4A01339AE633690133E9 +:10D6A0000CE773680AE76B1E9C42BFF4B6AE0A2310 +:10D6B00004F1010A3B55D7E5B3680B2BD4BF002218 +:10D6C0000122604B03EB8203D3F8A4B0584600F06C +:10D6D00041FD04EB000A5C480BF1FF3B691EA245CB +:10D6E0003FF4C2ADA1427FF698AE98F800201BF837 +:10D6F000013F502A06D1C25C02F00302012A08BF92 +:10D700002033DBB23B550134E9E70322336993FB55 +:10D71000F2F34E4A01335CE673684D4A0093B368F6 +:10D72000291B381901F042FF70E6336A002B77DBC2 +:10D7300000F0A0FA029B0BB900F0A8FA02F02EFE4E +:10D74000336A002BD4BF00220122282302FB0333BB +:10D75000C358C3F1000A00F093FA012302937269DF +:10D76000291BB2F145034FEAE27C6CF1000CBCF1DD +:10D77000000F07EB040002DA03334CF1000C4FF00A +:10D78000640B02F1FF3E9EFBFBFE4FF4C87B9B083F +:10D7900043EA8C73B3EB0E034FEAAC0C6CEBEE7CFC +:10D7A00002F22B1E9EFBFBFE13EB0E034CEBEE7CFA +:10D7B00040F26D1E463A0EFB02F24FF0180E9B1817 +:10D7C0004CEBE27CF2699B184CEBE27CA3FB0E2352 +:10D7D0000EFB0C33D6F808C012EB0C0243EBEC73D3 +:10D7E0004FF03C0CA2FB0C2E0CFB03E3D6F804E03C +:10D7F00012EB0E0243EBEE73A2FB0CE20CFB0322D6 +:10D80000D6F800C01EEB0C0342EBEC72B3EB0A033C +:10D8100062EBEA72CDE900320E4A01F0C7FEF5E58F +:10D820004FF0000A9BE7336848E600BF94F8FFFF1B +:10D8300095F8FFFF524E01086D340108414E010872 +:10D84000564E010824530108215401085B4E01087B +:10D850006A4E0108604E01086B1E9C42BFF4DDADAC +:10D86000092304F1010A25E73368A14A019373688B +:10D870000093B368A2E56B1E9C42BFF4CEADB369C2 +:10D8800004F1010A3C4413B937232370ECE430332C +:10D89000FBE7F369B26907339B1A072293FBF2F3A4 +:10D8A0000CE63046FFF7DEFBB269034662B1013A8F +:10D8B000012B3FF403AE0133F16907D007230A318E +:10D8C000891A91FBF3F3F9E50622F1E7531A72691D +:10D8D00040F26B71002AA8BF6FF064010A449107FF +:10D8E00005D1642092FBF0F100FB112171B94FF4D6 +:10D8F000C87192FBF1F001FB1022B2FA82F25209D8 +:10D900009A1A042ACCBF34233523D7E50122F7E73E +:10D910000DF1180B77495846039300F0F7FB584672 +:10D9200000F018FC039B0BEB000A0AF1010A73B12B +:10D93000B9F1050F0BF8003002D9B9F106030AD18D +:10D9400050466D4900F0E2FB33465A46EEE42B2385 +:10D950000BF8003004230EA95046A1EB0A01674AD8 +:10D9600001F024FE0028C8BF8244E9E76B1E9C42F8 +:10D97000BFF453AD337E04F1010A30339AE6B26945 +:10D980001AB1013AF369073386E70622FAE77069AC +:10D99000002805DB642390FBF3F202FB13038DE503 +:10D9A00000F26C7000F0DEFBF4E7716954488142CC +:10D9B00012DA4FF02D0CA0EB010A8DF818C00120EF +:10D9C0000DF11901B9F1000F01D0A9EB00092520D3 +:10D9D00008707BB9481CFDE52B2B01F26C7A06D14F +:10D9E00042F20F718A4502D98DF81830E7E700201E +:10D9F00006A9E7E73023881C4B70EBE5336A002B60 +:10DA000001DAA24630E400F035F9029B0BB900F0D0 +:10DA10003DF902F0C3FC336A002BD4BF002201227F +:10DA2000282302FB0333C358C3F1000900F028F98F +:10DA30003C2399FBF3F001F067FA3C2390FBF3F2EF +:10DA400002FB13004FF46163009099FBF3F32D4A3E +:10DA5000291B381901F0AAFD0028FFF6DEAC00EB07 +:10DA6000040A55457FF6D9AC01230293FFF7FCBBAE +:10DA7000336A002BC5DB00F0FDF8029B0BB900F008 +:10DA800005F9336A204A002BD4BF0023012352F842 +:10DA90002390A246484600F05DFB09F1FF3920447F +:10DAA0006B1E824502D100F0EBF8DDE79A4506D205 +:10DAB00019F8012F07F80A200AF1010AF1E700F02E +:10DAC000DFF8AAE46B1E9C42BFF4A7AC252304F147 +:10DAD000010AEFE5A246002D3FF4A1AC002307F8B0 +:10DAE0000A309CE401283FF4FBAC4FF0000AD9E473 +:10DAF000654E0108744E0108C94F0108464E0108E1 +:10DB000094F8FFFF7C4E0108940B0020FFF7FCBA4D +:10DB10002DE9F041044602F041FC40F2B1739C4211 +:10DB200040F3A1806FF4F662A61840F26D12A4F2E1 +:10DB3000B273B61002FB03666FF06302A4F26D735A +:10DB400093FBF2F36FF4C8614FF4C8721E4463187C +:10DB5000B3FBF2F30546454A44601E4400F150070A +:10DB60002B7A4A2B3AD1696914F0030F01EB0603B3 +:10DB700008D14FF0640E94FBFEFC0EFB1C4CBCF174 +:10DB8000000F08D14FF4C87E94FBFEFC0EFB1C4C2A +:10DB9000BCF1000F20D13B29D4BF002101210B444F +:10DBA000013BA9694FEAE17CC3FB021CAB6AC918BF +:10DBB0004CEBE373C5E908132835AF42D0D1D0E967 +:10DBC0000843D0E912128C429341B4BF01230023D1 +:10DBD00003600120BDE8F0810021E0E7442B02D181 +:10DBE0006B693344DDE7A30705D1642194FBF1F3AE +:10DBF00001FB13438BBB4FF4C87194FBF1F301FBA2 +:10DC00001343B3FA83F35B0959424FF0000E3346D6 +:10DC1000DFF85CC001F03001D5F80C8061440EF1F2 +:10DC2000010EF04551F82EC019DC072103F1040E56 +:10DC30009EFBF1F1C1EBC101AEEB010E6969B1EBE5 +:10DC40000E0E296948BF0EF1070E0139C1EBC10163 +:10DC50007144614505DA0B44A3E70123D4E763442B +:10DC6000DDE70739F5E70020B4E700BF8051010088 +:10DC7000C0520108014800F010B800BFEC150020A8 +:10DC8000014800F00CB800BFEC150020014B1868EB +:10DC900000F008B89C0B0020704770477047704731 +:10DCA000704700002DE9F04F8DB0074602F076FB7B +:10DCB000BC490446384601F021F9BB4D06462968A7 +:10DCC00010BBBA4BBA4A1860BA4BC4E90366186075 +:10DCD000B94B4A20C3E9002200220023207284F8B5 +:10DCE0003000C4E905660846C4E90823C4E90D66A6 +:10DCF000C4E90F66C4E91223A662266501F068FA3A +:10DD00002E600DB0BDE8F08F002940F08F802868AC +:10DD100001F05EFA304600F01DFA411C384601F071 +:10DD200081FA2860002840F087800023A14A002063 +:10DD300013600021A14AA04FC4E90333C7E90022C0 +:10DD40004A22C4E90533C4E90801C4E90D33C4E932 +:10DD50000F33C4E91201DFF854A22272CAF800306E +:10DD6000A36284F83020236533780DF1280B3A2B19 +:10DD700008BF013633783C2B62D1751C5B462846C0 +:10DD80008F4A904901F0DCFF0028BADD0A9BDA1EB9 +:10DD9000072AB6D8EA5C3E2AB3D10236F518F35CFE +:10DDA0002D2B5BD14FF0FF38013500230DF12009F9 +:10DDB000ADF81E30ADF820300DF11E03009328465B +:10DDC0005B46CDE901B98049CDF80CB007AA01F056 +:10DDD000B7FF002895DD3C22BDF81E30BDF820605D +:10DDE00002FB03664FF46162BDF81C3002FB036660 +:10DDF0000A9B08FB06F605EB0308EB5C3C2B40F0A6 +:10DE0000ED8008F101055B462846704A6D4901F036 +:10DE100097FF002828DC98F801303E2B24D1684B6E +:10DE2000A662C7E90033CAF800606AE700F064F947 +:10DE300000287FF46CAF64E7314600F067F974E7BF +:10DE40005B4630465E4A624901F07AFF00287FF760 +:10DE500058AF0A9BDA1E072AA0D952E72B2B4FF0A6 +:10DE6000010808BF0135A0E70A9BDA1E072A3FF622 +:10DE700048AFEA5C3E2A7FF444AF08F1020808EBA1 +:10DE8000030518F803302D2B40F0B7804FF0FF3812 +:10DE900001350023ADF81C30ADF81E30ADF8203050 +:10DEA0000A930DF11E03009328465B46CDE9029BC1 +:10DEB0004549CDF804B007AA01F042FF002800F35D +:10DEC000A280A6F56163A0464FF0000B04930A9B65 +:10DED0001D442B782C2B08BF013595F80090B9F123 +:10DEE0004D0F40F0A0800AAB0DF12602CDE90132C2 +:10DEF00009AA00922846374903930DF1220201F046 +:10DF00001FFF03287FF4FDAEBDF822104B1E0B2B24 +:10DF10003FF6F7AEBDF82420531E042B3FF6F1AEBA +:10DF2000BDF82630062B3FF6ECAEC8E9031288F8A0 +:10DF30000890C8F814300A9B05EB030900254FF040 +:10DF40000203ADF81E50ADF81C30ADF820500A9514 +:10DF500099F800302F2B40F094800AAB08AACDE945 +:10DF600001320DF11E02009248461B49039307AA95 +:10DF700001F0E6FEA84200F384804A21002200233B +:10DF8000C4E90355C4E90555C4E90823C4E90D559E +:10DF9000C4E90F55C4E912232172A56284F8301038 +:10DFA0002565AEE6884E0108F01500200C1600200D +:10DFB0008B4E010810160020940B0020EB20010866 +:10DFC000001600208F4E0108C44E0108F4150020F1 +:10DFD000A24E0108B04E0108C34E01085B46404600 +:10DFE0003F4A404901F0ACFE00287FF718AF0A9B7A +:10DFF000DA1E072A7FF643AF83E62B2B4FF001088A +:10E0000008BF013545E73C21BDF81E20BDF8203092 +:10E0100001FB02334FF46161BDF81C2001FB0233A8 +:10E0200008FB03F34FE7B9F14A0F0ABF4B464423FD +:10E0300001350A2228460BA9059302F085F8DDF880 +:10E040002C90059BA945ADF8260014D14D23BBF1BA +:10E05000000F07D1032123720223C4F814B0C4E9CE +:10E0600003136BE70B2284F830300123C4E90D233E +:10E070000023E36362E780B288F80830C8F8140030 +:10E080005CE73C21BDF81E20BDF8203008F12808CF +:10E0900001FB02334FF46161BDF81C2001FB023328 +:10E0A00048F8103C0A9D0BF10103022B4FF0010BC5 +:10E0B0004D447FF40EAF049B606823650A4BA66253 +:10E0C0003B60074B7B60FFF723FDA26A236DCAF814 +:10E0D00000209B1A18BF0123044A136011E600BFF9 +:10E0E000F4150020A24E0108001600201016002092 +:10E0F00000487047380D002010F8012B11F8013B43 +:10E10000012A28BF9A42F7D0D01A7047034611F867 +:10E11000012B03F8012B002AF9D17047034610B5F3 +:10E12000C9B20244934201D1002004E018460478A9 +:10E1300001338C42F6D110BD0A44914200F1FF3305 +:10E1400000D1704710B511F8014B914203F8014F0F +:10E15000F9D110BD034613F8012B002AFBD1181A80 +:10E16000013870470028B8BF404270471FB51D46B0 +:10E17000094B06461B68D86852B1084C3346CDE9B6 +:10E18000014200912A46064901F0F0FE02F0E4F94E +:10E19000044C2246F2E700BF9C0B0020F84F010818 +:10E1A00005500108EB20010891FBF2F302FB13116B +:10E1B0000360416070472DE9F74F03690C698046A1 +:10E1C000A3427EDB013CA30000F1140501F114071A +:10E1D000009305EB8403019357F8243055F824206D +:10E1E00001339A42B2FBF3F607EB84092ED34FF0CA +:10E1F000000ABC46AE46D3465CF8043B98B206FB28 +:10E2000000A01B0C020C06FB0323DEF8002080B2EA +:10E2100092B2121A5A44DEF800004FEA134A9BB237 +:10E22000C3EB224303EB104392B242EA0342E145BF +:10E230004FEA234B4EF8042BDED2009BEB582BB950 +:10E24000019B1A1F954230D3C8F81040404601F098 +:10E250006BFC002825DB29460020013657F8042BEB +:10E26000D1F800C01FFA82FE1FFA8CF3A3EB0E0355 +:10E270000344120CC2EB234202EB1C429BB243EA62 +:10E280000243B9454FEA224041F8043BE6D255F833 +:10E29000242005EB840322B9043B9D420BD3C8F82C +:10E2A0001040304603B0BDE8F08F1368002BCBD18F +:10E2B000043A013CC6E71A68002AF0D1043B013C4D +:10E2C000EBE70020EEE700002DE9F04F16461F4671 +:10E2D000C26999B08146CDE90E67259C82B91020AC +:10E2E00000F06EFF0246C9F81C0020B9EF21A24BD6 +:10E2F000A248FFF73BFF0023C0E901330360C3607E +:10E30000116859B101235268484693404A608B60B6 +:10E3100001F0BCF90022D9F81C301A60B7F10008EE +:10E32000B5BF0123002323602360954BBCBF28F0B9 +:10E330000048CDF83C8033EA08031AD142F20F734B +:10E34000249AC8F3130858EA0608136000F06D8594 +:10E35000269B53B98B4B21E08B4B03930833269AB2 +:10E360001360039819B0BDE8F08F864B0393033315 +:10E37000F5E7DDE90E34CDE90A34DDE90A010022D2 +:10E38000002303F06FF9824650B10123249A1360F1 +:10E39000269B13B17D4B269A13607D4B0393E0E7D8 +:10E3A00016AB019317AB00934846DDE90A2301F051 +:10E3B0006FFC5FEA1854169D04907CD0DDE90A01D9 +:10E3C0000B9BA4F2FF34C3F3130343F07F5343F4D6 +:10E3D0004013CDF850A0194600226E4B02F022FDEA +:10E3E0005FA3D3E9002302F0D5FE5FA3D3E90023A6 +:10E3F00002F01AFD064620460F4602F061FE5CA3BD +:10E40000D3E9002302F0C6FE02460B4630463946E9 +:10E4100002F00AFD06460F4603F06CF90022804622 +:10E4200000233046394603F027F948B1404602F050 +:10E4300047FE32463B4603F015F908B908F1FF38AC +:10E44000B8F1160F54D8DDE90A01534B03EBC803AA +:10E45000D3E9002303F010F900284BD0002308F182 +:10E46000FF3811932D1B6B1E099349BF0023002712 +:10E47000C5F101070993B8F1000F3DDB099BCDF809 +:10E4800040804344099300230C93229B092B00F204 +:10E490008780052BC4BF043B2293229BC8BF002466 +:10E4A000A3F10203D8BF0124032B00F28580DFE82B +:10E4B00003F05153362B179C2C4404F23243202B8B +:10E4C000C1BFC3F1400308FA03F804F2124326FA6D +:10E4D00003F3D6BFC3F1200348EA030006FA03F0B2 +:10E4E00002F0DEFD0122A1F1F873013C149272E703 +:10E4F0000123B6E71190B5E7C8F100030C930023A0 +:10E50000A7EB08071093C0E701230D93239B434417 +:10E5100008930133012B0593B8BF012306E00123C3 +:10E520000D93239B002B4ADD0893059300210422C1 +:10E53000D9F81C0002F114059D4245D941604846B6 +:10E5400001F066F80390002841D1024640F2AF1175 +:10E55000124BCDE60023E3E70023D6E7AFF30080BC +:10E5600061436F63A787D23FB3C8608B288AC63FD9 +:10E57000FB799F501344D33F4A4D01084150010895 +:10E580000000F07F3D5001083450010814300108AC +:10E59000133001080000F83F58550108A250010847 +:10E5A000012400230D9422934FF0FF33002208939F +:10E5B000059323921223B9E701230D93F4E7012376 +:10E5C000089305932393B1E701315200B2E7D9F8DC +:10E5D0001C30039A1A60059B0E2B75D8002C73D043 +:10E5E000B8F1000F40F3C4809F4B08F00F0203EB1B +:10E5F000C20318F4807F4FEA2815D3E900AB00F07E +:10E60000A380DDE90A01994B0324D3E9082302F032 +:10E61000EBFECDE9060105F00F05944E002D40F00C +:10E620009980DDE9060152465B4602F0DDFE824636 +:10E630008B46119B002B00F0C380002250465946A8 +:10E640008B4B03F019F8002800F0BA80059B002BD3 +:10E6500000F0B680089B002B36DD08F1FF335046F2 +:10E66000594606930022834B02F094FD82468B4666 +:10E67000089E0134204602F023FD52465B4602F01C +:10E6800089FD00227C4B02F0CFFB0446A1F15075BE +:10E69000CDE91245002E40F09780002250465946A1 +:10E6A000764B02F0BFFB22462B4682468B4603F098 +:10E6B00001F8002840F0C18222465046594605F133 +:10E6C000004302F0D9FF20BB179B002BC0F29181C1 +:10E6D000B8F10E0F00F38D81634B03EBC803D3E950 +:10E6E00000AB239B002B80F21B81059B002B00F3CA +:10E6F00017810ED10022614B5046594602F04AFD67 +:10E7000002460B46DDE90A0102F0C0FF002800F0D6 +:10E71000978200252C46239B039EDB4306932746C6 +:10E7200000242946484600F0B1FF002F00F0EE809B +:10E730002CB1BC4203D02146484600F0A7FF394621 +:10E74000484600F0A3FFE1E0DDE90A34CDE90634F4 +:10E75000022462E7E90708D5D6E900235046594666 +:10E7600002F018FD82468B4601346D10083655E7DD +:10E7700022D0DDE90A01C8F100053B4B05F00F028C +:10E7800003EBC203D3E9002302F004FD0224824616 +:10E790008B46364E2D11002D3FF44BAFEA0708D5BE +:10E7A000D6E900235046594602F0F4FC82468B46D7 +:10E7B00001346D100836EEE70224DDE90AAB38E7D4 +:10E7C000059ECDF8188055E7274B03EBC60353E9A8 +:10E7D00002010D9B002B55D002460B460020284914 +:10E7E00002F002FEDDE9122302F01CFB039BCDE9DF +:10E7F00012019D191E465946504602F07BFF00F15A +:10E80000300402F05DFC02460B465046594602F0C9 +:10E8100009FBDDE9122306F8014B82468B4602F024 +:10E820002BFF002872D152465B460020104902F0AF +:10E83000F9FADDE9122302F01FFF002840F0BA8048 +:10E84000AE423FF441AFDDE912010022094B02F074 +:10E85000A1FC0022CDE91201064B5046594602F0B8 +:10E8600099FC82468B46C6E7585501083055010889 +:10E870000000F03F0000244000001C400000144055 +:10E880000000E03FDDE9122302F084FC039BCDE9A8 +:10E8900012013344039C15935946504602F02AFF57 +:10E8A00000F1300502F00CFC0B460246594650467A +:10E8B00002F0B8FA159B04F8015B9C4282468B4635 +:10E8C00027D1DDE91201039B00221E44AC4B02F06C +:10E8D000ABFA02460B465046594602F0EBFE0028C2 +:10E8E00068D1DDE912230020A54902F09BFA024617 +:10E8F0000B465046594602F0BFFE00283FF4E4AEF6 +:10E90000334616F8012D302AFAD01E46DDF818805D +:10E910003EE000229B4B02F03DFC82468B46BBE76B +:10E920000024039E974D5246DDE90A015B4602F042 +:10E930005BFD02F0DFFE074602F0C2FB52465B467B +:10E9400002F028FC02460B46DDE90A0102F06AFAF1 +:10E9500007F1300C06F801CBDDF80CC0DDF814E04F +:10E96000A6EB0C0CE64502460B4633D102F05CFAEE +:10E9700052465B4604460D4602F09CFEC0B9524624 +:10E980005B462046294602F06DFE08B1FB070FD416 +:10E990004846049900F07AFE0023249A337008F167 +:10E9A00001031360269B002B3FF4DBAC1E60D8E410 +:10E9B000CDF8188033461E4613F8012D392A06D1AA +:10E9C000039A9A42F7D1069A013206923022013216 +:10E9D0001A709BE722462B4602F0DCFB02460B46F0 +:10E9E000CDE90A230022002302F03CFE00289AD041 +:10E9F000CEE70D9A002A00F0DF80229A012A00F368 +:10EA0000C380149A002A00F0B78003F233430C9DB0 +:10EA10003E46099A01211A4448461F44099200F0D3 +:10EA2000E9FE044656B1099B002B07DDB342A8BF9F +:10EA30003346099AFF1AF61AD31A09930C9B0BB3A3 +:10EA40000D9B002B00F0BF80002D00F0B980214607 +:10EA50002A46484600F09AFF049A01460446484672 +:10EA600000F0DEFE04998246484600F00FFE0C9B43 +:10EA70005B1B0C9300F0AA8051460C9A484600F0AC +:10EA800085FF04900121484600F0B4FE109B054626 +:10EA9000002B00F0D1811A460146484600F076FF6F +:10EAA000229B0546012B00F399800E9B002B40F022 +:10EAB00090800F9BC3F31303002B40F08A800F9BC1 +:10EAC00023F000431B0D1B05002B00F085804FF049 +:10EAD000010A099B013701330993109B002B00F0B9 +:10EAE000B1812B6905EB8303186900F037FEC0F193 +:10EAF0002000099B184410F01F0076D01B2870DC02 +:10EB0000C0F11C000744064403440993002F05DDAF +:10EB10003A464846049900F095FF0490099B002B63 +:10EB200005DD29461A46484600F08CFF0546119B34 +:10EB3000002B5FD02946049800F0F6FF002859DA30 +:10EB400008F1FF3306930A2200234846049900F097 +:10EB5000BFFD0D9B0490002B00F076810023214621 +:10EB60000A22484600F0B4FD089B0446002B71DCE5 +:10EB7000229B022B47DC6DE0169BC3F1360346E770 +:10EB80000000E03F00002440059B5D1E0C9BAB4253 +:10EB900008DB5D1B059B002BBFF63AAF059BFE1AF9 +:10EBA000002336E70C9B109AEB1A1A440C953E464C +:10EBB0000025059B10922CE73E460C9D0D9C31E7ED +:10EBC000DDF810A058E70C9A049957E7CDF810A08B +:10EBD00058E74FF0000A80E79A467EE74FF0000AB8 +:10EBE0007FE71C2892D0C0F120001C30099B07440D +:10EBF000064489E7059BCDF81880002B24DC089398 +:10EC0000229B022B22DD089B002B7FF484AD29463A +:10EC10000522089B484600F05BFD01460546049826 +:10EC200000F082FF00287FF776AD3123039E06F8BF +:10EC3000013B069B0133069371E535462C46F4E70C +:10EC4000059DCDF81880F9E7059B08930D9B002BD7 +:10EC500000F0FE80002E05DD21463246484600F0D9 +:10EC6000F1FE0446BAF1000F58D04846616800F042 +:10EC7000CFFC064628B9024640F2EF217F4BFFF752 +:10EC800037BB226904F10C01023292000C30FFF70D +:10EC900053FA01223146484600F0D4FE0746039B52 +:10ECA000039A03F10108089B13440A930E9B03F097 +:10ECB0000103099329460498FFF77DFA2146059040 +:10ECC00000F1300B049800F02FFF3A4608902946D7 +:10ECD000484600F045FFC268064608F1FF3AFAB917 +:10ECE0000146049800F020FF0246314648460C9247 +:10ECF00000F0CCFC229B0C9A464642EA0301099B99 +:10ED000019430FD1BBF1390F28D0089B002B02DD2E +:10ED1000059B03F1310B8AF800B002E52746BEE7F8 +:10ED20000122E2E7089B002B04DB22990B4309999F +:10ED30000B4320D1002AEEDD01220499484600F061 +:10ED400081FE2946049000F0EFFE002803DCE2D1AA +:10ED50001BF0010FDFD0BBF1390FD9D139238AF86D +:10ED6000003033461E4616F8012C013B392A53D099 +:10ED700001321A70D5E4002A07DDBBF1390FEDD05E +:10ED80000BF101038AF80030CBE40A9B08F801BCC0 +:10ED900043452BD000230A220499484600F098FCF2 +:10EDA000BC4204904FF000034FF00A02214648464F +:10EDB00006D100F08DFC0446074608F1010879E70A +:10EDC00000F086FC3946044600230A22484600F03B +:10EDD0007FFC0746F1E7089B2746002B03F1FF362F +:10EDE000D8BF00260024039B5A1C16440122049914 +:10EDF000484600F027FE2946049000F095FE0028C2 +:10EE0000AFDC02D11BF0010FABD133461E4613F825 +:10EE1000012D302AFAD084E4039A9A42A2D1069BAB +:10EE200001330693312313707BE4269B002B7FF480 +:10EE300093AA134BFFF7B2BA229B012B7FF735AE93 +:10EE4000DDF840A0012054E6089B002B7FF7D8AEE8 +:10EE5000039E29460498FFF7AEF9039B00F1300B9F +:10EE600006F801BBF21A089B9342B4DD00230A2284 +:10EE70004846049900F02CFC0490EAE7A2500108EF +:10EE8000345001082DE9F84FDFF86CA0064689469A +:10EE9000174601F07DFBDAF8004034B14A4613789A +:10EEA0004BB13D2B02F10102F9D1304601F076FB66 +:10EEB0000020BDE8F88FA2EB09082068A3460028CF +:10EEC000F3D042464946043401F012FA0028F4D146 +:10EED00054F8043C03EB080513F808303D2BECD143 +:10EEE000DAF800303046ABEB03039B103B6001F0D7 +:10EEF00055FB681CDDE700BFB40D002007B501AA73 +:10EF0000FFF7C0FF03B000BD0028B8BF4042704704 +:10EF10002DE9F0471F468E688246BE420C46904659 +:10EF2000334653D8B1F90C0010F4906F2BD06569BB +:10EF30002368096905EB4505A3EB010905EBD575C8 +:10EF40007B1C6D104B44AB422A4684BF1D462A46AB +:10EF5000430527D51146504600F064F9064658B3DC +:10EF60004A462169FFF7E8F8A38923F4906343F048 +:10EF70008003A38126614E4426603B463E46656180 +:10EF8000A5EB0905A5601F463A464146206801F0F9 +:10EF900096F90020A3689B1BA36023683B44236071 +:10EFA000BDE8F087504600F0F3FF06460028E1D1A7 +:10EFB0005046216901F0F8FA0C23CAF80030A38901 +:10EFC0004FF0FF3043F04003A381E9E73E46DBE723 +:10EFD0002DE9F0471F468B8906461B060D46144651 +:10EFE0009CB010D50B6973B9402100F01BF9286063 +:10EFF000286130B90C2333604FF0FF301CB0BDE8FE +:10F00000F08740236B610023099320238DF829307A +:10F0100030234FF001080397644F8DF82A302346C0 +:10F020001A7899461AB1252A03F10103F8D1B9EBF0 +:10F03000040A0BD05346224629463046FFF768FFA4 +:10F04000013000F0A380099A5244099299F80030E7 +:10F05000002B00F09B8000224FF0FF33CDE90532FA +:10F0600009F10109049207928DF853201A924C4637 +:10F07000052214F8011B4D48FFF750F8049AD0B947 +:10F08000D00644BF20238DF85330110744BF2B23F3 +:10F090008DF8533099F800302A2B13D04B460020BE +:10F0A0004FF00A0C07991A781C46303A092A4AD9B7 +:10F0B000A8B1079113E0C01B08FA00F01043A14665 +:10F0C0000490D4E7039B191D1B680391002BBBBF61 +:10F0D0005B4242F0020207930793B8BF0492237881 +:10F0E0002E2B0AD163782A2B32D1039B02341A1DAE +:10F0F0001B68039243EAE3730593DFF8B49003229D +:10F1000048462178FFF70AF838B14022049BA0EB6B +:10F1100009008240134301340493217806222548D4 +:10F120008DF82810FEF7FAFF002835D0224818BBCA +:10F13000039B073323F0070308330393099B013430 +:10F14000034409936BE701200CFB01210133AAE77B +:10F1500000234FF00A0C18460593611C0A780C46F0 +:10F16000303A092A03D9002BC7D00590C5E70123FF +:10F170000CFB00200131F1E703AB00932A46304637 +:10F180000E4B04A9FCF7B6FD421CD7D1AB895B0638 +:10F190003FF532AF099831E703AB00932A4630467A +:10F1A000064B04A9FDF746F8EEE700BFB35001088F +:10F1B000B9500108BD500108F5BC000811EF000866 +:10F1C000024B0146186800F02DB800BF9C0B0020D0 +:10F1D000024B0146186801F0E7B900BF9C0B002004 +:10F1E00070B50F4C0E462168054611B901F0C6F8FE +:10F1F00020603146284601F0C1F8431C03D14FF08E +:10F20000FF34204670BDC41C24F00304A042F8D093 +:10F21000211A284601F0B2F80130F2D1EFE700BF21 +:10F22000141600202DE9F843CD1C25F00305083500 +:10F230000C2D38BF0C25002D064601DBA94204D950 +:10F240000C2333600020BDE8F883334F00F0A2F9AF +:10F250003B681C463CBB29463046FFF7C1FF431CB8 +:10F26000044656D13C68A046B8F1000F40D1002CAE +:10F2700049D023684146304604EB030901F07EF88B +:10F28000814540D1216830466D1A2946FFF7A8FF15 +:10F29000013038D023682B4423603B685A685ABB3E +:10F2A000C7F800800EE02268521B1ED40B2A16D924 +:10F2B0006119A342256018BF5960636808BF3960AF +:10F2C00062514B60304600F06BF904F10B00231DD6 +:10F2D00020F00700C21A1CBF1B1AA350B3E76268D4 +:10F2E000A3420CBF3A605A60ECE723466468B1E77A +:10F2F0004446D8F80480B7E71A465B68A342FBD1BE +:10F3000000235360DEE70C233046336000F048F9F9 +:10F3100098E70560D6E700BF18160020936810B480 +:10F32000013B002B936007DA9469A34201DB0A29B1 +:10F3300002D110BC00F05ABE1368581C106019703E +:10F34000084610BC7047F8B506460F461446D51857 +:10F35000AC4201D1002007E03A46304614F8011BC8 +:10F36000FFF7DCFF431CF3D1F8BD00002DE9F047A7 +:10F3700006460D4614461F469CB018B1036A0BB9E9 +:10F38000FDF732F96B6ED90705D4AB899A0502D423 +:10F39000A86DFEF783FCAB891B0701D52B699BB9D0 +:10F3A0002946304600F0DAFE70B16B6EDE0704D5F8 +:10F3B0004FF0FF301CB0BDE8F087AB899C05F7D457 +:10F3C000A86DFEF76DFCF3E70023099320238DF869 +:10F3D000293030234FF001080397694F8DF82A3008 +:10F3E00023461A7899461AB1252A03F10103F8D168 +:10F3F000B9EB040A0BD05346224629463046FFF7A4 +:10F40000A2FF013000F0A380099A5244099299F8B2 +:10F410000030002B00F09B8000224FF0FF33CDE93D +:10F42000053209F10109049207928DF853201A92CE +:10F430004C46052214F8011B5148FEF76FFE049A52 +:10F44000D0B9D00644BF20238DF85330110744BFF4 +:10F450002B238DF8533099F800302A2B13D04B46CC +:10F4600000204FF00A0C07991A781C46303A092AF6 +:10F470004AD9A8B1079113E0C01B08FA00F0104365 +:10F48000A1460490D4E7039B191D1B680391002B30 +:10F49000BBBF5B4242F0020207930793B8BF0492DE +:10F4A00023782E2B0AD163782A2B32D1039B023486 +:10F4B0001A1D1B68039243EAE3730593DFF8C490B7 +:10F4C000032248462178FEF729FE38B14022049BEA +:10F4D000A0EB0900824013430134049321780622F3 +:10F4E00029488DF82810FEF719FE00283ED027483D +:10F4F00018BB039B073323F0070308330393099BCF +:10F500000134034409936BE701200CFB0121013313 +:10F51000AAE700234FF00A0C18460593611C0A78ED +:10F520000C46303A092A03D9002BC7D00590C5E70D +:10F5300001230CFB00200131F1E703AB00932A46C5 +:10F540003046134B04A9FCF7D5FB431CD7D16B6E97 +:10F55000D90705D4AB899A0502D4A86DFEF7A0FBA4 +:10F56000AB895B063FF524AF099823E703AB009313 +:10F570002A463046064B04A9FCF75CFEE5E700BFCF +:10F58000B3500108B9500108BD500108F5BC00088E +:10F5900047F300080148FEF781BB00BFEE150020CD +:10F5A0000148FEF77DBB00BFEE1500200CB430B55E +:10F5B000154B0C1E1D689DB008DA8B234FF0FF30F1 +:10F5C0002B601DB0BDE8304002B070474FF0000323 +:10F5D0001B9318BF0123E31A049307930B4B02906C +:10F5E00006900593284621AB209A02A90193FFF7C4 +:10F5F000EFFC431CBCBF8B232B60002CE1D000220E +:10F60000029B1A70DDE700BF9C0B00200802FFFF81 +:10F6100070B5C46905460E4684B91020FFF7D0FDC9 +:10F620000446E86128B902466B21164B1648FEF7DE +:10F630009DFD0023C0E901330360C360E36853B953 +:10F6400021220421284600F08EFFEB69E060DB6890 +:10F650000BB9002070BD53F8260030B1026843F8A2 +:10F6600026200023C0E90333F4E7012101FA06F460 +:10F67000621D2846920000F076FF0028E9D0C0E91C +:10F680000164EEE74A4D0108C450010870B5C46931 +:10F6900006460D4674B91020FFF792FD0246F06150 +:10F6A00020B98F21084B0948FEF760FDC0E90144ED +:10F6B0000460C4603DB1F3696A68DB6853F82210E6 +:10F6C000296043F8225070BD4A4D0108C45001081A +:10F6D0002DE9F04107460C461E4600200D6901F158 +:10F6E000140CDCF80030013099B202FB01611E0CF1 +:10F6F0000B0C02FB063389B201EB034185424FEA52 +:10F7000013464CF8041BECDC0EB3A368AB4219DCC7 +:10F71000616838460131FFF77BFF804628B9024611 +:10F72000BA210C4B0C48FEF721FD226904F10C01B3 +:10F73000023292000C30FEF7FFFC21463846FFF7FC +:10F74000A5FF444604EB850301355E612561204633 +:10F75000BDE8F081A2500108C45001080346B0F58D +:10F76000803F3ABF030410200020B3F1807F3CBFEC +:10F770001B020830B3F1805F3CBF1B010430B3F1C2 +:10F78000804F3CBF9B000230002B04DB5B0001D5A7 +:10F7900001307047202070470368014613F00702CC +:10F7A0000BD0DA0722D4980749BF5B089B080120D9 +:10F7B0000B605CBF02200B60704798B2A0B91020AC +:10F7C0001B0CDAB20AB908301B0A1A0704BF1B095E +:10F7D00004309A0704BF9B080230DA0702D45B08A2 +:10F7E00006D001300B6070471046EAE700207047F2 +:10F7F0002020704710B50C460121FFF709FF024693 +:10F8000028B940F24511044B0448FEF7AFFC012330 +:10F810004461036110BD00BFA2500108C45001083B +:10F820002DE9F04FD1F81080D2F810900E46C8455F +:10F83000144685B004DB4B460C46C1461646984636 +:10F84000A368616809EB0807BB42B8BF0131FFF745 +:10F85000DFFE30B902464FF4B1714A4B4A48FEF719 +:10F8600085FC00F114052B46002205EB870B5B4558 +:10F8700022D306F1140101EB880304F1140C0CEB04 +:10F88000890C029304F1150363458CBF0023012307 +:10F890000093ACEB0403153B9B080193029B03917F +:10F8A0008B420CD8002F03DD5BF8043D002B67D0A2 +:10F8B000076105B0BDE8F08F43F8042BD7E7B1F836 +:10F8C00000A0BAF1000F28D0A9464FF0000E04F1B5 +:10F8D000140858F8042BD9F8003096B29BB20AFBF2 +:10F8E0000633D9F80060120C360C0AFB026673442A +:10F8F00006EB13469BB243EA0643C4454FEA164E55 +:10F9000049F8043BE5D8009A019B002A4FEA83039B +:10F9100008BF00232B44C3F804E0039B0431B3F871 +:10F9200002E0BEF1000F29D02B68A94698464FF09F +:10F93000000A04F1140632889BB20EFB02A202EB0D +:10F94000184243EA024349F8043B56F8043BD9F80D +:10F9500000804FEA134A1FFA88F30EFB0A33B445BE +:10F9600003EB12434FEA134AE5D8009E019A002E9A +:10F970004FEA820208BF00222A44536004358DE713 +:10F98000013F8FE7A2500108C45001082DE9F84358 +:10F99000174612F0030280460D4607D0264C013A66 +:10F9A000002354F82220FFF793FE0546BF103FD0F6 +:10F9B000D8F81C4094B91020FFF702FC0446C8F8A0 +:10F9C0001C0030B9024640F2B3111C4B1C48FEF734 +:10F9D000CDFB0023C0E901330360C360A66846B9CC +:10F9E00040F271214046FFF705FF00230646A06064 +:10F9F00003602C464FF0000907F001037F1053B15C +:10FA0000294632464046FFF70BFF21460546404651 +:10FA1000FFF73CFE67B1306838B9324631464046A0 +:10FA2000FFF7FEFE3060C0F8009006462C46E3E784 +:10FA30002846BDE8F88300BF245501084A4D010857 +:10FA4000C45001082DE9F84F0C4607469146266937 +:10FA5000496806EB6216A3684FEA621A06F10108CC +:10FA600043450BDB3846FFF7D3FD054648B9024650 +:10FA70004FF4EF712A4B2B48FEF778FB01315B0006 +:10FA8000EEE7002300F114010A461846534539DB1E +:10FA900020692AEAEA7A01EB8A0104F1140319F0D9 +:10FAA0001F098C4603EB800030D04FF0000EC9F1E7 +:10FAB000200AE3461A680CF1040C02FA09F242EA41 +:10FAC0000E02CBF8002053F8042B984222FA0AFECB +:10FAD000EFD8031B153B23F0030304F115029042FA +:10FAE00038BF00231944C1F804E0BEF1000F00D173 +:10FAF000B04638462146C5F81080FFF7C7FD2846B6 +:10FB0000BDE8F88F42F8040B0133BFE753F8041B3C +:10FB10000CF1040C98424CF8041CF7D8E8E700BF3D +:10FB2000A2500108C450010803690A6930B59B1A44 +:10FB30000ED11430143100EB820401EB820154F831 +:10FB4000045D51F8042D954204D006D24FF0FF33E6 +:10FB5000184630BDA042F2D3FAE70123F8E70000CF +:10FB60002DE9F74F8A460646114650461446FFF7E0 +:10FB7000DBFF051E12D129463046FFF749FD02463C +:10FB800028B940F23721404B4048FEF7EFFA0123F5 +:10FB9000C0E90435104603B0BDE8F08FBCBF534642 +:10FBA000A2463046DAF80410BABF1C4601250025EB +:10FBB000FFF72EFD024618B940F24521324BE3E72C +:10FBC000C56000F11405AB464FF0000CDAF8107078 +:10FBD00026690AF1140904F1140E0AF1100309EB65 +:10FBE00087080EEB86060193019B5EF8040B53F821 +:10FBF00004AF81B201931FFA8AF35B1A000C6344CD +:10FC0000C0EB1A4000EB23409BB243EA0043764529 +:10FC10004FEA204C4BF8043BE6D8331B153B153418 +:10FC200023F00303A64238BF0023E8184B441C1DF1 +:10FC300026460430A5EB090546450ED308F103011D +:10FC4000091B21F003010133984538BF002101440D +:10FC500051F8043DB3B117619CE7E24606EB050E8F +:10FC600056F8041B1FFA81FCD4444FEA1149514451 +:10FC700009EB2C4989B241EA09414FEA294CCEF8F7 +:10FC80000010D9E7013FE3E7A2500108C450010882 +:10FC90002DE97343012190469946089EFFF7B8FC71 +:10FCA000054630B9024640F20F31234B2348FEF798 +:10FCB0005DFAC9F30A54C9F313030CB143F480137A +:10FCC0000193B8F1000324D068460093FFF764FD68 +:10FCD0000099E0B1019AC0F1200302FA03F30B434B +:10FCE000C2406B610192019B002B0CBF01220222DA +:10FCF000AB612A61ACB1A4F2334404443460C0F176 +:10FD00003500099B1860284602B0BDE87083696120 +:10FD1000E9E701A8FFF740FD019B01226B6120305C +:10FD2000E7E7A0F2324005EB820330601869FFF785 +:10FD300015FDC0EB4210E4E7A2500108C4500108D1 +:10FD40000EB44FF4017370B500259DB021AC54F88A +:10FD5000046BADF814301B9502900690FEF7FAF98B +:10FD60000B4B03900B934FF6FF7307900948ADF8C8 +:10FD700016303246234602A900680F951495019467 +:10FD800000F0B6FC1DB0BDE8704003B0704700BF86 +:10FD9000BBFD00089C0B002010B50C46B1F90E10FD +:10FDA00000F0DAFA0028ABBF636DA3891B1823F4B7 +:10FDB0008053ACBF6365A38110BD002070472DE95F +:10FDC000F0411F468B890546DB050C46164605D5D6 +:10FDD00002230022B1F90E1000F0ACFAA3893246DA +:10FDE00023F48053A38128463B46B4F90E10BDE8A6 +:10FDF000F04100F07DBB10B50C46B1F90E1000F0DB +:10FE000099FAB4F90C30421C0BBF23F4805343F42D +:10FE10008053A381A38118BF606510BDB1F90E1096 +:10FE200000F078BBB1F90C20F8B5160705460C4672 +:10FE300051D44B68002B02DC0B6C002B49DDE66AC9 +:10FE4000002E46D0002312F480522F682B6031D050 +:10FE5000626DA389590705D56368D21A636B0BB12C +:10FE6000236CD21A00232846E66A216AB047421C56 +:10FE7000B4F90C3006D129681D2944D8264ACA4055 +:10FE8000D60740D5002262602269D904226004D5D9 +:10FE9000421C01D12B6803B96065616B2F60C1B151 +:10FEA00004F14403994202D0284600F07DFB002370 +:10FEB00063630EE001232846216AB0470246501CC6 +:10FEC000C7D12B68002BC4D01D2B01D0162B19D104 +:10FED0002F6000201CE00F69002FFAD0930718BF95 +:10FEE00000230E6808BF4B69F61B0F608B60002E65 +:10FEF000EFDD33463A462846216AD4F828C0E04769 +:10FF0000002806DCA3894FF0FF3043F04003A381B3 +:10FF1000F8BD0744361AEAE70100402038B50B69FE +:10FF200005460C4613B91D46284638BD18B1036A6C +:10FF30000BB9FCF759FBB4F90C30002BF3D0626E0F +:10FF4000D00704D4990502D4A06DFDF7A7FE28467A +:10FF50002146FFF767FF636E0546DA07E4D4A389FD +:10FF60009B05E1D4A06DFDF79BFEDDE70EB403B564 +:10FF7000014603AB054853F8042B00680193FFF7D3 +:10FF8000F5F902B05DF804EB03B070479C0B00205C +:10FF90002DE9F041074615460C4621B91146BDE84A +:10FFA000F041FFF73FB92AB900F0FEFA2C4620468F +:10FFB000BDE8F08100F0A1FE8542064602D8B5EB0F +:10FFC000500FF4D829463846FFF72CF9804608B977 +:10FFD0004446ECE7B5422A46214628BF3246FEF7A2 +:10FFE000ABF82146384600F0DFFAF1E7F8B50546F0 +:10FFF0000F46144618B1036A0BB9FCF7F5FAA3696A +:020000040801F1 +:10000000A360A3891A0701D5236943B9214628466D +:1000100000F0A4F818B14FF0FF363046F8BD236960 +:100020002068C01A6369834205DC21462846FFF731 +:1000300075FF0028EFD1A3680130013BA36023685E +:10004000FEB25A1C22601F706369834204D0A389E8 +:10005000DB07E2D50A2EE0D121462846FFF75EFFF6 +:100060000028DAD0D7E700002DE9F04386460D4698 +:10007000334E284615F8014B375D17F00807F8D1C5 +:100080002D2C10D101272C78851C33F0100015D1B0 +:10009000302C0DD1287800F0DF00582808D16C787A +:1000A000023510230AE02B2C04BF2C78851CECE7CA +:1000B000002BF6D1302C14BF0A2308234FF0FF3851 +:1000C000B8FBF3F8002603FB08F930466FEA09098C +:1000D000A4F1300CBCF1090F10D86446A3421EDD18 +:1000E000B6F1FF3F07D0804516D301D1A14513DB00 +:1000F000012600FB034015F8014BE9E7A4F1410C90 +:10010000BCF1190F01D8373CE8E7A4F1610CBCF150 +:10011000190F04D8573CE1E74FF0FF36EBE7731CAB +:1001200006D122233046CEF8003032B9BDE8F08344 +:1001300007B14042002AF9D006B1691E1160F5E707 +:1001400021540108FFF790BF13460A4601460248B2 +:100150000068FFF789BF00BF9C0B002038B5284B13 +:10016000054618680C4618B1036A0BB9FCF73CFA4F +:10017000B4F90C30190720D4DA0607D409222A6012 +:1001800043F040034FF0FF30A38131E0580711D511 +:10019000616B41B104F14403994202D0284600F05A +:1001A00003FA002363630022A3896260226923F0BB +:1001B0002403226043F00803A38123694BB9A38978 +:1001C00003F42073B3F5007F03D02146284600F0E6 +:1001D0003DF8B4F90C3013F001020AD00022A260FD +:1001E00062695242A261226942B913F08000C7D10C +:1001F00038BD990758BF6269A260F4E70020F7E7AD +:100200009C0B002070B50E46B1F90E101446002963 +:100210001D4696B00ADAB28912F0800213D14FF46B +:10022000806100202A60216016B070BD6A4600F02F +:1002300081F90028EFDB019A02F47042A2F5005325 +:100240005A425A41EBE700224021EAE78B8973B515 +:100250009E0705460C4607D504F14703236023613A +:100260000123636102B070BD01AB6A46FFF7CAFFAC +:10027000009E28463146FEF7D5FFB4F90C3038B958 +:100280009A05EFD423F0030343F00203A381E3E7CD +:1002900043F08003A381019BC4E904062060002B86 +:1002A000E0D02846B4F90E1000F034F80028D9D078 +:1002B000A38923F0030343F00103A381D2E788421B +:1002C00010B501EB020402D98442234607D8431E2D +:1002D000A14207D011F8012B03F8012FF8E70244DF +:1002E000824200D110BD13F8011D02F8011DF7E78D +:1002F00010B56AB101398418027811F8013F9A42A9 +:1003000004D10130A04201D0002AF5D1D01A10BD8D +:100310001046FCE738B50023054C05460846236027 +:1003200001F07CFE431C02D1236803B12B6038BD71 +:100330001C16002038B50546084611460022054C1B +:1003400022601A4601F07AFE431C02D1236803B1F1 +:100350002B6038BD1C16002038B5054608461146EE +:100360000022054C22601A4601F070FE431C02D1A7 +:10037000236803B12B6038BD1C16002038B500235C +:10038000054C05460846236001F068FE431C02D177 +:10039000236803B12B6038BD1C160020004870474D +:1003A000F00B00202DE9F04100230C46D0E90001BC +:1003B0004B4A01F025FC4FF46161002ABCBF02F5F5 +:1003C000A83202F5C072B2FBF1F301FB13224FF029 +:1003D0003C01A360B2FBF1F301FB132222604FF05A +:1003E000070200F52F20ACBF00F66C2000F66B2052 +:1003F0006360C31C93FBF2F2C2EBC2029B1A394941 +:1004000054D50733A361A0F50E33A3F52C7393FBEA +:10041000F1F1354B48F6AC6203FB010040F2B453F6 +:10042000B0FBF2F2B0FBF3F30244D21A2F4B642676 +:10043000B0FBF3F3D21A40F26D13B2FBF3F2B2FB4E +:10044000F6F5284403FB12039920A3EB920303EB78 +:1004500083070237B7FBF0FC4FF0050800FB0CF0F8 +:100460000230B0FBF8F003F1010EAEEB000040F2F9 +:10047000F95E77458CBF6FF00907022767444FF498 +:10048000C87C0CFB0121012F98BF0131B3F5997F86 +:1004900012D3A3F59973E3610023A1F26C71E060BC +:1004A000C4E9047120462362BDE8F0810028A361FD +:1004B000A9DB90FBF1F1ACE712F0030F02D106FBD0 +:1004C00015255DB94FF4C875B2FBF5F605FB16228C +:1004D000B2FA82F252093B331344DCE70122FAE715 +:1004E00080510100B13A02004FC5FDFFB03A020051 +:1004F00038B50546084611460022054C22601A46CA +:10050000FBF71AFB431C02D1236803B12B6038BDF3 +:100510001C16002038B50023054C0546084623600C +:1005200001F064FD431C02D1236803B12B6038BD88 +:100530001C16002038B50023064C05460846114617 +:10054000236001F05BFD431C02D1236803B12B60E3 +:1005500038BD00BF1C160020062008B500F042FC84 +:10056000012001F089FD70B5A1FB026535B9314666 +:10057000FEF758FE044628B9204670BD0C2300241F +:100580000360F9E732462946FCF71CF9F4E700005E +:100590000148FDF783BB00BFED1500200148FDF7C2 +:1005A0007FBB00BFED15002037B5002942D051F8C0 +:1005B000043C0C1F002BB8BFE4180190FEF7EAFFC3 +:1005C0001D4A0198136833B96360146003B0BDE835 +:1005D0003040FEF7E5BFA34208D9256861198B4278 +:1005E00001BF19685B6849192160EDE71A465B682D +:1005F0000BB1A342FAD911685518A5420BD1246852 +:1006000021445418A3421160E0D11C685B680C447B +:1006100014605360DAE702D90C230360D6E725683B +:1006200061198B4201BF19685B68491921606360D9 +:100630005460CBE703B030BD1816002038B54B1C12 +:10064000144603D14FF0FF35284638BD9389CDB20B +:1006500023F020039381636B52688BB1A36B9342A9 +:1006600008DD23685A1E226003F8015C63680133C9 +:100670006360E9E7214600F048FB0028F1D0E1E79C +:100680002169236851B1994208D213F8011CA9428B +:1006900004D1013B013223606260D5E7C4E90F3227 +:1006A00004F1440363630323A363234603F8465F13 +:1006B00023600123DCE710B50C46496B69B104F1F6 +:1006C0004403994201D0FFF76FFF0020236C606361 +:1006D000636013B1E36B236010BD23694FF0FF30FB +:1006E000236000236360A38943F02003A381F3E721 +:1006F0002DE9F04F0D460021ADF5237D80466F4674 +:10070000CDE9441101A94691A449DFF894B2A09122 +:10071000A4490093A19192F80090B9F1000F00F064 +:1007200058811BF80930561C13F008031AD06B6867 +:10073000002B10DD2B681A781BF80220120701D459 +:100740003246E8E7459A0133013245926A682B60E8 +:10075000013A6A60EBE729464046A19B984700288A +:10076000E8D0EDE7B9F1250F40F085804193439340 +:1007700053782A2B04BF1023961C4FF00A0208BF9F +:100780004193B2461AF8011BA1F13003092B1CD981 +:1007900003228548FDF7C2FC38B1834B5646C01A88 +:1007A0000123419A83401343419316F8013B782B70 +:1007B00006D8572B10D8252B5DD057D8002B75D0D5 +:1007C000032347930A23429388E0439B564602FB48 +:1007D000031130394391D4E7A3F15802202AEFD80E +:1007E00001A151F822F000BFBB080108C1070108B0 +:1007F000C107010817090108C1070108C10701085D +:10080000C1070108C1070108C1070108C1070108A4 +:10081000C10701082D09010813090108730801081F +:100820007308010873080108C1070108CD08010811 +:10083000C1070108C1070108C1070108C107010874 +:100840003D090108D5080108B3080108C1070108DE +:10085000C107010839090108C10701081309010886 +:10086000C1070108C1070108BB080108453B022B6D +:10087000A6D8052331E06B68002B0DDD2B681A78B4 +:100880004A4540F0A68001336A682B60459B013AD7 +:1008900001336A60459353E729464046A19B984738 +:1008A0000028EBD04498002840F08B804FF0FF30B8 +:1008B0008BE0419A42F020024192419A42F4007248 +:1008C000419210226E2B429206D801E000234293FF +:1008D000032302E008234293042347936B68002B11 +:1008E0003ADD419B590605D42B681A781BF8022083 +:1008F000120738D4479B022B47DC3B462A4640462A +:1009000041A900F07DF8012863D002287FF418AFD8 +:10091000C8E70A22D6E7314601A800F0B5F9419BA5 +:10092000064643F0400341930123D6E7419B43F041 +:10093000400341930023D0E70223CEE74198C3064A +:100940003FF5FEAE3B68459A191D39601B68C40728 +:100950004CBF1A801A60F3E629464046A19B98478F +:100960000028BED09EE7459A013245926A68013A56 +:10097000002A6A6002DD01332B60B5E72946404654 +:10098000A19B98470028AFD08CE7042B0EDC3B4698 +:100990002A46404641A900F08DF8B4E73D0601081B +:1009A00021540108B7060108B95001080A4B002B71 +:1009B0003FF4C6AE3B462A46404641A9AFF300800D +:1009C000A1E7AB895B063FF571AF0DF5237DBDE86F +:1009D000F08F4498F9E700BF0000000082B001B931 +:1009E00001A942B14BB113780B601278101E18BFE9 +:1009F000012002B070471046FBE76FF00100F8E7F6 +:100A00002DE9F84315468A6880460C4632B98A6952 +:100A1000002A14BF4FF0FF3201228A6000272268AB +:100A2000DFF88C90D1065FBF1A68111D1960166837 +:100A3000A06988B1012807D12B681A7863699B5C8B +:100A400053B9002F32D023E0022821D12B681B7824 +:100A500019F803301B071BD423680137DA065EBF81 +:100A60002B681B7806F8013B6B68013B6B602B68B9 +:100A700001332B60A368013BA3604BB16B68002B73 +:100A8000D6DC29464046D4F8803198470028CFD09C +:100A9000236813F0100305D1E2680132E260A26915 +:100AA00002B13370002023693B442361BDE8F88321 +:100AB000215401082DE9F04F0C4699466E4B87B042 +:100AC0008246164693E8070003AB83E807006B4BAA +:100AD000A1696B4A2746032908BF1A46A3680192F9 +:100AE0005A1EB2F5AE7F81BF6FF4AE7503EB0508F9 +:100AF00040F25D13A36057F81C3B98BF4FF000080D +:100B00003D464FF0000B43F450632360316803AB64 +:100B10000222097853F82B00FDF700FB20B3BBF14C +:100B2000010F54D162682AB908212268616042F439 +:100B300000722260226822F4A0622260A268511E24 +:100B4000A1608AB13268511C3160127805F8012B1E +:100B50007268013A002A726006DC31465046D4F8C9 +:100B60008021904700287DD10BF1010BBBF1030FD1 +:100B7000CCD1616809B90A216160424B6069591A98 +:100B800000F082F84FF0000BA368002B3BD03168D7 +:100B900062690878125C002A35D03028226824D196 +:100BA000100522D50BF1010BB8F1000F03D0013372 +:100BB00008F1FF38A3607368013B002B73601BDDF5 +:100BC000336801333360A368013BA360DCE7BBF10A +:100BD000020FB3D1226802F4C061B1F5007FC8D121 +:100BE000102142F480726160A7E722F41062226053 +:100BF0000B7805F8013BDEE731465046D4F88031EA +:100C000098470028DFD02368DB050BD5BD4207D904 +:100C100015F8011C32465046D4F87C319847013D06 +:100C2000BD4227D0226812F0100212D12A70394634 +:100C30006368019E5046B047D9F8003021681A1DFC +:100C4000C9F800208E061B680FD51860E3680133D1 +:100C5000E36000202369ED1B5D442B44236107B052 +:100C6000BDE8F08F4FF0000BCDE7CA074CBF1880EE +:100C70001860EBE70120F2E7205601084DC7000895 +:100C8000450101083E51010870B50B7800F1FF05E0 +:100C90005E2B13BF002201224B784C1C08BF8C1C1A +:100CA000411E01F8012FA942FBD113B9621E104663 +:100CB00070BD82F001012246C154144614F8015B54 +:100CC0002D2D05D05D2D16D0002DF0D02B46F2E74E +:100CD00056785D2EFAD0B342F8DC1C46023201345D +:100CE000A6420155FBDCF41A013CB342A8BF002424 +:100CF00001332344E1E72246D9E751F8043C181FA9 +:100D0000002BBCBF0B58C01870472DE9F0410C46B2 +:100D1000496B04F1440399421BD14FF48061FEF703 +:100D200081FA18B94FF0FF30BDE8F0814FF48063CD +:100D3000A36394F84630606380F8FF3394F845303D +:100D400000F2FD30437094F84430037020600020BE +:100D5000EAE7A66B77003A46FFF71AF9054600283E +:100D6000E0D000EB0608014632464046FDF7E4F9C4 +:100D7000C4E90D57C4F80080E9E749B1FF2A8BBFE9 +:100D80008A23012003600A7088BF4FF0FF3070474C +:100D9000084670471F2938B505460C4604D9162366 +:100DA00003604FF0FF3038BDC26B12B152F82130F2 +:100DB0004BB9284600F030F8224601462846BDE8E7 +:100DC000384000F017B8012B0AD0591C03D1162364 +:100DD00003600120E7E70021204642F824109847ED +:100DE0000020E0E7024B01461868FFF7D3BF00BFC1 +:100DF0009C0B002038B50023064C054608461146DA +:100E0000236001F013F9431C02D1236803B12B6066 +:100E100038BD00BF1C16002001F0F8B881F0004179 +:100E200002E000BF83F0004330B54FEA41044FEACF +:100E3000430594EA050F08BF90EA020F1FBF54EA6A +:100E4000000C55EA020C7FEA645C7FEA655C00F006 +:100E5000E2804FEA5454D4EB5555B8BF6D420CDDD7 +:100E60002C4480EA020281EA030382EA000083EA5A +:100E7000010180EA020281EA0303362D88BF30BDFA +:100E800011F0004F4FEA01314FF4801C4CEA113150 +:100E900002D0404261EB410113F0004F4FEA0333AF +:100EA0004CEA133302D0524263EB430394EA050F3A +:100EB00000F0A780A4F10104D5F1200E0DDB02FAA9 +:100EC0000EFC22FA05F2801841F1000103FA0EF23D +:100ED000801843FA05F359410EE0A5F120050EF103 +:100EE000200E012A03FA0EFC28BF4CF0020C43FA34 +:100EF00005F3C01851EBE37101F0004507D54FF041 +:100F0000000EDCF1000C7EEB00006EEB0101B1F590 +:100F1000801F1BD3B1F5001F0CD349085FEA3000D6 +:100F20004FEA3C0C04F101044FEA445212F5800FE1 +:100F300080F09A80BCF1004F08BF5FEA500C50F17E +:100F4000000041EB045141EA050130BD5FEA4C0C61 +:100F5000404141EB0101013C28BFB1F5801FE9D2BE +:100F600091F0000F04BF01460020B1FA81F308BFE1 +:100F70002033A3F10B03B3F120020CDA0C3208DDAD +:100F800002F1140CC2F10C0201FA0CF021FA02F188 +:100F90000CE002F11402D8BFC2F1200C01FA02F1F8 +:100FA00020FA0CFCDCBF41EA0C019040E41AA2BF1D +:100FB00001EB0451294330BD6FEA04041F3C1CDAE5 +:100FC0000C340EDC04F11404C4F1200220FA04F005 +:100FD00001FA02F340EA030021FA04F345EA0301AF +:100FE00030BDC4F10C04C4F1200220FA02F001FA71 +:100FF00004F340EA0300294630BD21FA04F02946F3 +:1010000030BD94F0000F83F4801306BF81F480118B +:101010000134013D4EE77FEA645C18BF7FEA655CFE +:1010200029D094EA050F08BF90EA020F05D054EAD0 +:10103000000C04BF1946104630BD91EA030F1EBFD5 +:101040000021002030BD5FEA545C05D140004941D9 +:1010500028BF41F0004130BD14F580043CBF01F5CC +:10106000801130BD01F0004545F0FE4141F47001B2 +:101070004FF0000030BD7FEA645C1ABF194610468D +:101080007FEA655C1CBF0B46024650EA013406BF8E +:1010900052EA033591EA030F41F4002130BD00BF4D +:1010A00090F0000F04BF0021704730B54FF480640A +:1010B00004F132044FF000054FF0000150E700BF8B +:1010C00090F0000F04BF0021704730B54FF48064EA +:1010D00004F1320410F0004548BF40424FF00001D7 +:1010E0003EE700BF42004FEAE2014FEA31014FEA1A +:1010F00002701FBF12F07F4393F07F4F81F0605169 +:10110000704732F07F4208BF704793F07F4F04BFB3 +:1011100041F40021704730B54FF4607401F0004590 +:1011200021F000411CE700BF50EA010208BF7047F0 +:1011300030B54FF000050AE050EA010208BF7047E1 +:1011400030B511F0004502D5404261EB41014FF44A +:10115000806404F132045FEA915C3FF4D8AE4FF052 +:1011600003025FEADC0C18BF03325FEADC0C18BF35 +:10117000033202EBDC02C2F1200300FA03FC20FA86 +:1011800002F001FA03FE40EA0E0021FA02F11444D3 +:10119000BDE600BF70B54FF0FF0C4CF4E06C1CEAEC +:1011A00011541DBF1CEA135594EA0C0F95EA0C0F5D +:1011B00000F0DEF82C4481EA030621EA4C5123EAD0 +:1011C0004C5350EA013518BF52EA033541F48011FF +:1011D00043F4801338D0A0FB02CE4FF00005E1FBB2 +:1011E00002E506F00042E0FB03E54FF00006E1FBFC +:1011F00003569CF0000F18BF4EF0010EA4F1FF043F +:10120000B6F5007F64F5407404D25FEA4E0E6D417E +:1012100046EB060642EAC62141EA55514FEAC5208F +:1012200040EA5E504FEACE2EB4F1FD0C88BFBCF50B +:10123000E06F1ED8BEF1004F08BF5FEA500E50F1BC +:10124000000041EB045170BD06F0004646EA010182 +:1012500040EA020081EA0301B4EB5C04C2BFD4EBB4 +:101260000C0541EA045170BD41F480114FF0000EAD +:10127000013C00F3AB8014F1360FDEBF002001F01B +:10128000004170BDC4F10004203C35DA0C341BDC95 +:1012900004F11404C4F1200500FA05F320FA04F067 +:1012A00001FA05F240EA020001F0004221F000419B +:1012B00010EBD37021FA04F642EB06015EEA430E0E +:1012C00008BF20EAD37070BDC4F10C04C4F120053E +:1012D00000FA04F320FA05F001FA04F240EA0200F1 +:1012E00001F0004110EBD37041F100015EEA430EC2 +:1012F00008BF20EAD37070BDC4F1200500FA05F2E2 +:101300004EEA020E20FA04F301FA05F243EA020360 +:1013100021FA04F001F0004121FA04F220EA02006F +:1013200000EBD3705EEA430E08BF20EAD37070BDB5 +:1013300094F0000F0FD101F00046400041EB010195 +:1013400011F4801F08BF013CF7D041EA060195F077 +:10135000000F18BF704703F00046520043EB030331 +:1013600013F4801F08BF013DF7D043EA060370471E +:1013700094EA0C0F0CEA135518BF95EA0C0F0CD029 +:1013800050EA410618BF52EA4306D1D181EA03016F +:1013900001F000414FF0000070BD50EA410606BF69 +:1013A0001046194652EA430619D094EA0C0F02D1AE +:1013B00050EA013613D195EA0C0F05D152EA0336F3 +:1013C0001CBF104619460AD181EA030101F0004111 +:1013D00041F0FE4141F470014FF0000070BD41F05A +:1013E000FE4141F4780170BD70B54FF0FF0C4CF434 +:1013F000E06C1CEA11541DBF1CEA135594EA0C0F53 +:1014000095EA0C0F00F0A7F8A4EB050481EA030E9F +:1014100052EA03354FEA013100F088804FEA033386 +:101420004FF0805545EA131343EA12634FEA022254 +:1014300045EA111545EA10654FEA00260EF0004115 +:101440009D4208BF964244F1FD0404F5407402D267 +:101450005B084FEA3202B61A65EB03055B084FEAF8 +:1014600032024FF480104FF4002CB6EB020E75EBF5 +:10147000030E22BFB61A754640EA0C005B084FEA1D +:101480003202B6EB020E75EB030E22BFB61A75469A +:1014900040EA5C005B084FEA3202B6EB020E75EBE5 +:1014A000030E22BFB61A754640EA9C005B084FEA5D +:1014B0003202B6EB020E75EB030E22BFB61A75466A +:1014C00040EADC0055EA060E18D04FEA051545EA59 +:1014D00016754FEA06164FEAC30343EA52734FEA02 +:1014E000C2025FEA1C1CC0D111F4801F0BD141EA7B +:1014F00000014FF000004FF0004CB6E711F4801FE0 +:1015000004BF01430020B4F1FD0C88BFBCF5E06FBF +:101510003FF6AFAEB5EB030C04BFB6EB020C5FEACF +:10152000500C50F1000041EB045170BD0EF0004E24 +:101530004EEA113114EB5C04C2BFD4EB0C0541EA56 +:10154000045170BD41F480114FF0000E013C90E653 +:1015500045EA060E8DE60CEA135594EA0C0F08BF17 +:1015600095EA0C0F3FF43BAF94EA0C0F0AD150EA16 +:1015700001347FF434AF95EA0C0F7FF425AF1046A9 +:1015800019462CE795EA0C0F06D152EA03353FF4D1 +:10159000FDAE1046194622E750EA410618BF52EA4E +:1015A00043067FF4C5AE50EA41047FF40DAF52EA22 +:1015B00043057FF4EBAE12E74FF0FF3C06E000BFBF +:1015C0004FF0010C02E000BF4FF0010C4DF804CDCC +:1015D0004FEA410C7FEA6C5C4FEA430C18BF7FEA8C +:1015E0006C5C1BD001B050EA410C0CBF52EA430CBA +:1015F00091EA030F02BF90EA020F0020704710F13A +:10160000000F91EA030F58BF994208BF90422CBFC8 +:10161000D8176FEAE37040F0010070474FEA410CC1 +:101620007FEA6C5C02D150EA013C07D14FEA430CDF +:101630007FEA6C5CD6D152EA033CD3D05DF8040B50 +:10164000704700BF8446104662468C461946634682 +:1016500000E000BF01B5FFF7B7FF002848BF10F159 +:10166000000F01BD4DF808EDFFF7F4FF0CBF01209E +:1016700000205DF808FB00BF4DF808EDFFF7EAFF1A +:1016800034BF012000205DF808FB00BF4DF808EDD5 +:10169000FFF7E0FF94BF012000205DF808FB00BFCA +:1016A0004DF808EDFFF7CEFF94BF012000205DF854 +:1016B00008FB00BF4DF808EDFFF7C4FF34BF012061 +:1016C00000205DF808FB00BF4FEA410C7FEA6C5C2C +:1016D00002D150EA013C0AD14FEA430C7FEA6C5C2C +:1016E00002D152EA033C02D14FF0000070474FF0A4 +:1016F000010070474FEA410212F5001215D211D5D0 +:101700006FF47873B3EB625212D94FEAC12343F0FE +:10171000004343EA505311F0004F23FA02F018BF80 +:10172000404270474FF00000704750EA013005D149 +:1017300011F0004008BF6FF0004070474FF000000C +:10174000704700BF80F0004002E000BF81F0004120 +:1017500042001FBF5FEA410392EA030F7FEA226C57 +:101760007FEA236C6AD04FEA1262D2EB1363C1BFE7 +:10177000D218414048404140B8BF5B42192B88BF56 +:10178000704710F0004F40F4000020F07F4018BF79 +:10179000404211F0004F41F4000121F07F4118BF99 +:1017A000494292EA030F3FD0A2F1010241FA03FC41 +:1017B00010EB0C00C3F1200301FA03F100F0004329 +:1017C00002D5494260EB4000B0F5000F13D3B0F1F1 +:1017D000807F06D340084FEA310102F10102FE2A60 +:1017E00051D2B1F1004F40EBC25008BF20F00100D0 +:1017F00040EA03007047490040EB0000013A28BF6F +:10180000B0F5000FEDD2B0FA80FCACF1080CB2EBF1 +:101810000C0200FA0CF0AABF00EBC250524218436F +:10182000BCBFD0401843704792F0000F81F4000114 +:1018300006BF80F400000132013BB5E74FEA4103E7 +:101840007FEA226C18BF7FEA236C21D092EA030F53 +:1018500004D092F0000F08BF0846704790EA010FCD +:101860001CBF0020704712F07F4F04D1400028BFFA +:1018700040F00040704712F100723CBF00F50000DC +:10188000704700F0004343F0FE4040F40000704712 +:101890007FEA226216BF08467FEA236301464202BE +:1018A00006BF5FEA412390EA010F40F480007047D1 +:1018B0004FF0000304E000BF10F0004348BF404277 +:1018C0005FEA000C08BF704743F0964301464FF0B3 +:1018D00000001CE050EA010208BF70474FF000030F +:1018E0000AE000BF50EA010208BF704711F0004350 +:1018F00002D5404261EB41015FEA010C02BF844620 +:101900000146002043F0B64308BFA3F18053A3F57E +:101910000003BCFA8CF2083AA3EBC25310DB01FAC5 +:1019200002FC634400FA02FCC2F12002BCF1004F49 +:1019300020FA02F243EB020008BF20F001007047DA +:1019400002F1200201FA02FCC2F1200250EA4C002E +:1019500021FA02F243EB020008BF20EADC70704774 +:101960004FF0FF0C1CEAD0521EBF1CEAD15392EA82 +:101970000C0F93EA0C0F6FD01A4480EA010C40025E +:1019800018BF5FEA41211ED04FF0006343EA5010B8 +:1019900043EA5111A0FB01310CF00040B1F5000FFA +:1019A0003EBF490041EAD3715B0040EA010062F1A9 +:1019B0007F02FD2A1DD8B3F1004F40EBC25008BF93 +:1019C00020F00100704790F0000F0CF0004C08BFB1 +:1019D00049024CEA502040EA51207F3AC2BFD2F17E +:1019E000FF0340EAC250704740F400004FF000038C +:1019F000013A5DDC12F1190FDCBF00F000407047C6 +:101A0000C2F10002410021FA02F1C2F1200200FA03 +:101A100002FC5FEA310040F1000053EA4C0308BFCA +:101A200020EADC70704792F0000F00F0004C02BF1B +:101A3000400010F4000F013AF9D040EA0C0093F096 +:101A4000000F01F0004C02BF490011F4000F013BF0 +:101A5000F9D041EA0C018FE70CEAD15392EA0C0F5E +:101A600018BF93EA0C0F0AD030F0004C18BF31F0C9 +:101A7000004CD8D180EA010000F00040704790F09F +:101A8000000F17BF90F0004F084691F0000F91F043 +:101A9000004F14D092EA0C0F01D142020FD193EA09 +:101AA0000C0F03D14B0218BF084608D180EA010091 +:101AB00000F0004040F0FE4040F40000704740F06D +:101AC000FE4040F4400070474FF0FF0C1CEAD0523B +:101AD0001EBF1CEAD15392EA0C0F93EA0C0F69D097 +:101AE000A2EB030280EA010C49024FEA402037D002 +:101AF0004FF0805343EA111143EA10130CF00040F9 +:101B00008B4238BF5B0042F17D024FF4000C8B42E8 +:101B100024BF5B1A40EA0C00B3EB510F24BFA3EBC8 +:101B2000510340EA5C00B3EB910F24BFA3EB910398 +:101B300040EA9C00B3EBD10F24BFA3EBD10340EAF2 +:101B4000DC001B0118BF5FEA1C1CE0D1FD2A3FF638 +:101B500050AF8B4240EBC25008BF20F001007047ED +:101B60000CF0004C4CEA50207F32C2BFD2F1FF0390 +:101B700040EAC250704740F400004FF00003013AC1 +:101B800037E792F0000F00F0004C02BF400010F465 +:101B9000000F013AF9D040EA0C0093F0000F01F079 +:101BA000004C02BF490011F4000F013BF9D041EA9B +:101BB0000C0195E70CEAD15392EA0C0F08D14202CE +:101BC0007FF47DAF93EA0C0F7FF470AF084676E7A1 +:101BD00093EA0C0F04D14B023FF44CAF08466EE77A +:101BE00030F0004C18BF31F0004CCAD130F0004248 +:101BF0007FF45CAF31F000437FF43CAF5FE700BFA0 +:101C00007BB972B90029BEBF00204FF0004106E049 +:101C100008BF00281CBF6FF000414FF0FF3000F0FC +:101C2000E3B9ADF1080C6DE904CE002909DB002B06 +:101C30001ADB00F04DF8DDF804E0DDE9022304B022 +:101C40007047404261EB4101002B1BDB00F040F884 +:101C5000DDF804E0DDE9022304B0404261EB41011C +:101C6000524263EB43037047524263EB430300F07D +:101C70002FF8DDF804E0DDE9022304B0404261EB17 +:101C800041017047524263EB430300F021F8DDF855 +:101C900004E0DDE9022304B0524263EB43037047E2 +:101CA00053B94AB9002908BF00281CBF4FF0FF31C3 +:101CB0004FF0FF3000F098B9ADF1080C6DE904CE9B +:101CC00000F006F8DDF804E0DDE9022304B0704717 +:101CD0002DE9F047074616460846BC460D46089AC9 +:101CE000002B4FD18E42B64669D9B6FA86F44CB174 +:101CF000C4F12003A54027FA03F306FA04FE1D43AE +:101D000007FA04FC4FEA1E47B5FBF7F107FB115534 +:101D10001FFA8EF04FEA1C4343EA054301FB00F52E +:101D20009D420AD91EEB030301F1FF3680F0F680D5 +:101D30009D4240F2F380023973445B1BB3FBF7F51D +:101D400007FB153305FB00F01FFA8CFC4CEA034C33 +:101D500060450AD91EEB0C0C05F1FF3380F0E080E2 +:101D6000604540F2DD80F444023DACEB000C45EAF6 +:101D70000140002122B12CFA04F30024C2E900340E +:101D8000BDE8F0878B4206D90AB1C2E90071002193 +:101D90000846BDE8F087B3FA83F100294CD18342AD +:101DA00002D3BE4200F20F81B7EB060C60EB0303D7 +:101DB00001201D46002AE3D0C2E900C5E0E7002E5D +:101DC00000F095801C46B6FA86F3002B40F0AA80FE +:101DD0008D1B0121370CB6B2B5FBF7F007FB105590 +:101DE0004FEA1C4343EA054306FB00F59D4208D930 +:101DF0001EEB030300F1FF3802D29D4200F2E8809F +:101E000040465B1BB3FBF7F507FB15331FFA8CFC51 +:101E10004CEA034C06FB05F3634508D91EEB0C0C9A +:101E200005F1FF3602D2634500F2CF803546ACEBB8 +:101E3000030C45EA00409DE7C1F120058B4026FADE +:101E400005FC4CEA030C20FA05F44FEA1C4E06FA96 +:101E500001F9B4FBFEF6884027FA05F303430EFBB5 +:101E600016401FFA8CF807FA01FA1F0C47EA0044E3 +:101E700006FB08F0A0420AD91CEB040406F1FF3768 +:101E800080F09F80A04240F29C80023E6444241A6D +:101E9000B4FBFEF00EFB104400FB08FE9BB243EACD +:101EA00004439E450AD91CEB030300F1FF3480F084 +:101EB00086809E4540F283800238634440EA0640B3 +:101EC000A0FB0974A3EB0E03A342BE46264665D3CE +:101ED00062D052B1BAEB0E0463EB060303FA05F5C8 +:101EE000CC402543CB40C2E90053002148E77B08A2 +:101EF00043EAC1734C08190C41EA04419BB2B4FB9C +:101F0000F6F04FEAC77C43EA01433546B1FBF6F1F0 +:101F100037461F245D1B41EA00415DE731460CE76F +:101F20001D4622E71C4606FA03FEC3F1200321FAF0 +:101F300003F5A04027FA03F307FA04FC4FEA1E4713 +:101F40000343B5FBF7F007FB10551FFA8EF6190C8B +:101F500041EA054100FB06F58D423ED91EEB010129 +:101F600001D28D4221D8491BB1FBF7F5A84605FBEC +:101F700006F5013807FB18119BB243EA0143AB4257 +:101F800029D21EEB030308F1FF31C3D2AB42C1D209 +:101F9000A8F102017344BDE7BA459AD2B7EB090E26 +:101FA00064EB0C040138264693E7AEEB05052944A3 +:101FB000B1FBF7F50238A84605FB06F5DAE720463F +:101FC0007CE73E4663E70846F4E6F444023D2EE72C +:101FD0000238734415E741469CE7491BB1FBF7F50E +:101FE000A84605FB06F5C5E7704700BF5822024B1F +:101FF0004FF0FF301A6070471C1600205822024B29 +:102000004FF0FF301A6070471C1600205822024B18 +:102010004FF0FF301A6070471C1600205822024B08 +:1020200000201A60704700BF1C1600205822024B87 +:102030004FF0FF301A6070471C1600205822024BE8 +:102040004FF0FF301A6070471C1600205822024BD8 +:102050004FF0FF301A6070471C160020044A0549F3 +:102060001368002B08BF0B461844106018467047D1 +:1020700024160020603B0020FEE700BF0D0ACAD7EF +:10208000B4CE475053D0C5CFA2B7A2CBCDA3A10D9C +:102090000A000D0A2A2A2A2A2A2A2A2A2A2A2A2A27 +:1020A0002A2A2A53797374656D2052756E6E696E93 +:1020B000672A2A2A2A2A2A2A2A2A2A2A2A2A2A2A43 +:1020C0000D0A000D0AC9E8D6C34943BFA8C4A3BF7F +:1020D000E9B2CECAFD202D2D3E0D0A000D0A544353 +:1020E00050203C2D2D202564200D0A0025592D253A +:1020F0006D2D25642025483A254D3A2553000D0ABB +:10210000B8FCD0C2CAB1BCE4A3BA25730D0A000D55 +:102110000ACEB4BBF1B5C3C8D5C6DACAB1BCE42196 +:102120000D0A000D0A44617461206F766572666C59 +:102130006F770D0A007975656E673D2573000D0A8E +:102140005043202D2D3E203078253032580D0A0086 +:1021500056322E315F3236303730395F34434800E3 +:102160000D0A307836312055706461746520443131 +:102170003D25642C2044323D25642C2044333D25EC +:10218000642C2044343D25640D0A000D0A30783655 +:1021900032204F46203D2025642C2025642C20250C +:1021A000642C2025640D0A00636F6E6E65637400F5 +:1021B0000D0ACEB4D6AAD6B8C1EEA3A10D0A000D61 +:1021C0000A5043203C2D2D203078253032580D0AFE +:1021D0000030782530325820000D0AD3C3BBA7C980 +:1021E000EDB7DDCAB6B1F0A3BA0D0A005479706537 +:1021F0003A2025640D0A004C656E3A2025640D0ACC +:1022000000446174614275663A2025730D0A000D21 +:102210000ABFAAC3C5BFA8C6A5C5E4A3A10D0A00ED +:102220000D0ABFAACABCBCECCBF70D0A000D0AB55B +:10223000B1C7B0D3C3BBA7D2D1BEADB1BBBDFBD379 +:10224000C3A3A1D4DA20256420CEBB0D0A000D0A59 +:10225000B5B1C7B0D3C3BBA7D5FDB3A3A3A10D0A26 +:10226000000D0ABFAAC3C5BFA8B2BBC6A5C5E4A3DB +:10227000A10D0A000D0AC1D9CAB1BFAAC3C5B6FED5 +:10228000CEACC2EBBFAAC3C5A3A10D0A000D0AA123 +:10229000B0CAD5D4CBB6FECEACC2EBBFAAC3C5A1E3 +:1022A000B1B9A6C4DCD2D1CDA3D3C3A3A10D0A007A +:1022B0000D0AC8CFD6A4B3ACCAB1CDCBB3F6A3A197 +:1022C0000D0A000D0ACAD5D4CBD5CBBAC5CEDED007 +:1022D000A7BBF2CEB4B5C7BCC7A3A10D0A000D0AB7 +:1022E000CAD5D4CBD5CBBAC5D5FDB3A3A3A10D0A0E +:1022F000000D0ACAD5D4CBD5CBBAC5B1BBBDFBD373 +:10230000C3A3A10D0A000D0A476574207573657299 +:1023100020496E666F0D0A000D0AD5CBBAC5BBD633 +:10232000B8B4D5FDB3A3A3A10D0A000D0AD5CBBA4D +:10233000C5B4A6D3DABDFBD3C3D7B4CCACA3A10D2F +:102340000A000D0A576F726B537461203D2025649B +:102350000D0A000D0AC9E8B1B8B9A4D7F7D7B4CCB3 +:10236000ACD3D0B1E4BBAFA3A10D0A000D0AB0B449 +:10237000BCFCCAE4B3F63A204E756D203D202578AA +:102380002C20537461203D2025780D0A000D0ACDC4 +:10239000B6B7C5BFDA31D7B4CCACB7A2C9FAB1E48D +:1023A000BBAFA3A82564A3A90D0A000D0ACDB6B73B +:1023B000C5BFDA32D7B4CCACB7A2C9FAB1E4BBAF6F +:1023C000A3A82564A3A90D0A000D0A2D2D2D2D2DDE +:1023D0002D2D2D2D3E20D3C3BBA7C7EBC7F3BFAA1E +:1023E000C3C5CDB6B7C5A3A1A3A1A3A10D0A000D76 +:1023F0000AD5FDD4DABDF8D0D0CDB6B7C5B2D9D79D +:10240000F72E2E2E2E2E2E0D0A000D0AB5C8B4FD65 +:10241000CDB6B7C5CDEAB3C9B3ACCAB1B7B5BBD8B1 +:102420000D0A000D0ACAD5B5BDCDB6B7C5CDEAB304 +:10243000C9A3ACD5FDD4DAB4A6C0ED2E2E2E2E2E17 +:102440002E0D0A000D0A2D2D3E20CAD5B5BDB1BEF8 +:10245000B4CECDB6B7C5CAFDBEDDC8E7CFC2A3BAFC +:10246000000D0A2D2D3E20547970653A2025640018 +:102470000D0A2D2D3E204C656E3A202564000D0A74 +:102480002D2D3E20446174613A20000D0A2D2D3E11 +:1024900020446174613A2025730D0A000D0ACDB005 +:1024A000313A2025322E3266204B67A3AC25322EDE +:1024B0003266204B67202D3E2025322E3266204B7F +:1024C00067A3ACBEE0C0EBA3BA25332E3166206310 +:1024D0006D0D0A000D0ACDB0323A2025322E32663B +:1024E000204B67A3AC25322E3266204B67202D3E51 +:1024F0002025322E3266204B67A3ACBEE0C0EBA392 +:10250000BA25332E316620636D0D0A000D0ACDB059 +:10251000333A2025322E3266204B67A3AC25322E6B +:102520003266204B67202D3E2025322E3266204B0E +:1025300067A3ACBEE0C0EBA3BA25332E316620639F +:102540006D0D0A000D0ACDB0343A2025322E3266C8 +:10255000204B67A3AC25322E3266204B67202D3EE0 +:102560002025322E3266204B67A3ACBEE0C0EBA321 +:10257000BA25332E316620636D0D0A000D0A2D2D0C +:102580002D2D2D2D2D2D2D2D3ECDB6B7C5CDEAB33C +:10259000C9A3A1A3A1A3A10D0A000D0AB1BEB4CE87 +:1025A000D3D0CDB6B7C5A3ACB5C8B4FDBAF3CCA8EB +:1025B000BBD8D3A6BDB1C0F80D0A000D0ACFD4CA4E +:1025C000BECDB6B7C5CAB1BCE4B5BDA3ACC7D2CE0B +:1025D000DECDB6B7C5CDCBB3F60D0A000D0AD6AE2B +:1025E000C7B0D3E0B6EE203D20252E3266200D0A7E +:1025F000000D0AD6AEBAF3D3E0B6EE203D20252E6C +:102600003266200D0A000D0ABDB1C0F8BDF0B6EE6D +:10261000203D20252E3266200D0A000D0ACFD4CA97 +:10262000BECDB6B7C5CAB1BCE4B5BD0D0A000D0A32 +:10263000CFD4CABEBDE1CAF80D0A000D0AC8CBC18D +:10264000B3C2BCC8EBD6D8D0C2B2D9D7F70D0A00F6 +:102650000D0AC8CBC1B3C2BCC8EBCDCBB3F6A3A1A6 +:102660000D0A000D0AC2BCC8EBB3ACCAB1CDCBB3E6 +:10267000F6A3A10D0A000D0ACAD5D4CBC3C5D7B4A1 +:10268000CCACB7A2C9FAB1E4BBAFA3A10D0A000D4F +:102690000ACAD5D4CBC3C5B9D8B1D5A3A10D0A00F8 +:1026A0000D0ACAD5D4CBC3C5B4F2BFAAA3A10D0AE3 +:1026B000000D0AB3F5B4CEBFAABBFACFF2C9CFCE94 +:1026C000BBBBFAB7A2CBCDCAD5D4CBC3C5D7B4CC8C +:1026D000ACA3A10D0A000D0AB6A8CAB1B5BDB4F2EB +:1026E000BFAAC5E7C1DCCFFBB6BEA3A128257329CD +:1026F0000D0A000D0ACFFBB6BECAB1BCE4B5BDB928 +:10270000D8B1D5C5E7C1DCCFFBB6BEA3A10D0A0089 +:102710000D0AB5B1C7B0D5FDD4DACDB6B7C5A3A102 +:10272000D4DDCDA3C5E7C1DCCFFBB6BEA3A10D0AA6 +:10273000000D0AB4F2BFAACAD5D4CBC3C5BDE1CA45 +:10274000F8C5E7C1DCCFFBB6BEA3A10D0A000D0A98 +:10275000CDB6B7C5BDE1CAF8A3A1BBD6B8B4C5E72D +:10276000C1DCCFFBB6BEA3A10D0A000D0AB6A8CAF4 +:10277000B1B5BDB4F2BFAA5556CFFBB6BEA3A128D2 +:102780002573290D0A000D0ACFFBB6BECAB1BCE401 +:10279000B5BDB9D8B1D55556CFFBB6BEA3A10D0A6C +:1027A000000D0AB5B1C7B0D5FDD4DACDB6B7C5A313 +:1027B000A1D4DDCDA35556CFFBB6BEA3A10D0A0013 +:1027C0000D0AB4F2BFAACAD5D4CBC3C5BDE1CAF8BD +:1027D0005556CFFBB6BEA3A10D0A000D0ACDB6B764 +:1027E000C5BDE1CAF8A3A1BBD6B8B45556CFFBB658 +:1027F000BEA3A10D0A000D0AB5B1C7B0D3C3BBA7D4 +:10280000CAFDC1BFA3BA25642C206E657874496ED9 +:10281000646578203D2025643A000D0A44617461A6 +:10282000206F75740D0A000D0A47534DC4A3BFE90C +:10283000D5FDD4DABFAABBFA0D0A0041542B43538D +:1028400051000D0A47534DD0C5BAC5C7BFB6C82001 +:102850003D2025640D0A000D0A47534DD0C5BAC569 +:10286000C8F5A3ACC7EBBCECB2E9CCECCFDFC1AC94 +:10287000BDD3CAC7B7F1D5FDB3A30D0A000D0ACE6B +:10288000DE47534DD0C5BAC5A3A1A3A1A3A10D0A8C +:10289000000D0ABFAACABCCDACB2BD4E5450B7FEA3 +:1028A000CEF1C6F70D0A0041542B51494143543D26 +:1028B00031000D0ABCA4BBEE504450204F4B0D0A12 +:1028C000000D0ABCA4BBEE504450204552524F525A +:1028D0000D0A000D0AD3A6B4F0B3ACCAB1A3ACBCC8 +:1028E000A4BBEE504450CAA7B0DC0D0A0041542BE3 +:1028F000514E54503D312C223230322E3131322E55 +:1029000031302E3336222C313233000D0ACAB1BC9D +:10291000E4CDACB2BD4F4B0D0A000D0ACAB1BCE408 +:10292000CDACB2BD204552524F520D0A000D0AD314 +:10293000A6B4F0B3ACCAB1A3ACCAB1BCE4CDACB2DE +:10294000BDCAA7B0DC0D0A0041542B43434C4B3F9A +:10295000000D0A54696D653A25730D0A000D0A478A +:1029600065742054696D65204552524F520D0A001E +:102970000D0AD3A6B4F0B3ACCAB1A3AC47657420BA +:1029800054696D65CAA7B0DC0D0A0041542B51494A +:1029900044454143543D31000D0A504450C8A5BC44 +:1029A000A4BBEE204F4B0D0A000D0A504450C8A5A1 +:1029B000BCA4BBEE204552524F520D0A000D0AD363 +:1029C000A6B4F0B3ACCAB1A3AC504450C8A5BCA4E3 +:1029D000BBEECAA7B0DC0D0A000D0ACDACB2BD4EED +:1029E0005450B7FECEF1C6F7CDEAB3C9A3A10D0A84 +:1029F000000D0ABCECB2E2C4A3BFE90D0A004154C9 +:102A0000000D0AC4A3BFE9D5FDB3A30D0A000D0A4A +:102A1000B3ACCAB1CEB4BCFBC4A3BFE9D3A6B4F077 +:102A20000D0A000D0AB9D8B1D5BBD8CFD40D0A0014 +:102A300041544530000D0AB9D8B1D5BBD8CFD4B375 +:102A4000ACCAB1CEB4D3A6B4F00D0A0041542B43A6 +:102A500047534E000D0A494D4549203D2025730D31 +:102A60000A000D0ABBF1C8A1D3B2BCFED0C5CFA2EB +:102A7000B3ACCAB10D0A000D0AB2E9D1AF53494D4A +:102A8000BFA8D7B4CCACB3ACCAB1BBF253494DBFAD +:102A9000A8CEDED0A7A3A1A3A1A3A10D0A004154F3 +:102AA0002B4350494E3F000D0A53494DBFA8D2D188 +:102AB000BEADBECDD0F70D0A000D0AB2E9D1AF49C7 +:102AC00043434944BAC50D0A0041542B514343497D +:102AD00044000D0A4943434944203D2025730D0A13 +:102AE000000D0ABBF1C8A153494DBFA8B5C4494365 +:102AF000434944B3ACCAB10D0A000D0AB2E9D1AFE3 +:102B0000B2BBB5BDCDF8C2E7D0C5BAC5A3A1A3A1DC +:102B1000A3A10D0A000D0AD0C5BAC5C7BFB6C8D556 +:102B2000FDB3A3203D2025640D0A000D0AB2E9D1B2 +:102B3000AFCDF8C2E7D7A2B2E1D7B4CCAC0D0A0052 +:102B40000D0AB5C8B4FDB3ACCAB1A3ACC9D0CEB4FC +:102B5000D7A2B2E1CDF8C2E7A3A1A3A1A3A10D0A18 +:102B60000041542B435245473F000D0AD2D1BEAD20 +:102B7000D7A2B2E1CDF8C2E70D0A000D0AB2E9D141 +:102B8000AFCAC7B7F1B8BDD7C547505253D2B5CEBB +:102B9000F1A3BF0D0A000D0A436E74203D20256489 +:102BA0000D0A000D0AB5C8B4FDB3ACCAB1A3ACC9D7 +:102BB000D0CEB4B8BDD7C5475052530D0A004154CA +:102BC0002B43475245473F000D0AD2D1BEADB8BD99 +:102BD000D7C547505253D2B5CEF10D0A0041542B00 +:102BE000434F50533F000D0AD6D0B9FAD2C6B6AF04 +:102BF0000D0A000D0AD6D0B9FAC1AACDA80D0A0057 +:102C00000D0AD3A6B4F0B3ACCAB1A3A10D0A000D4E +:102C10000A4E545020CDACB2BDB3ACCAB1A3A10D85 +:102C20000A000D0AC4A3BFE9BCD3D4D8CAA7B0DC3C +:102C3000A3A10D0A000D0AC4A3BFE9BCD3D4D8B91F +:102C4000FDB3CCB8B4CEBBA3A10D0A000D0AD7BC0E +:102C5000B1B8B4B4BDA85443502F495020536F634A +:102C60006B6574210D0A000D0ABFAACABCC8CECE7E +:102C7000F1A3ACC9E8D6C341504E0D0A0041542B14 +:102C80005149435347503D312C312C22434D4E4541 +:102C900054222C2C2C310041542B51494353475082 +:102CA0003D312C312C22554E494E4554222C2C2C92 +:102CB00031000D0AC9E8D6C341504E204F4B0D0AD2 +:102CC000000D0AC9E8D6C341504E204552524F521A +:102CD0000D0A000D0AB5C8B4FDD3A6B4F0B3ACCA52 +:102CE000B1A3ACC9E8D6C341504EB4EDCEF30D0A42 +:102CF000000D0AB7B4BCA4BBEE0D0A000D0AB7B4B0 +:102D0000BCA4BBEE4F4B0D0A000D0ABDA8C1A2CE5C +:102D1000DECFDFC1B4C2B7204552524F520D0A0078 +:102D20000D0AD3A6B4F04F4BB3ACCAB1A3ACBDA847 +:102D3000C1A2CEDECFDFC1B4C2B7CAA7B0DC0D0AD4 +:102D4000000D0ABDA8C1A2CEDECFDFC1B4C2B70D4F +:102D50000A000D0ABDA8C1A2CEDECFDFC1B4C2B742 +:102D60004F4B0D0A000D0ABBF1B5C3B1BEB5D84932 +:102D7000500D0A0041542B51494143543F000D0A64 +:102D8000D2D1BBF1B5C34950B5D8D6B70D0A000DA5 +:102D90000ABBF1B5C3B1BEB5D84950CAA7B0DC2053 +:102DA0004552524F520D0A000D0AD3A6B4F04F4BB4 +:102DB000B3ACCAB1A3ACBBF1B5C3B1BEB5D8495031 +:102DC000CAA7B0DC0D0A000D0ABFAACABCC1B4BDB7 +:102DD000D3D4B6B6CBB7FECEF1C6F70D0A00415438 +:102DE0002B51494F50454E3D312C302C22544350ED +:102DF000222C223131322E37342E34312E323238D9 +:102E0000222C393935362C302C31000D0AC1ACBD9D +:102E1000D3B3C9B9A60D0A000D0AC1ACBDD3CAA768 +:102E2000B0DC0D0A000D0AC1ACBDD3B3ACCAB121F0 +:102E300021210D0A000D0A6E6574776F726B436F66 +:102E40006E6E656374696F6E436F756E74203D209E +:102E500025640D0A000D0AB4B4BDA8536F636B65F9 +:102E600074CAA7B0DCA3A10D0A000D0AB4B4BDA8B2 +:102E7000536F636B6574CAA7B0DCB4CECAFD203D46 +:102E80002025640D0A000D0AB4B4BDA8536F636B0E +:102E90006574B9FDB3CCB8B4CEBBA3A10D0A000DC7 +:102EA0000ACEB4D6AAD7B4CCACA3ACD6D8C6F4C498 +:102EB000A3BFE9A3A1A3A1A3A10D0A0041542B51D3 +:102EC0004953454E443D302C2564000D0AD3A6B429 +:102ED000F0203E204F4B0D0A000D0AD3A6B4F03E61 +:102EE000204552524F520D0A000D0AB7A2CBCD45D4 +:102EF00052524F52B4CECAFD203D2025640D0A0027 +:102F00000D0AC1ACBDD3D2D1BEADB9D8B1D5A3AC39 +:102F1000B7A2CBCDCAA7B0DC0D0A000D0AB3ACCA6C +:102F2000B1CEB4D3A6B4F03EC8A1CFFBB7A2CBCDEF +:102F30000D0A000D0AD5FDD4DAB7A2CBCDCAFDBE6D +:102F4000DD2E2E2E2E2E2E0D0A000D0AB7A2CBCD71 +:102F5000BCD3D4D8B3C9B9A6A3A10D0A000D0A45A4 +:102F60006E6454696D65203D2025640D0A000D0ACC +:102F7000B7A2CBCDBCD3D4D8CAA7B0DC0D0A000D04 +:102F80000AB7A2CBCDCAA7B0DCB4CECAFD203D2083 +:102F900025640D0A000D0AB3ACCAB1CAFDBEDDC975 +:102FA000D0CEB4B7A2B3F6A3ACB7A2CBCDCAA7B06C +:102FB000DC0D0A000D0ACAD5B5BD7365727665725F +:102FC000CAFDBEDDA3A10D0A000D0AB2E9D1AFCA48 +:102FD000FDBEDDCAC7B7F1D2D1B7A2CBCDB3C9B957 +:102FE000A6A3BF0D0A000D0AB3ACB3F6B7A2CBCDB2 +:102FF000CAB1BCE4CAFDBEDDC9D0CEB4C4DCB7A240 +:10300000B3F6A3A10D0A0041542B514953454E4438 +:103010003D302C30000D0A42797465733A20747883 +:10302000203D2025642C2061636B203D2025640D0C +:103030000A000D0ACAFDBEDDD2D1B3C9B9A6B7A236 +:10304000CBCDB5BDB6D4B7BDA3A10D0A000D0AB254 +:10305000E9D1AFCAFDBEDDB7A2CBCDB3ACCAB1A337 +:10306000A10D0A000D0ACAFDBEDDD2D1BEADB7A2C8 +:10307000CBCDA3ACB5ABC3BBD3D0CAD5B5BDBBD844 +:10308000B8B4A3A10D0A000D0AD0C5BAC5C7BFB612 +:10309000C8203D2025640D0A000D0ACAFDBEDDB71B +:1030A000A2CBCDCAA7B0DCB7B5BBD8A3A10D0A008F +:1030B0000D0A457863657074696F6E5FCEB4D6AAE9 +:1030C000D7B4CCACA3ACD6D8C6F4C4A3BFE9A3A1F3 +:1030D000A3A1A3A10D0A000D0ACAFDBEDDCAD5B782 +:1030E000A2B9FDB3CCB8B4CEBBA3A10D0A000D0AA2 +:1030F000B3F6CFD6D1CFD6D8B4EDCEF32D2D3ED664 +:10310000D8C6F4A3A10D0A000D0AB7A2CBCDCAA759 +:10311000B0DCB4CECAFDB3ACB3F6D4A4C9E8D6B51E +:103120002D2D3ED6D8C6F4A3A10D0A000D0AD4CB8E +:10313000D0D0B9FDB3CC4552524F52B4CECAFDB334 +:10314000ACB3F6D4A4C9E8D6B52D2D3ED6D8C6F476 +:10315000A3A10D0A000D0AC1ACBDD3D2D1B6CFBF19 +:10316000AAA3A10D0A002B51495552430072656371 +:1031700076002B51495552433A20227265637622DC +:10318000002C00636C6F73656400696E636F6D691A +:103190006E672066756C6C000D0AC1ACBDD3D2D1D0 +:1031A000C2FA555243A3A10D0A006E636F6D696E9A +:1031B00067000D0ABFCDBBA7B6CBC1ACBDD355527E +:1031C00043A3A10D0A007064706465616374000D0F +:1031D0000A504450C8A5BCA4BBEE555243A3A10D50 +:1031E0000A004552524F52002B434D452045525242 +:1031F0004F523A002B435245473A20302C35002B92 +:1032000043475245473A20302C35004348494E4108 +:10321000204D4F42494C450043484E2D554E4943A1 +:103220004F4D003E0053454E44204F4B0053454EFA +:1032300044204641494C00434C4F534544003133F0 +:103240003537393735333132343638363432000D8C +:103250000AC9FAB3C9BFA8BAC5CEAAA3BA000D0A53 +:103260004943BFA8BAC5A3BA000D0A4943BFA8D3B2 +:10327000D0D0A7A3ACD3C3BBA7BFA8A3A1A3A1A32E +:10328000A10D0A000D0A4943BFA8D3D0D0A7A3AC13 +:10329000CAD5D4CBBFA8A3A1A3A1A3A10D0A002581 +:1032A000303158000D0A6C656E203D2025640D0AF2 +:1032B000000D0A4943203D2025730D0A000D0AD256 +:1032C000F8D0D0BFA8D3C3BBA7A3A10D0A000D0A95 +:1032D000D0A3D1E9B4EDCEF3A3A10D0A000D0A49A4 +:1032E00043203D20257320206C656E203D20256401 +:1032F0000D0A000D0AD6D0C1AA4943BFA8A3ACD37A +:10330000C3BBA7BFA8A3A10D0A000D0AD4C1C4DC8A +:103310004943BFA8A3A10D0A000D0AD2F8D0D0BF1F +:10332000A8A3A10D0A000D0AD6D0C1AA4943BFA87F +:10333000A3A10D0A000D0ACEDED0A7BFA8A3A10D40 +:103340000A003D000D0A4C656E3A25642C2064612C +:1033500074613A25730D0A000D0A71724C656E2076 +:1033600025642C2025640D0A006465765365743A43 +:10337000000D0AB3ACB3F6B3A4B6C8A3A10D0A00FE +:103380000D0ACEDED0A7B6FECEACC2EBA3A1A3A1A0 +:10339000A3A10D0A000D0AC9E8D6C3B6FECEACC281 +:1033A000EBA3A10D0A000D0A64617461203D202584 +:1033B000730D0A000D0A646174614C656E203D2036 +:1033C00025640D0A0068747470733A2F2F7777772D +:1033D0002E7761737465726564756374696F6E2EA0 +:1033E000676F762E686B000D0ACFE3B8DBBFCDBBED +:1033F000A7B6FECEACC2EBA3A10D0A000D0AD6F70C +:10340000B0E5CEC2B6C8A3BA25322E316620A1E6F9 +:103410000D0A0020202020202020202020202020F5 +:103420002020200020202020C2CCC9ABC9FABBEE4E +:1034300020202020002D2DCFB5CDB3D5FDD4DAC668 +:10344000F4B6AF2D2D00CBDC00B2A300BDF000BF61 +:10345000C900B3F800C6BF00B5E700D6AF00CAE99F +:1034600000B1A800C6E400B8C900CAAA00253264A9 +:1034700000D6BDC0E000CBDCC1CF00B2A3C1A70025 +:10348000BDF0CAF400BFC9BBD800B3F8D3E000B5A3 +:10349000E7B3D800D6AFCEEF00CAE9B1BE00B1A8FD +:1034A000D6BD00C6E4CBFC00D3D0BAA600C0E0D0A5 +:1034B000CDA3BA25732573257300C0E0D0CDA3BA80 +:1034C000257325732573257300C9E8B1B8D0C5CF1E +:1034D000A200BBB6D3ADCAB9D3C30020202020C1FF +:1034E000ACBDD3D6D02020202020200020202020BA +:1034F000C1ACBDD3D6D02E202020202000202020FB +:1035000020C1ACBDD3D6D02E2E20202020002020DC +:103510002020C1ACBDD3D6D02E2E2E20202000BB23 +:10352000B6D3ADC4FAC9A8C2EBBBF2CBA2BFA80008 +:1035300020202020BFAAC3C5CDB6B7C5202020209B +:1035400000C2CCC9ABC9FABBEE002020C9E8B1B8B3 +:10355000D5FDD4DACEACBBA420200020202020D47E +:10356000DDCDA3CAB9D3C320202020002020D5FD63 +:10357000D4DABCD3D4D82E2E2E20202000BFA8BA57 +:10358000C5A3BA2A2A2A25732000D3E0B6EEA3BA2F +:10359000252E326600D5CBBAC5A3BA256400A3A8F0 +:1035A000C7EBD1A1CDB6B7C5C0E0D0CDA3A9000D62 +:1035B0000AD3E0B6EEB2BBD7E30D0A002020A3A8E1 +:1035C000D3E0B6EEB2BBD7E3A3A92020000D0ABF1B +:1035D000A8BAC5B1BBBDFBD3C30D0A002020A3A868 +:1035E000BFA8B1BBBDFBD3C3A3A92020000D0AC651 +:1035F000E4CBFBB4EDCEF30D0A002020A3A8494391 +:10360000BFA8CEDED0A7A3A92020000D0AC9EDB720 +:10361000DDCEDED0A70D0A002020A3A8C9EDB7DDBE +:10362000CEDED0A7A3A9202000CDB6B7C5CEDEB789 +:10363000A8BBF1B5C3BDB1C0F800202020202025D3 +:103640003364C3EBBAF3B9D8C3C5002020202020CF +:10365000202020D5FDD4DAB9D8C3C5002573A3BA7C +:1036600025322E3266204B6700BDB1C0F8A3BA25C3 +:103670002E326600A1EFB8D0D0BBC4FACEAAB5D81E +:10368000C7F2A1EF002020D4F6CCEDD2BBB7DDC34A +:10369000C0C0F6202000B9CAD5CFC2EBA3BA2533EB +:1036A000642025336400B9CAD5CFC2EBA3BA253351 +:1036B0006400C9E8B1B8B9CAD5CFD4DDCDA3CAB9C1 +:1036C000D3C300D0A3D7BCB3C6C5CCA3BA2564006E +:1036D0002D3ED5FDD4DABDF8C8EBD0A3D7BC002D64 +:1036E0003EC7EBB7C5C8EB31304B67EDC0C2EB004E +:1036F0002D3ED0A3D7BCCDEAB3C9A3A1000D0AC308 +:10370000BBD3D0B4CBCDA8B5C0B5E7B4C5CBF8A377 +:10371000A12D3E2025640D0A000D0AB5E7BBFAA3D2 +:10372000A82564A3A9D5FDD7AAA3A10D0A000D0A57 +:10373000B5E7BBFAA3A82564A3A9B7B4D7AAA3A1E8 +:103740000D0A000D0AB5E7BBFAA3A82564A3A9CD0D +:10375000A3D6B9A3A10D0A000D0AC3C531D2D1CD9C +:10376000EAB3C9B8B4CEBBA3A1A3A1A3A10D0A001B +:103770000D0A20B5E7BBFA31B8B4CEBBCEB4D6AA99 +:10378000D7B4CCACA3A1A3A1A3A10D0A000D0A2D0F +:103790002D3E20B5E7BBFA31B4F2BFAA210D0A00D5 +:1037A0000D0AC3C531B4F2BFAA0D0A000D0ABFAAA3 +:1037B000C3C5CFDECEBBBCECB2E2310D0A000D0AB0 +:1037C000CFDECEBBB3ACCAB1CDA3D6B9310D0A00A2 +:1037D0000D0AB5C8B4FDCDB6B7C5310D0A000D0A46 +:1037E00035B7D6D6D3B3ACCAB1D7D4B6AFB9D8C330 +:1037F000C5310D0A000D0AC3C531B9D8B1D5D6D02F +:103800000D0A000D0ACDB6BFDA31CFDECEBBBFAA9E +:10381000B9D8D3D0D2ECB3A3A3A10D0A000D0A4EA0 +:103820006F2E31204F4BA3A10D0A000D0A452D3EEE +:10383000BFAACBF8310D0A000D0A452D3EBFAAC321 +:10384000C5310D0A000D0A452D3EB9D8CBF8A3AC01 +:10385000C3C531CDA3D6B90D0A000D0A452D3EC30F +:10386000C531B8B4CEBB0D0A000D0AC3C532D2D1E2 +:10387000CDEAB3C9B8B4CEBBA3A1A3A1A3A10D0A3D +:10388000000D0A20B5E7BBFA32B8B4CEBBCEB4D631 +:10389000AAD7B4CCACA3A1A3A1A3A10D0A000D0A81 +:1038A0002D2D3E20B5E7BBFA32B4F2BFAA210D0A96 +:1038B000000D0AC3C532B4F2BFAA0D0A000D0ABF3B +:1038C000AAC3C5CFDECEBBBCECB2E2320D0A000DFE +:1038D0000ACFDECEBBB3ACCAB1CDA3D6B9320D0A86 +:1038E000000D0AB5C8B4FDCDB6B7C5320D0A000D3E +:1038F0000A35B7D6D6D3B3ACCAB1D7D4B6AFB9D8D8 +:10390000C3C5320D0A000D0AC3C532B9D8B1D5D628 +:10391000D00D0A000D0ACDB6BFDA32CFDECEBBBF66 +:10392000AAB9D8D3D0D2ECB3A3A3A10D0A000D0A33 +:103930004E6F2E32204F4BA3A10D0A000D0A452DCC +:103940003EBFAACBF8320D0A000D0A452D3EBFAA94 +:10395000C3C5320D0A000D0A452D3EB9D8CBF8A3D8 +:10396000ACC3C532CDA3D6B90D0A000D0A452D3E14 +:10397000C3C532B8B4CEBB0D0A000D0AC3C533D2DD +:10398000D1CDEAB3C9B8B4CEBBA3A1A3A1A3A10D65 +:103990000A000D0A20B5E7BBFA33B8B4CEBBCEB4EB +:1039A000D6AAD7B4CCACA3A1A3A1A3A10D0A000DA4 +:1039B0000A2D2D3E20B5E7BBFA33B4F2BFAA210D84 +:1039C0000A000D0AC3C533B4F2BFAA0D0A000D0ADE +:1039D000BFAAC3C5CFDECEBBBCECB2E2330D0A003A +:1039E0000D0ACFDECEBBB3ACCAB1CDA3D6B9330D71 +:1039F0000A000D0AB5C8B4FDCDB6B7C5330D0A002F +:103A00000D0A35B7D6D6D3B3ACCAB1D7D4B6AFB991 +:103A1000D8C3C5330D0A000D0AC3C533B9D8B1D513 +:103A2000D6D00D0A000D0A4E6F2E33204F4BA3A1A6 +:103A30000D0A000D0A452D3EBFAACBF8330D0A0032 +:103A40000D0A452D3EBFAAC3C5330D0A000D0A4518 +:103A50002D3EB9D8CBF8A3ACC3C533CDA3D6B90D91 +:103A60000A000D0A452D3EC3C533B8B4CEBB0D0ABE +:103A7000000D0AC3C534D2D1CDEAB3C9B8B4CEBBA8 +:103A8000A3A1A3A1A3A10D0A000D0A20B5E7BBFACB +:103A900034B8B4CEBBCEB4D6AAD7B4CCACA3A1A311 +:103AA000A1A3A10D0A000D0A2D2D3E20B5E7BBFAFA +:103AB00034B4F2BFAA210D0A000D0AC3C534B4F212 +:103AC000BFAA0D0A000D0ABFAAC3C5CFDECEBBBC7C +:103AD000ECB2E2340D0A000D0ACFDECEBBB3ACCAA5 +:103AE000B1CDA3D6B9340D0A000D0AB5C8B4FDCDC9 +:103AF000B6B7C5340D0A000D0A35B7D6D6D3B3AC68 +:103B0000CAB1D7D4B6AFB9D8C3C5340D0A000D0AAF +:103B1000C3C534B9D8B1D5D6D00D0A000D0A4E6F41 +:103B20002E34204F4BA3A10D0A000D0A452D3EBF98 +:103B3000AACBF8340D0A000D0A452D3EBFAAC3C515 +:103B4000340D0A000D0A452D3EB9D8CBF8A3ACC3FD +:103B5000C534CDA3D6B90D0A000D0A452D3EC3C507 +:103B600034B8B4CEBB0D0A000D0AD5FDD4DAB3F5D6 +:103B7000CABCBBAFC9E8B1B8CFB5CDB3B2CECAFDF0 +:103B8000A3A10D0A000D0A506172616D4174537456 +:103B9000617274203D2025640D0A000D0AC9E8B148 +:103BA000B8B3F5CABCBBAF2E2E2E2E2E2E0D0A009A +:103BB000B0E6B1BE3A2573000D0AC9E8B1B8B3F555 +:103BC000CABCBBAFCDEAB3C9A3A1A3A1A3A10D0AEF +:103BD000000D0AD3B2BCFEB2E2CAD4A3A10D0A0002 +:103BE0000D0AB2E2CAD4C5E7C1DCCFFBB6BEA3A1C1 +:103BF0000D0A000D0AB2E2CAD4C5E7C1DCC3F0BBAE +:103C0000F0A3A10D0A000D0AB2E2CAD45556CFFBAB +:103C1000B6BEA3A10D0A000D0AB2E2CAD4C5C5C63C +:103C2000F8C9C8A3A10D0A000D0AD3B2BCFEB2E2C6 +:103C3000CAD4BDE1CAF8A3A10D0A000D0ACBA2495E +:103C400043BFA80D0A000D0AC9A8B6FECEACC2EB50 +:103C50000D0A000D0A2D2D2D2D3E20D3D0BFAAC355 +:103C6000C5C7EBC7F3A3ACC9E8B1B8BECDD0F72048 +:103C70003C2D2D2D2D0D0A000D0AB5C8B4FDD3C362 +:103C8000BBA7CDB6B7C50D0A000D0ACDB6B7C5CADC +:103C9000B1BCE4B5BDCDCBB3F60D0A000D0A4F7033 +:103CA000656E446F6F72526571756573745461739C +:103CB0006BD1D3B3D9210D0A000D0A31BAC5B0B406 +:103CC000BCFCB0B4CFC20D0A000D0A31BAC5D2D1C6 +:103CD000C2FAA3A10D0A000D0A32BAC5B0B4BCFCE9 +:103CE000B0B4CFC20D0A000D0A32BAC5D2D1C2FAA1 +:103CF000A3A10D0A000D0A33BAC5B0B4BCFCB0B420 +:103D0000CFC20D0A000D0A33BAC5D2D1C2FAA3A19F +:103D10000D0A000D0A34BAC5B0B4BCFCB0B4CFC2B1 +:103D20000D0A000D0A34BAC5D2D1C2FAA3A10D0AF8 +:103D3000000D0AD3C3BBA7D2D1BEADCDB6B7C5CD9A +:103D4000EAB3C90D0A000D0A2D2D2D2D3E20D3D02A +:103D5000BFAAC3C5C7EBC7F30D0A000D0AC8A1B3BC +:103D6000F6BFAAC3C5C7B0B5C4D6D8C1BFA3BA00F1 +:103D70005731203D2025322E3266204B672C2057AC +:103D800032203D2025322E3266204B672C205733BF +:103D9000203D2025322E3266204B672C20573420C0 +:103DA0003D2025322E3266204B670D0A000D0A3564 +:103DB000B7D6D6D3B3ACCAB1D7D4B6AFB9D8C3C5CA +:103DC0000D0A000D0AD1D3B3D9B9D8C3C5310D0A34 +:103DD000000D0AD1D3B3D9B9D8C3C5320D0A000D2D +:103DE0000AD1D3B3D9B9D8C3C5330D0A000D0AD14E +:103DF000D3B3D9B9D8C3C5340D0A000D0AC8CBD284 +:103E0000D1BEADC0EBBFAA0D0A000D0AB9D8C3C51B +:103E10000D0A000D0AC9CFCEBBBBFAC7EBC7F3B979 +:103E2000D8B1D5CDB6BFDA0D0A000D0ABDE1CAF88A +:103E3000CDB6B7C5A3ACD5FDD4DAB9D8C3C50D0A84 +:103E4000000D0AB5C8B4FDB9D8C3C5CAB1BCE4B544 +:103E5000BD0D0A000D0ABCC6CBE3B1BEB4CECDB6D3 +:103E6000B7C5D6D8C1BF0D0A000D0AB3D331D6D815 +:103E7000C1BF3A2025322E3266204B67202D3E20CE +:103E800025322E3266204B670D0A000D0AB3D3325D +:103E9000D6D8C1BF3A2025322E3266204B67202D5E +:103EA0003E2025322E3266204B670D0A000D0AB3E4 +:103EB000D333D6D8C1BF3A2025322E3266204B6785 +:103EC000202D3E2025322E3266204B670D0A000D34 +:103ED0000AB3D334D6D8C1BF3A2025322E32662059 +:103EE0004B67202D3E2025322E3266204B670D0A6F +:103EF000000D0AD5FDD4DABBF1C8A1B2E2BEE0CA1A +:103F0000FDBEDD0D0A000D0AB6D4CAFDBEDDBDF84A +:103F1000D0D0BBE3D7DC0D0A000D0AB1EAD6BECD86 +:103F2000B6B7C5CAFDBEDDD2D1C9FAB3C9A3A10DCA +:103F30000A000D0A2D2D2D3E20CDB6B7C5BFD8D60F +:103F4000C6CDEAB3C9A3A10D0A000D0AB8F84D43C6 +:103F50005531B7A2CBCDCDB0D2D1C2FABDFBD6B9C7 +:103F6000BFAAC3C5D6B8C1EE0D0A000D0A2D2D2D6E +:103F70002D2D2D2D2D2D3E20BDE1CAF8CDB6B7C576 +:103F8000A3A1A3A1A3A10D0A000D0AB8F84D4355A2 +:103F900031B7A2CBCDC9E8B1B8B9CAD5CFD6B8C16F +:103FA000EE0D0A000D0A2D2D2D2D2D2D2D2D2D3E22 +:103FB00020B1BEB4CECDB6B7C5BDE1CAF8A3A1A3AA +:103FC000A1A3A10D0A000D0AB5B1C7B0D5FDD4DA81 +:103FD000CAD5D4CBA3ACB1A3B3D6D2BBB6CECAB1EB +:103FE000BCE4B2BBCFFBB6BEA3A10D0A000D0ACA4A +:103FF000D5D4CBB1A3B3D6CAB1BCE4B5BDA3A10D92 +:104000000A000D0AB4F2BFAACFE4CCE5C3C5A3A150 +:104010000D0A000D0AB4F2BFAAB2B9B9E2B5C6A33F +:10402000A10D0A000D0AB9D8B1D5B2B9B9E2B5C629 +:10403000A3A10D0A000D0ACEC2B6C8B9FDC8C8A317 +:10404000ACC6F4B6AFC9A2C8C8B7E7C9C8A3A10D2A +:104050000A000D0ACEC2B6C8BBD6B8B4D5FDB3A30C +:10406000A3A10D0A000D0AD1CCCEEDB4ABB8D0C6D9 +:10407000F7BCE0B2E2B5BDD2ECB3A3A3ACC6F4B6D4 +:10408000AFC5E7C1DCA3A10D0A000D0ACEC2B6C8B8 +:10409000B9FDC8C8283E3830B6C829A3ACC6F4B6A6 +:1040A000AFC5E7C1DCA3A10D0A000D0ACEC2B6C898 +:1040B000283C3735B6C829BBD6B8B4D5FDB3A3A3C1 +:1040C000A10D0A000D0AD1CCCEEDB4ABB8D0C6F725 +:1040D000BBD6B8B4D5FDB3A3A3A10D0A00BFC9BB1D +:1040E000D8CAD5CEEF00D0A1CBDCC1CFC6BFD7D3C5 +:1040F00000B4F3CBDCC1CFC6BFD7D300D2D7C0AD9D +:10410000B9DE00B3F8D3E03100B3F8D3E03200CB2E +:10411000DCC1CF3200B8C9C0ACBBF800CAAAC0AC81 +:10412000BBF800CEB4D6AA28256429000D0AC9E838 +:10413000B1B8D0C5CFA2A3BA0D0A00C8EDBCFE2508 +:10414000730D0A00C9E8B1B8C0E0D0CD3A20A1B0E3 +:10415000D2BBB7D6C0E0C9E8B1B8A1B1202800C928 +:10416000E8B1B8C0E0D0CD3A20A1B0C1BDB7D6C04B +:10417000E0C9E8B1B8A1B1202800A1A200C9E8B106 +:10418000B8C0E0D0CD3A20A1B0C1BDB7D6C0E0C91B +:10419000E8B1B85FBAACC6BFC0E0A1B1202800C981 +:1041A000E8B1B8C0E0D0CD3A20A1B0C8FDB7D6C0C4 +:1041B000E0C9E8B1B8A1B1202800C9E8B1B8C0E0B1 +:1041C000D0CD3A20A1B0CBC4B7D6C0E0C9E8B1B8D1 +:1041D000A1B12028002D2D2D2D2D2D2D2D2D2D2D56 +:1041E0002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2DFF +:1041F0000D0A000D0AC9E8B1B8C9E8D6C3B2CECAE3 +:10420000FDB3F5CABCBBAFCDEAB3C9A3A1A3A1A3BB +:10421000A10D0A000D0A536574506172616D3A0D6B +:104220000A00503D25643B2049443D25643B204421 +:104230006576547970653D25643B20436E743D2559 +:10424000640D0A0054313D25642C2068313D2564FD +:104250002C2048313D25642C2041313D25640D0A38 +:104260000054323D25642C2068323D25642C2048C2 +:10427000323D25642C2041323D25640D0A00543323 +:104280003D25642C2068333D25642C2048333D2592 +:10429000642C2041333D25640D0A0054343D2564CF +:1042A0002C2068343D25642C2048343D25642C2086 +:1042B00041343D25640D0A004943453D25642C20C9 +:1042C000494351523D25640D0A000D0A4465766943 +:1042D000636520506172616D20496E6974204F4B97 +:1042E000A3A1A3A1A3A10D0A000D0A4375725061F9 +:1042F00072616D3A0D0A0030313233343536373859 +:1043000039000D0AC4DAC8DDB8F1CABDB4EDCEF388 +:104310000D0A000D0A77726F6E6720666F726D610D +:1043200074A3A10D0A000D0AB7D6C0EBB2CECAFD28 +:10433000A3A10D0A000D0AB2CECAFDB7D6C0EBB3D9 +:10434000F6B4EDA3A1B3A4B6C8B9FDB3A40D0A0099 +:104350000D0A6C656E203D2025642C20646174611B +:104360004C6973743A207B0025732C20007D0D0A64 +:10437000000D0A636D64203D2025640D0A000D0ABE +:10438000D6B8C1EED3D0B1E4BBAFA3A10D0A000DE6 +:104390000AC3FCC1EEB4EDCEF30D0A000D0A73653D +:1043A00074436D64203D2025640D0A000D0A5345B9 +:1043B00054202D2D3E20B9DCC0EDC3DCC2EBC8B7C4 +:1043C000C8CFA3A10D0A000D0A6C6973745B315D3F +:1043D000A3BA25730D0A000D0AC3DCC2EBCEAAA353 +:1043E000BA25640D0A000D0AC8B7C8CFC3DCC2EBFA +:1043F000C4DAC8DDB8F1CABDB4EDCEF30D0A000DC4 +:104400000A534554202D2D3E20C3DCC2EBD0DEB82C +:10441000C4A3A10D0A000D0AC9E8D6C3C3DCC2EBD0 +:10442000C4DAC8DDB8F1CABDB4EDCEF30D0A000D93 +:104430000A534554202D2D3E20C9E8B1B8C0E0D024 +:10444000CDC9E8D6C3A3A10D0A000D0AC9E8B1B8C9 +:10445000C0E0D0CDCEAAA3BA25640D0A000D0A6C27 +:104460006973745B325DA3BA25730D0A000D0AC926 +:10447000E8D6C3C0E0D0CDC4DAC8DDB8F1CABDB457 +:10448000EDCEF30D0A000D0AC9E8B1B8CDB6BFDA1A +:10449000CDA8B5C0CAFDC1BFCEAAA3BA25640D0A76 +:1044A000000D0AC9E8B1B8CDB6BFDACDA8B5C0CA0B +:1044B000FDC1BFC4DAC8DDB8F1CABDB4EDCEF30D9D +:1044C0000A000D0ABBD8CAD5C0E0D0CD31A3BA25A9 +:1044D000640D0A000D0ABBD8CAD5C0E0D0CD32A306 +:1044E000BA25642C2025640D0A000D0ABBD8CAD554 +:1044F000C0E0D0CD33A3BA25642C2025642C202520 +:10450000640D0A000D0ABBD8CAD5C0E0D0CD34A3D3 +:10451000BA25642C2025642C2025642C2025640DCC +:104520000A000D0AC9E8D6C3BBD8CAD5C0E0D0CDB1 +:10453000C4DAC8DDB8F1CABDB4EDCEF30D0A000D82 +:104540000A534554202D2D3E20C9E8B1B8BFCDBB3C +:10455000A7BAC5C9E8D6C3A3A10D0A000D0ABFCDED +:10456000BBA7BAC5CEAAA3BA25640D0A000D0AC915 +:10457000E8D6C3BFCDBBA7BAC5C4DAC8DDB8F1CA97 +:10458000BDB4EDCEF30D0A000D0A534554202D2D78 +:104590003EA3A8BDFBD3C3B5C44943BFA8B2BBC4A7 +:1045A000DCBFAAC3C5A3A9B9A6C4DCC9E8D6C3A306 +:1045B000A10D0A000D0AD7B4CCACCEAAA3BA2564CB +:1045C0000D0A000D0AC9E8D6C3A3A8BDFBD3C3B525 +:1045D000C44943BFA8B2BBC4DCBFAAC3C5A3A9C416 +:1045E000DAC8DDB8F1CABDB4EDCEF30D0A000D0A8C +:1045F000534554202D2D3EA3A8CAD5D4CBB6FECE0C +:10460000ACC2EBBFAAC3C5A3A9B9A6C4DCC9E8D68E +:10461000C3A3A10D0A000D0AC9E8D6C3A3A8CAD531 +:10462000D4CBB6FECEACC2EBBFAAC3C5A3A9C4DA35 +:10463000C8DDB8F1CABDB4EDCEF30D0A000D0A53C2 +:104640004554202D2D3EA3A8C2FAD2E7B2CECAFD12 +:10465000A3A9B9A6C4DCC9E8D6C3A3A10D0A000D5D +:104660000A4F46313A2025642C2025642C202564ED +:104670000D0A000D0A4F46313A2025642C2025648E +:104680002C2025643B204F46323A2025642C2025DF +:10469000642C2025640D0A000D0A4F46313A20256E +:1046A000642C2025642C2025643B204F46323A2080 +:1046B00025642C2025642C2025643B204F46333A6A +:1046C0002025642C2025642C2025640D0A000D0A69 +:1046D0004F46313A2025642C2025642C2025643B4C +:1046E000204F46323A2025642C2025642C20256456 +:1046F0003B204F46333A2025642C2025642C20256E +:10470000643B204F46343A2025642C2025642C201D +:1047100025640D0A000D0AC9E8D6C3C2FAD2E7B271 +:10472000CECAFDC4DAC8DDB8F1CABDB4EDCEF30D12 +:104730000A000D0A534554202D2D3E20B3C6C5CC8A +:10474000D0A3D7BCA3A10D0A000D0AB3C6C5CCB136 +:10475000E0BAC5CEAAA3BA25640D0A000D0AD0A3FB +:10476000D7BCB3C6C5CCB2D9D7F7C4DAC8DDB8F167 +:10477000CABDB4EDCEF30D0A000D0A534554202DE9 +:104780002D3E20C1D9CAB1BFAAC3C5A3A10D0A003D +:104790000D0ABFAAC3C5B1E0BAC5CEAAA3BA2564A3 +:1047A0000D0A000D0AC1D9CAB1BFAAC3C5B2D9D773 +:1047B000F7C4DAC8DDB8F1CABDB4EDCEF30D0A0016 +:1047C0000D0A534554202D2D3E20C3DCC2EBC7BF3C +:1047D000D6C6D0DEB8C4A3A10D0A000D0AC7BFD645 +:1047E000C6C9E8D6C3C3DCC2EBC4DAC8DDB8F1CAB7 +:1047F000BDB4EDCEF30D0A000D0A534554202D2D06 +:104800003E20C9E8B1B8B2CECAFDBBD6B8B4B3F643 +:10481000B3A7C9E8D6C3A3A10D0A000D0AC3DCC221 +:10482000EBD0A3D1E9D5FDC8B7A3A10D0A000D0AAD +:10483000C3DCC2EBD0A3D1E9B4EDCEF3A3A10D0A42 +:10484000000D0AC3DCC2EBD0DEB8C4B3C9B9A6A35D +:10485000A10D0A000D0AB2CECAFDC9E8D6C3C3FC39 +:10486000C1EED3D0C7D0BBBBA3A1A3A10D0A000D3D +:104870000AC3DCC2EBC7BFD6C6D0DEB8C4B3C9B961 +:10488000A6A3A10D0A000D0AD2D1C8A1B5C3C0E0EC +:10489000D0CDA3ACB5C8B4FDC8B7C8CFC3DCC2EB9C +:1048A000A3A10D0A000D0ABFCDBBA7BAC5D0DEB8C3 +:1048B000C4B3C9B9A6A3A10D0A000D0AA1B0BDFBDE +:1048C000D3C3B5C44943BFA8B2BBC4DCBFAAC3C5E8 +:1048D000A1B1B9A6C4DCD0DEB8C4B3C9B9A6A3A13E +:1048E0000D0A000D0ACDA3D3C3A3A10D0A000D0A22 +:1048F000C6F4D3C3A3A10D0A000D0AA1B0CAD5D432 +:10490000CBB6FECEACC2EBBFAAC3C5A1B1B9A6C49B +:10491000DCD0DEB8C4B3C9B9A6A3A10D0A000D0A44 +:10492000BFAAC6F4B3C6C5CCD0A3D7BCA3A10D0AF9 +:10493000000D0AC8A1B5C3D0A3D7BCC1E3B5E3B38A +:10494000ACCAB1CDCBB3F6A3A10D0A000D0ACAD5EE +:10495000B5BDB3C631D0A3D7BCC1E3B5E3A3A10DA8 +:104960000A000D0ACAD5B5BDB3C632D0A3D7BCC1A3 +:10497000E3B5E3A3A10D0A000D0ACAD5B5BDB3C6C0 +:1049800031D0A3D7BCCDEAB3C9A3A10D0A000D0A4B +:10499000CAD5B5BDB3C632D0A3D7BCCDEAB3C9A37F +:1049A000A10D0A000D0AD7BCB1B8B4F2BFAACAD58E +:1049B000D4CBC3C5A3A10D0A000D0ABFAACABCBBB4 +:1049C000D6B8B4C9E8B1B8B2CECAFDA3A10D0A00E9 +:1049D0000D0ABDF8C8EBB2CECAFDC9E8D6C3B2D93C +:1049E000D7F72D2D2D2D3E0D0A000D0A434831D746 +:1049F000B0C2FA0D0A000D0A434831D2D1C7E5BF53 +:104A0000D50D0A000D0A6431203D2025642C20615B +:104A100031203D2025642C204131203D2025642576 +:104A2000250D0A000D0A434832D7B0C2FA0D0A001C +:104A30000D0A434832D2D1C7E5BFD50D0A000D0A91 +:104A40006432203D2025642C206132203D202564E5 +:104A50002C204132203D20256425250D0A000D0A19 +:104A60006433203D2025642C206133203D202564C3 +:104A70002C204133203D20256425250D0A000D0AF8 +:104A80006434203D2025642C206134203D202564A1 +:104A90002C204134203D20256425250D0A000D0AD7 +:104AA000CDA8B5C031A3BA6431203D2025642C20A7 +:104AB0006131203D2025642C204131203D2025649A +:104AC00025250D0A000D0ACDA8B5C032A3BA64325F +:104AD000203D2025642C206132203D2025642C209F +:104AE0004132203D20256425250D0A000D0ACDA860 +:104AF000B5C033A3BA6433203D2025642C20613334 +:104B0000203D2025642C204133203D20256425258F +:104B10000D0A000D0ACDA8B5C034A3BA6434203DF7 +:104B20002025642C206134203D2025642C20413434 +:104B3000203D20256425250D0A0041463A256400C4 +:104B400041373A25303564000D0ACDA3D6B9B2A558 +:104B5000B7C5A3A10D0A000D0A54696D6531203D4A +:104B60002025640D0A000D0A54696D6532203D2030 +:104B700025640D0A000D0A54696D6533203D20251A +:104B8000640D0A000D0A54696D6534203D202564CA +:104B90000D0A000D0AB2CECAFDB1A3B4E6B3C9B97D +:104BA000A6A3A10D0A000D0AB2CECAFDB6C1C8A1C6 +:104BB000B3C9B9A6A3A10D0A000D0A53657420500C +:104BC0003D25643B2049443D25643B205479706574 +:104BD0003D25643B20436E743D25643B2054313DAC +:104BE00025642C2068313D25642C2048313D256406 +:104BF0002C2041313D25643B2054323D25642C203E +:104C000068323D25642C2048323D25642C204132F9 +:104C10003D25642C204943453D25643B20494351B3 +:104C2000523D25643B206465764C656E3D25643BB2 +:104C30002064657649443D25733B2049503D2564F9 +:104C40002E25642E25642E25643A25640D0A000D58 +:104C50000ABBB9C3BBD3D0B1A3B4E6B9FDC9E8B1AF +:104C6000B8B2CECAFDA3A10D0A000D0AC9E8B1B8B9 +:104C7000C5E4D6C3B2CECAFDD2D1BBD6B8B4B3C98F +:104C8000B3F6B3A7C9E8D6C3A3A10D0A000D0A4D18 +:104C90002D3E53202D2D3E203078253032580D0AE0 +:104CA000000D0A4765742044313D25642C204432B0 +:104CB0003D25642C2044333D25642C2044343D257F +:104CC000640D0A000D0AC6F4B6AFCFFBB6BEB3FD45 +:104CD000B3F4A3A10D0A000D0ACDA3D6B9CFFBB63C +:104CE000BEB3FDB3F4A3A10D0A000D0AC6F4B6AF1E +:104CF000C5E7C1DCCFFBB6BEB3FDB3F4A3A10D0A7B +:104D0000000D0ACDA3D6B9C5E7C1DCCFFBB6BEB353 +:104D1000FDB3F4A3A10D0A00494E4600696E66007A +:104D20004E414E006E616E003031323334353637CD +:104D30003839414243444546003031323334353608 +:104D4000373839616263646566005245454E5420C8 +:104D50006D616C6C6F632073756363656564656416 +:104D6000002F566F6C756D65732F646174612F6AC7 +:104D7000656E6B696E732F776F726B7370616365AD +:104D80002F474E552D746F6F6C636861696E2F618C +:104D9000726D2D31352F7372632F6E65776C69627A +:104DA0002D63796777696E2F6E65776C69622F6CFA +:104DB0006962632F737472696E672F737472746F94 +:104DC0006B2E63002F566F6C756D65732F64617465 +:104DD000612F6A656E6B696E732F776F726B73707C +:104DE0006163652F474E552D746F6F6C6368616901 +:104DF0006E2F61726D2D31352F7372632F6E657753 +:104E00006C69622D63796777696E2F6E65776C695F +:104E1000622F6C6962632F74696D652F6C636C74AB +:104E2000696D652E63002573252E2A640025732580 +:104E3000302E2A64002B00252E32642F252E32645A +:104E40002F252E326400256C7500592D256D2D25DA +:104E500064002E2A7500252E336400252E3164004F +:104E6000256C6C6400252E32643A252E32643A2576 +:104E70002E32640025652D25622D2500252B30332B +:104E80006C64252E326C6400545A00474D54002542 +:104E900031315B2D2B302D39412D5A612D7A5D2515 +:104EA0006E002531315B412D5A612D7A5D256E00F2 +:104EB0004D256875256E2E256875256E2E2568751D +:104EC000256E002F256875256E3A256875256E3A82 +:104ED000256875256E004A616E00466562004D6169 +:104EE0007200417072004D6179004A756E004A751A +:104EF0006C0041756700536570004F6374004E6F1E +:104F00007600446563004A616E756172790046659A +:104F1000627275617279004D6172636800417072EE +:104F2000696C004A756E65004A756C790041756759 +:104F30007573740053657074656D626572004F63BC +:104F4000746F626572004E6F76656D6265720044C3 +:104F50006563656D6265720053756E004D6F6E001E +:104F600054756500576564005468750046726900A1 +:104F70005361740053756E646179004D6F6E6461A6 +:104F8000790054756573646179005765646E657363 +:104F9000646179005468757273646179004672695E +:104FA00064617900536174757264617900256D2FB5 +:104FB00025642F257900256120256220256520257F +:104FC000483A254D3A255320255900414D00504D72 +:104FD0000025612025622025652025483A254D3A87 +:104FE000255320255A202559006D640025493A256E +:104FF0004D3A2553202570002C2066756E63746928 +:105000006F6E3A2000617373657274696F6E20224F +:10501000257322206661696C65643A2066696C6557 +:1050200020222573222C206C696E6520256425734F +:1050300025730A00496E66696E697479004E614E87 +:10504000002F566F6C756D65732F646174612F6AE4 +:10505000656E6B696E732F776F726B7370616365CA +:105060002F474E552D746F6F6C636861696E2F61A9 +:10507000726D2D31352F7372632F6E65776C696297 +:105080002D63796777696E2F6E65776C69622F6C17 +:105090006962632F7374646C69622F64746F612E2C +:1050A000630042616C6C6F63207375636365656454 +:1050B000656400232D302B2000686C4C006566670A +:1050C000454647002F566F6C756D65732F6461748C +:1050D000612F6A656E6B696E732F776F726B737079 +:1050E0006163652F474E552D746F6F6C63686169FE +:1050F0006E2F61726D2D31352F7372632F6E657750 +:105100006C69622D63796777696E2F6E65776C695C +:10511000622F6C6962632F7374646C69622F6D70A7 +:105120007265632E6300504F534958002E00412D85 +:1051300046612D66383930313233343536375D00CB +:105140002B2D003030007858008090889800007C2B +:1051500000380010001000100010000000000000D7 +:105160000000000000000000000000000000007CC3 +:1051700000380010001000120012000000000000B3 +:105180000000000000000000000000000000007CA3 +:105190000038001000108012801280000000000013 +:1051A0000000000000000000000000000000007C83 +:1051B000003800102010A012A012A0000000000073 +:1051C0000000000000000000000000000000007C63 +:1051D000003808102810A812A812A800000000002B +:1051E0000000000000000000000000000000007C43 +:1051F000003811100A1084128A1291000000000079 +:105200000000000000000000000000000000007C22 +:10521000043804100410841280128400000000007E +:105220000000000000000000000000000000007C02 +:1052300074389411141114111011F40000000000BE +:105240000000000000000000000000000002040652 +:10525000080000000001020304010203040607081D +:1052600009000000000000001F0000003B000000DB +:105270005A0000007800000097000000B500000010 +:10528000D4000000F3000000110100003001000014 +:105290004E0100001F0000001C0000001F00000065 +:1052A0001E0000001F0000001E0000001F00000084 +:1052B0001F0000001E0000001F0000001E00000074 +:1052C0001F0000001F0000001C0000001F00000065 +:1052D0001E0000001F0000001E0000001F00000054 +:1052E0001F0000001E0000001F0000001E00000044 +:1052F0001F0000001F0000001D0000001F00000034 +:105300001E0000001F0000001E0000001F00000023 +:105310001F0000001E0000001F0000001E00000013 +:105320001F000000D64E0108DA4E0108DE4E0108CB +:10533000E24E0108E64E0108EA4E0108EE4E010871 +:10534000F24E0108F64E0108FA4E0108FE4E010821 +:10535000024F0108064F01080E4F0108174F0108C0 +:105360001D4F0108E64E0108234F0108284F010890 +:105370002D4F0108344F01083E4F0108464F0108E8 +:105380004F4F0108584F01085C4F0108604F01085A +:10539000644F0108684F01086C4F0108704F010805 +:1053A000744F01087B4F0108824F01088A4F0108A2 +:1053B000944F01089D4F0108A44F0108F5200108F2 +:1053C000AD4F0108B64F0108CB4F0108CE4F010881 +:1053D000D14F0108064F01080E4F0108174F010871 +:1053E0001D4F0108E64E0108234F0108284F010810 +:1053F0002D4F0108344F01083E4F0108464F010868 +:105400004F4F0108E94F0108EC4F0108EB2001085C +:10541000EB200108EB200108EB200108EB2001083C +:105420000020202020202020202028282828282074 +:10543000202020202020202020202020202020206C +:1054400020881010101010101010101010101010D4 +:1054500010040404040404040404041010101010C4 +:10546000101041414141414101010101010101018E +:1054700001010101010101010101010110101010E0 +:105480001010424242424242020202020202020260 +:1054900002020202020202020202020210101010B4 +:1054A00020000000000000000000000000000000DC +:1054B00000000000000000000000000000000000EC +:1054C00000000000000000000000000000000000DC +:1054D00000000000000000000000000000000000CC +:1054E00000000000000000000000000000000000BC +:1054F00000000000000000000000000000000000AC +:10550000000000000000000000000000000000009B +:10551000000000000000000000000000000000008B +:105520000000000005000000190000007D000000E0 +:105530000080E03779C34143176E05B5B5B893468F +:10554000F5F93FE9034F384D321D30F94877825A5B +:105550003CBF737FDD4F1575000000000000F03F79 +:10556000000000000000244000000000000059403E +:105570000000000000408F40000000000088C34091 +:1055800000000000006AF8400000000080842E4106 +:1055900000000000D01263410000000084D7974152 +:1055A0000000000065CDCD41000000205FA0024258 +:1055B000000000E876483742000000A2941A6D42CD +:1055C000000040E59C30A2420000901EC4BCD642C0 +:1055D00000003426F56B0C430080E03779C341436B +:1055E00000A0D8855734764300C84E676DC1AB43E1 +:1055F000003D9160E458E143408CB5781DAF1544FF +:1056000050EFE2D6E41A4B4492D54D06CFF08044D9 +:10561000F64AE1C7022DB544B49DD9794378EA44EE +:10562000405101084351010846510108F8B500BF37 +:10563000F8BC08BC9E467047F8B500BFF8BC08BC73 +:045640009E467047CB +:08564400B48AFF7F01000000A1 +:04564C0099010008B8 +:0456500071010008DC +:1056540000A24A0401015AA0645AA0645A9B645AE5 +:105664009B641E00B9E10100010305040405FFFF6A +:10567400FFFF010101415400000000000000000090 +:105684000000000000000000000000000000000016 +:105694000000000000000000000000000000000006 +:1056A40000000000000000000000000000000000F6 +:1056B40000000000004F4B0000000000000000004C +:1056C400000000004552524F52000000000000004C +:1056D400000000FF024154453000000000000000BB +:1056E40000000000000000000000000000000000B6 +:1056F40000000000000000000000000000000000A6 +:105704000000000000000000000000000000000095 +:1057140000000000004F4B000000000000000000EB +:10572400000000004552524F5200000000000000EB +:10573400000000FF0341542B4347534E0000000078 +:105744000000000000000000000000000000000055 +:105754000000000000000000000000000000000045 +:105764000000000000000000000000000000000035 +:1057740000000000004F4B0000000000000000008B +:10578400000000004552524F52000000000000008B +:10579400000000FF0441542B4350494E3F000000D9 +:1057A40000000000000000000000000000000000F5 +:1057B40000000000000000000000000000000000E5 +:1057C40000000000000000000000000000000000D5 +:1057D40000000000002B4350494E3A2052454144FA +:1057E400590000004552524F5200000000000000D2 +:1057F400000000FF0541542B51434349440000007D +:105804000000000000000000000000000000000094 +:105814000000000000000000000000000000000084 +:105824000000000000000000000000000000000074 +:1058340000000000002B51434349443A000000009B +:10584400000000004552524F5200000000000000CA +:10585400000000FF0641542B435351000000000098 +:105864000000000000000000000000000000000034 +:105874000000000000000000000000000000000024 +:105884000000000000000000000000000000000014 +:1058940000000000002B4353513A000000000000B8 +:1058A400000000004552524F52000000000000006A +:1058B400000000FF0741542B435245473F000000BE +:1058C40000000000000000000000000000000000D4 +:1058D40000000000000000000000000000000000C4 +:1058E40000000000000000000000000000000000B4 +:1058F40000000000002B435245473A20302C310071 +:10590400000000004552524F520000000000000009 +:10591400000000FF0841542B43475245473F000015 +:105924000000000000000000000000000000000073 +:105934000000000000000000000000000000000063 +:105944000000000000000000000000000000000053 +:1059540000000000002B43475245473A20302C31C9 +:10596400000000004552524F5200000000000000A9 +:10597400000000FF0941542B434F50533F000000E7 +:105984000000000000000000000000000000000013 +:105994000000000000000000000000000000000003 +:1059A40000000000000000000000000000000000F3 +:1059B40000000000004F4B00000000000000000049 +:1059C400000000004552524F520000000000000049 +:1059D400000000FF0A41542B5149435347503D31C5 +:1059E4002C312C22554E494E4554222C2C2C31005E +:1059F40000000000000000000000000000000000A3 +:105A04000000000000000000000000000000000092 +:105A140000000000004F4B000000000000000000E8 +:105A2400000000004552524F5200000000000000E8 +:105A3400000000FF0B41542B51494143543D3100B8 +:105A44000000000000000000000000000000000052 +:105A54000000000000000000000000000000000042 +:105A64000000000000000000000000000000000032 +:105A740000000000004F4B00000000000000000088 +:105A8400000000004552524F520000000000000088 +:105A9400000000FF0C41542B514944454143543DFF +:105AA40031000000000000000000000000000000C1 +:105AB40000000000000000000000000000000000E2 +:105AC40000000000000000000000000000000000D2 +:105AD40000000000004F4B00000000000000000028 +:105AE400000000004552524F520000000000000028 +:105AF400000000FF0D41542B51494143543F000025 +:105B04000000000000000000000000000000000091 +:105B14000000000000000000000000000000000081 +:105B24000000000000000000000000000000000071 +:105B340000000000004F4B000000000000000000C7 +:105B4400000000004552524F5200000000000000C7 +:105B5400000000FF0E41542B51494F50454E3D313A +:105B64002C302C22544350222C223131322E373403 +:105B74002E34312E323238222C393935362C302C11 +:105B840031000000000000000000000000000000E0 +:105B940000000000002B51494F50454E3A20302C54 +:105BA40030000000434F4E4E454354204641494C7B +:105BB400000000FF0F41542B5149434C4F53453DC6 +:105BC40030000000000000000000000000000000A1 +:105BD40000000000000000000000000000000000C1 +:105BE40000000000000000000000000000000000B1 +:105BF40000000000004F4B00000000000000000007 +:105C04000000000053454E44204641494C0000002A +:105C1400000000FF1041542B514953454E443D3080 +:105C24002C34000000000000000000000000000010 +:105C34000000000000000000000000000000000060 +:105C44000000000000000000000000000000000050 +:105C540000000000003E0000000000000000000002 +:105C64000000000053454E44204F4B00000000004C +:105C7400000000FF1141542B514953454E443D301F +:105C84002C300000000000000000000000000000B4 +:105C94000000000000000000000000000000000000 +:105CA40000000000000000000000000000000000F0 +:105CB40000000000002B514953454E443A000000B7 +:105CC400000000004552524F520000000000000046 +:105CD400000000FF1241542B514952443D302C31F5 +:105CE400353030000000000000000000000000001B +:105CF40000000000000000000000000000000000A0 +:105D0400000000000000000000000000000000008F +:105D140000000000002B514952443A0000000000EA +:105D2400000000004552524F5200000000000000E5 +:105D3400000000FF1341542B514E5450000000004A +:105D4400000000000000000000000000000000004F +:105D5400000000000000000000000000000000003F +:105D6400000000000000000000000000000000002F +:105D740000000000002B514E54503A000000000077 +:105D8400000000004552524F520000000000000085 +:105D9400000000FF1441542B43434C4B3F000000D0 +:105DA40000000000000000000000000000000000EF +:105DB40000000000000000000000000000000000DF +:105DC40000000000000000000000000000000000CF +:105DD40000000000002B43434C4B3A00000000003D +:105DE400000000002B434D45204552524F52000005 +:105DF400000000FF000000000000000000000000A0 +:105E0400000000000000000000000000000000008E +:105E1400000000000000000000000000000000007E +:105E2400000000000000000000000000000000006E +:105E3400000000000000000000000000000000005E +:105E4400000000000000000000000000000000004E +:105E5400000000000000000000000000000000003E +:105E6400000000000000000000000000000000002E +:105E7400000000000000000000000000000000001E +:105E8400000000000000000000000000000000000E +:105E940000000000000000000000000000000000FE +:105EA40000000000000000000000000000000000EE +:105EB40000000000000000000000000000000000DE +:105EC40000000000000000000000000000000000CE +:105ED40000000000000000000000000000000000BE +:105EE40000000000000000000000000000000000AE +:105EF400000000000000000000000000000000009E +:105F0400000000000000000000000000000000008D +:105F1400000000000000000000000000000000007D +:105F2400000000000000000000000000000000006D +:105F3400000000000000000000000000000000005D +:105F4400000000000000000000000000000000004D +:105F5400000000000000000000000000000000003D +:105F6400000000000000000000000000000000002D +:105F7400000000000000000000000000000000001D +:105F8400000000000000000000000000000000000D +:105F940000000000000000000000000000000000FD +:105FA40000000000000000000000000000000000ED +:105FB40000000000000000000000000000000000DD +:105FC40000000000000000000000000000000000CD +:105FD40000000000000000000000000000000000BD +:105FE40000000000000000000000000000000000AD +:105FF400000000000000000000000000000000009D +:10600400000000000000000000000000000000008C +:10601400000000000000000000000000000000007C +:10602400000000000000000000000000000000006C +:10603400000000000000000000000000000000005C +:10604400000000000000000000000000000000004C +:10605400000000000000000000000000000000003C +:10606400000000000000000000000000000000002C +:10607400000000000000000000000000000000001C +:10608400000000000000000000000000000000000C +:1060940000000000000000000000000000000000FC +:1060A40000000000000000000000000000000000EC +:1060B40000000000000000000000000000000000DC +:1060C40000000000000000000000000000000000CC +:1060D40000000000000000000000000000000000BC +:1060E40000000000000000000000000000000000AC +:1060F400000000000000000000000000000000009C +:10610400000000000000000000000000000000008B +:10611400000000000000000000000000000000007B +:10612400000000000000000000000000000000006B +:10613400000000000000000000000000000000005B +:10614400000000000000000000000000000000004B +:10615400000000000000000000000000000000003B +:10616400000000000000000000000000000000002B +:10617400000000000000000000000000000000001B +:10618400000000000000000000000000000000000B +:1061940000000000000000000000000000000000FB +:1061A40000000000000000000000000000000000EB +:1061B400000000000315C3207FFFFFFFFFFFFF0760 +:1061C40080696FFFFFFFFFFF0B0308C12003090075 +:1061D4001FFFFFFFFF00000000000000030000009D +:1061E400B01400208B4E01088B4E0108A00B002038 +:1061F40000000000B01400201815002080150020B5 +:10620400000000000000000000000000000000008A +:10621400000000000000000000000000000000007A +:10622400000000000000000000000000000000006A +:10623400000000000000000000000000000000005A +:1062440001000000000000004A00000000000000FF +:10625400000000000000000000000000000000003A +:10626400000000000000000000000000000000002A +:106274004A000000000000000000000000000000D0 +:10628400000000000000000000000000000000000A +:1062940000000000000000004300000000000000B7 +:1062A40000000000000000000000000000000000EA +:1062B4000000000000000000430000000000000097 +:1062C40000000000000000000000000000000000CA +:1062D4000000000000000000430000000000000077 +:1062E40000000000000000000000000000000000AA +:1062F4000000000000000000430000000000000057 +:106304000000000000000000000000000000000089 +:106314000000000000000000430000000000000036 +:106324000000000000000000000000000000000069 +:106334000000000000000000430000000000000016 +:106344000000000000000000000000000000000049 +:1063540000000000000000004300000000000000F6 +:106364000000000000000000000000000000000029 +:1063740000000000000000007B0D0108DD09010899 +:1063840000000000205401082C510108EB200108F2 +:10639400EB200108EB200108EB200108EB200108A9 +:1063A400EB200108EB200108EB200108EB20010899 +:1063B400FFFFFFFFFFFFFFFFFFFFFFFFFFFF0000E7 +:1063C400010041534349490000000000000000005F +:1063D40000000000000000000000000000000000B9 +:1063E4000000415343494900000000000000000040 +:1063F4000000000000000000000000000000000099 +:0864040000000000201600203A +:040000050800BB65CF +:00000001FF diff --git a/STM32_4路称重_Git提交精简工程/gcc_build/Makefile b/STM32_4路称重_Git提交精简工程/gcc_build/Makefile new file mode 100644 index 0000000..79b7d82 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/gcc_build/Makefile @@ -0,0 +1,76 @@ +PROJECT_XML := ../src/Project/Project.uvprojx +BUILD_DIR := build +TARGET := $(BUILD_DIR)/V2.1_260709_4CH + +CC := arm-none-eabi-gcc +OBJCOPY := arm-none-eabi-objcopy +SIZE := arm-none-eabi-size + +C_SOURCES := $(filter-out ../src/CMSIS/core_cm3.c,$(shell perl extract_sources.pl $(PROJECT_XML))) +S_SOURCES := startup_stm32f10x_hd_gcc.S +OBJECTS := $(patsubst ../src/%.c,$(BUILD_DIR)/%.o,$(C_SOURCES)) +OBJECTS += $(BUILD_DIR)/gcc_syscalls.o +OBJECTS += $(BUILD_DIR)/startup_stm32f10x_hd_gcc.o + +INCLUDES := \ + -I../src/USER -I../src/CORE -I../src/CMSIS \ + -I../src/SYSTEM/delay -I../src/SYSTEM/debug -I../src/SYSTEM/usart \ + -I../src/STM32F10x_FWLib/inc \ + -I../src/HARDWARE/LED -I../src/HARDWARE/KEY -I../src/HARDWARE/LCD \ + -I../src/HARDWARE/24CXX -I../src/HARDWARE/FLASH -I../src/HARDWARE/IIC \ + -I../src/HARDWARE/SPI -I../src/HARDWARE/BUZZER -I../src/HARDWARE/RFID \ + -I../src/HARDWARE/EXTI -I../src/HARDWARE/TIMER \ + -I../src/HARDWARE/UltrasonicWave -I../src/HARDWARE/USART \ + -I../src/HARDWARE/GPS -I../src/HARDWARE/GSM -I../src/HARDWARE/QR_Code \ + -I../src/HARDWARE/DEVICE -I../src/HARDWARE/NTC_ADC -I../src/HARDWARE/WDG \ + -I../src/HARDWARE/SCALE -I../src/HARDWARE/ElectronicLock \ + -I../src/HARDWARE/MOTOR -I../src/HARDWARE/AUDIO -I../src/HARDWARE/OPTO_SWITCH \ + -I../src/HARDWARE/IR_Distancer -I../src/HARDWARE/RS485 \ + -I../src/HARDWARE/STMFLASH -I../src/HARDWARE/Disinfection + +ARCH_FLAGS := -mcpu=cortex-m3 -mthumb +DEFINES := -DSTM32F10X_HD -DUSE_STDPERIPH_DRIVER -Dsignal=gsm_signal_strength +WARNINGS := -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable \ + -Wno-unused-but-set-variable -Wno-sign-compare -Wno-implicit-int \ + -Wno-unknown-pragmas -Wno-format +CFLAGS := $(ARCH_FLAGS) -std=gnu99 -Os -g3 -ffunction-sections -fdata-sections \ + -fcommon -fno-strict-aliasing -fno-builtin -include gcc_compat.h $(DEFINES) $(INCLUDES) $(WARNINGS) +ASFLAGS := $(ARCH_FLAGS) -x assembler-with-cpp -g3 +LDFLAGS := $(ARCH_FLAGS) -T stm32f103rc.ld -Wl,--gc-sections \ + -Wl,-Map=$(TARGET).map,--cref -Wl,--print-memory-usage \ + --specs=nano.specs --specs=nosys.specs -u _printf_float +LDLIBS := -Wl,--start-group -lc -lm -Wl,--end-group + +.PHONY: all clean verify + +all: $(TARGET).hex $(TARGET).bin + $(SIZE) $(TARGET).elf + +$(TARGET).elf: $(OBJECTS) stm32f103rc.ld | $(BUILD_DIR) + $(CC) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@ + +$(TARGET).hex: $(TARGET).elf + $(OBJCOPY) -O ihex $< $@ + +$(TARGET).bin: $(TARGET).elf + $(OBJCOPY) -O binary $< $@ + +$(BUILD_DIR)/%.o: ../src/%.c gcc_compat.h + @mkdir -p $(dir $@) + $(CC) $(CFLAGS) -MMD -MP -c $< -o $@ + +$(BUILD_DIR)/startup_stm32f10x_hd_gcc.o: startup_stm32f10x_hd_gcc.S + @mkdir -p $(dir $@) + $(CC) $(ASFLAGS) -c $< -o $@ + +$(BUILD_DIR)/gcc_syscalls.o: gcc_syscalls.c gcc_compat.h + @mkdir -p $(dir $@) + $(CC) $(CFLAGS) -MMD -MP -c $< -o $@ + +$(BUILD_DIR): + mkdir -p $@ + +clean: + rm -rf $(BUILD_DIR) + +-include $(OBJECTS:.o=.d) diff --git a/STM32_4路称重_Git提交精简工程/gcc_build/extract_sources.pl b/STM32_4路称重_Git提交精简工程/gcc_build/extract_sources.pl new file mode 100644 index 0000000..374c0f9 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/gcc_build/extract_sources.pl @@ -0,0 +1,13 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +my $project = shift @ARGV or die "usage: $0 Project.uvprojx\n"; +open my $fh, '<', $project or die "cannot open $project: $!\n"; +while (my $line = <$fh>) { + next unless $line =~ m{\.\.\\(.+\.c)}; + my $path = $1; + $path =~ s{\\}{/}g; + print "../src/$path "; +} +close $fh; diff --git a/STM32_4路称重_Git提交精简工程/gcc_build/gcc_compat.h b/STM32_4路称重_Git提交精简工程/gcc_build/gcc_compat.h new file mode 100644 index 0000000..8a15067 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/gcc_build/gcc_compat.h @@ -0,0 +1,12 @@ +#ifndef GCC_COMPAT_H +#define GCC_COMPAT_H + +#ifndef __align +#define __align(n) __attribute__((aligned(n))) +#endif + +#ifndef __packed +#define __packed __attribute__((packed)) +#endif + +#endif diff --git a/STM32_4路称重_Git提交精简工程/gcc_build/gcc_syscalls.c b/STM32_4路称重_Git提交精简工程/gcc_build/gcc_syscalls.c new file mode 100644 index 0000000..1b200d2 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/gcc_build/gcc_syscalls.c @@ -0,0 +1,17 @@ +#include "stm32f10x.h" + +int _write(int file, char *data, int length) +{ + int index; + + (void)file; + for (index = 0; index < length; ++index) + { + while (USART_GetFlagStatus(UART5, USART_FLAG_TC) == RESET) + { + } + USART_SendData(UART5, (uint8_t)data[index]); + } + + return length; +} diff --git a/STM32_4路称重_Git提交精简工程/gcc_build/startup_stm32f10x_hd_gcc.S b/STM32_4路称重_Git提交精简工程/gcc_build/startup_stm32f10x_hd_gcc.S new file mode 100644 index 0000000..d6eb084 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/gcc_build/startup_stm32f10x_hd_gcc.S @@ -0,0 +1,201 @@ +.syntax unified +.cpu cortex-m3 +.thumb + +.global g_pfnVectors +.global Reset_Handler +.extern SystemInit +.extern main +.extern __libc_init_array + +.section .isr_vector,"a",%progbits +.type g_pfnVectors, %object +g_pfnVectors: + .word _estack + .word Reset_Handler + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0, 0, 0, 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + .word WWDG_IRQHandler + .word PVD_IRQHandler + .word TAMPER_IRQHandler + .word RTC_IRQHandler + .word FLASH_IRQHandler + .word RCC_IRQHandler + .word EXTI0_IRQHandler + .word EXTI1_IRQHandler + .word EXTI2_IRQHandler + .word EXTI3_IRQHandler + .word EXTI4_IRQHandler + .word DMA1_Channel1_IRQHandler + .word DMA1_Channel2_IRQHandler + .word DMA1_Channel3_IRQHandler + .word DMA1_Channel4_IRQHandler + .word DMA1_Channel5_IRQHandler + .word DMA1_Channel6_IRQHandler + .word DMA1_Channel7_IRQHandler + .word ADC1_2_IRQHandler + .word USB_HP_CAN1_TX_IRQHandler + .word USB_LP_CAN1_RX0_IRQHandler + .word CAN1_RX1_IRQHandler + .word CAN1_SCE_IRQHandler + .word EXTI9_5_IRQHandler + .word TIM1_BRK_IRQHandler + .word TIM1_UP_IRQHandler + .word TIM1_TRG_COM_IRQHandler + .word TIM1_CC_IRQHandler + .word TIM2_IRQHandler + .word TIM3_IRQHandler + .word TIM4_IRQHandler + .word I2C1_EV_IRQHandler + .word I2C1_ER_IRQHandler + .word I2C2_EV_IRQHandler + .word I2C2_ER_IRQHandler + .word SPI1_IRQHandler + .word SPI2_IRQHandler + .word USART1_IRQHandler + .word USART2_IRQHandler + .word USART3_IRQHandler + .word EXTI15_10_IRQHandler + .word RTCAlarm_IRQHandler + .word USBWakeUp_IRQHandler + .word TIM8_BRK_IRQHandler + .word TIM8_UP_IRQHandler + .word TIM8_TRG_COM_IRQHandler + .word TIM8_CC_IRQHandler + .word ADC3_IRQHandler + .word FSMC_IRQHandler + .word SDIO_IRQHandler + .word TIM5_IRQHandler + .word SPI3_IRQHandler + .word UART4_IRQHandler + .word UART5_IRQHandler + .word TIM6_IRQHandler + .word TIM7_IRQHandler + .word DMA2_Channel1_IRQHandler + .word DMA2_Channel2_IRQHandler + .word DMA2_Channel3_IRQHandler + .word DMA2_Channel4_5_IRQHandler +.size g_pfnVectors, .-g_pfnVectors + +.section .text.Reset_Handler,"ax",%progbits +.thumb_func +Reset_Handler: + ldr r0, =_sidata + ldr r1, =_sdata + ldr r2, =_edata +1: + cmp r1, r2 + bcc 2f + b 3f +2: + ldr r3, [r0], #4 + str r3, [r1], #4 + b 1b +3: + ldr r1, =_sbss + ldr r2, =_ebss + movs r3, #0 +4: + cmp r1, r2 + bcc 5f + b 6f +5: + str r3, [r1], #4 + b 4b +6: + bl SystemInit + bl __libc_init_array + bl main +7: + b 7b + +.section .text.Default_Handler,"ax",%progbits +.thumb_func +Default_Handler: + b Default_Handler + +.macro weak_handler name + .weak \name + .thumb_set \name, Default_Handler +.endm + +weak_handler NMI_Handler +weak_handler HardFault_Handler +weak_handler MemManage_Handler +weak_handler BusFault_Handler +weak_handler UsageFault_Handler +weak_handler SVC_Handler +weak_handler DebugMon_Handler +weak_handler PendSV_Handler +weak_handler SysTick_Handler +weak_handler WWDG_IRQHandler +weak_handler PVD_IRQHandler +weak_handler TAMPER_IRQHandler +weak_handler RTC_IRQHandler +weak_handler FLASH_IRQHandler +weak_handler RCC_IRQHandler +weak_handler EXTI0_IRQHandler +weak_handler EXTI1_IRQHandler +weak_handler EXTI2_IRQHandler +weak_handler EXTI3_IRQHandler +weak_handler EXTI4_IRQHandler +weak_handler DMA1_Channel1_IRQHandler +weak_handler DMA1_Channel2_IRQHandler +weak_handler DMA1_Channel3_IRQHandler +weak_handler DMA1_Channel4_IRQHandler +weak_handler DMA1_Channel5_IRQHandler +weak_handler DMA1_Channel6_IRQHandler +weak_handler DMA1_Channel7_IRQHandler +weak_handler ADC1_2_IRQHandler +weak_handler USB_HP_CAN1_TX_IRQHandler +weak_handler USB_LP_CAN1_RX0_IRQHandler +weak_handler CAN1_RX1_IRQHandler +weak_handler CAN1_SCE_IRQHandler +weak_handler EXTI9_5_IRQHandler +weak_handler TIM1_BRK_IRQHandler +weak_handler TIM1_UP_IRQHandler +weak_handler TIM1_TRG_COM_IRQHandler +weak_handler TIM1_CC_IRQHandler +weak_handler TIM2_IRQHandler +weak_handler TIM3_IRQHandler +weak_handler TIM4_IRQHandler +weak_handler I2C1_EV_IRQHandler +weak_handler I2C1_ER_IRQHandler +weak_handler I2C2_EV_IRQHandler +weak_handler I2C2_ER_IRQHandler +weak_handler SPI1_IRQHandler +weak_handler SPI2_IRQHandler +weak_handler USART1_IRQHandler +weak_handler USART2_IRQHandler +weak_handler USART3_IRQHandler +weak_handler EXTI15_10_IRQHandler +weak_handler RTCAlarm_IRQHandler +weak_handler USBWakeUp_IRQHandler +weak_handler TIM8_BRK_IRQHandler +weak_handler TIM8_UP_IRQHandler +weak_handler TIM8_TRG_COM_IRQHandler +weak_handler TIM8_CC_IRQHandler +weak_handler ADC3_IRQHandler +weak_handler FSMC_IRQHandler +weak_handler SDIO_IRQHandler +weak_handler TIM5_IRQHandler +weak_handler SPI3_IRQHandler +weak_handler UART4_IRQHandler +weak_handler UART5_IRQHandler +weak_handler TIM6_IRQHandler +weak_handler TIM7_IRQHandler +weak_handler DMA2_Channel1_IRQHandler +weak_handler DMA2_Channel2_IRQHandler +weak_handler DMA2_Channel3_IRQHandler +weak_handler DMA2_Channel4_5_IRQHandler + +.section .note.GNU-stack,"",%progbits diff --git a/STM32_4路称重_Git提交精简工程/gcc_build/stm32f103rc.ld b/STM32_4路称重_Git提交精简工程/gcc_build/stm32f103rc.ld new file mode 100644 index 0000000..6c6f1bf --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/gcc_build/stm32f103rc.ld @@ -0,0 +1,95 @@ +ENTRY(Reset_Handler) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 256K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K +} + +_estack = ORIGIN(RAM) + LENGTH(RAM); +_Min_Heap_Size = 0x200; +_Min_Stack_Size = 0x400; + +SECTIONS +{ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) + . = ALIGN(4); + } > FLASH + + .text : + { + . = ALIGN(4); + *(.text .text.*) + *(.rodata .rodata.*) + KEEP(*(.init)) + KEEP(*(.fini)) + . = ALIGN(4); + _etext = .; + } > FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } > FLASH + .ARM.exidx : + { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } > FLASH + + .preinit_array : + { + PROVIDE_HIDDEN(__preinit_array_start = .); + KEEP(*(.preinit_array*)) + PROVIDE_HIDDEN(__preinit_array_end = .); + } > FLASH + .init_array : + { + PROVIDE_HIDDEN(__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array*)) + PROVIDE_HIDDEN(__init_array_end = .); + } > FLASH + .fini_array : + { + PROVIDE_HIDDEN(__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array*)) + PROVIDE_HIDDEN(__fini_array_end = .); + } > FLASH + + _sidata = LOADADDR(.data); + .data : + { + . = ALIGN(4); + _sdata = .; + *(.data .data.*) + . = ALIGN(4); + _edata = .; + } > RAM AT > FLASH + + .bss (NOLOAD) : + { + . = ALIGN(4); + _sbss = .; + __bss_start__ = _sbss; + *(.bss .bss.*) + *(COMMON) + . = ALIGN(4); + _ebss = .; + __bss_end__ = _ebss; + } > RAM + + ._user_heap_stack (NOLOAD) : + { + . = ALIGN(8); + PROVIDE(end = .); + PROVIDE(_end = .); + . += _Min_Heap_Size; + . += _Min_Stack_Size; + . = ALIGN(8); + } > RAM + + /DISCARD/ : { *(.note.GNU-stack) } +} diff --git a/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_cl.s b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_cl.s new file mode 100755 index 0000000..8196e69 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_cl.s @@ -0,0 +1,368 @@ +;******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** +;* File Name : startup_stm32f10x_cl.s +;* Author : MCD Application Team +;* Version : V3.5.0 +;* Date : 11-March-2011 +;* Description : STM32F10x Connectivity line devices vector table for MDK-ARM +;* toolchain. +;* This module performs: +;* - Set the initial SP +;* - Set the initial PC == Reset_Handler +;* - Set the vector table entries with the exceptions ISR address +;* - Configure the clock system +;* - Branches to __main in the C library (which eventually +;* calls main()). +;* After Reset the CortexM3 processor is in Thread mode, +;* priority is Privileged, and the Stack is set to Main. +;* <<< Use Configuration Wizard in Context Menu >>> +;******************************************************************************* +; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS +; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. +; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, +; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE +; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING +; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. +;******************************************************************************* + +; Amount of memory (in bytes) allocated for Stack +; Tailor this value to your application needs +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Stack_Size EQU 0x00000400 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD MemManage_Handler ; MPU Fault Handler + DCD BusFault_Handler ; Bus Fault Handler + DCD UsageFault_Handler ; Usage Fault Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall Handler + DCD DebugMon_Handler ; Debug Monitor Handler + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV Handler + DCD SysTick_Handler ; SysTick Handler + + ; External Interrupts + DCD WWDG_IRQHandler ; Window Watchdog + DCD PVD_IRQHandler ; PVD through EXTI Line detect + DCD TAMPER_IRQHandler ; Tamper + DCD RTC_IRQHandler ; RTC + DCD FLASH_IRQHandler ; Flash + DCD RCC_IRQHandler ; RCC + DCD EXTI0_IRQHandler ; EXTI Line 0 + DCD EXTI1_IRQHandler ; EXTI Line 1 + DCD EXTI2_IRQHandler ; EXTI Line 2 + DCD EXTI3_IRQHandler ; EXTI Line 3 + DCD EXTI4_IRQHandler ; EXTI Line 4 + DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 + DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 + DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 + DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 + DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 + DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 + DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 + DCD ADC1_2_IRQHandler ; ADC1 and ADC2 + DCD CAN1_TX_IRQHandler ; CAN1 TX + DCD CAN1_RX0_IRQHandler ; CAN1 RX0 + DCD CAN1_RX1_IRQHandler ; CAN1 RX1 + DCD CAN1_SCE_IRQHandler ; CAN1 SCE + DCD EXTI9_5_IRQHandler ; EXTI Line 9..5 + DCD TIM1_BRK_IRQHandler ; TIM1 Break + DCD TIM1_UP_IRQHandler ; TIM1 Update + DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation + DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare + DCD TIM2_IRQHandler ; TIM2 + DCD TIM3_IRQHandler ; TIM3 + DCD TIM4_IRQHandler ; TIM4 + DCD I2C1_EV_IRQHandler ; I2C1 Event + DCD I2C1_ER_IRQHandler ; I2C1 Error + DCD I2C2_EV_IRQHandler ; I2C2 Event + DCD I2C2_ER_IRQHandler ; I2C1 Error + DCD SPI1_IRQHandler ; SPI1 + DCD SPI2_IRQHandler ; SPI2 + DCD USART1_IRQHandler ; USART1 + DCD USART2_IRQHandler ; USART2 + DCD USART3_IRQHandler ; USART3 + DCD EXTI15_10_IRQHandler ; EXTI Line 15..10 + DCD RTCAlarm_IRQHandler ; RTC alarm through EXTI line + DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD TIM5_IRQHandler ; TIM5 + DCD SPI3_IRQHandler ; SPI3 + DCD UART4_IRQHandler ; UART4 + DCD UART5_IRQHandler ; UART5 + DCD TIM6_IRQHandler ; TIM6 + DCD TIM7_IRQHandler ; TIM7 + DCD DMA2_Channel1_IRQHandler ; DMA2 Channel1 + DCD DMA2_Channel2_IRQHandler ; DMA2 Channel2 + DCD DMA2_Channel3_IRQHandler ; DMA2 Channel3 + DCD DMA2_Channel4_IRQHandler ; DMA2 Channel4 + DCD DMA2_Channel5_IRQHandler ; DMA2 Channel5 + DCD ETH_IRQHandler ; Ethernet + DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line + DCD CAN2_TX_IRQHandler ; CAN2 TX + DCD CAN2_RX0_IRQHandler ; CAN2 RX0 + DCD CAN2_RX1_IRQHandler ; CAN2 RX1 + DCD CAN2_SCE_IRQHandler ; CAN2 SCE + DCD OTG_FS_IRQHandler ; USB OTG FS +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + +; Reset handler +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +MemManage_Handler\ + PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler\ + PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + + EXPORT WWDG_IRQHandler [WEAK] + EXPORT PVD_IRQHandler [WEAK] + EXPORT TAMPER_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT RCC_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT DMA1_Channel1_IRQHandler [WEAK] + EXPORT DMA1_Channel2_IRQHandler [WEAK] + EXPORT DMA1_Channel3_IRQHandler [WEAK] + EXPORT DMA1_Channel4_IRQHandler [WEAK] + EXPORT DMA1_Channel5_IRQHandler [WEAK] + EXPORT DMA1_Channel6_IRQHandler [WEAK] + EXPORT DMA1_Channel7_IRQHandler [WEAK] + EXPORT ADC1_2_IRQHandler [WEAK] + EXPORT CAN1_TX_IRQHandler [WEAK] + EXPORT CAN1_RX0_IRQHandler [WEAK] + EXPORT CAN1_RX1_IRQHandler [WEAK] + EXPORT CAN1_SCE_IRQHandler [WEAK] + EXPORT EXTI9_5_IRQHandler [WEAK] + EXPORT TIM1_BRK_IRQHandler [WEAK] + EXPORT TIM1_UP_IRQHandler [WEAK] + EXPORT TIM1_TRG_COM_IRQHandler [WEAK] + EXPORT TIM1_CC_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT TIM3_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT I2C1_EV_IRQHandler [WEAK] + EXPORT I2C1_ER_IRQHandler [WEAK] + EXPORT I2C2_EV_IRQHandler [WEAK] + EXPORT I2C2_ER_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT SPI2_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT USART2_IRQHandler [WEAK] + EXPORT USART3_IRQHandler [WEAK] + EXPORT EXTI15_10_IRQHandler [WEAK] + EXPORT RTCAlarm_IRQHandler [WEAK] + EXPORT OTG_FS_WKUP_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT SPI3_IRQHandler [WEAK] + EXPORT UART4_IRQHandler [WEAK] + EXPORT UART5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT TIM7_IRQHandler [WEAK] + EXPORT DMA2_Channel1_IRQHandler [WEAK] + EXPORT DMA2_Channel2_IRQHandler [WEAK] + EXPORT DMA2_Channel3_IRQHandler [WEAK] + EXPORT DMA2_Channel4_IRQHandler [WEAK] + EXPORT DMA2_Channel5_IRQHandler [WEAK] + EXPORT ETH_IRQHandler [WEAK] + EXPORT ETH_WKUP_IRQHandler [WEAK] + EXPORT CAN2_TX_IRQHandler [WEAK] + EXPORT CAN2_RX0_IRQHandler [WEAK] + EXPORT CAN2_RX1_IRQHandler [WEAK] + EXPORT CAN2_SCE_IRQHandler [WEAK] + EXPORT OTG_FS_IRQHandler [WEAK] + +WWDG_IRQHandler +PVD_IRQHandler +TAMPER_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +RCC_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +DMA1_Channel1_IRQHandler +DMA1_Channel2_IRQHandler +DMA1_Channel3_IRQHandler +DMA1_Channel4_IRQHandler +DMA1_Channel5_IRQHandler +DMA1_Channel6_IRQHandler +DMA1_Channel7_IRQHandler +ADC1_2_IRQHandler +CAN1_TX_IRQHandler +CAN1_RX0_IRQHandler +CAN1_RX1_IRQHandler +CAN1_SCE_IRQHandler +EXTI9_5_IRQHandler +TIM1_BRK_IRQHandler +TIM1_UP_IRQHandler +TIM1_TRG_COM_IRQHandler +TIM1_CC_IRQHandler +TIM2_IRQHandler +TIM3_IRQHandler +TIM4_IRQHandler +I2C1_EV_IRQHandler +I2C1_ER_IRQHandler +I2C2_EV_IRQHandler +I2C2_ER_IRQHandler +SPI1_IRQHandler +SPI2_IRQHandler +USART1_IRQHandler +USART2_IRQHandler +USART3_IRQHandler +EXTI15_10_IRQHandler +RTCAlarm_IRQHandler +OTG_FS_WKUP_IRQHandler +TIM5_IRQHandler +SPI3_IRQHandler +UART4_IRQHandler +UART5_IRQHandler +TIM6_IRQHandler +TIM7_IRQHandler +DMA2_Channel1_IRQHandler +DMA2_Channel2_IRQHandler +DMA2_Channel3_IRQHandler +DMA2_Channel4_IRQHandler +DMA2_Channel5_IRQHandler +ETH_IRQHandler +ETH_WKUP_IRQHandler +CAN2_TX_IRQHandler +CAN2_RX0_IRQHandler +CAN2_RX1_IRQHandler +CAN2_SCE_IRQHandler +OTG_FS_IRQHandler + + B . + + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap + +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, =(Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END + +;******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE***** diff --git a/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_hd.s b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_hd.s new file mode 100755 index 0000000..adc9b94 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_hd.s @@ -0,0 +1,358 @@ +;******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** +;* File Name : startup_stm32f10x_hd.s +;* Author : MCD Application Team +;* Version : V3.5.0 +;* Date : 11-March-2011 +;* Description : STM32F10x High Density Devices vector table for MDK-ARM +;* toolchain. +;* This module performs: +;* - Set the initial SP +;* - Set the initial PC == Reset_Handler +;* - Set the vector table entries with the exceptions ISR address +;* - Configure the clock system and also configure the external +;* SRAM mounted on STM3210E-EVAL board to be used as data +;* memory (optional, to be enabled by user) +;* - Branches to __main in the C library (which eventually +;* calls main()). +;* After Reset the CortexM3 processor is in Thread mode, +;* priority is Privileged, and the Stack is set to Main. +;* <<< Use Configuration Wizard in Context Menu >>> +;******************************************************************************* +; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS +; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. +; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, +; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE +; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING +; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. +;******************************************************************************* + +; Amount of memory (in bytes) allocated for Stack +; Tailor this value to your application needs +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Stack_Size EQU 0x00000400 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD MemManage_Handler ; MPU Fault Handler + DCD BusFault_Handler ; Bus Fault Handler + DCD UsageFault_Handler ; Usage Fault Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall Handler + DCD DebugMon_Handler ; Debug Monitor Handler + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV Handler + DCD SysTick_Handler ; SysTick Handler + + ; External Interrupts + DCD WWDG_IRQHandler ; Window Watchdog + DCD PVD_IRQHandler ; PVD through EXTI Line detect + DCD TAMPER_IRQHandler ; Tamper + DCD RTC_IRQHandler ; RTC + DCD FLASH_IRQHandler ; Flash + DCD RCC_IRQHandler ; RCC + DCD EXTI0_IRQHandler ; EXTI Line 0 + DCD EXTI1_IRQHandler ; EXTI Line 1 + DCD EXTI2_IRQHandler ; EXTI Line 2 + DCD EXTI3_IRQHandler ; EXTI Line 3 + DCD EXTI4_IRQHandler ; EXTI Line 4 + DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 + DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 + DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 + DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 + DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 + DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 + DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 + DCD ADC1_2_IRQHandler ; ADC1 & ADC2 + DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX + DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0 + DCD CAN1_RX1_IRQHandler ; CAN1 RX1 + DCD CAN1_SCE_IRQHandler ; CAN1 SCE + DCD EXTI9_5_IRQHandler ; EXTI Line 9..5 + DCD TIM1_BRK_IRQHandler ; TIM1 Break + DCD TIM1_UP_IRQHandler ; TIM1 Update + DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation + DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare + DCD TIM2_IRQHandler ; TIM2 + DCD TIM3_IRQHandler ; TIM3 + DCD TIM4_IRQHandler ; TIM4 + DCD I2C1_EV_IRQHandler ; I2C1 Event + DCD I2C1_ER_IRQHandler ; I2C1 Error + DCD I2C2_EV_IRQHandler ; I2C2 Event + DCD I2C2_ER_IRQHandler ; I2C2 Error + DCD SPI1_IRQHandler ; SPI1 + DCD SPI2_IRQHandler ; SPI2 + DCD USART1_IRQHandler ; USART1 + DCD USART2_IRQHandler ; USART2 + DCD USART3_IRQHandler ; USART3 + DCD EXTI15_10_IRQHandler ; EXTI Line 15..10 + DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line + DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend + DCD TIM8_BRK_IRQHandler ; TIM8 Break + DCD TIM8_UP_IRQHandler ; TIM8 Update + DCD TIM8_TRG_COM_IRQHandler ; TIM8 Trigger and Commutation + DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare + DCD ADC3_IRQHandler ; ADC3 + DCD FSMC_IRQHandler ; FSMC + DCD SDIO_IRQHandler ; SDIO + DCD TIM5_IRQHandler ; TIM5 + DCD SPI3_IRQHandler ; SPI3 + DCD UART4_IRQHandler ; UART4 + DCD UART5_IRQHandler ; UART5 + DCD TIM6_IRQHandler ; TIM6 + DCD TIM7_IRQHandler ; TIM7 + DCD DMA2_Channel1_IRQHandler ; DMA2 Channel1 + DCD DMA2_Channel2_IRQHandler ; DMA2 Channel2 + DCD DMA2_Channel3_IRQHandler ; DMA2 Channel3 + DCD DMA2_Channel4_5_IRQHandler ; DMA2 Channel4 & Channel5 +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + +; Reset handler +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT __main + IMPORT SystemInit + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +MemManage_Handler\ + PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler\ + PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + + EXPORT WWDG_IRQHandler [WEAK] + EXPORT PVD_IRQHandler [WEAK] + EXPORT TAMPER_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT RCC_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT DMA1_Channel1_IRQHandler [WEAK] + EXPORT DMA1_Channel2_IRQHandler [WEAK] + EXPORT DMA1_Channel3_IRQHandler [WEAK] + EXPORT DMA1_Channel4_IRQHandler [WEAK] + EXPORT DMA1_Channel5_IRQHandler [WEAK] + EXPORT DMA1_Channel6_IRQHandler [WEAK] + EXPORT DMA1_Channel7_IRQHandler [WEAK] + EXPORT ADC1_2_IRQHandler [WEAK] + EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK] + EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK] + EXPORT CAN1_RX1_IRQHandler [WEAK] + EXPORT CAN1_SCE_IRQHandler [WEAK] + EXPORT EXTI9_5_IRQHandler [WEAK] + EXPORT TIM1_BRK_IRQHandler [WEAK] + EXPORT TIM1_UP_IRQHandler [WEAK] + EXPORT TIM1_TRG_COM_IRQHandler [WEAK] + EXPORT TIM1_CC_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT TIM3_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT I2C1_EV_IRQHandler [WEAK] + EXPORT I2C1_ER_IRQHandler [WEAK] + EXPORT I2C2_EV_IRQHandler [WEAK] + EXPORT I2C2_ER_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT SPI2_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT USART2_IRQHandler [WEAK] + EXPORT USART3_IRQHandler [WEAK] + EXPORT EXTI15_10_IRQHandler [WEAK] + EXPORT RTCAlarm_IRQHandler [WEAK] + EXPORT USBWakeUp_IRQHandler [WEAK] + EXPORT TIM8_BRK_IRQHandler [WEAK] + EXPORT TIM8_UP_IRQHandler [WEAK] + EXPORT TIM8_TRG_COM_IRQHandler [WEAK] + EXPORT TIM8_CC_IRQHandler [WEAK] + EXPORT ADC3_IRQHandler [WEAK] + EXPORT FSMC_IRQHandler [WEAK] + EXPORT SDIO_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT SPI3_IRQHandler [WEAK] + EXPORT UART4_IRQHandler [WEAK] + EXPORT UART5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT TIM7_IRQHandler [WEAK] + EXPORT DMA2_Channel1_IRQHandler [WEAK] + EXPORT DMA2_Channel2_IRQHandler [WEAK] + EXPORT DMA2_Channel3_IRQHandler [WEAK] + EXPORT DMA2_Channel4_5_IRQHandler [WEAK] + +WWDG_IRQHandler +PVD_IRQHandler +TAMPER_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +RCC_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +DMA1_Channel1_IRQHandler +DMA1_Channel2_IRQHandler +DMA1_Channel3_IRQHandler +DMA1_Channel4_IRQHandler +DMA1_Channel5_IRQHandler +DMA1_Channel6_IRQHandler +DMA1_Channel7_IRQHandler +ADC1_2_IRQHandler +USB_HP_CAN1_TX_IRQHandler +USB_LP_CAN1_RX0_IRQHandler +CAN1_RX1_IRQHandler +CAN1_SCE_IRQHandler +EXTI9_5_IRQHandler +TIM1_BRK_IRQHandler +TIM1_UP_IRQHandler +TIM1_TRG_COM_IRQHandler +TIM1_CC_IRQHandler +TIM2_IRQHandler +TIM3_IRQHandler +TIM4_IRQHandler +I2C1_EV_IRQHandler +I2C1_ER_IRQHandler +I2C2_EV_IRQHandler +I2C2_ER_IRQHandler +SPI1_IRQHandler +SPI2_IRQHandler +USART1_IRQHandler +USART2_IRQHandler +USART3_IRQHandler +EXTI15_10_IRQHandler +RTCAlarm_IRQHandler +USBWakeUp_IRQHandler +TIM8_BRK_IRQHandler +TIM8_UP_IRQHandler +TIM8_TRG_COM_IRQHandler +TIM8_CC_IRQHandler +ADC3_IRQHandler +FSMC_IRQHandler +SDIO_IRQHandler +TIM5_IRQHandler +SPI3_IRQHandler +UART4_IRQHandler +UART5_IRQHandler +TIM6_IRQHandler +TIM7_IRQHandler +DMA2_Channel1_IRQHandler +DMA2_Channel2_IRQHandler +DMA2_Channel3_IRQHandler +DMA2_Channel4_5_IRQHandler + B . + + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap + +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, =(Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END + +;******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE***** diff --git a/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_hd_vl.s b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_hd_vl.s new file mode 100755 index 0000000..d6082b0 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_hd_vl.s @@ -0,0 +1,346 @@ +;******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** +;* File Name : startup_stm32f10x_hd_vl.s +;* Author : MCD Application Team +;* Version : V3.5.0 +;* Date : 11-March-2011 +;* Description : STM32F10x High Density Value Line Devices vector table +;* for MDK-ARM toolchain. +;* This module performs: +;* - Set the initial SP +;* - Set the initial PC == Reset_Handler +;* - Set the vector table entries with the exceptions ISR address +;* - Configure the clock system and also configure the external +;* SRAM mounted on STM32100E-EVAL board to be used as data +;* memory (optional, to be enabled by user) +;* - Branches to __main in the C library (which eventually +;* calls main()). +;* After Reset the CortexM3 processor is in Thread mode, +;* priority is Privileged, and the Stack is set to Main. +;* <<< Use Configuration Wizard in Context Menu >>> +;******************************************************************************* +; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS +; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. +; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, +; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE +; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING +; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. +;******************************************************************************* + +; Amount of memory (in bytes) allocated for Stack +; Tailor this value to your application needs +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Stack_Size EQU 0x00000400 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD MemManage_Handler ; MPU Fault Handler + DCD BusFault_Handler ; Bus Fault Handler + DCD UsageFault_Handler ; Usage Fault Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall Handler + DCD DebugMon_Handler ; Debug Monitor Handler + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV Handler + DCD SysTick_Handler ; SysTick Handler + + ; External Interrupts + DCD WWDG_IRQHandler ; Window Watchdog + DCD PVD_IRQHandler ; PVD through EXTI Line detect + DCD TAMPER_IRQHandler ; Tamper + DCD RTC_IRQHandler ; RTC + DCD FLASH_IRQHandler ; Flash + DCD RCC_IRQHandler ; RCC + DCD EXTI0_IRQHandler ; EXTI Line 0 + DCD EXTI1_IRQHandler ; EXTI Line 1 + DCD EXTI2_IRQHandler ; EXTI Line 2 + DCD EXTI3_IRQHandler ; EXTI Line 3 + DCD EXTI4_IRQHandler ; EXTI Line 4 + DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 + DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 + DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 + DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 + DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 + DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 + DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 + DCD ADC1_IRQHandler ; ADC1 + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD EXTI9_5_IRQHandler ; EXTI Line 9..5 + DCD TIM1_BRK_TIM15_IRQHandler ; TIM1 Break and TIM15 + DCD TIM1_UP_TIM16_IRQHandler ; TIM1 Update and TIM16 + DCD TIM1_TRG_COM_TIM17_IRQHandler ; TIM1 Trigger and Commutation and TIM17 + DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare + DCD TIM2_IRQHandler ; TIM2 + DCD TIM3_IRQHandler ; TIM3 + DCD TIM4_IRQHandler ; TIM4 + DCD I2C1_EV_IRQHandler ; I2C1 Event + DCD I2C1_ER_IRQHandler ; I2C1 Error + DCD I2C2_EV_IRQHandler ; I2C2 Event + DCD I2C2_ER_IRQHandler ; I2C2 Error + DCD SPI1_IRQHandler ; SPI1 + DCD SPI2_IRQHandler ; SPI2 + DCD USART1_IRQHandler ; USART1 + DCD USART2_IRQHandler ; USART2 + DCD USART3_IRQHandler ; USART3 + DCD EXTI15_10_IRQHandler ; EXTI Line 15..10 + DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line + DCD CEC_IRQHandler ; HDMI-CEC + DCD TIM12_IRQHandler ; TIM12 + DCD TIM13_IRQHandler ; TIM13 + DCD TIM14_IRQHandler ; TIM14 + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD TIM5_IRQHandler ; TIM5 + DCD SPI3_IRQHandler ; SPI3 + DCD UART4_IRQHandler ; UART4 + DCD UART5_IRQHandler ; UART5 + DCD TIM6_DAC_IRQHandler ; TIM6 and DAC underrun + DCD TIM7_IRQHandler ; TIM7 + DCD DMA2_Channel1_IRQHandler ; DMA2 Channel1 + DCD DMA2_Channel2_IRQHandler ; DMA2 Channel2 + DCD DMA2_Channel3_IRQHandler ; DMA2 Channel3 + DCD DMA2_Channel4_5_IRQHandler ; DMA2 Channel4 & Channel5 + DCD DMA2_Channel5_IRQHandler ; DMA2 Channel5 +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + +; Reset handler +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT __main + IMPORT SystemInit + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +MemManage_Handler\ + PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler\ + PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + + EXPORT WWDG_IRQHandler [WEAK] + EXPORT PVD_IRQHandler [WEAK] + EXPORT TAMPER_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT RCC_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT DMA1_Channel1_IRQHandler [WEAK] + EXPORT DMA1_Channel2_IRQHandler [WEAK] + EXPORT DMA1_Channel3_IRQHandler [WEAK] + EXPORT DMA1_Channel4_IRQHandler [WEAK] + EXPORT DMA1_Channel5_IRQHandler [WEAK] + EXPORT DMA1_Channel6_IRQHandler [WEAK] + EXPORT DMA1_Channel7_IRQHandler [WEAK] + EXPORT ADC1_IRQHandler [WEAK] + EXPORT EXTI9_5_IRQHandler [WEAK] + EXPORT TIM1_BRK_TIM15_IRQHandler [WEAK] + EXPORT TIM1_UP_TIM16_IRQHandler [WEAK] + EXPORT TIM1_TRG_COM_TIM17_IRQHandler [WEAK] + EXPORT TIM1_CC_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT TIM3_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT I2C1_EV_IRQHandler [WEAK] + EXPORT I2C1_ER_IRQHandler [WEAK] + EXPORT I2C2_EV_IRQHandler [WEAK] + EXPORT I2C2_ER_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT SPI2_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT USART2_IRQHandler [WEAK] + EXPORT USART3_IRQHandler [WEAK] + EXPORT EXTI15_10_IRQHandler [WEAK] + EXPORT RTCAlarm_IRQHandler [WEAK] + EXPORT CEC_IRQHandler [WEAK] + EXPORT TIM12_IRQHandler [WEAK] + EXPORT TIM13_IRQHandler [WEAK] + EXPORT TIM14_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT SPI3_IRQHandler [WEAK] + EXPORT UART4_IRQHandler [WEAK] + EXPORT UART5_IRQHandler [WEAK] + EXPORT TIM6_DAC_IRQHandler [WEAK] + EXPORT TIM7_IRQHandler [WEAK] + EXPORT DMA2_Channel1_IRQHandler [WEAK] + EXPORT DMA2_Channel2_IRQHandler [WEAK] + EXPORT DMA2_Channel3_IRQHandler [WEAK] + EXPORT DMA2_Channel4_5_IRQHandler [WEAK] + EXPORT DMA2_Channel5_IRQHandler [WEAK] + +WWDG_IRQHandler +PVD_IRQHandler +TAMPER_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +RCC_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +DMA1_Channel1_IRQHandler +DMA1_Channel2_IRQHandler +DMA1_Channel3_IRQHandler +DMA1_Channel4_IRQHandler +DMA1_Channel5_IRQHandler +DMA1_Channel6_IRQHandler +DMA1_Channel7_IRQHandler +ADC1_IRQHandler +EXTI9_5_IRQHandler +TIM1_BRK_TIM15_IRQHandler +TIM1_UP_TIM16_IRQHandler +TIM1_TRG_COM_TIM17_IRQHandler +TIM1_CC_IRQHandler +TIM2_IRQHandler +TIM3_IRQHandler +TIM4_IRQHandler +I2C1_EV_IRQHandler +I2C1_ER_IRQHandler +I2C2_EV_IRQHandler +I2C2_ER_IRQHandler +SPI1_IRQHandler +SPI2_IRQHandler +USART1_IRQHandler +USART2_IRQHandler +USART3_IRQHandler +EXTI15_10_IRQHandler +RTCAlarm_IRQHandler +CEC_IRQHandler +TIM12_IRQHandler +TIM13_IRQHandler +TIM14_IRQHandler +TIM5_IRQHandler +SPI3_IRQHandler +UART4_IRQHandler +UART5_IRQHandler +TIM6_DAC_IRQHandler +TIM7_IRQHandler +DMA2_Channel1_IRQHandler +DMA2_Channel2_IRQHandler +DMA2_Channel3_IRQHandler +DMA2_Channel4_5_IRQHandler +DMA2_Channel5_IRQHandler + B . + + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap + +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, =(Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END + +;******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE***** diff --git a/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_ld.s b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_ld.s new file mode 100755 index 0000000..3f3ac2f --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_ld.s @@ -0,0 +1,297 @@ +;******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** +;* File Name : startup_stm32f10x_ld.s +;* Author : MCD Application Team +;* Version : V3.5.0 +;* Date : 11-March-2011 +;* Description : STM32F10x Low Density Devices vector table for MDK-ARM +;* toolchain. +;* This module performs: +;* - Set the initial SP +;* - Set the initial PC == Reset_Handler +;* - Set the vector table entries with the exceptions ISR address +;* - Configure the clock system +;* - Branches to __main in the C library (which eventually +;* calls main()). +;* After Reset the CortexM3 processor is in Thread mode, +;* priority is Privileged, and the Stack is set to Main. +;* <<< Use Configuration Wizard in Context Menu >>> +;******************************************************************************* +; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS +; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. +; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, +; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE +; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING +; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. +;******************************************************************************* + +; Amount of memory (in bytes) allocated for Stack +; Tailor this value to your application needs +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Stack_Size EQU 0x00000400 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD MemManage_Handler ; MPU Fault Handler + DCD BusFault_Handler ; Bus Fault Handler + DCD UsageFault_Handler ; Usage Fault Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall Handler + DCD DebugMon_Handler ; Debug Monitor Handler + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV Handler + DCD SysTick_Handler ; SysTick Handler + + ; External Interrupts + DCD WWDG_IRQHandler ; Window Watchdog + DCD PVD_IRQHandler ; PVD through EXTI Line detect + DCD TAMPER_IRQHandler ; Tamper + DCD RTC_IRQHandler ; RTC + DCD FLASH_IRQHandler ; Flash + DCD RCC_IRQHandler ; RCC + DCD EXTI0_IRQHandler ; EXTI Line 0 + DCD EXTI1_IRQHandler ; EXTI Line 1 + DCD EXTI2_IRQHandler ; EXTI Line 2 + DCD EXTI3_IRQHandler ; EXTI Line 3 + DCD EXTI4_IRQHandler ; EXTI Line 4 + DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 + DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 + DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 + DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 + DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 + DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 + DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 + DCD ADC1_2_IRQHandler ; ADC1_2 + DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX + DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0 + DCD CAN1_RX1_IRQHandler ; CAN1 RX1 + DCD CAN1_SCE_IRQHandler ; CAN1 SCE + DCD EXTI9_5_IRQHandler ; EXTI Line 9..5 + DCD TIM1_BRK_IRQHandler ; TIM1 Break + DCD TIM1_UP_IRQHandler ; TIM1 Update + DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation + DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare + DCD TIM2_IRQHandler ; TIM2 + DCD TIM3_IRQHandler ; TIM3 + DCD 0 ; Reserved + DCD I2C1_EV_IRQHandler ; I2C1 Event + DCD I2C1_ER_IRQHandler ; I2C1 Error + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SPI1_IRQHandler ; SPI1 + DCD 0 ; Reserved + DCD USART1_IRQHandler ; USART1 + DCD USART2_IRQHandler ; USART2 + DCD 0 ; Reserved + DCD EXTI15_10_IRQHandler ; EXTI Line 15..10 + DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line + DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + +; Reset handler routine +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT __main + IMPORT SystemInit + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +MemManage_Handler\ + PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler\ + PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + + EXPORT WWDG_IRQHandler [WEAK] + EXPORT PVD_IRQHandler [WEAK] + EXPORT TAMPER_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT RCC_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT DMA1_Channel1_IRQHandler [WEAK] + EXPORT DMA1_Channel2_IRQHandler [WEAK] + EXPORT DMA1_Channel3_IRQHandler [WEAK] + EXPORT DMA1_Channel4_IRQHandler [WEAK] + EXPORT DMA1_Channel5_IRQHandler [WEAK] + EXPORT DMA1_Channel6_IRQHandler [WEAK] + EXPORT DMA1_Channel7_IRQHandler [WEAK] + EXPORT ADC1_2_IRQHandler [WEAK] + EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK] + EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK] + EXPORT CAN1_RX1_IRQHandler [WEAK] + EXPORT CAN1_SCE_IRQHandler [WEAK] + EXPORT EXTI9_5_IRQHandler [WEAK] + EXPORT TIM1_BRK_IRQHandler [WEAK] + EXPORT TIM1_UP_IRQHandler [WEAK] + EXPORT TIM1_TRG_COM_IRQHandler [WEAK] + EXPORT TIM1_CC_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT TIM3_IRQHandler [WEAK] + EXPORT I2C1_EV_IRQHandler [WEAK] + EXPORT I2C1_ER_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT USART2_IRQHandler [WEAK] + EXPORT EXTI15_10_IRQHandler [WEAK] + EXPORT RTCAlarm_IRQHandler [WEAK] + EXPORT USBWakeUp_IRQHandler [WEAK] + +WWDG_IRQHandler +PVD_IRQHandler +TAMPER_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +RCC_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +DMA1_Channel1_IRQHandler +DMA1_Channel2_IRQHandler +DMA1_Channel3_IRQHandler +DMA1_Channel4_IRQHandler +DMA1_Channel5_IRQHandler +DMA1_Channel6_IRQHandler +DMA1_Channel7_IRQHandler +ADC1_2_IRQHandler +USB_HP_CAN1_TX_IRQHandler +USB_LP_CAN1_RX0_IRQHandler +CAN1_RX1_IRQHandler +CAN1_SCE_IRQHandler +EXTI9_5_IRQHandler +TIM1_BRK_IRQHandler +TIM1_UP_IRQHandler +TIM1_TRG_COM_IRQHandler +TIM1_CC_IRQHandler +TIM2_IRQHandler +TIM3_IRQHandler +I2C1_EV_IRQHandler +I2C1_ER_IRQHandler +SPI1_IRQHandler +USART1_IRQHandler +USART2_IRQHandler +EXTI15_10_IRQHandler +RTCAlarm_IRQHandler +USBWakeUp_IRQHandler + + B . + + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap + +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, =(Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END + +;******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE***** diff --git a/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_ld_vl.s b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_ld_vl.s new file mode 100755 index 0000000..fe22fc0 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_ld_vl.s @@ -0,0 +1,304 @@ +;******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** +;* File Name : startup_stm32f10x_ld_vl.s +;* Author : MCD Application Team +;* Version : V3.5.0 +;* Date : 11-March-2011 +;* Description : STM32F10x Low Density Value Line Devices vector table +;* for MDK-ARM toolchain. +;* This module performs: +;* - Set the initial SP +;* - Set the initial PC == Reset_Handler +;* - Set the vector table entries with the exceptions ISR address +;* - Configure the clock system +;* - Branches to __main in the C library (which eventually +;* calls main()). +;* After Reset the CortexM3 processor is in Thread mode, +;* priority is Privileged, and the Stack is set to Main. +;* <<< Use Configuration Wizard in Context Menu >>> +;******************************************************************************* +; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS +; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. +; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, +; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE +; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING +; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. +;******************************************************************************* + +; Amount of memory (in bytes) allocated for Stack +; Tailor this value to your application needs +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Stack_Size EQU 0x00000400 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD MemManage_Handler ; MPU Fault Handler + DCD BusFault_Handler ; Bus Fault Handler + DCD UsageFault_Handler ; Usage Fault Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall Handler + DCD DebugMon_Handler ; Debug Monitor Handler + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV Handler + DCD SysTick_Handler ; SysTick Handler + + ; External Interrupts + DCD WWDG_IRQHandler ; Window Watchdog + DCD PVD_IRQHandler ; PVD through EXTI Line detect + DCD TAMPER_IRQHandler ; Tamper + DCD RTC_IRQHandler ; RTC + DCD FLASH_IRQHandler ; Flash + DCD RCC_IRQHandler ; RCC + DCD EXTI0_IRQHandler ; EXTI Line 0 + DCD EXTI1_IRQHandler ; EXTI Line 1 + DCD EXTI2_IRQHandler ; EXTI Line 2 + DCD EXTI3_IRQHandler ; EXTI Line 3 + DCD EXTI4_IRQHandler ; EXTI Line 4 + DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 + DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 + DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 + DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 + DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 + DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 + DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 + DCD ADC1_IRQHandler ; ADC1 + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD EXTI9_5_IRQHandler ; EXTI Line 9..5 + DCD TIM1_BRK_TIM15_IRQHandler ; TIM1 Break and TIM15 + DCD TIM1_UP_TIM16_IRQHandler ; TIM1 Update and TIM16 + DCD TIM1_TRG_COM_TIM17_IRQHandler ; TIM1 Trigger and Commutation and TIM17 + DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare + DCD TIM2_IRQHandler ; TIM2 + DCD TIM3_IRQHandler ; TIM3 + DCD 0 ; Reserved + DCD I2C1_EV_IRQHandler ; I2C1 Event + DCD I2C1_ER_IRQHandler ; I2C1 Error + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SPI1_IRQHandler ; SPI1 + DCD 0 ; Reserved + DCD USART1_IRQHandler ; USART1 + DCD USART2_IRQHandler ; USART2 + DCD 0 ; Reserved + DCD EXTI15_10_IRQHandler ; EXTI Line 15..10 + DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line + DCD CEC_IRQHandler ; HDMI-CEC + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD TIM6_DAC_IRQHandler ; TIM6 and DAC underrun + DCD TIM7_IRQHandler ; TIM7 +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + +; Reset handler +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT __main + IMPORT SystemInit + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +MemManage_Handler\ + PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler\ + PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + + EXPORT WWDG_IRQHandler [WEAK] + EXPORT PVD_IRQHandler [WEAK] + EXPORT TAMPER_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT RCC_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT DMA1_Channel1_IRQHandler [WEAK] + EXPORT DMA1_Channel2_IRQHandler [WEAK] + EXPORT DMA1_Channel3_IRQHandler [WEAK] + EXPORT DMA1_Channel4_IRQHandler [WEAK] + EXPORT DMA1_Channel5_IRQHandler [WEAK] + EXPORT DMA1_Channel6_IRQHandler [WEAK] + EXPORT DMA1_Channel7_IRQHandler [WEAK] + EXPORT ADC1_IRQHandler [WEAK] + EXPORT EXTI9_5_IRQHandler [WEAK] + EXPORT TIM1_BRK_TIM15_IRQHandler [WEAK] + EXPORT TIM1_UP_TIM16_IRQHandler [WEAK] + EXPORT TIM1_TRG_COM_TIM17_IRQHandler [WEAK] + EXPORT TIM1_CC_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT TIM3_IRQHandler [WEAK] + EXPORT I2C1_EV_IRQHandler [WEAK] + EXPORT I2C1_ER_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT USART2_IRQHandler [WEAK] + EXPORT EXTI15_10_IRQHandler [WEAK] + EXPORT RTCAlarm_IRQHandler [WEAK] + EXPORT CEC_IRQHandler [WEAK] + EXPORT TIM6_DAC_IRQHandler [WEAK] + EXPORT TIM7_IRQHandler [WEAK] +WWDG_IRQHandler +PVD_IRQHandler +TAMPER_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +RCC_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +DMA1_Channel1_IRQHandler +DMA1_Channel2_IRQHandler +DMA1_Channel3_IRQHandler +DMA1_Channel4_IRQHandler +DMA1_Channel5_IRQHandler +DMA1_Channel6_IRQHandler +DMA1_Channel7_IRQHandler +ADC1_IRQHandler +EXTI9_5_IRQHandler +TIM1_BRK_TIM15_IRQHandler +TIM1_UP_TIM16_IRQHandler +TIM1_TRG_COM_TIM17_IRQHandler +TIM1_CC_IRQHandler +TIM2_IRQHandler +TIM3_IRQHandler +I2C1_EV_IRQHandler +I2C1_ER_IRQHandler +SPI1_IRQHandler +USART1_IRQHandler +USART2_IRQHandler +EXTI15_10_IRQHandler +RTCAlarm_IRQHandler +CEC_IRQHandler +TIM6_DAC_IRQHandler +TIM7_IRQHandler + B . + + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap + +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, =(Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END + +;******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE***** diff --git a/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_md.s b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_md.s new file mode 100755 index 0000000..3223fc9 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_md.s @@ -0,0 +1,307 @@ +;******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** +;* File Name : startup_stm32f10x_md.s +;* Author : MCD Application Team +;* Version : V3.5.0 +;* Date : 11-March-2011 +;* Description : STM32F10x Medium Density Devices vector table for MDK-ARM +;* toolchain. +;* This module performs: +;* - Set the initial SP +;* - Set the initial PC == Reset_Handler +;* - Set the vector table entries with the exceptions ISR address +;* - Configure the clock system +;* - Branches to __main in the C library (which eventually +;* calls main()). +;* After Reset the CortexM3 processor is in Thread mode, +;* priority is Privileged, and the Stack is set to Main. +;* <<< Use Configuration Wizard in Context Menu >>> +;******************************************************************************* +; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS +; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. +; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, +; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE +; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING +; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. +;******************************************************************************* + +; Amount of memory (in bytes) allocated for Stack +; Tailor this value to your application needs +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Stack_Size EQU 0x00000400 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD MemManage_Handler ; MPU Fault Handler + DCD BusFault_Handler ; Bus Fault Handler + DCD UsageFault_Handler ; Usage Fault Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall Handler + DCD DebugMon_Handler ; Debug Monitor Handler + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV Handler + DCD SysTick_Handler ; SysTick Handler + + ; External Interrupts + DCD WWDG_IRQHandler ; Window Watchdog + DCD PVD_IRQHandler ; PVD through EXTI Line detect + DCD TAMPER_IRQHandler ; Tamper + DCD RTC_IRQHandler ; RTC + DCD FLASH_IRQHandler ; Flash + DCD RCC_IRQHandler ; RCC + DCD EXTI0_IRQHandler ; EXTI Line 0 + DCD EXTI1_IRQHandler ; EXTI Line 1 + DCD EXTI2_IRQHandler ; EXTI Line 2 + DCD EXTI3_IRQHandler ; EXTI Line 3 + DCD EXTI4_IRQHandler ; EXTI Line 4 + DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 + DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 + DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 + DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 + DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 + DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 + DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 + DCD ADC1_2_IRQHandler ; ADC1_2 + DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX + DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0 + DCD CAN1_RX1_IRQHandler ; CAN1 RX1 + DCD CAN1_SCE_IRQHandler ; CAN1 SCE + DCD EXTI9_5_IRQHandler ; EXTI Line 9..5 + DCD TIM1_BRK_IRQHandler ; TIM1 Break + DCD TIM1_UP_IRQHandler ; TIM1 Update + DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation + DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare + DCD TIM2_IRQHandler ; TIM2 + DCD TIM3_IRQHandler ; TIM3 + DCD TIM4_IRQHandler ; TIM4 + DCD I2C1_EV_IRQHandler ; I2C1 Event + DCD I2C1_ER_IRQHandler ; I2C1 Error + DCD I2C2_EV_IRQHandler ; I2C2 Event + DCD I2C2_ER_IRQHandler ; I2C2 Error + DCD SPI1_IRQHandler ; SPI1 + DCD SPI2_IRQHandler ; SPI2 + DCD USART1_IRQHandler ; USART1 + DCD USART2_IRQHandler ; USART2 + DCD USART3_IRQHandler ; USART3 + DCD EXTI15_10_IRQHandler ; EXTI Line 15..10 + DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line + DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + +; Reset handler +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT __main + IMPORT SystemInit + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +MemManage_Handler\ + PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler\ + PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + + EXPORT WWDG_IRQHandler [WEAK] + EXPORT PVD_IRQHandler [WEAK] + EXPORT TAMPER_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT RCC_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT DMA1_Channel1_IRQHandler [WEAK] + EXPORT DMA1_Channel2_IRQHandler [WEAK] + EXPORT DMA1_Channel3_IRQHandler [WEAK] + EXPORT DMA1_Channel4_IRQHandler [WEAK] + EXPORT DMA1_Channel5_IRQHandler [WEAK] + EXPORT DMA1_Channel6_IRQHandler [WEAK] + EXPORT DMA1_Channel7_IRQHandler [WEAK] + EXPORT ADC1_2_IRQHandler [WEAK] + EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK] + EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK] + EXPORT CAN1_RX1_IRQHandler [WEAK] + EXPORT CAN1_SCE_IRQHandler [WEAK] + EXPORT EXTI9_5_IRQHandler [WEAK] + EXPORT TIM1_BRK_IRQHandler [WEAK] + EXPORT TIM1_UP_IRQHandler [WEAK] + EXPORT TIM1_TRG_COM_IRQHandler [WEAK] + EXPORT TIM1_CC_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT TIM3_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT I2C1_EV_IRQHandler [WEAK] + EXPORT I2C1_ER_IRQHandler [WEAK] + EXPORT I2C2_EV_IRQHandler [WEAK] + EXPORT I2C2_ER_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT SPI2_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT USART2_IRQHandler [WEAK] + EXPORT USART3_IRQHandler [WEAK] + EXPORT EXTI15_10_IRQHandler [WEAK] + EXPORT RTCAlarm_IRQHandler [WEAK] + EXPORT USBWakeUp_IRQHandler [WEAK] + +WWDG_IRQHandler +PVD_IRQHandler +TAMPER_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +RCC_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +DMA1_Channel1_IRQHandler +DMA1_Channel2_IRQHandler +DMA1_Channel3_IRQHandler +DMA1_Channel4_IRQHandler +DMA1_Channel5_IRQHandler +DMA1_Channel6_IRQHandler +DMA1_Channel7_IRQHandler +ADC1_2_IRQHandler +USB_HP_CAN1_TX_IRQHandler +USB_LP_CAN1_RX0_IRQHandler +CAN1_RX1_IRQHandler +CAN1_SCE_IRQHandler +EXTI9_5_IRQHandler +TIM1_BRK_IRQHandler +TIM1_UP_IRQHandler +TIM1_TRG_COM_IRQHandler +TIM1_CC_IRQHandler +TIM2_IRQHandler +TIM3_IRQHandler +TIM4_IRQHandler +I2C1_EV_IRQHandler +I2C1_ER_IRQHandler +I2C2_EV_IRQHandler +I2C2_ER_IRQHandler +SPI1_IRQHandler +SPI2_IRQHandler +USART1_IRQHandler +USART2_IRQHandler +USART3_IRQHandler +EXTI15_10_IRQHandler +RTCAlarm_IRQHandler +USBWakeUp_IRQHandler + + B . + + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap + +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, =(Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END + +;******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE***** diff --git a/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_md_vl.s b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_md_vl.s new file mode 100755 index 0000000..d3b8aa6 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_md_vl.s @@ -0,0 +1,315 @@ +;******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** +;* File Name : startup_stm32f10x_md_vl.s +;* Author : MCD Application Team +;* Version : V3.5.0 +;* Date : 11-March-2011 +;* Description : STM32F10x Medium Density Value Line Devices vector table +;* for MDK-ARM toolchain. +;* This module performs: +;* - Set the initial SP +;* - Set the initial PC == Reset_Handler +;* - Set the vector table entries with the exceptions ISR address +;* - Configure the clock system +;* - Branches to __main in the C library (which eventually +;* calls main()). +;* After Reset the CortexM3 processor is in Thread mode, +;* priority is Privileged, and the Stack is set to Main. +;* <<< Use Configuration Wizard in Context Menu >>> +;******************************************************************************* +; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS +; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. +; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, +; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE +; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING +; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. +;******************************************************************************* + +; Amount of memory (in bytes) allocated for Stack +; Tailor this value to your application needs +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Stack_Size EQU 0x00000400 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD MemManage_Handler ; MPU Fault Handler + DCD BusFault_Handler ; Bus Fault Handler + DCD UsageFault_Handler ; Usage Fault Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall Handler + DCD DebugMon_Handler ; Debug Monitor Handler + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV Handler + DCD SysTick_Handler ; SysTick Handler + + ; External Interrupts + DCD WWDG_IRQHandler ; Window Watchdog + DCD PVD_IRQHandler ; PVD through EXTI Line detect + DCD TAMPER_IRQHandler ; Tamper + DCD RTC_IRQHandler ; RTC + DCD FLASH_IRQHandler ; Flash + DCD RCC_IRQHandler ; RCC + DCD EXTI0_IRQHandler ; EXTI Line 0 + DCD EXTI1_IRQHandler ; EXTI Line 1 + DCD EXTI2_IRQHandler ; EXTI Line 2 + DCD EXTI3_IRQHandler ; EXTI Line 3 + DCD EXTI4_IRQHandler ; EXTI Line 4 + DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 + DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 + DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 + DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 + DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 + DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 + DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 + DCD ADC1_IRQHandler ; ADC1 + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD EXTI9_5_IRQHandler ; EXTI Line 9..5 + DCD TIM1_BRK_TIM15_IRQHandler ; TIM1 Break and TIM15 + DCD TIM1_UP_TIM16_IRQHandler ; TIM1 Update and TIM16 + DCD TIM1_TRG_COM_TIM17_IRQHandler ; TIM1 Trigger and Commutation and TIM17 + DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare + DCD TIM2_IRQHandler ; TIM2 + DCD TIM3_IRQHandler ; TIM3 + DCD TIM4_IRQHandler ; TIM4 + DCD I2C1_EV_IRQHandler ; I2C1 Event + DCD I2C1_ER_IRQHandler ; I2C1 Error + DCD I2C2_EV_IRQHandler ; I2C2 Event + DCD I2C2_ER_IRQHandler ; I2C2 Error + DCD SPI1_IRQHandler ; SPI1 + DCD SPI2_IRQHandler ; SPI2 + DCD USART1_IRQHandler ; USART1 + DCD USART2_IRQHandler ; USART2 + DCD USART3_IRQHandler ; USART3 + DCD EXTI15_10_IRQHandler ; EXTI Line 15..10 + DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line + DCD CEC_IRQHandler ; HDMI-CEC + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD TIM6_DAC_IRQHandler ; TIM6 and DAC underrun + DCD TIM7_IRQHandler ; TIM7 +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + +; Reset handler +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT __main + IMPORT SystemInit + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +MemManage_Handler\ + PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler\ + PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + + EXPORT WWDG_IRQHandler [WEAK] + EXPORT PVD_IRQHandler [WEAK] + EXPORT TAMPER_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT RCC_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT DMA1_Channel1_IRQHandler [WEAK] + EXPORT DMA1_Channel2_IRQHandler [WEAK] + EXPORT DMA1_Channel3_IRQHandler [WEAK] + EXPORT DMA1_Channel4_IRQHandler [WEAK] + EXPORT DMA1_Channel5_IRQHandler [WEAK] + EXPORT DMA1_Channel6_IRQHandler [WEAK] + EXPORT DMA1_Channel7_IRQHandler [WEAK] + EXPORT ADC1_IRQHandler [WEAK] + EXPORT EXTI9_5_IRQHandler [WEAK] + EXPORT TIM1_BRK_TIM15_IRQHandler [WEAK] + EXPORT TIM1_UP_TIM16_IRQHandler [WEAK] + EXPORT TIM1_TRG_COM_TIM17_IRQHandler [WEAK] + EXPORT TIM1_CC_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT TIM3_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT I2C1_EV_IRQHandler [WEAK] + EXPORT I2C1_ER_IRQHandler [WEAK] + EXPORT I2C2_EV_IRQHandler [WEAK] + EXPORT I2C2_ER_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT SPI2_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT USART2_IRQHandler [WEAK] + EXPORT USART3_IRQHandler [WEAK] + EXPORT EXTI15_10_IRQHandler [WEAK] + EXPORT RTCAlarm_IRQHandler [WEAK] + EXPORT CEC_IRQHandler [WEAK] + EXPORT TIM6_DAC_IRQHandler [WEAK] + EXPORT TIM7_IRQHandler [WEAK] + +WWDG_IRQHandler +PVD_IRQHandler +TAMPER_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +RCC_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +DMA1_Channel1_IRQHandler +DMA1_Channel2_IRQHandler +DMA1_Channel3_IRQHandler +DMA1_Channel4_IRQHandler +DMA1_Channel5_IRQHandler +DMA1_Channel6_IRQHandler +DMA1_Channel7_IRQHandler +ADC1_IRQHandler +EXTI9_5_IRQHandler +TIM1_BRK_TIM15_IRQHandler +TIM1_UP_TIM16_IRQHandler +TIM1_TRG_COM_TIM17_IRQHandler +TIM1_CC_IRQHandler +TIM2_IRQHandler +TIM3_IRQHandler +TIM4_IRQHandler +I2C1_EV_IRQHandler +I2C1_ER_IRQHandler +I2C2_EV_IRQHandler +I2C2_ER_IRQHandler +SPI1_IRQHandler +SPI2_IRQHandler +USART1_IRQHandler +USART2_IRQHandler +USART3_IRQHandler +EXTI15_10_IRQHandler +RTCAlarm_IRQHandler +CEC_IRQHandler +TIM6_DAC_IRQHandler +TIM7_IRQHandler + B . + + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap + +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, =(Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END + +;******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE***** diff --git a/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_xl.s b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_xl.s new file mode 100755 index 0000000..7970052 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/CMSIS/Startup/startup_stm32f10x_xl.s @@ -0,0 +1,358 @@ +;******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** +;* File Name : startup_stm32f10x_xl.s +;* Author : MCD Application Team +;* Version : V3.5.0 +;* Date : 11-March-2011 +;* Description : STM32F10x XL-Density Devices vector table for MDK-ARM +;* toolchain. +;* This module performs: +;* - Set the initial SP +;* - Set the initial PC == Reset_Handler +;* - Set the vector table entries with the exceptions ISR address +;* - Configure the clock system and also configure the external +;* SRAM mounted on STM3210E-EVAL board to be used as data +;* memory (optional, to be enabled by user) +;* - Branches to __main in the C library (which eventually +;* calls main()). +;* After Reset the CortexM3 processor is in Thread mode, +;* priority is Privileged, and the Stack is set to Main. +;* <<< Use Configuration Wizard in Context Menu >>> +;******************************************************************************* +; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS +; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. +; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, +; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE +; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING +; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. +;******************************************************************************* + +; Amount of memory (in bytes) allocated for Stack +; Tailor this value to your application needs +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Stack_Size EQU 0x00000400 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Heap_Size EQU 0x00000200 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD MemManage_Handler ; MPU Fault Handler + DCD BusFault_Handler ; Bus Fault Handler + DCD UsageFault_Handler ; Usage Fault Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall Handler + DCD DebugMon_Handler ; Debug Monitor Handler + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV Handler + DCD SysTick_Handler ; SysTick Handler + + ; External Interrupts + DCD WWDG_IRQHandler ; Window Watchdog + DCD PVD_IRQHandler ; PVD through EXTI Line detect + DCD TAMPER_IRQHandler ; Tamper + DCD RTC_IRQHandler ; RTC + DCD FLASH_IRQHandler ; Flash + DCD RCC_IRQHandler ; RCC + DCD EXTI0_IRQHandler ; EXTI Line 0 + DCD EXTI1_IRQHandler ; EXTI Line 1 + DCD EXTI2_IRQHandler ; EXTI Line 2 + DCD EXTI3_IRQHandler ; EXTI Line 3 + DCD EXTI4_IRQHandler ; EXTI Line 4 + DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 + DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 + DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 + DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 + DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 + DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 + DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 + DCD ADC1_2_IRQHandler ; ADC1 & ADC2 + DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX + DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0 + DCD CAN1_RX1_IRQHandler ; CAN1 RX1 + DCD CAN1_SCE_IRQHandler ; CAN1 SCE + DCD EXTI9_5_IRQHandler ; EXTI Line 9..5 + DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9 + DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10 + DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11 + DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare + DCD TIM2_IRQHandler ; TIM2 + DCD TIM3_IRQHandler ; TIM3 + DCD TIM4_IRQHandler ; TIM4 + DCD I2C1_EV_IRQHandler ; I2C1 Event + DCD I2C1_ER_IRQHandler ; I2C1 Error + DCD I2C2_EV_IRQHandler ; I2C2 Event + DCD I2C2_ER_IRQHandler ; I2C2 Error + DCD SPI1_IRQHandler ; SPI1 + DCD SPI2_IRQHandler ; SPI2 + DCD USART1_IRQHandler ; USART1 + DCD USART2_IRQHandler ; USART2 + DCD USART3_IRQHandler ; USART3 + DCD EXTI15_10_IRQHandler ; EXTI Line 15..10 + DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line + DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend + DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12 + DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13 + DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14 + DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare + DCD ADC3_IRQHandler ; ADC3 + DCD FSMC_IRQHandler ; FSMC + DCD SDIO_IRQHandler ; SDIO + DCD TIM5_IRQHandler ; TIM5 + DCD SPI3_IRQHandler ; SPI3 + DCD UART4_IRQHandler ; UART4 + DCD UART5_IRQHandler ; UART5 + DCD TIM6_IRQHandler ; TIM6 + DCD TIM7_IRQHandler ; TIM7 + DCD DMA2_Channel1_IRQHandler ; DMA2 Channel1 + DCD DMA2_Channel2_IRQHandler ; DMA2 Channel2 + DCD DMA2_Channel3_IRQHandler ; DMA2 Channel3 + DCD DMA2_Channel4_5_IRQHandler ; DMA2 Channel4 & Channel5 +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + +; Reset handler +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT __main + IMPORT SystemInit + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +MemManage_Handler\ + PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler\ + PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + + EXPORT WWDG_IRQHandler [WEAK] + EXPORT PVD_IRQHandler [WEAK] + EXPORT TAMPER_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT RCC_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT DMA1_Channel1_IRQHandler [WEAK] + EXPORT DMA1_Channel2_IRQHandler [WEAK] + EXPORT DMA1_Channel3_IRQHandler [WEAK] + EXPORT DMA1_Channel4_IRQHandler [WEAK] + EXPORT DMA1_Channel5_IRQHandler [WEAK] + EXPORT DMA1_Channel6_IRQHandler [WEAK] + EXPORT DMA1_Channel7_IRQHandler [WEAK] + EXPORT ADC1_2_IRQHandler [WEAK] + EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK] + EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK] + EXPORT CAN1_RX1_IRQHandler [WEAK] + EXPORT CAN1_SCE_IRQHandler [WEAK] + EXPORT EXTI9_5_IRQHandler [WEAK] + EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK] + EXPORT TIM1_UP_TIM10_IRQHandler [WEAK] + EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK] + EXPORT TIM1_CC_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT TIM3_IRQHandler [WEAK] + EXPORT TIM4_IRQHandler [WEAK] + EXPORT I2C1_EV_IRQHandler [WEAK] + EXPORT I2C1_ER_IRQHandler [WEAK] + EXPORT I2C2_EV_IRQHandler [WEAK] + EXPORT I2C2_ER_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT SPI2_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT USART2_IRQHandler [WEAK] + EXPORT USART3_IRQHandler [WEAK] + EXPORT EXTI15_10_IRQHandler [WEAK] + EXPORT RTCAlarm_IRQHandler [WEAK] + EXPORT USBWakeUp_IRQHandler [WEAK] + EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK] + EXPORT TIM8_UP_TIM13_IRQHandler [WEAK] + EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK] + EXPORT TIM8_CC_IRQHandler [WEAK] + EXPORT ADC3_IRQHandler [WEAK] + EXPORT FSMC_IRQHandler [WEAK] + EXPORT SDIO_IRQHandler [WEAK] + EXPORT TIM5_IRQHandler [WEAK] + EXPORT SPI3_IRQHandler [WEAK] + EXPORT UART4_IRQHandler [WEAK] + EXPORT UART5_IRQHandler [WEAK] + EXPORT TIM6_IRQHandler [WEAK] + EXPORT TIM7_IRQHandler [WEAK] + EXPORT DMA2_Channel1_IRQHandler [WEAK] + EXPORT DMA2_Channel2_IRQHandler [WEAK] + EXPORT DMA2_Channel3_IRQHandler [WEAK] + EXPORT DMA2_Channel4_5_IRQHandler [WEAK] + +WWDG_IRQHandler +PVD_IRQHandler +TAMPER_IRQHandler +RTC_IRQHandler +FLASH_IRQHandler +RCC_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +DMA1_Channel1_IRQHandler +DMA1_Channel2_IRQHandler +DMA1_Channel3_IRQHandler +DMA1_Channel4_IRQHandler +DMA1_Channel5_IRQHandler +DMA1_Channel6_IRQHandler +DMA1_Channel7_IRQHandler +ADC1_2_IRQHandler +USB_HP_CAN1_TX_IRQHandler +USB_LP_CAN1_RX0_IRQHandler +CAN1_RX1_IRQHandler +CAN1_SCE_IRQHandler +EXTI9_5_IRQHandler +TIM1_BRK_TIM9_IRQHandler +TIM1_UP_TIM10_IRQHandler +TIM1_TRG_COM_TIM11_IRQHandler +TIM1_CC_IRQHandler +TIM2_IRQHandler +TIM3_IRQHandler +TIM4_IRQHandler +I2C1_EV_IRQHandler +I2C1_ER_IRQHandler +I2C2_EV_IRQHandler +I2C2_ER_IRQHandler +SPI1_IRQHandler +SPI2_IRQHandler +USART1_IRQHandler +USART2_IRQHandler +USART3_IRQHandler +EXTI15_10_IRQHandler +RTCAlarm_IRQHandler +USBWakeUp_IRQHandler +TIM8_BRK_TIM12_IRQHandler +TIM8_UP_TIM13_IRQHandler +TIM8_TRG_COM_TIM14_IRQHandler +TIM8_CC_IRQHandler +ADC3_IRQHandler +FSMC_IRQHandler +SDIO_IRQHandler +TIM5_IRQHandler +SPI3_IRQHandler +UART4_IRQHandler +UART5_IRQHandler +TIM6_IRQHandler +TIM7_IRQHandler +DMA2_Channel1_IRQHandler +DMA2_Channel2_IRQHandler +DMA2_Channel3_IRQHandler +DMA2_Channel4_5_IRQHandler + B . + + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap + +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, =(Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END + +;******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE***** diff --git a/STM32_4路称重_Git提交精简工程/src/CMSIS/core_cm3.c b/STM32_4路称重_Git提交精简工程/src/CMSIS/core_cm3.c new file mode 100755 index 0000000..56fddc5 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/CMSIS/core_cm3.c @@ -0,0 +1,784 @@ +/**************************************************************************//** + * @file core_cm3.c + * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Source File + * @version V1.30 + * @date 30. October 2009 + * + * @note + * Copyright (C) 2009 ARM Limited. All rights reserved. + * + * @par + * ARM Limited (ARM) is supplying this software for use with Cortex-M + * processor based microcontrollers. This file can be freely distributed + * within development tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +#include + +/* define compiler specific symbols */ +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only avaiable in High optimization mode! */ + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + +#endif + + +/* ################### Compiler specific Intrinsics ########################### */ + +#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/ +/* ARM armcc specific functions */ + +/** + * @brief Return the Process Stack Pointer + * + * @return ProcessStackPointer + * + * Return the actual process stack pointer + */ +__ASM uint32_t __get_PSP(void) +{ + mrs r0, psp + bx lr +} + +/** + * @brief Set the Process Stack Pointer + * + * @param topOfProcStack Process Stack Pointer + * + * Assign the value ProcessStackPointer to the MSP + * (process stack pointer) Cortex processor register + */ +__ASM void __set_PSP(uint32_t topOfProcStack) +{ + msr psp, r0 + bx lr +} + +/** + * @brief Return the Main Stack Pointer + * + * @return Main Stack Pointer + * + * Return the current value of the MSP (main stack pointer) + * Cortex processor register + */ +__ASM uint32_t __get_MSP(void) +{ + mrs r0, msp + bx lr +} + +/** + * @brief Set the Main Stack Pointer + * + * @param topOfMainStack Main Stack Pointer + * + * Assign the value mainStackPointer to the MSP + * (main stack pointer) Cortex processor register + */ +__ASM void __set_MSP(uint32_t mainStackPointer) +{ + msr msp, r0 + bx lr +} + +/** + * @brief Reverse byte order in unsigned short value + * + * @param value value to reverse + * @return reversed value + * + * Reverse byte order in unsigned short value + */ +__ASM uint32_t __REV16(uint16_t value) +{ + rev16 r0, r0 + bx lr +} + +/** + * @brief Reverse byte order in signed short value with sign extension to integer + * + * @param value value to reverse + * @return reversed value + * + * Reverse byte order in signed short value with sign extension to integer + */ +__ASM int32_t __REVSH(int16_t value) +{ + revsh r0, r0 + bx lr +} + + +#if (__ARMCC_VERSION < 400000) + +/** + * @brief Remove the exclusive lock created by ldrex + * + * Removes the exclusive lock which is created by ldrex. + */ +__ASM void __CLREX(void) +{ + clrex +} + +/** + * @brief Return the Base Priority value + * + * @return BasePriority + * + * Return the content of the base priority register + */ +__ASM uint32_t __get_BASEPRI(void) +{ + mrs r0, basepri + bx lr +} + +/** + * @brief Set the Base Priority value + * + * @param basePri BasePriority + * + * Set the base priority register + */ +__ASM void __set_BASEPRI(uint32_t basePri) +{ + msr basepri, r0 + bx lr +} + +/** + * @brief Return the Priority Mask value + * + * @return PriMask + * + * Return state of the priority mask bit from the priority mask register + */ +__ASM uint32_t __get_PRIMASK(void) +{ + mrs r0, primask + bx lr +} + +/** + * @brief Set the Priority Mask value + * + * @param priMask PriMask + * + * Set the priority mask bit in the priority mask register + */ +__ASM void __set_PRIMASK(uint32_t priMask) +{ + msr primask, r0 + bx lr +} + +/** + * @brief Return the Fault Mask value + * + * @return FaultMask + * + * Return the content of the fault mask register + */ +__ASM uint32_t __get_FAULTMASK(void) +{ + mrs r0, faultmask + bx lr +} + +/** + * @brief Set the Fault Mask value + * + * @param faultMask faultMask value + * + * Set the fault mask register + */ +__ASM void __set_FAULTMASK(uint32_t faultMask) +{ + msr faultmask, r0 + bx lr +} + +/** + * @brief Return the Control Register value + * + * @return Control value + * + * Return the content of the control register + */ +__ASM uint32_t __get_CONTROL(void) +{ + mrs r0, control + bx lr +} + +/** + * @brief Set the Control Register value + * + * @param control Control value + * + * Set the control register + */ +__ASM void __set_CONTROL(uint32_t control) +{ + msr control, r0 + bx lr +} + +#endif /* __ARMCC_VERSION */ + + + +#elif (defined (__ICCARM__)) /*------------------ ICC Compiler -------------------*/ +/* IAR iccarm specific functions */ +#pragma diag_suppress=Pe940 + +/** + * @brief Return the Process Stack Pointer + * + * @return ProcessStackPointer + * + * Return the actual process stack pointer + */ +uint32_t __get_PSP(void) +{ + __ASM("mrs r0, psp"); + __ASM("bx lr"); +} + +/** + * @brief Set the Process Stack Pointer + * + * @param topOfProcStack Process Stack Pointer + * + * Assign the value ProcessStackPointer to the MSP + * (process stack pointer) Cortex processor register + */ +void __set_PSP(uint32_t topOfProcStack) +{ + __ASM("msr psp, r0"); + __ASM("bx lr"); +} + +/** + * @brief Return the Main Stack Pointer + * + * @return Main Stack Pointer + * + * Return the current value of the MSP (main stack pointer) + * Cortex processor register + */ +uint32_t __get_MSP(void) +{ + __ASM("mrs r0, msp"); + __ASM("bx lr"); +} + +/** + * @brief Set the Main Stack Pointer + * + * @param topOfMainStack Main Stack Pointer + * + * Assign the value mainStackPointer to the MSP + * (main stack pointer) Cortex processor register + */ +void __set_MSP(uint32_t topOfMainStack) +{ + __ASM("msr msp, r0"); + __ASM("bx lr"); +} + +/** + * @brief Reverse byte order in unsigned short value + * + * @param value value to reverse + * @return reversed value + * + * Reverse byte order in unsigned short value + */ +uint32_t __REV16(uint16_t value) +{ + __ASM("rev16 r0, r0"); + __ASM("bx lr"); +} + +/** + * @brief Reverse bit order of value + * + * @param value value to reverse + * @return reversed value + * + * Reverse bit order of value + */ +uint32_t __RBIT(uint32_t value) +{ + __ASM("rbit r0, r0"); + __ASM("bx lr"); +} + +/** + * @brief LDR Exclusive (8 bit) + * + * @param *addr address pointer + * @return value of (*address) + * + * Exclusive LDR command for 8 bit values) + */ +uint8_t __LDREXB(uint8_t *addr) +{ + __ASM("ldrexb r0, [r0]"); + __ASM("bx lr"); +} + +/** + * @brief LDR Exclusive (16 bit) + * + * @param *addr address pointer + * @return value of (*address) + * + * Exclusive LDR command for 16 bit values + */ +uint16_t __LDREXH(uint16_t *addr) +{ + __ASM("ldrexh r0, [r0]"); + __ASM("bx lr"); +} + +/** + * @brief LDR Exclusive (32 bit) + * + * @param *addr address pointer + * @return value of (*address) + * + * Exclusive LDR command for 32 bit values + */ +uint32_t __LDREXW(uint32_t *addr) +{ + __ASM("ldrex r0, [r0]"); + __ASM("bx lr"); +} + +/** + * @brief STR Exclusive (8 bit) + * + * @param value value to store + * @param *addr address pointer + * @return successful / failed + * + * Exclusive STR command for 8 bit values + */ +uint32_t __STREXB(uint8_t value, uint8_t *addr) +{ + __ASM("strexb r0, r0, [r1]"); + __ASM("bx lr"); +} + +/** + * @brief STR Exclusive (16 bit) + * + * @param value value to store + * @param *addr address pointer + * @return successful / failed + * + * Exclusive STR command for 16 bit values + */ +uint32_t __STREXH(uint16_t value, uint16_t *addr) +{ + __ASM("strexh r0, r0, [r1]"); + __ASM("bx lr"); +} + +/** + * @brief STR Exclusive (32 bit) + * + * @param value value to store + * @param *addr address pointer + * @return successful / failed + * + * Exclusive STR command for 32 bit values + */ +uint32_t __STREXW(uint32_t value, uint32_t *addr) +{ + __ASM("strex r0, r0, [r1]"); + __ASM("bx lr"); +} + +#pragma diag_default=Pe940 + + +#elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/ +/* GNU gcc specific functions */ + +/** + * @brief Return the Process Stack Pointer + * + * @return ProcessStackPointer + * + * Return the actual process stack pointer + */ +uint32_t __get_PSP(void) __attribute__( ( naked ) ); +uint32_t __get_PSP(void) +{ + uint32_t result=0; + + __ASM volatile ("MRS %0, psp\n\t" + "MOV r0, %0 \n\t" + "BX lr \n\t" : "=r" (result) ); + return(result); +} + +/** + * @brief Set the Process Stack Pointer + * + * @param topOfProcStack Process Stack Pointer + * + * Assign the value ProcessStackPointer to the MSP + * (process stack pointer) Cortex processor register + */ +void __set_PSP(uint32_t topOfProcStack) __attribute__( ( naked ) ); +void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0\n\t" + "BX lr \n\t" : : "r" (topOfProcStack) ); +} + +/** + * @brief Return the Main Stack Pointer + * + * @return Main Stack Pointer + * + * Return the current value of the MSP (main stack pointer) + * Cortex processor register + */ +uint32_t __get_MSP(void) __attribute__( ( naked ) ); +uint32_t __get_MSP(void) +{ + uint32_t result=0; + + __ASM volatile ("MRS %0, msp\n\t" + "MOV r0, %0 \n\t" + "BX lr \n\t" : "=r" (result) ); + return(result); +} + +/** + * @brief Set the Main Stack Pointer + * + * @param topOfMainStack Main Stack Pointer + * + * Assign the value mainStackPointer to the MSP + * (main stack pointer) Cortex processor register + */ +void __set_MSP(uint32_t topOfMainStack) __attribute__( ( naked ) ); +void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0\n\t" + "BX lr \n\t" : : "r" (topOfMainStack) ); +} + +/** + * @brief Return the Base Priority value + * + * @return BasePriority + * + * Return the content of the base priority register + */ +uint32_t __get_BASEPRI(void) +{ + uint32_t result=0; + + __ASM volatile ("MRS %0, basepri_max" : "=r" (result) ); + return(result); +} + +/** + * @brief Set the Base Priority value + * + * @param basePri BasePriority + * + * Set the base priority register + */ +void __set_BASEPRI(uint32_t value) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (value) ); +} + +/** + * @brief Return the Priority Mask value + * + * @return PriMask + * + * Return state of the priority mask bit from the priority mask register + */ +uint32_t __get_PRIMASK(void) +{ + uint32_t result=0; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + +/** + * @brief Set the Priority Mask value + * + * @param priMask PriMask + * + * Set the priority mask bit in the priority mask register + */ +void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) ); +} + +/** + * @brief Return the Fault Mask value + * + * @return FaultMask + * + * Return the content of the fault mask register + */ +uint32_t __get_FAULTMASK(void) +{ + uint32_t result=0; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + +/** + * @brief Set the Fault Mask value + * + * @param faultMask faultMask value + * + * Set the fault mask register + */ +void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) ); +} + +/** + * @brief Return the Control Register value +* +* @return Control value + * + * Return the content of the control register + */ +uint32_t __get_CONTROL(void) +{ + uint32_t result=0; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + +/** + * @brief Set the Control Register value + * + * @param control Control value + * + * Set the control register + */ +void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) ); +} + + +/** + * @brief Reverse byte order in integer value + * + * @param value value to reverse + * @return reversed value + * + * Reverse byte order in integer value + */ +uint32_t __REV(uint32_t value) +{ + uint32_t result=0; + + __ASM volatile ("rev %0, %1" : "=r" (result) : "r" (value) ); + return(result); +} + +/** + * @brief Reverse byte order in unsigned short value + * + * @param value value to reverse + * @return reversed value + * + * Reverse byte order in unsigned short value + */ +uint32_t __REV16(uint16_t value) +{ + uint32_t result=0; + + __ASM volatile ("rev16 %0, %1" : "=r" (result) : "r" (value) ); + return(result); +} + +/** + * @brief Reverse byte order in signed short value with sign extension to integer + * + * @param value value to reverse + * @return reversed value + * + * Reverse byte order in signed short value with sign extension to integer + */ +int32_t __REVSH(int16_t value) +{ + uint32_t result=0; + + __ASM volatile ("revsh %0, %1" : "=r" (result) : "r" (value) ); + return(result); +} + +/** + * @brief Reverse bit order of value + * + * @param value value to reverse + * @return reversed value + * + * Reverse bit order of value + */ +uint32_t __RBIT(uint32_t value) +{ + uint32_t result=0; + + __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) ); + return(result); +} + +/** + * @brief LDR Exclusive (8 bit) + * + * @param *addr address pointer + * @return value of (*address) + * + * Exclusive LDR command for 8 bit value + */ +uint8_t __LDREXB(uint8_t *addr) +{ + uint8_t result=0; + + __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) ); + return(result); +} + +/** + * @brief LDR Exclusive (16 bit) + * + * @param *addr address pointer + * @return value of (*address) + * + * Exclusive LDR command for 16 bit values + */ +uint16_t __LDREXH(uint16_t *addr) +{ + uint16_t result=0; + + __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) ); + return(result); +} + +/** + * @brief LDR Exclusive (32 bit) + * + * @param *addr address pointer + * @return value of (*address) + * + * Exclusive LDR command for 32 bit values + */ +uint32_t __LDREXW(uint32_t *addr) +{ + uint32_t result=0; + + __ASM volatile ("ldrex %0, [%1]" : "=r" (result) : "r" (addr) ); + return(result); +} + +/** + * @brief STR Exclusive (8 bit) + * + * @param value value to store + * @param *addr address pointer + * @return successful / failed + * + * Exclusive STR command for 8 bit values + */ +uint32_t __STREXB(uint8_t value, uint8_t *addr) +{ + uint32_t result=0; + + __ASM volatile ("strexb %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) ); + return(result); +} + +/** + * @brief STR Exclusive (16 bit) + * + * @param value value to store + * @param *addr address pointer + * @return successful / failed + * + * Exclusive STR command for 16 bit values + */ +uint32_t __STREXH(uint16_t value, uint16_t *addr) +{ + uint32_t result=0; + + __ASM volatile ("strexh %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) ); + return(result); +} + +/** + * @brief STR Exclusive (32 bit) + * + * @param value value to store + * @param *addr address pointer + * @return successful / failed + * + * Exclusive STR command for 32 bit values + */ +uint32_t __STREXW(uint32_t value, uint32_t *addr) +{ + uint32_t result=0; + + __ASM volatile ("strex %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) ); + return(result); +} + + +#elif (defined (__TASKING__)) /*------------------ TASKING Compiler ---------------------*/ +/* TASKING carm specific functions */ + +/* + * The CMSIS functions have been implemented as intrinsics in the compiler. + * Please use "carm -?i" to get an up to date list of all instrinsics, + * Including the CMSIS ones. + */ + +#endif diff --git a/STM32_4路称重_Git提交精简工程/src/CMSIS/core_cm3.h b/STM32_4路称重_Git提交精简工程/src/CMSIS/core_cm3.h new file mode 100755 index 0000000..2b6b51a --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/CMSIS/core_cm3.h @@ -0,0 +1,1818 @@ +/**************************************************************************//** + * @file core_cm3.h + * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Header File + * @version V1.30 + * @date 30. October 2009 + * + * @note + * Copyright (C) 2009 ARM Limited. All rights reserved. + * + * @par + * ARM Limited (ARM) is supplying this software for use with Cortex-M + * processor based microcontrollers. This file can be freely distributed + * within development tools that are supporting such ARM based processors. + * + * @par + * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED + * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. + * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. + * + ******************************************************************************/ + +#ifndef __CM3_CORE_H__ +#define __CM3_CORE_H__ + +/** @addtogroup CMSIS_CM3_core_LintCinfiguration CMSIS CM3 Core Lint Configuration + * + * List of Lint messages which will be suppressed and not shown: + * - Error 10: \n + * register uint32_t __regBasePri __asm("basepri"); \n + * Error 10: Expecting ';' + * . + * - Error 530: \n + * return(__regBasePri); \n + * Warning 530: Symbol '__regBasePri' (line 264) not initialized + * . + * - Error 550: \n + * __regBasePri = (basePri & 0x1ff); \n + * Warning 550: Symbol '__regBasePri' (line 271) not accessed + * . + * - Error 754: \n + * uint32_t RESERVED0[24]; \n + * Info 754: local structure member '' (line 109, file ./cm3_core.h) not referenced + * . + * - Error 750: \n + * #define __CM3_CORE_H__ \n + * Info 750: local macro '__CM3_CORE_H__' (line 43, file./cm3_core.h) not referenced + * . + * - Error 528: \n + * static __INLINE void NVIC_DisableIRQ(uint32_t IRQn) \n + * Warning 528: Symbol 'NVIC_DisableIRQ(unsigned int)' (line 419, file ./cm3_core.h) not referenced + * . + * - Error 751: \n + * } InterruptType_Type; \n + * Info 751: local typedef 'InterruptType_Type' (line 170, file ./cm3_core.h) not referenced + * . + * Note: To re-enable a Message, insert a space before 'lint' * + * + */ + +/*lint -save */ +/*lint -e10 */ +/*lint -e530 */ +/*lint -e550 */ +/*lint -e754 */ +/*lint -e750 */ +/*lint -e528 */ +/*lint -e751 */ + + +/** @addtogroup CMSIS_CM3_core_definitions CM3 Core Definitions + This file defines all structures and symbols for CMSIS core: + - CMSIS version number + - Cortex-M core registers and bitfields + - Cortex-M core peripheral base address + @{ + */ + +#ifdef __cplusplus + extern "C" { +#endif + +#define __CM3_CMSIS_VERSION_MAIN (0x01) /*!< [31:16] CMSIS HAL main version */ +#define __CM3_CMSIS_VERSION_SUB (0x30) /*!< [15:0] CMSIS HAL sub version */ +#define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16) | __CM3_CMSIS_VERSION_SUB) /*!< CMSIS HAL version number */ + +#define __CORTEX_M (0x03) /*!< Cortex core */ + +#include /* Include standard types */ + +#if defined (__ICCARM__) + #include /* IAR Intrinsics */ +#endif + + +#ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 4 /*!< standard definition for NVIC Priority Bits */ +#endif + + + + +/** + * IO definitions + * + * define access restrictions to peripheral registers + */ + +#ifdef __cplusplus + #define __I volatile /*!< defines 'read only' permissions */ +#else + #define __I volatile const /*!< defines 'read only' permissions */ +#endif +#define __O volatile /*!< defines 'write only' permissions */ +#define __IO volatile /*!< defines 'read / write' permissions */ + + + +/******************************************************************************* + * Register Abstraction + ******************************************************************************/ +/** @addtogroup CMSIS_CM3_core_register CMSIS CM3 Core Register + @{ +*/ + + +/** @addtogroup CMSIS_CM3_NVIC CMSIS CM3 NVIC + memory mapped structure for Nested Vectored Interrupt Controller (NVIC) + @{ + */ +typedef struct +{ + __IO uint32_t ISER[8]; /*!< Offset: 0x000 Interrupt Set Enable Register */ + uint32_t RESERVED0[24]; + __IO uint32_t ICER[8]; /*!< Offset: 0x080 Interrupt Clear Enable Register */ + uint32_t RSERVED1[24]; + __IO uint32_t ISPR[8]; /*!< Offset: 0x100 Interrupt Set Pending Register */ + uint32_t RESERVED2[24]; + __IO uint32_t ICPR[8]; /*!< Offset: 0x180 Interrupt Clear Pending Register */ + uint32_t RESERVED3[24]; + __IO uint32_t IABR[8]; /*!< Offset: 0x200 Interrupt Active bit Register */ + uint32_t RESERVED4[56]; + __IO uint8_t IP[240]; /*!< Offset: 0x300 Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644]; + __O uint32_t STIR; /*!< Offset: 0xE00 Software Trigger Interrupt Register */ +} NVIC_Type; +/*@}*/ /* end of group CMSIS_CM3_NVIC */ + + +/** @addtogroup CMSIS_CM3_SCB CMSIS CM3 SCB + memory mapped structure for System Control Block (SCB) + @{ + */ +typedef struct +{ + __I uint32_t CPUID; /*!< Offset: 0x00 CPU ID Base Register */ + __IO uint32_t ICSR; /*!< Offset: 0x04 Interrupt Control State Register */ + __IO uint32_t VTOR; /*!< Offset: 0x08 Vector Table Offset Register */ + __IO uint32_t AIRCR; /*!< Offset: 0x0C Application Interrupt / Reset Control Register */ + __IO uint32_t SCR; /*!< Offset: 0x10 System Control Register */ + __IO uint32_t CCR; /*!< Offset: 0x14 Configuration Control Register */ + __IO uint8_t SHP[12]; /*!< Offset: 0x18 System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IO uint32_t SHCSR; /*!< Offset: 0x24 System Handler Control and State Register */ + __IO uint32_t CFSR; /*!< Offset: 0x28 Configurable Fault Status Register */ + __IO uint32_t HFSR; /*!< Offset: 0x2C Hard Fault Status Register */ + __IO uint32_t DFSR; /*!< Offset: 0x30 Debug Fault Status Register */ + __IO uint32_t MMFAR; /*!< Offset: 0x34 Mem Manage Address Register */ + __IO uint32_t BFAR; /*!< Offset: 0x38 Bus Fault Address Register */ + __IO uint32_t AFSR; /*!< Offset: 0x3C Auxiliary Fault Status Register */ + __I uint32_t PFR[2]; /*!< Offset: 0x40 Processor Feature Register */ + __I uint32_t DFR; /*!< Offset: 0x48 Debug Feature Register */ + __I uint32_t ADR; /*!< Offset: 0x4C Auxiliary Feature Register */ + __I uint32_t MMFR[4]; /*!< Offset: 0x50 Memory Model Feature Register */ + __I uint32_t ISAR[5]; /*!< Offset: 0x60 ISA Feature Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24 /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFul << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20 /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFul << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_PARTNO_Pos 4 /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFul << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0 /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFul << SCB_CPUID_REVISION_Pos) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31 /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1ul << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28 /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1ul << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27 /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1ul << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26 /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1ul << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25 /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1ul << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23 /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1ul << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22 /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1ul << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12 /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFul << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11 /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1ul << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0 /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFul << SCB_ICSR_VECTACTIVE_Pos) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_VTOR_TBLBASE_Pos 29 /*!< SCB VTOR: TBLBASE Position */ +#define SCB_VTOR_TBLBASE_Msk (0x1FFul << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ + +#define SCB_VTOR_TBLOFF_Pos 7 /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x3FFFFFul << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16 /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFul << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16 /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFul << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15 /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1ul << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8 /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7ul << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2 /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1ul << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1 /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1ul << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0 /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1ul << SCB_AIRCR_VECTRESET_Pos) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4 /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1ul << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2 /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1ul << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1 /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1ul << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9 /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1ul << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8 /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1ul << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4 /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1ul << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3 /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1ul << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1 /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1ul << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0 /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1ul << SCB_CCR_NONBASETHRDENA_Pos) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18 /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1ul << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17 /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1ul << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16 /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1ul << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15 /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1ul << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14 /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1ul << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13 /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1ul << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12 /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1ul << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11 /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1ul << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10 /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1ul << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8 /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1ul << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7 /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1ul << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3 /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1ul << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1 /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1ul << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0 /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1ul << SCB_SHCSR_MEMFAULTACT_Pos) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Registers Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16 /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFul << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8 /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFul << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0 /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFul << SCB_CFSR_MEMFAULTSR_Pos) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* SCB Hard Fault Status Registers Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31 /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1ul << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30 /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1ul << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1 /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1ul << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4 /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1ul << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3 /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1ul << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2 /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1ul << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1 /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1ul << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0 /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1ul << SCB_DFSR_HALTED_Pos) /*!< SCB DFSR: HALTED Mask */ +/*@}*/ /* end of group CMSIS_CM3_SCB */ + + +/** @addtogroup CMSIS_CM3_SysTick CMSIS CM3 SysTick + memory mapped structure for SysTick + @{ + */ +typedef struct +{ + __IO uint32_t CTRL; /*!< Offset: 0x00 SysTick Control and Status Register */ + __IO uint32_t LOAD; /*!< Offset: 0x04 SysTick Reload Value Register */ + __IO uint32_t VAL; /*!< Offset: 0x08 SysTick Current Value Register */ + __I uint32_t CALIB; /*!< Offset: 0x0C SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16 /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1ul << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2 /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1ul << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1 /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1ul << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0 /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1ul << SysTick_CTRL_ENABLE_Pos) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0 /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFul << SysTick_LOAD_RELOAD_Pos) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0 /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFul << SysTick_VAL_CURRENT_Pos) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31 /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1ul << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30 /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1ul << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0 /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFul << SysTick_VAL_CURRENT_Pos) /*!< SysTick CALIB: TENMS Mask */ +/*@}*/ /* end of group CMSIS_CM3_SysTick */ + + +/** @addtogroup CMSIS_CM3_ITM CMSIS CM3 ITM + memory mapped structure for Instrumentation Trace Macrocell (ITM) + @{ + */ +typedef struct +{ + __O union + { + __O uint8_t u8; /*!< Offset: ITM Stimulus Port 8-bit */ + __O uint16_t u16; /*!< Offset: ITM Stimulus Port 16-bit */ + __O uint32_t u32; /*!< Offset: ITM Stimulus Port 32-bit */ + } PORT [32]; /*!< Offset: 0x00 ITM Stimulus Port Registers */ + uint32_t RESERVED0[864]; + __IO uint32_t TER; /*!< Offset: ITM Trace Enable Register */ + uint32_t RESERVED1[15]; + __IO uint32_t TPR; /*!< Offset: ITM Trace Privilege Register */ + uint32_t RESERVED2[15]; + __IO uint32_t TCR; /*!< Offset: ITM Trace Control Register */ + uint32_t RESERVED3[29]; + __IO uint32_t IWR; /*!< Offset: ITM Integration Write Register */ + __IO uint32_t IRR; /*!< Offset: ITM Integration Read Register */ + __IO uint32_t IMCR; /*!< Offset: ITM Integration Mode Control Register */ + uint32_t RESERVED4[43]; + __IO uint32_t LAR; /*!< Offset: ITM Lock Access Register */ + __IO uint32_t LSR; /*!< Offset: ITM Lock Status Register */ + uint32_t RESERVED5[6]; + __I uint32_t PID4; /*!< Offset: ITM Peripheral Identification Register #4 */ + __I uint32_t PID5; /*!< Offset: ITM Peripheral Identification Register #5 */ + __I uint32_t PID6; /*!< Offset: ITM Peripheral Identification Register #6 */ + __I uint32_t PID7; /*!< Offset: ITM Peripheral Identification Register #7 */ + __I uint32_t PID0; /*!< Offset: ITM Peripheral Identification Register #0 */ + __I uint32_t PID1; /*!< Offset: ITM Peripheral Identification Register #1 */ + __I uint32_t PID2; /*!< Offset: ITM Peripheral Identification Register #2 */ + __I uint32_t PID3; /*!< Offset: ITM Peripheral Identification Register #3 */ + __I uint32_t CID0; /*!< Offset: ITM Component Identification Register #0 */ + __I uint32_t CID1; /*!< Offset: ITM Component Identification Register #1 */ + __I uint32_t CID2; /*!< Offset: ITM Component Identification Register #2 */ + __I uint32_t CID3; /*!< Offset: ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0 /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFul << ITM_TPR_PRIVMASK_Pos) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23 /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1ul << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_ATBID_Pos 16 /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_ATBID_Msk (0x7Ful << ITM_TCR_ATBID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_TSPrescale_Pos 8 /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3ul << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4 /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1ul << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3 /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1ul << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2 /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1ul << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1 /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1ul << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0 /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1ul << ITM_TCR_ITMENA_Pos) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Integration Write Register Definitions */ +#define ITM_IWR_ATVALIDM_Pos 0 /*!< ITM IWR: ATVALIDM Position */ +#define ITM_IWR_ATVALIDM_Msk (1ul << ITM_IWR_ATVALIDM_Pos) /*!< ITM IWR: ATVALIDM Mask */ + +/* ITM Integration Read Register Definitions */ +#define ITM_IRR_ATREADYM_Pos 0 /*!< ITM IRR: ATREADYM Position */ +#define ITM_IRR_ATREADYM_Msk (1ul << ITM_IRR_ATREADYM_Pos) /*!< ITM IRR: ATREADYM Mask */ + +/* ITM Integration Mode Control Register Definitions */ +#define ITM_IMCR_INTEGRATION_Pos 0 /*!< ITM IMCR: INTEGRATION Position */ +#define ITM_IMCR_INTEGRATION_Msk (1ul << ITM_IMCR_INTEGRATION_Pos) /*!< ITM IMCR: INTEGRATION Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2 /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1ul << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1 /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1ul << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0 /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1ul << ITM_LSR_Present_Pos) /*!< ITM LSR: Present Mask */ +/*@}*/ /* end of group CMSIS_CM3_ITM */ + + +/** @addtogroup CMSIS_CM3_InterruptType CMSIS CM3 Interrupt Type + memory mapped structure for Interrupt Type + @{ + */ +typedef struct +{ + uint32_t RESERVED0; + __I uint32_t ICTR; /*!< Offset: 0x04 Interrupt Control Type Register */ +#if ((defined __CM3_REV) && (__CM3_REV >= 0x200)) + __IO uint32_t ACTLR; /*!< Offset: 0x08 Auxiliary Control Register */ +#else + uint32_t RESERVED1; +#endif +} InterruptType_Type; + +/* Interrupt Controller Type Register Definitions */ +#define InterruptType_ICTR_INTLINESNUM_Pos 0 /*!< InterruptType ICTR: INTLINESNUM Position */ +#define InterruptType_ICTR_INTLINESNUM_Msk (0x1Ful << InterruptType_ICTR_INTLINESNUM_Pos) /*!< InterruptType ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#define InterruptType_ACTLR_DISFOLD_Pos 2 /*!< InterruptType ACTLR: DISFOLD Position */ +#define InterruptType_ACTLR_DISFOLD_Msk (1ul << InterruptType_ACTLR_DISFOLD_Pos) /*!< InterruptType ACTLR: DISFOLD Mask */ + +#define InterruptType_ACTLR_DISDEFWBUF_Pos 1 /*!< InterruptType ACTLR: DISDEFWBUF Position */ +#define InterruptType_ACTLR_DISDEFWBUF_Msk (1ul << InterruptType_ACTLR_DISDEFWBUF_Pos) /*!< InterruptType ACTLR: DISDEFWBUF Mask */ + +#define InterruptType_ACTLR_DISMCYCINT_Pos 0 /*!< InterruptType ACTLR: DISMCYCINT Position */ +#define InterruptType_ACTLR_DISMCYCINT_Msk (1ul << InterruptType_ACTLR_DISMCYCINT_Pos) /*!< InterruptType ACTLR: DISMCYCINT Mask */ +/*@}*/ /* end of group CMSIS_CM3_InterruptType */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1) +/** @addtogroup CMSIS_CM3_MPU CMSIS CM3 MPU + memory mapped structure for Memory Protection Unit (MPU) + @{ + */ +typedef struct +{ + __I uint32_t TYPE; /*!< Offset: 0x00 MPU Type Register */ + __IO uint32_t CTRL; /*!< Offset: 0x04 MPU Control Register */ + __IO uint32_t RNR; /*!< Offset: 0x08 MPU Region RNRber Register */ + __IO uint32_t RBAR; /*!< Offset: 0x0C MPU Region Base Address Register */ + __IO uint32_t RASR; /*!< Offset: 0x10 MPU Region Attribute and Size Register */ + __IO uint32_t RBAR_A1; /*!< Offset: 0x14 MPU Alias 1 Region Base Address Register */ + __IO uint32_t RASR_A1; /*!< Offset: 0x18 MPU Alias 1 Region Attribute and Size Register */ + __IO uint32_t RBAR_A2; /*!< Offset: 0x1C MPU Alias 2 Region Base Address Register */ + __IO uint32_t RASR_A2; /*!< Offset: 0x20 MPU Alias 2 Region Attribute and Size Register */ + __IO uint32_t RBAR_A3; /*!< Offset: 0x24 MPU Alias 3 Region Base Address Register */ + __IO uint32_t RASR_A3; /*!< Offset: 0x28 MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +/* MPU Type Register */ +#define MPU_TYPE_IREGION_Pos 16 /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFul << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8 /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFul << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0 /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1ul << MPU_TYPE_SEPARATE_Pos) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register */ +#define MPU_CTRL_PRIVDEFENA_Pos 2 /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1ul << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1 /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1ul << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0 /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1ul << MPU_CTRL_ENABLE_Pos) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register */ +#define MPU_RNR_REGION_Pos 0 /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFul << MPU_RNR_REGION_Pos) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register */ +#define MPU_RBAR_ADDR_Pos 5 /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFul << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4 /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1ul << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0 /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFul << MPU_RBAR_REGION_Pos) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register */ +#define MPU_RASR_XN_Pos 28 /*!< MPU RASR: XN Position */ +#define MPU_RASR_XN_Msk (1ul << MPU_RASR_XN_Pos) /*!< MPU RASR: XN Mask */ + +#define MPU_RASR_AP_Pos 24 /*!< MPU RASR: AP Position */ +#define MPU_RASR_AP_Msk (7ul << MPU_RASR_AP_Pos) /*!< MPU RASR: AP Mask */ + +#define MPU_RASR_TEX_Pos 19 /*!< MPU RASR: TEX Position */ +#define MPU_RASR_TEX_Msk (7ul << MPU_RASR_TEX_Pos) /*!< MPU RASR: TEX Mask */ + +#define MPU_RASR_S_Pos 18 /*!< MPU RASR: Shareable bit Position */ +#define MPU_RASR_S_Msk (1ul << MPU_RASR_S_Pos) /*!< MPU RASR: Shareable bit Mask */ + +#define MPU_RASR_C_Pos 17 /*!< MPU RASR: Cacheable bit Position */ +#define MPU_RASR_C_Msk (1ul << MPU_RASR_C_Pos) /*!< MPU RASR: Cacheable bit Mask */ + +#define MPU_RASR_B_Pos 16 /*!< MPU RASR: Bufferable bit Position */ +#define MPU_RASR_B_Msk (1ul << MPU_RASR_B_Pos) /*!< MPU RASR: Bufferable bit Mask */ + +#define MPU_RASR_SRD_Pos 8 /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFul << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1 /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1Ful << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENA_Pos 0 /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENA_Msk (0x1Ful << MPU_RASR_ENA_Pos) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@}*/ /* end of group CMSIS_CM3_MPU */ +#endif + + +/** @addtogroup CMSIS_CM3_CoreDebug CMSIS CM3 Core Debug + memory mapped structure for Core Debug Register + @{ + */ +typedef struct +{ + __IO uint32_t DHCSR; /*!< Offset: 0x00 Debug Halting Control and Status Register */ + __O uint32_t DCRSR; /*!< Offset: 0x04 Debug Core Register Selector Register */ + __IO uint32_t DCRDR; /*!< Offset: 0x08 Debug Core Register Data Register */ + __IO uint32_t DEMCR; /*!< Offset: 0x0C Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16 /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFul << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25 /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1ul << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24 /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1ul << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19 /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1ul << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18 /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1ul << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17 /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1ul << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16 /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1ul << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5 /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1ul << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3 /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1ul << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2 /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1ul << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1 /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1ul << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0 /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1ul << CoreDebug_DHCSR_C_DEBUGEN_Pos) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register */ +#define CoreDebug_DCRSR_REGWnR_Pos 16 /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1ul << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0 /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1Ful << CoreDebug_DCRSR_REGSEL_Pos) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register */ +#define CoreDebug_DEMCR_TRCENA_Pos 24 /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1ul << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19 /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1ul << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18 /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1ul << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17 /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1ul << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16 /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1ul << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10 /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1ul << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9 /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1ul << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8 /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1ul << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7 /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1ul << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6 /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1ul << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5 /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1ul << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4 /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1ul << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0 /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1ul << CoreDebug_DEMCR_VC_CORERESET_Pos) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ +/*@}*/ /* end of group CMSIS_CM3_CoreDebug */ + + +/* Memory mapping of Cortex-M3 Hardware */ +#define SCS_BASE (0xE000E000) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000) /*!< ITM Base Address */ +#define CoreDebug_BASE (0xE000EDF0) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00) /*!< System Control Block Base Address */ + +#define InterruptType ((InterruptType_Type *) SCS_BASE) /*!< Interrupt Type Register */ +#define SCB ((SCB_Type *) SCB_BASE) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE) /*!< ITM configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1) + #define MPU_BASE (SCS_BASE + 0x0D90) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type*) MPU_BASE) /*!< Memory Protection Unit */ +#endif + +/*@}*/ /* end of group CMSIS_CM3_core_register */ + + +/******************************************************************************* + * Hardware Abstraction Layer + ******************************************************************************/ + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only avaiable in High optimization mode! */ + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + +#endif + + +/* ################### Compiler specific Intrinsics ########################### */ + +#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/ +/* ARM armcc specific functions */ + +#define __enable_fault_irq __enable_fiq +#define __disable_fault_irq __disable_fiq + +#define __NOP __nop +#define __WFI __wfi +#define __WFE __wfe +#define __SEV __sev +#define __ISB() __isb(0) +#define __DSB() __dsb(0) +#define __DMB() __dmb(0) +#define __REV __rev +#define __RBIT __rbit +#define __LDREXB(ptr) ((unsigned char ) __ldrex(ptr)) +#define __LDREXH(ptr) ((unsigned short) __ldrex(ptr)) +#define __LDREXW(ptr) ((unsigned int ) __ldrex(ptr)) +#define __STREXB(value, ptr) __strex(value, ptr) +#define __STREXH(value, ptr) __strex(value, ptr) +#define __STREXW(value, ptr) __strex(value, ptr) + + +/* intrinsic unsigned long long __ldrexd(volatile void *ptr) */ +/* intrinsic int __strexd(unsigned long long val, volatile void *ptr) */ +/* intrinsic void __enable_irq(); */ +/* intrinsic void __disable_irq(); */ + + +/** + * @brief Return the Process Stack Pointer + * + * @return ProcessStackPointer + * + * Return the actual process stack pointer + */ +extern uint32_t __get_PSP(void); + +/** + * @brief Set the Process Stack Pointer + * + * @param topOfProcStack Process Stack Pointer + * + * Assign the value ProcessStackPointer to the MSP + * (process stack pointer) Cortex processor register + */ +extern void __set_PSP(uint32_t topOfProcStack); + +/** + * @brief Return the Main Stack Pointer + * + * @return Main Stack Pointer + * + * Return the current value of the MSP (main stack pointer) + * Cortex processor register + */ +extern uint32_t __get_MSP(void); + +/** + * @brief Set the Main Stack Pointer + * + * @param topOfMainStack Main Stack Pointer + * + * Assign the value mainStackPointer to the MSP + * (main stack pointer) Cortex processor register + */ +extern void __set_MSP(uint32_t topOfMainStack); + +/** + * @brief Reverse byte order in unsigned short value + * + * @param value value to reverse + * @return reversed value + * + * Reverse byte order in unsigned short value + */ +extern uint32_t __REV16(uint16_t value); + +/** + * @brief Reverse byte order in signed short value with sign extension to integer + * + * @param value value to reverse + * @return reversed value + * + * Reverse byte order in signed short value with sign extension to integer + */ +extern int32_t __REVSH(int16_t value); + + +#if (__ARMCC_VERSION < 400000) + +/** + * @brief Remove the exclusive lock created by ldrex + * + * Removes the exclusive lock which is created by ldrex. + */ +extern void __CLREX(void); + +/** + * @brief Return the Base Priority value + * + * @return BasePriority + * + * Return the content of the base priority register + */ +extern uint32_t __get_BASEPRI(void); + +/** + * @brief Set the Base Priority value + * + * @param basePri BasePriority + * + * Set the base priority register + */ +extern void __set_BASEPRI(uint32_t basePri); + +/** + * @brief Return the Priority Mask value + * + * @return PriMask + * + * Return state of the priority mask bit from the priority mask register + */ +extern uint32_t __get_PRIMASK(void); + +/** + * @brief Set the Priority Mask value + * + * @param priMask PriMask + * + * Set the priority mask bit in the priority mask register + */ +extern void __set_PRIMASK(uint32_t priMask); + +/** + * @brief Return the Fault Mask value + * + * @return FaultMask + * + * Return the content of the fault mask register + */ +extern uint32_t __get_FAULTMASK(void); + +/** + * @brief Set the Fault Mask value + * + * @param faultMask faultMask value + * + * Set the fault mask register + */ +extern void __set_FAULTMASK(uint32_t faultMask); + +/** + * @brief Return the Control Register value + * + * @return Control value + * + * Return the content of the control register + */ +extern uint32_t __get_CONTROL(void); + +/** + * @brief Set the Control Register value + * + * @param control Control value + * + * Set the control register + */ +extern void __set_CONTROL(uint32_t control); + +#else /* (__ARMCC_VERSION >= 400000) */ + +/** + * @brief Remove the exclusive lock created by ldrex + * + * Removes the exclusive lock which is created by ldrex. + */ +#define __CLREX __clrex + +/** + * @brief Return the Base Priority value + * + * @return BasePriority + * + * Return the content of the base priority register + */ +static __INLINE uint32_t __get_BASEPRI(void) +{ + register uint32_t __regBasePri __ASM("basepri"); + return(__regBasePri); +} + +/** + * @brief Set the Base Priority value + * + * @param basePri BasePriority + * + * Set the base priority register + */ +static __INLINE void __set_BASEPRI(uint32_t basePri) +{ + register uint32_t __regBasePri __ASM("basepri"); + __regBasePri = (basePri & 0xff); +} + +/** + * @brief Return the Priority Mask value + * + * @return PriMask + * + * Return state of the priority mask bit from the priority mask register + */ +static __INLINE uint32_t __get_PRIMASK(void) +{ + register uint32_t __regPriMask __ASM("primask"); + return(__regPriMask); +} + +/** + * @brief Set the Priority Mask value + * + * @param priMask PriMask + * + * Set the priority mask bit in the priority mask register + */ +static __INLINE void __set_PRIMASK(uint32_t priMask) +{ + register uint32_t __regPriMask __ASM("primask"); + __regPriMask = (priMask); +} + +/** + * @brief Return the Fault Mask value + * + * @return FaultMask + * + * Return the content of the fault mask register + */ +static __INLINE uint32_t __get_FAULTMASK(void) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + return(__regFaultMask); +} + +/** + * @brief Set the Fault Mask value + * + * @param faultMask faultMask value + * + * Set the fault mask register + */ +static __INLINE void __set_FAULTMASK(uint32_t faultMask) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + __regFaultMask = (faultMask & 1); +} + +/** + * @brief Return the Control Register value + * + * @return Control value + * + * Return the content of the control register + */ +static __INLINE uint32_t __get_CONTROL(void) +{ + register uint32_t __regControl __ASM("control"); + return(__regControl); +} + +/** + * @brief Set the Control Register value + * + * @param control Control value + * + * Set the control register + */ +static __INLINE void __set_CONTROL(uint32_t control) +{ + register uint32_t __regControl __ASM("control"); + __regControl = control; +} + +#endif /* __ARMCC_VERSION */ + + + +#elif (defined (__ICCARM__)) /*------------------ ICC Compiler -------------------*/ +/* IAR iccarm specific functions */ + +#define __enable_irq __enable_interrupt /*!< global Interrupt enable */ +#define __disable_irq __disable_interrupt /*!< global Interrupt disable */ + +static __INLINE void __enable_fault_irq() { __ASM ("cpsie f"); } +static __INLINE void __disable_fault_irq() { __ASM ("cpsid f"); } + +#define __NOP __no_operation /*!< no operation intrinsic in IAR Compiler */ +static __INLINE void __WFI() { __ASM ("wfi"); } +static __INLINE void __WFE() { __ASM ("wfe"); } +static __INLINE void __SEV() { __ASM ("sev"); } +static __INLINE void __CLREX() { __ASM ("clrex"); } + +/* intrinsic void __ISB(void) */ +/* intrinsic void __DSB(void) */ +/* intrinsic void __DMB(void) */ +/* intrinsic void __set_PRIMASK(); */ +/* intrinsic void __get_PRIMASK(); */ +/* intrinsic void __set_FAULTMASK(); */ +/* intrinsic void __get_FAULTMASK(); */ +/* intrinsic uint32_t __REV(uint32_t value); */ +/* intrinsic uint32_t __REVSH(uint32_t value); */ +/* intrinsic unsigned long __STREX(unsigned long, unsigned long); */ +/* intrinsic unsigned long __LDREX(unsigned long *); */ + + +/** + * @brief Return the Process Stack Pointer + * + * @return ProcessStackPointer + * + * Return the actual process stack pointer + */ +extern uint32_t __get_PSP(void); + +/** + * @brief Set the Process Stack Pointer + * + * @param topOfProcStack Process Stack Pointer + * + * Assign the value ProcessStackPointer to the MSP + * (process stack pointer) Cortex processor register + */ +extern void __set_PSP(uint32_t topOfProcStack); + +/** + * @brief Return the Main Stack Pointer + * + * @return Main Stack Pointer + * + * Return the current value of the MSP (main stack pointer) + * Cortex processor register + */ +extern uint32_t __get_MSP(void); + +/** + * @brief Set the Main Stack Pointer + * + * @param topOfMainStack Main Stack Pointer + * + * Assign the value mainStackPointer to the MSP + * (main stack pointer) Cortex processor register + */ +extern void __set_MSP(uint32_t topOfMainStack); + +/** + * @brief Reverse byte order in unsigned short value + * + * @param value value to reverse + * @return reversed value + * + * Reverse byte order in unsigned short value + */ +extern uint32_t __REV16(uint16_t value); + +/** + * @brief Reverse bit order of value + * + * @param value value to reverse + * @return reversed value + * + * Reverse bit order of value + */ +extern uint32_t __RBIT(uint32_t value); + +/** + * @brief LDR Exclusive (8 bit) + * + * @param *addr address pointer + * @return value of (*address) + * + * Exclusive LDR command for 8 bit values) + */ +extern uint8_t __LDREXB(uint8_t *addr); + +/** + * @brief LDR Exclusive (16 bit) + * + * @param *addr address pointer + * @return value of (*address) + * + * Exclusive LDR command for 16 bit values + */ +extern uint16_t __LDREXH(uint16_t *addr); + +/** + * @brief LDR Exclusive (32 bit) + * + * @param *addr address pointer + * @return value of (*address) + * + * Exclusive LDR command for 32 bit values + */ +extern uint32_t __LDREXW(uint32_t *addr); + +/** + * @brief STR Exclusive (8 bit) + * + * @param value value to store + * @param *addr address pointer + * @return successful / failed + * + * Exclusive STR command for 8 bit values + */ +extern uint32_t __STREXB(uint8_t value, uint8_t *addr); + +/** + * @brief STR Exclusive (16 bit) + * + * @param value value to store + * @param *addr address pointer + * @return successful / failed + * + * Exclusive STR command for 16 bit values + */ +extern uint32_t __STREXH(uint16_t value, uint16_t *addr); + +/** + * @brief STR Exclusive (32 bit) + * + * @param value value to store + * @param *addr address pointer + * @return successful / failed + * + * Exclusive STR command for 32 bit values + */ +extern uint32_t __STREXW(uint32_t value, uint32_t *addr); + + + +#elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/ +/* GNU gcc specific functions */ + +static __INLINE void __enable_irq() { __ASM volatile ("cpsie i"); } +static __INLINE void __disable_irq() { __ASM volatile ("cpsid i"); } + +static __INLINE void __enable_fault_irq() { __ASM volatile ("cpsie f"); } +static __INLINE void __disable_fault_irq() { __ASM volatile ("cpsid f"); } + +static __INLINE void __NOP() { __ASM volatile ("nop"); } +static __INLINE void __WFI() { __ASM volatile ("wfi"); } +static __INLINE void __WFE() { __ASM volatile ("wfe"); } +static __INLINE void __SEV() { __ASM volatile ("sev"); } +static __INLINE void __ISB() { __ASM volatile ("isb"); } +static __INLINE void __DSB() { __ASM volatile ("dsb"); } +static __INLINE void __DMB() { __ASM volatile ("dmb"); } +static __INLINE void __CLREX() { __ASM volatile ("clrex"); } + + +/** + * @brief Return the Process Stack Pointer + * + * @return ProcessStackPointer + * + * Return the actual process stack pointer + */ +extern uint32_t __get_PSP(void); + +/** + * @brief Set the Process Stack Pointer + * + * @param topOfProcStack Process Stack Pointer + * + * Assign the value ProcessStackPointer to the MSP + * (process stack pointer) Cortex processor register + */ +extern void __set_PSP(uint32_t topOfProcStack); + +/** + * @brief Return the Main Stack Pointer + * + * @return Main Stack Pointer + * + * Return the current value of the MSP (main stack pointer) + * Cortex processor register + */ +extern uint32_t __get_MSP(void); + +/** + * @brief Set the Main Stack Pointer + * + * @param topOfMainStack Main Stack Pointer + * + * Assign the value mainStackPointer to the MSP + * (main stack pointer) Cortex processor register + */ +extern void __set_MSP(uint32_t topOfMainStack); + +/** + * @brief Return the Base Priority value + * + * @return BasePriority + * + * Return the content of the base priority register + */ +extern uint32_t __get_BASEPRI(void); + +/** + * @brief Set the Base Priority value + * + * @param basePri BasePriority + * + * Set the base priority register + */ +extern void __set_BASEPRI(uint32_t basePri); + +/** + * @brief Return the Priority Mask value + * + * @return PriMask + * + * Return state of the priority mask bit from the priority mask register + */ +extern uint32_t __get_PRIMASK(void); + +/** + * @brief Set the Priority Mask value + * + * @param priMask PriMask + * + * Set the priority mask bit in the priority mask register + */ +extern void __set_PRIMASK(uint32_t priMask); + +/** + * @brief Return the Fault Mask value + * + * @return FaultMask + * + * Return the content of the fault mask register + */ +extern uint32_t __get_FAULTMASK(void); + +/** + * @brief Set the Fault Mask value + * + * @param faultMask faultMask value + * + * Set the fault mask register + */ +extern void __set_FAULTMASK(uint32_t faultMask); + +/** + * @brief Return the Control Register value +* +* @return Control value + * + * Return the content of the control register + */ +extern uint32_t __get_CONTROL(void); + +/** + * @brief Set the Control Register value + * + * @param control Control value + * + * Set the control register + */ +extern void __set_CONTROL(uint32_t control); + +/** + * @brief Reverse byte order in integer value + * + * @param value value to reverse + * @return reversed value + * + * Reverse byte order in integer value + */ +extern uint32_t __REV(uint32_t value); + +/** + * @brief Reverse byte order in unsigned short value + * + * @param value value to reverse + * @return reversed value + * + * Reverse byte order in unsigned short value + */ +extern uint32_t __REV16(uint16_t value); + +/** + * @brief Reverse byte order in signed short value with sign extension to integer + * + * @param value value to reverse + * @return reversed value + * + * Reverse byte order in signed short value with sign extension to integer + */ +extern int32_t __REVSH(int16_t value); + +/** + * @brief Reverse bit order of value + * + * @param value value to reverse + * @return reversed value + * + * Reverse bit order of value + */ +extern uint32_t __RBIT(uint32_t value); + +/** + * @brief LDR Exclusive (8 bit) + * + * @param *addr address pointer + * @return value of (*address) + * + * Exclusive LDR command for 8 bit value + */ +extern uint8_t __LDREXB(uint8_t *addr); + +/** + * @brief LDR Exclusive (16 bit) + * + * @param *addr address pointer + * @return value of (*address) + * + * Exclusive LDR command for 16 bit values + */ +extern uint16_t __LDREXH(uint16_t *addr); + +/** + * @brief LDR Exclusive (32 bit) + * + * @param *addr address pointer + * @return value of (*address) + * + * Exclusive LDR command for 32 bit values + */ +extern uint32_t __LDREXW(uint32_t *addr); + +/** + * @brief STR Exclusive (8 bit) + * + * @param value value to store + * @param *addr address pointer + * @return successful / failed + * + * Exclusive STR command for 8 bit values + */ +extern uint32_t __STREXB(uint8_t value, uint8_t *addr); + +/** + * @brief STR Exclusive (16 bit) + * + * @param value value to store + * @param *addr address pointer + * @return successful / failed + * + * Exclusive STR command for 16 bit values + */ +extern uint32_t __STREXH(uint16_t value, uint16_t *addr); + +/** + * @brief STR Exclusive (32 bit) + * + * @param value value to store + * @param *addr address pointer + * @return successful / failed + * + * Exclusive STR command for 32 bit values + */ +extern uint32_t __STREXW(uint32_t value, uint32_t *addr); + + +#elif (defined (__TASKING__)) /*------------------ TASKING Compiler ---------------------*/ +/* TASKING carm specific functions */ + +/* + * The CMSIS functions have been implemented as intrinsics in the compiler. + * Please use "carm -?i" to get an up to date list of all instrinsics, + * Including the CMSIS ones. + */ + +#endif + + +/** @addtogroup CMSIS_CM3_Core_FunctionInterface CMSIS CM3 Core Function Interface + Core Function Interface containing: + - Core NVIC Functions + - Core SysTick Functions + - Core Reset Functions +*/ +/*@{*/ + +/* ########################## NVIC functions #################################### */ + +/** + * @brief Set the Priority Grouping in NVIC Interrupt Controller + * + * @param PriorityGroup is priority grouping field + * + * Set the priority grouping field using the required unlock sequence. + * The parameter priority_grouping is assigned to the field + * SCB->AIRCR [10:8] PRIGROUP field. Only values from 0..7 are used. + * In case of a conflict between priority grouping and available + * priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + */ +static __INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); /* clear bits to change */ + reg_value = (reg_value | + (0x5FA << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << 8)); /* Insert write key and priorty group */ + SCB->AIRCR = reg_value; +} + +/** + * @brief Get the Priority Grouping from NVIC Interrupt Controller + * + * @return priority grouping field + * + * Get the priority grouping from NVIC Interrupt Controller. + * priority grouping is SCB->AIRCR [10:8] PRIGROUP field. + */ +static __INLINE uint32_t NVIC_GetPriorityGrouping(void) +{ + return ((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos); /* read priority grouping field */ +} + +/** + * @brief Enable Interrupt in NVIC Interrupt Controller + * + * @param IRQn The positive number of the external interrupt to enable + * + * Enable a device specific interupt in the NVIC interrupt controller. + * The interrupt number cannot be a negative value. + */ +static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* enable interrupt */ +} + +/** + * @brief Disable the interrupt line for external interrupt specified + * + * @param IRQn The positive number of the external interrupt to disable + * + * Disable a device specific interupt in the NVIC interrupt controller. + * The interrupt number cannot be a negative value. + */ +static __INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* disable interrupt */ +} + +/** + * @brief Read the interrupt pending bit for a device specific interrupt source + * + * @param IRQn The number of the device specifc interrupt + * @return 1 = interrupt pending, 0 = interrupt not pending + * + * Read the pending register in NVIC and return 1 if its status is pending, + * otherwise it returns 0 + */ +static __INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t) ((NVIC->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if pending else 0 */ +} + +/** + * @brief Set the pending bit for an external interrupt + * + * @param IRQn The number of the interrupt for set pending + * + * Set the pending bit for the specified interrupt. + * The interrupt number cannot be a negative value. + */ +static __INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* set interrupt pending */ +} + +/** + * @brief Clear the pending bit for an external interrupt + * + * @param IRQn The number of the interrupt for clear pending + * + * Clear the pending bit for the specified interrupt. + * The interrupt number cannot be a negative value. + */ +static __INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */ +} + +/** + * @brief Read the active bit for an external interrupt + * + * @param IRQn The number of the interrupt for read active bit + * @return 1 = interrupt active, 0 = interrupt not active + * + * Read the active register in NVIC and returns 1 if its status is active, + * otherwise it returns 0. + */ +static __INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) +{ + return((uint32_t)((NVIC->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if active else 0 */ +} + +/** + * @brief Set the priority for an interrupt + * + * @param IRQn The number of the interrupt for set priority + * @param priority The priority to set + * + * Set the priority for the specified interrupt. The interrupt + * number can be positive to specify an external (device specific) + * interrupt, or negative to specify an internal (core) interrupt. + * + * Note: The priority cannot be set for every core interrupt. + */ +static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if(IRQn < 0) { + SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M3 System Interrupts */ + else { + NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for device specific Interrupts */ +} + +/** + * @brief Read the priority for an interrupt + * + * @param IRQn The number of the interrupt for get priority + * @return The priority for the interrupt + * + * Read the priority for the specified interrupt. The interrupt + * number can be positive to specify an external (device specific) + * interrupt, or negative to specify an internal (core) interrupt. + * + * The returned priority value is automatically aligned to the implemented + * priority bits of the microcontroller. + * + * Note: The priority cannot be set for every core interrupt. + */ +static __INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn) +{ + + if(IRQn < 0) { + return((uint32_t)(SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M3 system interrupts */ + else { + return((uint32_t)(NVIC->IP[(uint32_t)(IRQn)] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */ +} + + +/** + * @brief Encode the priority for an interrupt + * + * @param PriorityGroup The used priority group + * @param PreemptPriority The preemptive priority value (starting from 0) + * @param SubPriority The sub priority value (starting from 0) + * @return The encoded priority for the interrupt + * + * Encode the priority for an interrupt with the given priority group, + * preemptive priority value and sub priority value. + * In case of a conflict between priority grouping and available + * priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set. + * + * The returned priority value can be used for NVIC_SetPriority(...) function + */ +static __INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp; + SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS; + + return ( + ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) | + ((SubPriority & ((1 << (SubPriorityBits )) - 1))) + ); +} + + +/** + * @brief Decode the priority of an interrupt + * + * @param Priority The priority for the interrupt + * @param PriorityGroup The used priority group + * @param pPreemptPriority The preemptive priority value (starting from 0) + * @param pSubPriority The sub priority value (starting from 0) + * + * Decode an interrupt priority value with the given priority group to + * preemptive priority value and sub priority value. + * In case of a conflict between priority grouping and available + * priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set. + * + * The priority value can be retrieved with NVIC_GetPriority(...) function + */ +static __INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp; + SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS; + + *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1); + *pSubPriority = (Priority ) & ((1 << (SubPriorityBits )) - 1); +} + + + +/* ################################## SysTick function ############################################ */ + +#if (!defined (__Vendor_SysTickConfig)) || (__Vendor_SysTickConfig == 0) + +/** + * @brief Initialize and start the SysTick counter and its interrupt. + * + * @param ticks number of ticks between two interrupts + * @return 1 = failed, 0 = successful + * + * Initialise the system tick timer and its interrupt and start the + * system tick timer / counter in free running mode to generate + * periodical interrupts. + */ +static __INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */ + + SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Cortex-M0 System Interrupts */ + SysTick->VAL = 0; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0); /* Function successful */ +} + +#endif + + + + +/* ################################## Reset function ############################################ */ + +/** + * @brief Initiate a system reset request. + * + * Initiate a system reset request to reset the MCU + */ +static __INLINE void NVIC_SystemReset(void) +{ + SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + while(1); /* wait until reset */ +} + +/*@}*/ /* end of group CMSIS_CM3_Core_FunctionInterface */ + + + +/* ##################################### Debug In/Output function ########################################### */ + +/** @addtogroup CMSIS_CM3_CoreDebugInterface CMSIS CM3 Core Debug Interface + Core Debug Interface containing: + - Core Debug Receive / Transmit Functions + - Core Debug Defines + - Core Debug Variables +*/ +/*@{*/ + +extern volatile int ITM_RxBuffer; /*!< variable to receive characters */ +#define ITM_RXBUFFER_EMPTY 0x5AA55AA5 /*!< value identifying ITM_RxBuffer is ready for next character */ + + +/** + * @brief Outputs a character via the ITM channel 0 + * + * @param ch character to output + * @return character to output + * + * The function outputs a character via the ITM channel 0. + * The function returns when no debugger is connected that has booked the output. + * It is blocking when a debugger is connected, but the previous character send is not transmitted. + */ +static __INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk) && /* Trace enabled */ + (ITM->TCR & ITM_TCR_ITMENA_Msk) && /* ITM enabled */ + (ITM->TER & (1ul << 0) ) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0].u32 == 0); + ITM->PORT[0].u8 = (uint8_t) ch; + } + return (ch); +} + + +/** + * @brief Inputs a character via variable ITM_RxBuffer + * + * @return received character, -1 = no character received + * + * The function inputs a character via variable ITM_RxBuffer. + * The function returns when no debugger is connected that has booked the output. + * It is blocking when a debugger is connected, but the previous character send is not transmitted. + */ +static __INLINE int ITM_ReceiveChar (void) { + int ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + * @brief Check if a character via variable ITM_RxBuffer is available + * + * @return 1 = character available, 0 = no character available + * + * The function checks variable ITM_RxBuffer whether a character is available or not. + * The function returns '1' if a character is available and '0' if no character is available. + */ +static __INLINE int ITM_CheckChar (void) { + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) { + return (0); /* no character available */ + } else { + return (1); /* character available */ + } +} + +/*@}*/ /* end of group CMSIS_CM3_core_DebugInterface */ + + +#ifdef __cplusplus +} +#endif + +/*@}*/ /* end of group CMSIS_CM3_core_definitions */ + +#endif /* __CM3_CORE_H__ */ + +/*lint -restore */ diff --git a/STM32_4路称重_Git提交精简工程/src/CMSIS/stm32f10x.h b/STM32_4路称重_Git提交精简工程/src/CMSIS/stm32f10x.h new file mode 100755 index 0000000..af0c7c9 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/CMSIS/stm32f10x.h @@ -0,0 +1,8336 @@ +/** + ****************************************************************************** + * @file stm32f10x.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief CMSIS Cortex-M3 Device Peripheral Access Layer Header File. + * This file contains all the peripheral register's definitions, bits + * definitions and memory mapping for STM32F10x Connectivity line, + * High density, High density value line, Medium density, + * Medium density Value line, Low density, Low density Value line + * and XL-density devices. + * + * The file is the unique include file that the application programmer + * is using in the C source code, usually in main.c. This file contains: + * - Configuration section that allows to select: + * - The device used in the target application + * - To use or not the peripherals drivers in application code(i.e. + * code will be based on direct access to peripherals registers + * rather than drivers API), this option is controlled by + * "#define USE_STDPERIPH_DRIVER" + * - To change few application-specific parameters such as the HSE + * crystal frequency + * - Data structures and the address mapping for all peripherals + * - Peripheral's registers declarations and bits definition + * - Macros to access peripherals registers hardware + * + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32f10x + * @{ + */ + +#ifndef __STM32F10x_H +#define __STM32F10x_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup Library_configuration_section + * @{ + */ + +/* Uncomment the line below according to the target STM32 device used in your + application + */ + +#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL) + /* #define STM32F10X_LD */ /*!< STM32F10X_LD: STM32 Low density devices */ + /* #define STM32F10X_LD_VL */ /*!< STM32F10X_LD_VL: STM32 Low density Value Line devices */ + /* #define STM32F10X_MD */ /*!< STM32F10X_MD: STM32 Medium density devices */ + /* #define STM32F10X_MD_VL */ /*!< STM32F10X_MD_VL: STM32 Medium density Value Line devices */ + /* #define STM32F10X_HD */ /*!< STM32F10X_HD: STM32 High density devices */ + /* #define STM32F10X_HD_VL */ /*!< STM32F10X_HD_VL: STM32 High density value line devices */ + /* #define STM32F10X_XL */ /*!< STM32F10X_XL: STM32 XL-density devices */ + /* #define STM32F10X_CL */ /*!< STM32F10X_CL: STM32 Connectivity line devices */ +#endif +/* Tip: To avoid modifying this file each time you need to switch between these + devices, you can define the device in your toolchain compiler preprocessor. + + - Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers + where the Flash memory density ranges between 16 and 32 Kbytes. + - Low-density value line devices are STM32F100xx microcontrollers where the Flash + memory density ranges between 16 and 32 Kbytes. + - Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers + where the Flash memory density ranges between 64 and 128 Kbytes. + - Medium-density value line devices are STM32F100xx microcontrollers where the + Flash memory density ranges between 64 and 128 Kbytes. + - High-density devices are STM32F101xx and STM32F103xx microcontrollers where + the Flash memory density ranges between 256 and 512 Kbytes. + - High-density value line devices are STM32F100xx microcontrollers where the + Flash memory density ranges between 256 and 512 Kbytes. + - XL-density devices are STM32F101xx and STM32F103xx microcontrollers where + the Flash memory density ranges between 512 and 1024 Kbytes. + - Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers. + */ + +#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL) + #error "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)" +#endif + +#if !defined USE_STDPERIPH_DRIVER +/** + * @brief Comment the line below if you will not use the peripherals drivers. + In this case, these drivers will not be included and the application code will + be based on direct access to peripherals registers + */ + /*#define USE_STDPERIPH_DRIVER*/ +#endif + +/** + * @brief In the following line adjust the value of External High Speed oscillator (HSE) + used in your application + + Tip: To avoid modifying this file each time you need to use different HSE, you + can define the HSE value in your toolchain compiler preprocessor. + */ +#if !defined HSE_VALUE + #ifdef STM32F10X_CL + #define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ + #else + #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */ + #endif /* STM32F10X_CL */ +#endif /* HSE_VALUE */ + + +/** + * @brief In the following line adjust the External High Speed oscillator (HSE) Startup + Timeout value + */ +#define HSE_STARTUP_TIMEOUT ((uint16_t)0x0500) /*!< Time out for HSE start up */ + +#define HSI_VALUE ((uint32_t)8000000) /*!< Value of the Internal oscillator in Hz*/ + +/** + * @brief STM32F10x Standard Peripheral Library version number + */ +#define __STM32F10X_STDPERIPH_VERSION_MAIN (0x03) /*!< [31:24] main version */ +#define __STM32F10X_STDPERIPH_VERSION_SUB1 (0x05) /*!< [23:16] sub1 version */ +#define __STM32F10X_STDPERIPH_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ +#define __STM32F10X_STDPERIPH_VERSION_RC (0x00) /*!< [7:0] release candidate */ +#define __STM32F10X_STDPERIPH_VERSION ( (__STM32F10X_STDPERIPH_VERSION_MAIN << 24)\ + |(__STM32F10X_STDPERIPH_VERSION_SUB1 << 16)\ + |(__STM32F10X_STDPERIPH_VERSION_SUB2 << 8)\ + |(__STM32F10X_STDPERIPH_VERSION_RC)) + +/** + * @} + */ + +/** @addtogroup Configuration_section_for_CMSIS + * @{ + */ + +/** + * @brief Configuration of the Cortex-M3 Processor and Core Peripherals + */ +#ifdef STM32F10X_XL + #define __MPU_PRESENT 1 /*!< STM32 XL-density devices provide an MPU */ +#else + #define __MPU_PRESENT 0 /*!< Other STM32 devices does not provide an MPU */ +#endif /* STM32F10X_XL */ +#define __NVIC_PRIO_BITS 4 /*!< STM32 uses 4 Bits for the Priority Levels */ +#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */ + +/** + * @brief STM32F10x Interrupt Number Definition, according to the selected device + * in @ref Library_configuration_section + */ +typedef enum IRQn +{ +/****** Cortex-M3 Processor Exceptions Numbers ***************************************************/ + NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ + MemoryManagement_IRQn = -12, /*!< 4 Cortex-M3 Memory Management Interrupt */ + BusFault_IRQn = -11, /*!< 5 Cortex-M3 Bus Fault Interrupt */ + UsageFault_IRQn = -10, /*!< 6 Cortex-M3 Usage Fault Interrupt */ + SVCall_IRQn = -5, /*!< 11 Cortex-M3 SV Call Interrupt */ + DebugMonitor_IRQn = -4, /*!< 12 Cortex-M3 Debug Monitor Interrupt */ + PendSV_IRQn = -2, /*!< 14 Cortex-M3 Pend SV Interrupt */ + SysTick_IRQn = -1, /*!< 15 Cortex-M3 System Tick Interrupt */ + +/****** STM32 specific Interrupt Numbers *********************************************************/ + WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */ + PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */ + TAMPER_IRQn = 2, /*!< Tamper Interrupt */ + RTC_IRQn = 3, /*!< RTC global Interrupt */ + FLASH_IRQn = 4, /*!< FLASH global Interrupt */ + RCC_IRQn = 5, /*!< RCC global Interrupt */ + EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ + EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ + EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ + EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ + EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ + DMA1_Channel1_IRQn = 11, /*!< DMA1 Channel 1 global Interrupt */ + DMA1_Channel2_IRQn = 12, /*!< DMA1 Channel 2 global Interrupt */ + DMA1_Channel3_IRQn = 13, /*!< DMA1 Channel 3 global Interrupt */ + DMA1_Channel4_IRQn = 14, /*!< DMA1 Channel 4 global Interrupt */ + DMA1_Channel5_IRQn = 15, /*!< DMA1 Channel 5 global Interrupt */ + DMA1_Channel6_IRQn = 16, /*!< DMA1 Channel 6 global Interrupt */ + DMA1_Channel7_IRQn = 17, /*!< DMA1 Channel 7 global Interrupt */ + +#ifdef STM32F10X_LD + ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ + USB_HP_CAN1_TX_IRQn = 19, /*!< USB Device High Priority or CAN1 TX Interrupts */ + USB_LP_CAN1_RX0_IRQn = 20, /*!< USB Device Low Priority or CAN1 RX0 Interrupts */ + CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */ + CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */ + EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ + TIM1_BRK_IRQn = 24, /*!< TIM1 Break Interrupt */ + TIM1_UP_IRQn = 25, /*!< TIM1 Update Interrupt */ + TIM1_TRG_COM_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt */ + TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ + TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ + TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ + I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ + I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ + SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ + USART1_IRQn = 37, /*!< USART1 global Interrupt */ + USART2_IRQn = 38, /*!< USART2 global Interrupt */ + EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ + RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */ + USBWakeUp_IRQn = 42 /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */ +#endif /* STM32F10X_LD */ + +#ifdef STM32F10X_LD_VL + ADC1_IRQn = 18, /*!< ADC1 global Interrupt */ + EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ + TIM1_BRK_TIM15_IRQn = 24, /*!< TIM1 Break and TIM15 Interrupts */ + TIM1_UP_TIM16_IRQn = 25, /*!< TIM1 Update and TIM16 Interrupts */ + TIM1_TRG_COM_TIM17_IRQn = 26, /*!< TIM1 Trigger and Commutation and TIM17 Interrupt */ + TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ + TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ + TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ + I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ + I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ + SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ + USART1_IRQn = 37, /*!< USART1 global Interrupt */ + USART2_IRQn = 38, /*!< USART2 global Interrupt */ + EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ + RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */ + CEC_IRQn = 42, /*!< HDMI-CEC Interrupt */ + TIM6_DAC_IRQn = 54, /*!< TIM6 and DAC underrun Interrupt */ + TIM7_IRQn = 55 /*!< TIM7 Interrupt */ +#endif /* STM32F10X_LD_VL */ + +#ifdef STM32F10X_MD + ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ + USB_HP_CAN1_TX_IRQn = 19, /*!< USB Device High Priority or CAN1 TX Interrupts */ + USB_LP_CAN1_RX0_IRQn = 20, /*!< USB Device Low Priority or CAN1 RX0 Interrupts */ + CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */ + CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */ + EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ + TIM1_BRK_IRQn = 24, /*!< TIM1 Break Interrupt */ + TIM1_UP_IRQn = 25, /*!< TIM1 Update Interrupt */ + TIM1_TRG_COM_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt */ + TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ + TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ + TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ + TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ + I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ + I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ + I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ + I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ + SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ + SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ + USART1_IRQn = 37, /*!< USART1 global Interrupt */ + USART2_IRQn = 38, /*!< USART2 global Interrupt */ + USART3_IRQn = 39, /*!< USART3 global Interrupt */ + EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ + RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */ + USBWakeUp_IRQn = 42 /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */ +#endif /* STM32F10X_MD */ + +#ifdef STM32F10X_MD_VL + ADC1_IRQn = 18, /*!< ADC1 global Interrupt */ + EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ + TIM1_BRK_TIM15_IRQn = 24, /*!< TIM1 Break and TIM15 Interrupts */ + TIM1_UP_TIM16_IRQn = 25, /*!< TIM1 Update and TIM16 Interrupts */ + TIM1_TRG_COM_TIM17_IRQn = 26, /*!< TIM1 Trigger and Commutation and TIM17 Interrupt */ + TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ + TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ + TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ + TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ + I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ + I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ + I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ + I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ + SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ + SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ + USART1_IRQn = 37, /*!< USART1 global Interrupt */ + USART2_IRQn = 38, /*!< USART2 global Interrupt */ + USART3_IRQn = 39, /*!< USART3 global Interrupt */ + EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ + RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */ + CEC_IRQn = 42, /*!< HDMI-CEC Interrupt */ + TIM6_DAC_IRQn = 54, /*!< TIM6 and DAC underrun Interrupt */ + TIM7_IRQn = 55 /*!< TIM7 Interrupt */ +#endif /* STM32F10X_MD_VL */ + +#ifdef STM32F10X_HD + ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ + USB_HP_CAN1_TX_IRQn = 19, /*!< USB Device High Priority or CAN1 TX Interrupts */ + USB_LP_CAN1_RX0_IRQn = 20, /*!< USB Device Low Priority or CAN1 RX0 Interrupts */ + CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */ + CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */ + EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ + TIM1_BRK_IRQn = 24, /*!< TIM1 Break Interrupt */ + TIM1_UP_IRQn = 25, /*!< TIM1 Update Interrupt */ + TIM1_TRG_COM_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt */ + TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ + TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ + TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ + TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ + I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ + I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ + I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ + I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ + SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ + SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ + USART1_IRQn = 37, /*!< USART1 global Interrupt */ + USART2_IRQn = 38, /*!< USART2 global Interrupt */ + USART3_IRQn = 39, /*!< USART3 global Interrupt */ + EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ + RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */ + USBWakeUp_IRQn = 42, /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */ + TIM8_BRK_IRQn = 43, /*!< TIM8 Break Interrupt */ + TIM8_UP_IRQn = 44, /*!< TIM8 Update Interrupt */ + TIM8_TRG_COM_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt */ + TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare Interrupt */ + ADC3_IRQn = 47, /*!< ADC3 global Interrupt */ + FSMC_IRQn = 48, /*!< FSMC global Interrupt */ + SDIO_IRQn = 49, /*!< SDIO global Interrupt */ + TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ + SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ + UART4_IRQn = 52, /*!< UART4 global Interrupt */ + UART5_IRQn = 53, /*!< UART5 global Interrupt */ + TIM6_IRQn = 54, /*!< TIM6 global Interrupt */ + TIM7_IRQn = 55, /*!< TIM7 global Interrupt */ + DMA2_Channel1_IRQn = 56, /*!< DMA2 Channel 1 global Interrupt */ + DMA2_Channel2_IRQn = 57, /*!< DMA2 Channel 2 global Interrupt */ + DMA2_Channel3_IRQn = 58, /*!< DMA2 Channel 3 global Interrupt */ + DMA2_Channel4_5_IRQn = 59 /*!< DMA2 Channel 4 and Channel 5 global Interrupt */ +#endif /* STM32F10X_HD */ + +#ifdef STM32F10X_HD_VL + ADC1_IRQn = 18, /*!< ADC1 global Interrupt */ + EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ + TIM1_BRK_TIM15_IRQn = 24, /*!< TIM1 Break and TIM15 Interrupts */ + TIM1_UP_TIM16_IRQn = 25, /*!< TIM1 Update and TIM16 Interrupts */ + TIM1_TRG_COM_TIM17_IRQn = 26, /*!< TIM1 Trigger and Commutation and TIM17 Interrupt */ + TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ + TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ + TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ + TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ + I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ + I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ + I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ + I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ + SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ + SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ + USART1_IRQn = 37, /*!< USART1 global Interrupt */ + USART2_IRQn = 38, /*!< USART2 global Interrupt */ + USART3_IRQn = 39, /*!< USART3 global Interrupt */ + EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ + RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */ + CEC_IRQn = 42, /*!< HDMI-CEC Interrupt */ + TIM12_IRQn = 43, /*!< TIM12 global Interrupt */ + TIM13_IRQn = 44, /*!< TIM13 global Interrupt */ + TIM14_IRQn = 45, /*!< TIM14 global Interrupt */ + TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ + SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ + UART4_IRQn = 52, /*!< UART4 global Interrupt */ + UART5_IRQn = 53, /*!< UART5 global Interrupt */ + TIM6_DAC_IRQn = 54, /*!< TIM6 and DAC underrun Interrupt */ + TIM7_IRQn = 55, /*!< TIM7 Interrupt */ + DMA2_Channel1_IRQn = 56, /*!< DMA2 Channel 1 global Interrupt */ + DMA2_Channel2_IRQn = 57, /*!< DMA2 Channel 2 global Interrupt */ + DMA2_Channel3_IRQn = 58, /*!< DMA2 Channel 3 global Interrupt */ + DMA2_Channel4_5_IRQn = 59, /*!< DMA2 Channel 4 and Channel 5 global Interrupt */ + DMA2_Channel5_IRQn = 60 /*!< DMA2 Channel 5 global Interrupt (DMA2 Channel 5 is + mapped at position 60 only if the MISC_REMAP bit in + the AFIO_MAPR2 register is set) */ +#endif /* STM32F10X_HD_VL */ + +#ifdef STM32F10X_XL + ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ + USB_HP_CAN1_TX_IRQn = 19, /*!< USB Device High Priority or CAN1 TX Interrupts */ + USB_LP_CAN1_RX0_IRQn = 20, /*!< USB Device Low Priority or CAN1 RX0 Interrupts */ + CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */ + CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */ + EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ + TIM1_BRK_TIM9_IRQn = 24, /*!< TIM1 Break Interrupt and TIM9 global Interrupt */ + TIM1_UP_TIM10_IRQn = 25, /*!< TIM1 Update Interrupt and TIM10 global Interrupt */ + TIM1_TRG_COM_TIM11_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt */ + TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ + TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ + TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ + TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ + I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ + I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ + I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ + I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ + SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ + SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ + USART1_IRQn = 37, /*!< USART1 global Interrupt */ + USART2_IRQn = 38, /*!< USART2 global Interrupt */ + USART3_IRQn = 39, /*!< USART3 global Interrupt */ + EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ + RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */ + USBWakeUp_IRQn = 42, /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */ + TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global Interrupt */ + TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global Interrupt */ + TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ + TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare Interrupt */ + ADC3_IRQn = 47, /*!< ADC3 global Interrupt */ + FSMC_IRQn = 48, /*!< FSMC global Interrupt */ + SDIO_IRQn = 49, /*!< SDIO global Interrupt */ + TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ + SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ + UART4_IRQn = 52, /*!< UART4 global Interrupt */ + UART5_IRQn = 53, /*!< UART5 global Interrupt */ + TIM6_IRQn = 54, /*!< TIM6 global Interrupt */ + TIM7_IRQn = 55, /*!< TIM7 global Interrupt */ + DMA2_Channel1_IRQn = 56, /*!< DMA2 Channel 1 global Interrupt */ + DMA2_Channel2_IRQn = 57, /*!< DMA2 Channel 2 global Interrupt */ + DMA2_Channel3_IRQn = 58, /*!< DMA2 Channel 3 global Interrupt */ + DMA2_Channel4_5_IRQn = 59 /*!< DMA2 Channel 4 and Channel 5 global Interrupt */ +#endif /* STM32F10X_XL */ + +#ifdef STM32F10X_CL + ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ + CAN1_TX_IRQn = 19, /*!< USB Device High Priority or CAN1 TX Interrupts */ + CAN1_RX0_IRQn = 20, /*!< USB Device Low Priority or CAN1 RX0 Interrupts */ + CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */ + CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */ + EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ + TIM1_BRK_IRQn = 24, /*!< TIM1 Break Interrupt */ + TIM1_UP_IRQn = 25, /*!< TIM1 Update Interrupt */ + TIM1_TRG_COM_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt */ + TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ + TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ + TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ + TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ + I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ + I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ + I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ + I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ + SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ + SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ + USART1_IRQn = 37, /*!< USART1 global Interrupt */ + USART2_IRQn = 38, /*!< USART2 global Interrupt */ + USART3_IRQn = 39, /*!< USART3 global Interrupt */ + EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ + RTCAlarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */ + OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS WakeUp from suspend through EXTI Line Interrupt */ + TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ + SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ + UART4_IRQn = 52, /*!< UART4 global Interrupt */ + UART5_IRQn = 53, /*!< UART5 global Interrupt */ + TIM6_IRQn = 54, /*!< TIM6 global Interrupt */ + TIM7_IRQn = 55, /*!< TIM7 global Interrupt */ + DMA2_Channel1_IRQn = 56, /*!< DMA2 Channel 1 global Interrupt */ + DMA2_Channel2_IRQn = 57, /*!< DMA2 Channel 2 global Interrupt */ + DMA2_Channel3_IRQn = 58, /*!< DMA2 Channel 3 global Interrupt */ + DMA2_Channel4_IRQn = 59, /*!< DMA2 Channel 4 global Interrupt */ + DMA2_Channel5_IRQn = 60, /*!< DMA2 Channel 5 global Interrupt */ + ETH_IRQn = 61, /*!< Ethernet global Interrupt */ + ETH_WKUP_IRQn = 62, /*!< Ethernet Wakeup through EXTI line Interrupt */ + CAN2_TX_IRQn = 63, /*!< CAN2 TX Interrupt */ + CAN2_RX0_IRQn = 64, /*!< CAN2 RX0 Interrupt */ + CAN2_RX1_IRQn = 65, /*!< CAN2 RX1 Interrupt */ + CAN2_SCE_IRQn = 66, /*!< CAN2 SCE Interrupt */ + OTG_FS_IRQn = 67 /*!< USB OTG FS global Interrupt */ +#endif /* STM32F10X_CL */ +} IRQn_Type; + +/** + * @} + */ + +#include "core_cm3.h" +#include "system_stm32f10x.h" +#include + +/** @addtogroup Exported_types + * @{ + */ + +/*!< STM32F10x Standard Peripheral Library old types (maintained for legacy purpose) */ +typedef int32_t s32; +typedef int16_t s16; +typedef int8_t s8; + +typedef const int32_t sc32; /*!< Read Only */ +typedef const int16_t sc16; /*!< Read Only */ +typedef const int8_t sc8; /*!< Read Only */ + +typedef __IO int32_t vs32; +typedef __IO int16_t vs16; +typedef __IO int8_t vs8; + +typedef __I int32_t vsc32; /*!< Read Only */ +typedef __I int16_t vsc16; /*!< Read Only */ +typedef __I int8_t vsc8; /*!< Read Only */ + +typedef uint32_t u32; +typedef uint16_t u16; +typedef uint8_t u8; + +typedef const uint32_t uc32; /*!< Read Only */ +typedef const uint16_t uc16; /*!< Read Only */ +typedef const uint8_t uc8; /*!< Read Only */ + +typedef __IO uint32_t vu32; +typedef __IO uint16_t vu16; +typedef __IO uint8_t vu8; + +typedef __I uint32_t vuc32; /*!< Read Only */ +typedef __I uint16_t vuc16; /*!< Read Only */ +typedef __I uint8_t vuc8; /*!< Read Only */ + +typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus; + +typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState; +#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) + +typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus; + +/*!< STM32F10x Standard Peripheral Library old definitions (maintained for legacy purpose) */ +#define HSEStartUp_TimeOut HSE_STARTUP_TIMEOUT +#define HSE_Value HSE_VALUE +#define HSI_Value HSI_VALUE +/** + * @} + */ + +/** @addtogroup Peripheral_registers_structures + * @{ + */ + +/** + * @brief Analog to Digital Converter + */ + +typedef struct +{ + __IO uint32_t SR; + __IO uint32_t CR1; + __IO uint32_t CR2; + __IO uint32_t SMPR1; + __IO uint32_t SMPR2; + __IO uint32_t JOFR1; + __IO uint32_t JOFR2; + __IO uint32_t JOFR3; + __IO uint32_t JOFR4; + __IO uint32_t HTR; + __IO uint32_t LTR; + __IO uint32_t SQR1; + __IO uint32_t SQR2; + __IO uint32_t SQR3; + __IO uint32_t JSQR; + __IO uint32_t JDR1; + __IO uint32_t JDR2; + __IO uint32_t JDR3; + __IO uint32_t JDR4; + __IO uint32_t DR; +} ADC_TypeDef; + +/** + * @brief Backup Registers + */ + +typedef struct +{ + uint32_t RESERVED0; + __IO uint16_t DR1; + uint16_t RESERVED1; + __IO uint16_t DR2; + uint16_t RESERVED2; + __IO uint16_t DR3; + uint16_t RESERVED3; + __IO uint16_t DR4; + uint16_t RESERVED4; + __IO uint16_t DR5; + uint16_t RESERVED5; + __IO uint16_t DR6; + uint16_t RESERVED6; + __IO uint16_t DR7; + uint16_t RESERVED7; + __IO uint16_t DR8; + uint16_t RESERVED8; + __IO uint16_t DR9; + uint16_t RESERVED9; + __IO uint16_t DR10; + uint16_t RESERVED10; + __IO uint16_t RTCCR; + uint16_t RESERVED11; + __IO uint16_t CR; + uint16_t RESERVED12; + __IO uint16_t CSR; + uint16_t RESERVED13[5]; + __IO uint16_t DR11; + uint16_t RESERVED14; + __IO uint16_t DR12; + uint16_t RESERVED15; + __IO uint16_t DR13; + uint16_t RESERVED16; + __IO uint16_t DR14; + uint16_t RESERVED17; + __IO uint16_t DR15; + uint16_t RESERVED18; + __IO uint16_t DR16; + uint16_t RESERVED19; + __IO uint16_t DR17; + uint16_t RESERVED20; + __IO uint16_t DR18; + uint16_t RESERVED21; + __IO uint16_t DR19; + uint16_t RESERVED22; + __IO uint16_t DR20; + uint16_t RESERVED23; + __IO uint16_t DR21; + uint16_t RESERVED24; + __IO uint16_t DR22; + uint16_t RESERVED25; + __IO uint16_t DR23; + uint16_t RESERVED26; + __IO uint16_t DR24; + uint16_t RESERVED27; + __IO uint16_t DR25; + uint16_t RESERVED28; + __IO uint16_t DR26; + uint16_t RESERVED29; + __IO uint16_t DR27; + uint16_t RESERVED30; + __IO uint16_t DR28; + uint16_t RESERVED31; + __IO uint16_t DR29; + uint16_t RESERVED32; + __IO uint16_t DR30; + uint16_t RESERVED33; + __IO uint16_t DR31; + uint16_t RESERVED34; + __IO uint16_t DR32; + uint16_t RESERVED35; + __IO uint16_t DR33; + uint16_t RESERVED36; + __IO uint16_t DR34; + uint16_t RESERVED37; + __IO uint16_t DR35; + uint16_t RESERVED38; + __IO uint16_t DR36; + uint16_t RESERVED39; + __IO uint16_t DR37; + uint16_t RESERVED40; + __IO uint16_t DR38; + uint16_t RESERVED41; + __IO uint16_t DR39; + uint16_t RESERVED42; + __IO uint16_t DR40; + uint16_t RESERVED43; + __IO uint16_t DR41; + uint16_t RESERVED44; + __IO uint16_t DR42; + uint16_t RESERVED45; +} BKP_TypeDef; + +/** + * @brief Controller Area Network TxMailBox + */ + +typedef struct +{ + __IO uint32_t TIR; + __IO uint32_t TDTR; + __IO uint32_t TDLR; + __IO uint32_t TDHR; +} CAN_TxMailBox_TypeDef; + +/** + * @brief Controller Area Network FIFOMailBox + */ + +typedef struct +{ + __IO uint32_t RIR; + __IO uint32_t RDTR; + __IO uint32_t RDLR; + __IO uint32_t RDHR; +} CAN_FIFOMailBox_TypeDef; + +/** + * @brief Controller Area Network FilterRegister + */ + +typedef struct +{ + __IO uint32_t FR1; + __IO uint32_t FR2; +} CAN_FilterRegister_TypeDef; + +/** + * @brief Controller Area Network + */ + +typedef struct +{ + __IO uint32_t MCR; + __IO uint32_t MSR; + __IO uint32_t TSR; + __IO uint32_t RF0R; + __IO uint32_t RF1R; + __IO uint32_t IER; + __IO uint32_t ESR; + __IO uint32_t BTR; + uint32_t RESERVED0[88]; + CAN_TxMailBox_TypeDef sTxMailBox[3]; + CAN_FIFOMailBox_TypeDef sFIFOMailBox[2]; + uint32_t RESERVED1[12]; + __IO uint32_t FMR; + __IO uint32_t FM1R; + uint32_t RESERVED2; + __IO uint32_t FS1R; + uint32_t RESERVED3; + __IO uint32_t FFA1R; + uint32_t RESERVED4; + __IO uint32_t FA1R; + uint32_t RESERVED5[8]; +#ifndef STM32F10X_CL + CAN_FilterRegister_TypeDef sFilterRegister[14]; +#else + CAN_FilterRegister_TypeDef sFilterRegister[28]; +#endif /* STM32F10X_CL */ +} CAN_TypeDef; + +/** + * @brief Consumer Electronics Control (CEC) + */ +typedef struct +{ + __IO uint32_t CFGR; + __IO uint32_t OAR; + __IO uint32_t PRES; + __IO uint32_t ESR; + __IO uint32_t CSR; + __IO uint32_t TXD; + __IO uint32_t RXD; +} CEC_TypeDef; + +/** + * @brief CRC calculation unit + */ + +typedef struct +{ + __IO uint32_t DR; + __IO uint8_t IDR; + uint8_t RESERVED0; + uint16_t RESERVED1; + __IO uint32_t CR; +} CRC_TypeDef; + +/** + * @brief Digital to Analog Converter + */ + +typedef struct +{ + __IO uint32_t CR; + __IO uint32_t SWTRIGR; + __IO uint32_t DHR12R1; + __IO uint32_t DHR12L1; + __IO uint32_t DHR8R1; + __IO uint32_t DHR12R2; + __IO uint32_t DHR12L2; + __IO uint32_t DHR8R2; + __IO uint32_t DHR12RD; + __IO uint32_t DHR12LD; + __IO uint32_t DHR8RD; + __IO uint32_t DOR1; + __IO uint32_t DOR2; +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) + __IO uint32_t SR; +#endif +} DAC_TypeDef; + +/** + * @brief Debug MCU + */ + +typedef struct +{ + __IO uint32_t IDCODE; + __IO uint32_t CR; +}DBGMCU_TypeDef; + +/** + * @brief DMA Controller + */ + +typedef struct +{ + __IO uint32_t CCR; + __IO uint32_t CNDTR; + __IO uint32_t CPAR; + __IO uint32_t CMAR; +} DMA_Channel_TypeDef; + +typedef struct +{ + __IO uint32_t ISR; + __IO uint32_t IFCR; +} DMA_TypeDef; + +/** + * @brief Ethernet MAC + */ + +typedef struct +{ + __IO uint32_t MACCR; + __IO uint32_t MACFFR; + __IO uint32_t MACHTHR; + __IO uint32_t MACHTLR; + __IO uint32_t MACMIIAR; + __IO uint32_t MACMIIDR; + __IO uint32_t MACFCR; + __IO uint32_t MACVLANTR; /* 8 */ + uint32_t RESERVED0[2]; + __IO uint32_t MACRWUFFR; /* 11 */ + __IO uint32_t MACPMTCSR; + uint32_t RESERVED1[2]; + __IO uint32_t MACSR; /* 15 */ + __IO uint32_t MACIMR; + __IO uint32_t MACA0HR; + __IO uint32_t MACA0LR; + __IO uint32_t MACA1HR; + __IO uint32_t MACA1LR; + __IO uint32_t MACA2HR; + __IO uint32_t MACA2LR; + __IO uint32_t MACA3HR; + __IO uint32_t MACA3LR; /* 24 */ + uint32_t RESERVED2[40]; + __IO uint32_t MMCCR; /* 65 */ + __IO uint32_t MMCRIR; + __IO uint32_t MMCTIR; + __IO uint32_t MMCRIMR; + __IO uint32_t MMCTIMR; /* 69 */ + uint32_t RESERVED3[14]; + __IO uint32_t MMCTGFSCCR; /* 84 */ + __IO uint32_t MMCTGFMSCCR; + uint32_t RESERVED4[5]; + __IO uint32_t MMCTGFCR; + uint32_t RESERVED5[10]; + __IO uint32_t MMCRFCECR; + __IO uint32_t MMCRFAECR; + uint32_t RESERVED6[10]; + __IO uint32_t MMCRGUFCR; + uint32_t RESERVED7[334]; + __IO uint32_t PTPTSCR; + __IO uint32_t PTPSSIR; + __IO uint32_t PTPTSHR; + __IO uint32_t PTPTSLR; + __IO uint32_t PTPTSHUR; + __IO uint32_t PTPTSLUR; + __IO uint32_t PTPTSAR; + __IO uint32_t PTPTTHR; + __IO uint32_t PTPTTLR; + uint32_t RESERVED8[567]; + __IO uint32_t DMABMR; + __IO uint32_t DMATPDR; + __IO uint32_t DMARPDR; + __IO uint32_t DMARDLAR; + __IO uint32_t DMATDLAR; + __IO uint32_t DMASR; + __IO uint32_t DMAOMR; + __IO uint32_t DMAIER; + __IO uint32_t DMAMFBOCR; + uint32_t RESERVED9[9]; + __IO uint32_t DMACHTDR; + __IO uint32_t DMACHRDR; + __IO uint32_t DMACHTBAR; + __IO uint32_t DMACHRBAR; +} ETH_TypeDef; + +/** + * @brief External Interrupt/Event Controller + */ + +typedef struct +{ + __IO uint32_t IMR; + __IO uint32_t EMR; + __IO uint32_t RTSR; + __IO uint32_t FTSR; + __IO uint32_t SWIER; + __IO uint32_t PR; +} EXTI_TypeDef; + +/** + * @brief FLASH Registers + */ + +typedef struct +{ + __IO uint32_t ACR; + __IO uint32_t KEYR; + __IO uint32_t OPTKEYR; + __IO uint32_t SR; + __IO uint32_t CR; + __IO uint32_t AR; + __IO uint32_t RESERVED; + __IO uint32_t OBR; + __IO uint32_t WRPR; +#ifdef STM32F10X_XL + uint32_t RESERVED1[8]; + __IO uint32_t KEYR2; + uint32_t RESERVED2; + __IO uint32_t SR2; + __IO uint32_t CR2; + __IO uint32_t AR2; +#endif /* STM32F10X_XL */ +} FLASH_TypeDef; + +/** + * @brief Option Bytes Registers + */ + +typedef struct +{ + __IO uint16_t RDP; + __IO uint16_t USER; + __IO uint16_t Data0; + __IO uint16_t Data1; + __IO uint16_t WRP0; + __IO uint16_t WRP1; + __IO uint16_t WRP2; + __IO uint16_t WRP3; +} OB_TypeDef; + +/** + * @brief Flexible Static Memory Controller + */ + +typedef struct +{ + __IO uint32_t BTCR[8]; +} FSMC_Bank1_TypeDef; + +/** + * @brief Flexible Static Memory Controller Bank1E + */ + +typedef struct +{ + __IO uint32_t BWTR[7]; +} FSMC_Bank1E_TypeDef; + +/** + * @brief Flexible Static Memory Controller Bank2 + */ + +typedef struct +{ + __IO uint32_t PCR2; + __IO uint32_t SR2; + __IO uint32_t PMEM2; + __IO uint32_t PATT2; + uint32_t RESERVED0; + __IO uint32_t ECCR2; +} FSMC_Bank2_TypeDef; + +/** + * @brief Flexible Static Memory Controller Bank3 + */ + +typedef struct +{ + __IO uint32_t PCR3; + __IO uint32_t SR3; + __IO uint32_t PMEM3; + __IO uint32_t PATT3; + uint32_t RESERVED0; + __IO uint32_t ECCR3; +} FSMC_Bank3_TypeDef; + +/** + * @brief Flexible Static Memory Controller Bank4 + */ + +typedef struct +{ + __IO uint32_t PCR4; + __IO uint32_t SR4; + __IO uint32_t PMEM4; + __IO uint32_t PATT4; + __IO uint32_t PIO4; +} FSMC_Bank4_TypeDef; + +/** + * @brief General Purpose I/O + */ + +typedef struct +{ + __IO uint32_t CRL; + __IO uint32_t CRH; + __IO uint32_t IDR; + __IO uint32_t ODR; + __IO uint32_t BSRR; + __IO uint32_t BRR; + __IO uint32_t LCKR; +} GPIO_TypeDef; + +/** + * @brief Alternate Function I/O + */ + +typedef struct +{ + __IO uint32_t EVCR; + __IO uint32_t MAPR; + __IO uint32_t EXTICR[4]; + uint32_t RESERVED0; + __IO uint32_t MAPR2; +} AFIO_TypeDef; +/** + * @brief Inter Integrated Circuit Interface + */ + +typedef struct +{ + __IO uint16_t CR1; + uint16_t RESERVED0; + __IO uint16_t CR2; + uint16_t RESERVED1; + __IO uint16_t OAR1; + uint16_t RESERVED2; + __IO uint16_t OAR2; + uint16_t RESERVED3; + __IO uint16_t DR; + uint16_t RESERVED4; + __IO uint16_t SR1; + uint16_t RESERVED5; + __IO uint16_t SR2; + uint16_t RESERVED6; + __IO uint16_t CCR; + uint16_t RESERVED7; + __IO uint16_t TRISE; + uint16_t RESERVED8; +} I2C_TypeDef; + +/** + * @brief Independent WATCHDOG + */ + +typedef struct +{ + __IO uint32_t KR; + __IO uint32_t PR; + __IO uint32_t RLR; + __IO uint32_t SR; +} IWDG_TypeDef; + +/** + * @brief Power Control + */ + +typedef struct +{ + __IO uint32_t CR; + __IO uint32_t CSR; +} PWR_TypeDef; + +/** + * @brief Reset and Clock Control + */ + +typedef struct +{ + __IO uint32_t CR; + __IO uint32_t CFGR; + __IO uint32_t CIR; + __IO uint32_t APB2RSTR; + __IO uint32_t APB1RSTR; + __IO uint32_t AHBENR; + __IO uint32_t APB2ENR; + __IO uint32_t APB1ENR; + __IO uint32_t BDCR; + __IO uint32_t CSR; + +#ifdef STM32F10X_CL + __IO uint32_t AHBRSTR; + __IO uint32_t CFGR2; +#endif /* STM32F10X_CL */ + +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) + uint32_t RESERVED0; + __IO uint32_t CFGR2; +#endif /* STM32F10X_LD_VL || STM32F10X_MD_VL || STM32F10X_HD_VL */ +} RCC_TypeDef; + +/** + * @brief Real-Time Clock + */ + +typedef struct +{ + __IO uint16_t CRH; + uint16_t RESERVED0; + __IO uint16_t CRL; + uint16_t RESERVED1; + __IO uint16_t PRLH; + uint16_t RESERVED2; + __IO uint16_t PRLL; + uint16_t RESERVED3; + __IO uint16_t DIVH; + uint16_t RESERVED4; + __IO uint16_t DIVL; + uint16_t RESERVED5; + __IO uint16_t CNTH; + uint16_t RESERVED6; + __IO uint16_t CNTL; + uint16_t RESERVED7; + __IO uint16_t ALRH; + uint16_t RESERVED8; + __IO uint16_t ALRL; + uint16_t RESERVED9; +} RTC_TypeDef; + +/** + * @brief SD host Interface + */ + +typedef struct +{ + __IO uint32_t POWER; + __IO uint32_t CLKCR; + __IO uint32_t ARG; + __IO uint32_t CMD; + __I uint32_t RESPCMD; + __I uint32_t RESP1; + __I uint32_t RESP2; + __I uint32_t RESP3; + __I uint32_t RESP4; + __IO uint32_t DTIMER; + __IO uint32_t DLEN; + __IO uint32_t DCTRL; + __I uint32_t DCOUNT; + __I uint32_t STA; + __IO uint32_t ICR; + __IO uint32_t MASK; + uint32_t RESERVED0[2]; + __I uint32_t FIFOCNT; + uint32_t RESERVED1[13]; + __IO uint32_t FIFO; +} SDIO_TypeDef; + +/** + * @brief Serial Peripheral Interface + */ + +typedef struct +{ + __IO uint16_t CR1; + uint16_t RESERVED0; + __IO uint16_t CR2; + uint16_t RESERVED1; + __IO uint16_t SR; + uint16_t RESERVED2; + __IO uint16_t DR; + uint16_t RESERVED3; + __IO uint16_t CRCPR; + uint16_t RESERVED4; + __IO uint16_t RXCRCR; + uint16_t RESERVED5; + __IO uint16_t TXCRCR; + uint16_t RESERVED6; + __IO uint16_t I2SCFGR; + uint16_t RESERVED7; + __IO uint16_t I2SPR; + uint16_t RESERVED8; +} SPI_TypeDef; + +/** + * @brief TIM + */ + +typedef struct +{ + __IO uint16_t CR1; + uint16_t RESERVED0; + __IO uint16_t CR2; + uint16_t RESERVED1; + __IO uint16_t SMCR; + uint16_t RESERVED2; + __IO uint16_t DIER; + uint16_t RESERVED3; + __IO uint16_t SR; + uint16_t RESERVED4; + __IO uint16_t EGR; + uint16_t RESERVED5; + __IO uint16_t CCMR1; + uint16_t RESERVED6; + __IO uint16_t CCMR2; + uint16_t RESERVED7; + __IO uint16_t CCER; + uint16_t RESERVED8; + __IO uint16_t CNT; + uint16_t RESERVED9; + __IO uint16_t PSC; + uint16_t RESERVED10; + __IO uint16_t ARR; + uint16_t RESERVED11; + __IO uint16_t RCR; + uint16_t RESERVED12; + __IO uint16_t CCR1; + uint16_t RESERVED13; + __IO uint16_t CCR2; + uint16_t RESERVED14; + __IO uint16_t CCR3; + uint16_t RESERVED15; + __IO uint16_t CCR4; + uint16_t RESERVED16; + __IO uint16_t BDTR; + uint16_t RESERVED17; + __IO uint16_t DCR; + uint16_t RESERVED18; + __IO uint16_t DMAR; + uint16_t RESERVED19; +} TIM_TypeDef; + +/** + * @brief Universal Synchronous Asynchronous Receiver Transmitter + */ + +typedef struct +{ + __IO uint16_t SR; + uint16_t RESERVED0; + __IO uint16_t DR; + uint16_t RESERVED1; + __IO uint16_t BRR; + uint16_t RESERVED2; + __IO uint16_t CR1; + uint16_t RESERVED3; + __IO uint16_t CR2; + uint16_t RESERVED4; + __IO uint16_t CR3; + uint16_t RESERVED5; + __IO uint16_t GTPR; + uint16_t RESERVED6; +} USART_TypeDef; + +/** + * @brief Window WATCHDOG + */ + +typedef struct +{ + __IO uint32_t CR; + __IO uint32_t CFR; + __IO uint32_t SR; +} WWDG_TypeDef; + +/** + * @} + */ + +/** @addtogroup Peripheral_memory_map + * @{ + */ + + +#define FLASH_BASE ((uint32_t)0x08000000) /*!< FLASH base address in the alias region */ +#define SRAM_BASE ((uint32_t)0x20000000) /*!< SRAM base address in the alias region */ +#define PERIPH_BASE ((uint32_t)0x40000000) /*!< Peripheral base address in the alias region */ + +#define SRAM_BB_BASE ((uint32_t)0x22000000) /*!< SRAM base address in the bit-band region */ +#define PERIPH_BB_BASE ((uint32_t)0x42000000) /*!< Peripheral base address in the bit-band region */ + +#define FSMC_R_BASE ((uint32_t)0xA0000000) /*!< FSMC registers base address */ + +/*!< Peripheral memory map */ +#define APB1PERIPH_BASE PERIPH_BASE +#define APB2PERIPH_BASE (PERIPH_BASE + 0x10000) +#define AHBPERIPH_BASE (PERIPH_BASE + 0x20000) + +#define TIM2_BASE (APB1PERIPH_BASE + 0x0000) +#define TIM3_BASE (APB1PERIPH_BASE + 0x0400) +#define TIM4_BASE (APB1PERIPH_BASE + 0x0800) +#define TIM5_BASE (APB1PERIPH_BASE + 0x0C00) +#define TIM6_BASE (APB1PERIPH_BASE + 0x1000) +#define TIM7_BASE (APB1PERIPH_BASE + 0x1400) +#define TIM12_BASE (APB1PERIPH_BASE + 0x1800) +#define TIM13_BASE (APB1PERIPH_BASE + 0x1C00) +#define TIM14_BASE (APB1PERIPH_BASE + 0x2000) +#define RTC_BASE (APB1PERIPH_BASE + 0x2800) +#define WWDG_BASE (APB1PERIPH_BASE + 0x2C00) +#define IWDG_BASE (APB1PERIPH_BASE + 0x3000) +#define SPI2_BASE (APB1PERIPH_BASE + 0x3800) +#define SPI3_BASE (APB1PERIPH_BASE + 0x3C00) +#define USART2_BASE (APB1PERIPH_BASE + 0x4400) +#define USART3_BASE (APB1PERIPH_BASE + 0x4800) +#define UART4_BASE (APB1PERIPH_BASE + 0x4C00) +#define UART5_BASE (APB1PERIPH_BASE + 0x5000) +#define I2C1_BASE (APB1PERIPH_BASE + 0x5400) +#define I2C2_BASE (APB1PERIPH_BASE + 0x5800) +#define CAN1_BASE (APB1PERIPH_BASE + 0x6400) +#define CAN2_BASE (APB1PERIPH_BASE + 0x6800) +#define BKP_BASE (APB1PERIPH_BASE + 0x6C00) +#define PWR_BASE (APB1PERIPH_BASE + 0x7000) +#define DAC_BASE (APB1PERIPH_BASE + 0x7400) +#define CEC_BASE (APB1PERIPH_BASE + 0x7800) + +#define AFIO_BASE (APB2PERIPH_BASE + 0x0000) +#define EXTI_BASE (APB2PERIPH_BASE + 0x0400) +#define GPIOA_BASE (APB2PERIPH_BASE + 0x0800) +#define GPIOB_BASE (APB2PERIPH_BASE + 0x0C00) +#define GPIOC_BASE (APB2PERIPH_BASE + 0x1000) +#define GPIOD_BASE (APB2PERIPH_BASE + 0x1400) +#define GPIOE_BASE (APB2PERIPH_BASE + 0x1800) +#define GPIOF_BASE (APB2PERIPH_BASE + 0x1C00) +#define GPIOG_BASE (APB2PERIPH_BASE + 0x2000) +#define ADC1_BASE (APB2PERIPH_BASE + 0x2400) +#define ADC2_BASE (APB2PERIPH_BASE + 0x2800) +#define TIM1_BASE (APB2PERIPH_BASE + 0x2C00) +#define SPI1_BASE (APB2PERIPH_BASE + 0x3000) +#define TIM8_BASE (APB2PERIPH_BASE + 0x3400) +#define USART1_BASE (APB2PERIPH_BASE + 0x3800) +#define ADC3_BASE (APB2PERIPH_BASE + 0x3C00) +#define TIM15_BASE (APB2PERIPH_BASE + 0x4000) +#define TIM16_BASE (APB2PERIPH_BASE + 0x4400) +#define TIM17_BASE (APB2PERIPH_BASE + 0x4800) +#define TIM9_BASE (APB2PERIPH_BASE + 0x4C00) +#define TIM10_BASE (APB2PERIPH_BASE + 0x5000) +#define TIM11_BASE (APB2PERIPH_BASE + 0x5400) + +#define SDIO_BASE (PERIPH_BASE + 0x18000) + +#define DMA1_BASE (AHBPERIPH_BASE + 0x0000) +#define DMA1_Channel1_BASE (AHBPERIPH_BASE + 0x0008) +#define DMA1_Channel2_BASE (AHBPERIPH_BASE + 0x001C) +#define DMA1_Channel3_BASE (AHBPERIPH_BASE + 0x0030) +#define DMA1_Channel4_BASE (AHBPERIPH_BASE + 0x0044) +#define DMA1_Channel5_BASE (AHBPERIPH_BASE + 0x0058) +#define DMA1_Channel6_BASE (AHBPERIPH_BASE + 0x006C) +#define DMA1_Channel7_BASE (AHBPERIPH_BASE + 0x0080) +#define DMA2_BASE (AHBPERIPH_BASE + 0x0400) +#define DMA2_Channel1_BASE (AHBPERIPH_BASE + 0x0408) +#define DMA2_Channel2_BASE (AHBPERIPH_BASE + 0x041C) +#define DMA2_Channel3_BASE (AHBPERIPH_BASE + 0x0430) +#define DMA2_Channel4_BASE (AHBPERIPH_BASE + 0x0444) +#define DMA2_Channel5_BASE (AHBPERIPH_BASE + 0x0458) +#define RCC_BASE (AHBPERIPH_BASE + 0x1000) +#define CRC_BASE (AHBPERIPH_BASE + 0x3000) + +#define FLASH_R_BASE (AHBPERIPH_BASE + 0x2000) /*!< Flash registers base address */ +#define OB_BASE ((uint32_t)0x1FFFF800) /*!< Flash Option Bytes base address */ + +#define ETH_BASE (AHBPERIPH_BASE + 0x8000) +#define ETH_MAC_BASE (ETH_BASE) +#define ETH_MMC_BASE (ETH_BASE + 0x0100) +#define ETH_PTP_BASE (ETH_BASE + 0x0700) +#define ETH_DMA_BASE (ETH_BASE + 0x1000) + +#define FSMC_Bank1_R_BASE (FSMC_R_BASE + 0x0000) /*!< FSMC Bank1 registers base address */ +#define FSMC_Bank1E_R_BASE (FSMC_R_BASE + 0x0104) /*!< FSMC Bank1E registers base address */ +#define FSMC_Bank2_R_BASE (FSMC_R_BASE + 0x0060) /*!< FSMC Bank2 registers base address */ +#define FSMC_Bank3_R_BASE (FSMC_R_BASE + 0x0080) /*!< FSMC Bank3 registers base address */ +#define FSMC_Bank4_R_BASE (FSMC_R_BASE + 0x00A0) /*!< FSMC Bank4 registers base address */ + +#define DBGMCU_BASE ((uint32_t)0xE0042000) /*!< Debug MCU registers base address */ + +/** + * @} + */ + +/** @addtogroup Peripheral_declaration + * @{ + */ + +#define TIM2 ((TIM_TypeDef *) TIM2_BASE) +#define TIM3 ((TIM_TypeDef *) TIM3_BASE) +#define TIM4 ((TIM_TypeDef *) TIM4_BASE) +#define TIM5 ((TIM_TypeDef *) TIM5_BASE) +#define TIM6 ((TIM_TypeDef *) TIM6_BASE) +#define TIM7 ((TIM_TypeDef *) TIM7_BASE) +#define TIM12 ((TIM_TypeDef *) TIM12_BASE) +#define TIM13 ((TIM_TypeDef *) TIM13_BASE) +#define TIM14 ((TIM_TypeDef *) TIM14_BASE) +#define RTC ((RTC_TypeDef *) RTC_BASE) +#define WWDG ((WWDG_TypeDef *) WWDG_BASE) +#define IWDG ((IWDG_TypeDef *) IWDG_BASE) +#define SPI2 ((SPI_TypeDef *) SPI2_BASE) +#define SPI3 ((SPI_TypeDef *) SPI3_BASE) +#define USART2 ((USART_TypeDef *) USART2_BASE) +#define USART3 ((USART_TypeDef *) USART3_BASE) +#define UART4 ((USART_TypeDef *) UART4_BASE) +#define UART5 ((USART_TypeDef *) UART5_BASE) +#define I2C1 ((I2C_TypeDef *) I2C1_BASE) +#define I2C2 ((I2C_TypeDef *) I2C2_BASE) +#define CAN1 ((CAN_TypeDef *) CAN1_BASE) +#define CAN2 ((CAN_TypeDef *) CAN2_BASE) +#define BKP ((BKP_TypeDef *) BKP_BASE) +#define PWR ((PWR_TypeDef *) PWR_BASE) +#define DAC ((DAC_TypeDef *) DAC_BASE) +#define CEC ((CEC_TypeDef *) CEC_BASE) +#define AFIO ((AFIO_TypeDef *) AFIO_BASE) +#define EXTI ((EXTI_TypeDef *) EXTI_BASE) +#define GPIOA ((GPIO_TypeDef *) GPIOA_BASE) +#define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) +#define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) +#define GPIOD ((GPIO_TypeDef *) GPIOD_BASE) +#define GPIOE ((GPIO_TypeDef *) GPIOE_BASE) +#define GPIOF ((GPIO_TypeDef *) GPIOF_BASE) +#define GPIOG ((GPIO_TypeDef *) GPIOG_BASE) +#define ADC1 ((ADC_TypeDef *) ADC1_BASE) +#define ADC2 ((ADC_TypeDef *) ADC2_BASE) +#define TIM1 ((TIM_TypeDef *) TIM1_BASE) +#define SPI1 ((SPI_TypeDef *) SPI1_BASE) +#define TIM8 ((TIM_TypeDef *) TIM8_BASE) +#define USART1 ((USART_TypeDef *) USART1_BASE) +#define ADC3 ((ADC_TypeDef *) ADC3_BASE) +#define TIM15 ((TIM_TypeDef *) TIM15_BASE) +#define TIM16 ((TIM_TypeDef *) TIM16_BASE) +#define TIM17 ((TIM_TypeDef *) TIM17_BASE) +#define TIM9 ((TIM_TypeDef *) TIM9_BASE) +#define TIM10 ((TIM_TypeDef *) TIM10_BASE) +#define TIM11 ((TIM_TypeDef *) TIM11_BASE) +#define SDIO ((SDIO_TypeDef *) SDIO_BASE) +#define DMA1 ((DMA_TypeDef *) DMA1_BASE) +#define DMA2 ((DMA_TypeDef *) DMA2_BASE) +#define DMA1_Channel1 ((DMA_Channel_TypeDef *) DMA1_Channel1_BASE) +#define DMA1_Channel2 ((DMA_Channel_TypeDef *) DMA1_Channel2_BASE) +#define DMA1_Channel3 ((DMA_Channel_TypeDef *) DMA1_Channel3_BASE) +#define DMA1_Channel4 ((DMA_Channel_TypeDef *) DMA1_Channel4_BASE) +#define DMA1_Channel5 ((DMA_Channel_TypeDef *) DMA1_Channel5_BASE) +#define DMA1_Channel6 ((DMA_Channel_TypeDef *) DMA1_Channel6_BASE) +#define DMA1_Channel7 ((DMA_Channel_TypeDef *) DMA1_Channel7_BASE) +#define DMA2_Channel1 ((DMA_Channel_TypeDef *) DMA2_Channel1_BASE) +#define DMA2_Channel2 ((DMA_Channel_TypeDef *) DMA2_Channel2_BASE) +#define DMA2_Channel3 ((DMA_Channel_TypeDef *) DMA2_Channel3_BASE) +#define DMA2_Channel4 ((DMA_Channel_TypeDef *) DMA2_Channel4_BASE) +#define DMA2_Channel5 ((DMA_Channel_TypeDef *) DMA2_Channel5_BASE) +#define RCC ((RCC_TypeDef *) RCC_BASE) +#define CRC ((CRC_TypeDef *) CRC_BASE) +#define FLASH ((FLASH_TypeDef *) FLASH_R_BASE) +#define OB ((OB_TypeDef *) OB_BASE) +#define ETH ((ETH_TypeDef *) ETH_BASE) +#define FSMC_Bank1 ((FSMC_Bank1_TypeDef *) FSMC_Bank1_R_BASE) +#define FSMC_Bank1E ((FSMC_Bank1E_TypeDef *) FSMC_Bank1E_R_BASE) +#define FSMC_Bank2 ((FSMC_Bank2_TypeDef *) FSMC_Bank2_R_BASE) +#define FSMC_Bank3 ((FSMC_Bank3_TypeDef *) FSMC_Bank3_R_BASE) +#define FSMC_Bank4 ((FSMC_Bank4_TypeDef *) FSMC_Bank4_R_BASE) +#define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) + +/** + * @} + */ + +/** @addtogroup Exported_constants + * @{ + */ + + /** @addtogroup Peripheral_Registers_Bits_Definition + * @{ + */ + +/******************************************************************************/ +/* Peripheral Registers_Bits_Definition */ +/******************************************************************************/ + +/******************************************************************************/ +/* */ +/* CRC calculation unit */ +/* */ +/******************************************************************************/ + +/******************* Bit definition for CRC_DR register *********************/ +#define CRC_DR_DR ((uint32_t)0xFFFFFFFF) /*!< Data register bits */ + + +/******************* Bit definition for CRC_IDR register ********************/ +#define CRC_IDR_IDR ((uint8_t)0xFF) /*!< General-purpose 8-bit data register bits */ + + +/******************** Bit definition for CRC_CR register ********************/ +#define CRC_CR_RESET ((uint8_t)0x01) /*!< RESET bit */ + +/******************************************************************************/ +/* */ +/* Power Control */ +/* */ +/******************************************************************************/ + +/******************** Bit definition for PWR_CR register ********************/ +#define PWR_CR_LPDS ((uint16_t)0x0001) /*!< Low-Power Deepsleep */ +#define PWR_CR_PDDS ((uint16_t)0x0002) /*!< Power Down Deepsleep */ +#define PWR_CR_CWUF ((uint16_t)0x0004) /*!< Clear Wakeup Flag */ +#define PWR_CR_CSBF ((uint16_t)0x0008) /*!< Clear Standby Flag */ +#define PWR_CR_PVDE ((uint16_t)0x0010) /*!< Power Voltage Detector Enable */ + +#define PWR_CR_PLS ((uint16_t)0x00E0) /*!< PLS[2:0] bits (PVD Level Selection) */ +#define PWR_CR_PLS_0 ((uint16_t)0x0020) /*!< Bit 0 */ +#define PWR_CR_PLS_1 ((uint16_t)0x0040) /*!< Bit 1 */ +#define PWR_CR_PLS_2 ((uint16_t)0x0080) /*!< Bit 2 */ + +/*!< PVD level configuration */ +#define PWR_CR_PLS_2V2 ((uint16_t)0x0000) /*!< PVD level 2.2V */ +#define PWR_CR_PLS_2V3 ((uint16_t)0x0020) /*!< PVD level 2.3V */ +#define PWR_CR_PLS_2V4 ((uint16_t)0x0040) /*!< PVD level 2.4V */ +#define PWR_CR_PLS_2V5 ((uint16_t)0x0060) /*!< PVD level 2.5V */ +#define PWR_CR_PLS_2V6 ((uint16_t)0x0080) /*!< PVD level 2.6V */ +#define PWR_CR_PLS_2V7 ((uint16_t)0x00A0) /*!< PVD level 2.7V */ +#define PWR_CR_PLS_2V8 ((uint16_t)0x00C0) /*!< PVD level 2.8V */ +#define PWR_CR_PLS_2V9 ((uint16_t)0x00E0) /*!< PVD level 2.9V */ + +#define PWR_CR_DBP ((uint16_t)0x0100) /*!< Disable Backup Domain write protection */ + + +/******************* Bit definition for PWR_CSR register ********************/ +#define PWR_CSR_WUF ((uint16_t)0x0001) /*!< Wakeup Flag */ +#define PWR_CSR_SBF ((uint16_t)0x0002) /*!< Standby Flag */ +#define PWR_CSR_PVDO ((uint16_t)0x0004) /*!< PVD Output */ +#define PWR_CSR_EWUP ((uint16_t)0x0100) /*!< Enable WKUP pin */ + +/******************************************************************************/ +/* */ +/* Backup registers */ +/* */ +/******************************************************************************/ + +/******************* Bit definition for BKP_DR1 register ********************/ +#define BKP_DR1_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR2 register ********************/ +#define BKP_DR2_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR3 register ********************/ +#define BKP_DR3_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR4 register ********************/ +#define BKP_DR4_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR5 register ********************/ +#define BKP_DR5_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR6 register ********************/ +#define BKP_DR6_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR7 register ********************/ +#define BKP_DR7_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR8 register ********************/ +#define BKP_DR8_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR9 register ********************/ +#define BKP_DR9_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR10 register *******************/ +#define BKP_DR10_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR11 register *******************/ +#define BKP_DR11_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR12 register *******************/ +#define BKP_DR12_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR13 register *******************/ +#define BKP_DR13_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR14 register *******************/ +#define BKP_DR14_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR15 register *******************/ +#define BKP_DR15_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR16 register *******************/ +#define BKP_DR16_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR17 register *******************/ +#define BKP_DR17_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/****************** Bit definition for BKP_DR18 register ********************/ +#define BKP_DR18_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR19 register *******************/ +#define BKP_DR19_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR20 register *******************/ +#define BKP_DR20_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR21 register *******************/ +#define BKP_DR21_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR22 register *******************/ +#define BKP_DR22_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR23 register *******************/ +#define BKP_DR23_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR24 register *******************/ +#define BKP_DR24_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR25 register *******************/ +#define BKP_DR25_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR26 register *******************/ +#define BKP_DR26_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR27 register *******************/ +#define BKP_DR27_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR28 register *******************/ +#define BKP_DR28_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR29 register *******************/ +#define BKP_DR29_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR30 register *******************/ +#define BKP_DR30_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR31 register *******************/ +#define BKP_DR31_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR32 register *******************/ +#define BKP_DR32_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR33 register *******************/ +#define BKP_DR33_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR34 register *******************/ +#define BKP_DR34_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR35 register *******************/ +#define BKP_DR35_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR36 register *******************/ +#define BKP_DR36_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR37 register *******************/ +#define BKP_DR37_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR38 register *******************/ +#define BKP_DR38_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR39 register *******************/ +#define BKP_DR39_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR40 register *******************/ +#define BKP_DR40_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR41 register *******************/ +#define BKP_DR41_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/******************* Bit definition for BKP_DR42 register *******************/ +#define BKP_DR42_D ((uint16_t)0xFFFF) /*!< Backup data */ + +/****************** Bit definition for BKP_RTCCR register *******************/ +#define BKP_RTCCR_CAL ((uint16_t)0x007F) /*!< Calibration value */ +#define BKP_RTCCR_CCO ((uint16_t)0x0080) /*!< Calibration Clock Output */ +#define BKP_RTCCR_ASOE ((uint16_t)0x0100) /*!< Alarm or Second Output Enable */ +#define BKP_RTCCR_ASOS ((uint16_t)0x0200) /*!< Alarm or Second Output Selection */ + +/******************** Bit definition for BKP_CR register ********************/ +#define BKP_CR_TPE ((uint8_t)0x01) /*!< TAMPER pin enable */ +#define BKP_CR_TPAL ((uint8_t)0x02) /*!< TAMPER pin active level */ + +/******************* Bit definition for BKP_CSR register ********************/ +#define BKP_CSR_CTE ((uint16_t)0x0001) /*!< Clear Tamper event */ +#define BKP_CSR_CTI ((uint16_t)0x0002) /*!< Clear Tamper Interrupt */ +#define BKP_CSR_TPIE ((uint16_t)0x0004) /*!< TAMPER Pin interrupt enable */ +#define BKP_CSR_TEF ((uint16_t)0x0100) /*!< Tamper Event Flag */ +#define BKP_CSR_TIF ((uint16_t)0x0200) /*!< Tamper Interrupt Flag */ + +/******************************************************************************/ +/* */ +/* Reset and Clock Control */ +/* */ +/******************************************************************************/ + +/******************** Bit definition for RCC_CR register ********************/ +#define RCC_CR_HSION ((uint32_t)0x00000001) /*!< Internal High Speed clock enable */ +#define RCC_CR_HSIRDY ((uint32_t)0x00000002) /*!< Internal High Speed clock ready flag */ +#define RCC_CR_HSITRIM ((uint32_t)0x000000F8) /*!< Internal High Speed clock trimming */ +#define RCC_CR_HSICAL ((uint32_t)0x0000FF00) /*!< Internal High Speed clock Calibration */ +#define RCC_CR_HSEON ((uint32_t)0x00010000) /*!< External High Speed clock enable */ +#define RCC_CR_HSERDY ((uint32_t)0x00020000) /*!< External High Speed clock ready flag */ +#define RCC_CR_HSEBYP ((uint32_t)0x00040000) /*!< External High Speed clock Bypass */ +#define RCC_CR_CSSON ((uint32_t)0x00080000) /*!< Clock Security System enable */ +#define RCC_CR_PLLON ((uint32_t)0x01000000) /*!< PLL enable */ +#define RCC_CR_PLLRDY ((uint32_t)0x02000000) /*!< PLL clock ready flag */ + +#ifdef STM32F10X_CL + #define RCC_CR_PLL2ON ((uint32_t)0x04000000) /*!< PLL2 enable */ + #define RCC_CR_PLL2RDY ((uint32_t)0x08000000) /*!< PLL2 clock ready flag */ + #define RCC_CR_PLL3ON ((uint32_t)0x10000000) /*!< PLL3 enable */ + #define RCC_CR_PLL3RDY ((uint32_t)0x20000000) /*!< PLL3 clock ready flag */ +#endif /* STM32F10X_CL */ + +/******************* Bit definition for RCC_CFGR register *******************/ +/*!< SW configuration */ +#define RCC_CFGR_SW ((uint32_t)0x00000003) /*!< SW[1:0] bits (System clock Switch) */ +#define RCC_CFGR_SW_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define RCC_CFGR_SW_1 ((uint32_t)0x00000002) /*!< Bit 1 */ + +#define RCC_CFGR_SW_HSI ((uint32_t)0x00000000) /*!< HSI selected as system clock */ +#define RCC_CFGR_SW_HSE ((uint32_t)0x00000001) /*!< HSE selected as system clock */ +#define RCC_CFGR_SW_PLL ((uint32_t)0x00000002) /*!< PLL selected as system clock */ + +/*!< SWS configuration */ +#define RCC_CFGR_SWS ((uint32_t)0x0000000C) /*!< SWS[1:0] bits (System Clock Switch Status) */ +#define RCC_CFGR_SWS_0 ((uint32_t)0x00000004) /*!< Bit 0 */ +#define RCC_CFGR_SWS_1 ((uint32_t)0x00000008) /*!< Bit 1 */ + +#define RCC_CFGR_SWS_HSI ((uint32_t)0x00000000) /*!< HSI oscillator used as system clock */ +#define RCC_CFGR_SWS_HSE ((uint32_t)0x00000004) /*!< HSE oscillator used as system clock */ +#define RCC_CFGR_SWS_PLL ((uint32_t)0x00000008) /*!< PLL used as system clock */ + +/*!< HPRE configuration */ +#define RCC_CFGR_HPRE ((uint32_t)0x000000F0) /*!< HPRE[3:0] bits (AHB prescaler) */ +#define RCC_CFGR_HPRE_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define RCC_CFGR_HPRE_1 ((uint32_t)0x00000020) /*!< Bit 1 */ +#define RCC_CFGR_HPRE_2 ((uint32_t)0x00000040) /*!< Bit 2 */ +#define RCC_CFGR_HPRE_3 ((uint32_t)0x00000080) /*!< Bit 3 */ + +#define RCC_CFGR_HPRE_DIV1 ((uint32_t)0x00000000) /*!< SYSCLK not divided */ +#define RCC_CFGR_HPRE_DIV2 ((uint32_t)0x00000080) /*!< SYSCLK divided by 2 */ +#define RCC_CFGR_HPRE_DIV4 ((uint32_t)0x00000090) /*!< SYSCLK divided by 4 */ +#define RCC_CFGR_HPRE_DIV8 ((uint32_t)0x000000A0) /*!< SYSCLK divided by 8 */ +#define RCC_CFGR_HPRE_DIV16 ((uint32_t)0x000000B0) /*!< SYSCLK divided by 16 */ +#define RCC_CFGR_HPRE_DIV64 ((uint32_t)0x000000C0) /*!< SYSCLK divided by 64 */ +#define RCC_CFGR_HPRE_DIV128 ((uint32_t)0x000000D0) /*!< SYSCLK divided by 128 */ +#define RCC_CFGR_HPRE_DIV256 ((uint32_t)0x000000E0) /*!< SYSCLK divided by 256 */ +#define RCC_CFGR_HPRE_DIV512 ((uint32_t)0x000000F0) /*!< SYSCLK divided by 512 */ + +/*!< PPRE1 configuration */ +#define RCC_CFGR_PPRE1 ((uint32_t)0x00000700) /*!< PRE1[2:0] bits (APB1 prescaler) */ +#define RCC_CFGR_PPRE1_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define RCC_CFGR_PPRE1_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define RCC_CFGR_PPRE1_2 ((uint32_t)0x00000400) /*!< Bit 2 */ + +#define RCC_CFGR_PPRE1_DIV1 ((uint32_t)0x00000000) /*!< HCLK not divided */ +#define RCC_CFGR_PPRE1_DIV2 ((uint32_t)0x00000400) /*!< HCLK divided by 2 */ +#define RCC_CFGR_PPRE1_DIV4 ((uint32_t)0x00000500) /*!< HCLK divided by 4 */ +#define RCC_CFGR_PPRE1_DIV8 ((uint32_t)0x00000600) /*!< HCLK divided by 8 */ +#define RCC_CFGR_PPRE1_DIV16 ((uint32_t)0x00000700) /*!< HCLK divided by 16 */ + +/*!< PPRE2 configuration */ +#define RCC_CFGR_PPRE2 ((uint32_t)0x00003800) /*!< PRE2[2:0] bits (APB2 prescaler) */ +#define RCC_CFGR_PPRE2_0 ((uint32_t)0x00000800) /*!< Bit 0 */ +#define RCC_CFGR_PPRE2_1 ((uint32_t)0x00001000) /*!< Bit 1 */ +#define RCC_CFGR_PPRE2_2 ((uint32_t)0x00002000) /*!< Bit 2 */ + +#define RCC_CFGR_PPRE2_DIV1 ((uint32_t)0x00000000) /*!< HCLK not divided */ +#define RCC_CFGR_PPRE2_DIV2 ((uint32_t)0x00002000) /*!< HCLK divided by 2 */ +#define RCC_CFGR_PPRE2_DIV4 ((uint32_t)0x00002800) /*!< HCLK divided by 4 */ +#define RCC_CFGR_PPRE2_DIV8 ((uint32_t)0x00003000) /*!< HCLK divided by 8 */ +#define RCC_CFGR_PPRE2_DIV16 ((uint32_t)0x00003800) /*!< HCLK divided by 16 */ + +/*!< ADCPPRE configuration */ +#define RCC_CFGR_ADCPRE ((uint32_t)0x0000C000) /*!< ADCPRE[1:0] bits (ADC prescaler) */ +#define RCC_CFGR_ADCPRE_0 ((uint32_t)0x00004000) /*!< Bit 0 */ +#define RCC_CFGR_ADCPRE_1 ((uint32_t)0x00008000) /*!< Bit 1 */ + +#define RCC_CFGR_ADCPRE_DIV2 ((uint32_t)0x00000000) /*!< PCLK2 divided by 2 */ +#define RCC_CFGR_ADCPRE_DIV4 ((uint32_t)0x00004000) /*!< PCLK2 divided by 4 */ +#define RCC_CFGR_ADCPRE_DIV6 ((uint32_t)0x00008000) /*!< PCLK2 divided by 6 */ +#define RCC_CFGR_ADCPRE_DIV8 ((uint32_t)0x0000C000) /*!< PCLK2 divided by 8 */ + +#define RCC_CFGR_PLLSRC ((uint32_t)0x00010000) /*!< PLL entry clock source */ + +#define RCC_CFGR_PLLXTPRE ((uint32_t)0x00020000) /*!< HSE divider for PLL entry */ + +/*!< PLLMUL configuration */ +#define RCC_CFGR_PLLMULL ((uint32_t)0x003C0000) /*!< PLLMUL[3:0] bits (PLL multiplication factor) */ +#define RCC_CFGR_PLLMULL_0 ((uint32_t)0x00040000) /*!< Bit 0 */ +#define RCC_CFGR_PLLMULL_1 ((uint32_t)0x00080000) /*!< Bit 1 */ +#define RCC_CFGR_PLLMULL_2 ((uint32_t)0x00100000) /*!< Bit 2 */ +#define RCC_CFGR_PLLMULL_3 ((uint32_t)0x00200000) /*!< Bit 3 */ + +#ifdef STM32F10X_CL + #define RCC_CFGR_PLLSRC_HSI_Div2 ((uint32_t)0x00000000) /*!< HSI clock divided by 2 selected as PLL entry clock source */ + #define RCC_CFGR_PLLSRC_PREDIV1 ((uint32_t)0x00010000) /*!< PREDIV1 clock selected as PLL entry clock source */ + + #define RCC_CFGR_PLLXTPRE_PREDIV1 ((uint32_t)0x00000000) /*!< PREDIV1 clock not divided for PLL entry */ + #define RCC_CFGR_PLLXTPRE_PREDIV1_Div2 ((uint32_t)0x00020000) /*!< PREDIV1 clock divided by 2 for PLL entry */ + + #define RCC_CFGR_PLLMULL4 ((uint32_t)0x00080000) /*!< PLL input clock * 4 */ + #define RCC_CFGR_PLLMULL5 ((uint32_t)0x000C0000) /*!< PLL input clock * 5 */ + #define RCC_CFGR_PLLMULL6 ((uint32_t)0x00100000) /*!< PLL input clock * 6 */ + #define RCC_CFGR_PLLMULL7 ((uint32_t)0x00140000) /*!< PLL input clock * 7 */ + #define RCC_CFGR_PLLMULL8 ((uint32_t)0x00180000) /*!< PLL input clock * 8 */ + #define RCC_CFGR_PLLMULL9 ((uint32_t)0x001C0000) /*!< PLL input clock * 9 */ + #define RCC_CFGR_PLLMULL6_5 ((uint32_t)0x00340000) /*!< PLL input clock * 6.5 */ + + #define RCC_CFGR_OTGFSPRE ((uint32_t)0x00400000) /*!< USB OTG FS prescaler */ + +/*!< MCO configuration */ + #define RCC_CFGR_MCO ((uint32_t)0x0F000000) /*!< MCO[3:0] bits (Microcontroller Clock Output) */ + #define RCC_CFGR_MCO_0 ((uint32_t)0x01000000) /*!< Bit 0 */ + #define RCC_CFGR_MCO_1 ((uint32_t)0x02000000) /*!< Bit 1 */ + #define RCC_CFGR_MCO_2 ((uint32_t)0x04000000) /*!< Bit 2 */ + #define RCC_CFGR_MCO_3 ((uint32_t)0x08000000) /*!< Bit 3 */ + + #define RCC_CFGR_MCO_NOCLOCK ((uint32_t)0x00000000) /*!< No clock */ + #define RCC_CFGR_MCO_SYSCLK ((uint32_t)0x04000000) /*!< System clock selected as MCO source */ + #define RCC_CFGR_MCO_HSI ((uint32_t)0x05000000) /*!< HSI clock selected as MCO source */ + #define RCC_CFGR_MCO_HSE ((uint32_t)0x06000000) /*!< HSE clock selected as MCO source */ + #define RCC_CFGR_MCO_PLLCLK_Div2 ((uint32_t)0x07000000) /*!< PLL clock divided by 2 selected as MCO source */ + #define RCC_CFGR_MCO_PLL2CLK ((uint32_t)0x08000000) /*!< PLL2 clock selected as MCO source*/ + #define RCC_CFGR_MCO_PLL3CLK_Div2 ((uint32_t)0x09000000) /*!< PLL3 clock divided by 2 selected as MCO source*/ + #define RCC_CFGR_MCO_Ext_HSE ((uint32_t)0x0A000000) /*!< XT1 external 3-25 MHz oscillator clock selected as MCO source */ + #define RCC_CFGR_MCO_PLL3CLK ((uint32_t)0x0B000000) /*!< PLL3 clock selected as MCO source */ +#elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) + #define RCC_CFGR_PLLSRC_HSI_Div2 ((uint32_t)0x00000000) /*!< HSI clock divided by 2 selected as PLL entry clock source */ + #define RCC_CFGR_PLLSRC_PREDIV1 ((uint32_t)0x00010000) /*!< PREDIV1 clock selected as PLL entry clock source */ + + #define RCC_CFGR_PLLXTPRE_PREDIV1 ((uint32_t)0x00000000) /*!< PREDIV1 clock not divided for PLL entry */ + #define RCC_CFGR_PLLXTPRE_PREDIV1_Div2 ((uint32_t)0x00020000) /*!< PREDIV1 clock divided by 2 for PLL entry */ + + #define RCC_CFGR_PLLMULL2 ((uint32_t)0x00000000) /*!< PLL input clock*2 */ + #define RCC_CFGR_PLLMULL3 ((uint32_t)0x00040000) /*!< PLL input clock*3 */ + #define RCC_CFGR_PLLMULL4 ((uint32_t)0x00080000) /*!< PLL input clock*4 */ + #define RCC_CFGR_PLLMULL5 ((uint32_t)0x000C0000) /*!< PLL input clock*5 */ + #define RCC_CFGR_PLLMULL6 ((uint32_t)0x00100000) /*!< PLL input clock*6 */ + #define RCC_CFGR_PLLMULL7 ((uint32_t)0x00140000) /*!< PLL input clock*7 */ + #define RCC_CFGR_PLLMULL8 ((uint32_t)0x00180000) /*!< PLL input clock*8 */ + #define RCC_CFGR_PLLMULL9 ((uint32_t)0x001C0000) /*!< PLL input clock*9 */ + #define RCC_CFGR_PLLMULL10 ((uint32_t)0x00200000) /*!< PLL input clock10 */ + #define RCC_CFGR_PLLMULL11 ((uint32_t)0x00240000) /*!< PLL input clock*11 */ + #define RCC_CFGR_PLLMULL12 ((uint32_t)0x00280000) /*!< PLL input clock*12 */ + #define RCC_CFGR_PLLMULL13 ((uint32_t)0x002C0000) /*!< PLL input clock*13 */ + #define RCC_CFGR_PLLMULL14 ((uint32_t)0x00300000) /*!< PLL input clock*14 */ + #define RCC_CFGR_PLLMULL15 ((uint32_t)0x00340000) /*!< PLL input clock*15 */ + #define RCC_CFGR_PLLMULL16 ((uint32_t)0x00380000) /*!< PLL input clock*16 */ + +/*!< MCO configuration */ + #define RCC_CFGR_MCO ((uint32_t)0x07000000) /*!< MCO[2:0] bits (Microcontroller Clock Output) */ + #define RCC_CFGR_MCO_0 ((uint32_t)0x01000000) /*!< Bit 0 */ + #define RCC_CFGR_MCO_1 ((uint32_t)0x02000000) /*!< Bit 1 */ + #define RCC_CFGR_MCO_2 ((uint32_t)0x04000000) /*!< Bit 2 */ + + #define RCC_CFGR_MCO_NOCLOCK ((uint32_t)0x00000000) /*!< No clock */ + #define RCC_CFGR_MCO_SYSCLK ((uint32_t)0x04000000) /*!< System clock selected as MCO source */ + #define RCC_CFGR_MCO_HSI ((uint32_t)0x05000000) /*!< HSI clock selected as MCO source */ + #define RCC_CFGR_MCO_HSE ((uint32_t)0x06000000) /*!< HSE clock selected as MCO source */ + #define RCC_CFGR_MCO_PLL ((uint32_t)0x07000000) /*!< PLL clock divided by 2 selected as MCO source */ +#else + #define RCC_CFGR_PLLSRC_HSI_Div2 ((uint32_t)0x00000000) /*!< HSI clock divided by 2 selected as PLL entry clock source */ + #define RCC_CFGR_PLLSRC_HSE ((uint32_t)0x00010000) /*!< HSE clock selected as PLL entry clock source */ + + #define RCC_CFGR_PLLXTPRE_HSE ((uint32_t)0x00000000) /*!< HSE clock not divided for PLL entry */ + #define RCC_CFGR_PLLXTPRE_HSE_Div2 ((uint32_t)0x00020000) /*!< HSE clock divided by 2 for PLL entry */ + + #define RCC_CFGR_PLLMULL2 ((uint32_t)0x00000000) /*!< PLL input clock*2 */ + #define RCC_CFGR_PLLMULL3 ((uint32_t)0x00040000) /*!< PLL input clock*3 */ + #define RCC_CFGR_PLLMULL4 ((uint32_t)0x00080000) /*!< PLL input clock*4 */ + #define RCC_CFGR_PLLMULL5 ((uint32_t)0x000C0000) /*!< PLL input clock*5 */ + #define RCC_CFGR_PLLMULL6 ((uint32_t)0x00100000) /*!< PLL input clock*6 */ + #define RCC_CFGR_PLLMULL7 ((uint32_t)0x00140000) /*!< PLL input clock*7 */ + #define RCC_CFGR_PLLMULL8 ((uint32_t)0x00180000) /*!< PLL input clock*8 */ + #define RCC_CFGR_PLLMULL9 ((uint32_t)0x001C0000) /*!< PLL input clock*9 */ + #define RCC_CFGR_PLLMULL10 ((uint32_t)0x00200000) /*!< PLL input clock10 */ + #define RCC_CFGR_PLLMULL11 ((uint32_t)0x00240000) /*!< PLL input clock*11 */ + #define RCC_CFGR_PLLMULL12 ((uint32_t)0x00280000) /*!< PLL input clock*12 */ + #define RCC_CFGR_PLLMULL13 ((uint32_t)0x002C0000) /*!< PLL input clock*13 */ + #define RCC_CFGR_PLLMULL14 ((uint32_t)0x00300000) /*!< PLL input clock*14 */ + #define RCC_CFGR_PLLMULL15 ((uint32_t)0x00340000) /*!< PLL input clock*15 */ + #define RCC_CFGR_PLLMULL16 ((uint32_t)0x00380000) /*!< PLL input clock*16 */ + #define RCC_CFGR_USBPRE ((uint32_t)0x00400000) /*!< USB Device prescaler */ + +/*!< MCO configuration */ + #define RCC_CFGR_MCO ((uint32_t)0x07000000) /*!< MCO[2:0] bits (Microcontroller Clock Output) */ + #define RCC_CFGR_MCO_0 ((uint32_t)0x01000000) /*!< Bit 0 */ + #define RCC_CFGR_MCO_1 ((uint32_t)0x02000000) /*!< Bit 1 */ + #define RCC_CFGR_MCO_2 ((uint32_t)0x04000000) /*!< Bit 2 */ + + #define RCC_CFGR_MCO_NOCLOCK ((uint32_t)0x00000000) /*!< No clock */ + #define RCC_CFGR_MCO_SYSCLK ((uint32_t)0x04000000) /*!< System clock selected as MCO source */ + #define RCC_CFGR_MCO_HSI ((uint32_t)0x05000000) /*!< HSI clock selected as MCO source */ + #define RCC_CFGR_MCO_HSE ((uint32_t)0x06000000) /*!< HSE clock selected as MCO source */ + #define RCC_CFGR_MCO_PLL ((uint32_t)0x07000000) /*!< PLL clock divided by 2 selected as MCO source */ +#endif /* STM32F10X_CL */ + +/*!<****************** Bit definition for RCC_CIR register ********************/ +#define RCC_CIR_LSIRDYF ((uint32_t)0x00000001) /*!< LSI Ready Interrupt flag */ +#define RCC_CIR_LSERDYF ((uint32_t)0x00000002) /*!< LSE Ready Interrupt flag */ +#define RCC_CIR_HSIRDYF ((uint32_t)0x00000004) /*!< HSI Ready Interrupt flag */ +#define RCC_CIR_HSERDYF ((uint32_t)0x00000008) /*!< HSE Ready Interrupt flag */ +#define RCC_CIR_PLLRDYF ((uint32_t)0x00000010) /*!< PLL Ready Interrupt flag */ +#define RCC_CIR_CSSF ((uint32_t)0x00000080) /*!< Clock Security System Interrupt flag */ +#define RCC_CIR_LSIRDYIE ((uint32_t)0x00000100) /*!< LSI Ready Interrupt Enable */ +#define RCC_CIR_LSERDYIE ((uint32_t)0x00000200) /*!< LSE Ready Interrupt Enable */ +#define RCC_CIR_HSIRDYIE ((uint32_t)0x00000400) /*!< HSI Ready Interrupt Enable */ +#define RCC_CIR_HSERDYIE ((uint32_t)0x00000800) /*!< HSE Ready Interrupt Enable */ +#define RCC_CIR_PLLRDYIE ((uint32_t)0x00001000) /*!< PLL Ready Interrupt Enable */ +#define RCC_CIR_LSIRDYC ((uint32_t)0x00010000) /*!< LSI Ready Interrupt Clear */ +#define RCC_CIR_LSERDYC ((uint32_t)0x00020000) /*!< LSE Ready Interrupt Clear */ +#define RCC_CIR_HSIRDYC ((uint32_t)0x00040000) /*!< HSI Ready Interrupt Clear */ +#define RCC_CIR_HSERDYC ((uint32_t)0x00080000) /*!< HSE Ready Interrupt Clear */ +#define RCC_CIR_PLLRDYC ((uint32_t)0x00100000) /*!< PLL Ready Interrupt Clear */ +#define RCC_CIR_CSSC ((uint32_t)0x00800000) /*!< Clock Security System Interrupt Clear */ + +#ifdef STM32F10X_CL + #define RCC_CIR_PLL2RDYF ((uint32_t)0x00000020) /*!< PLL2 Ready Interrupt flag */ + #define RCC_CIR_PLL3RDYF ((uint32_t)0x00000040) /*!< PLL3 Ready Interrupt flag */ + #define RCC_CIR_PLL2RDYIE ((uint32_t)0x00002000) /*!< PLL2 Ready Interrupt Enable */ + #define RCC_CIR_PLL3RDYIE ((uint32_t)0x00004000) /*!< PLL3 Ready Interrupt Enable */ + #define RCC_CIR_PLL2RDYC ((uint32_t)0x00200000) /*!< PLL2 Ready Interrupt Clear */ + #define RCC_CIR_PLL3RDYC ((uint32_t)0x00400000) /*!< PLL3 Ready Interrupt Clear */ +#endif /* STM32F10X_CL */ + +/***************** Bit definition for RCC_APB2RSTR register *****************/ +#define RCC_APB2RSTR_AFIORST ((uint32_t)0x00000001) /*!< Alternate Function I/O reset */ +#define RCC_APB2RSTR_IOPARST ((uint32_t)0x00000004) /*!< I/O port A reset */ +#define RCC_APB2RSTR_IOPBRST ((uint32_t)0x00000008) /*!< I/O port B reset */ +#define RCC_APB2RSTR_IOPCRST ((uint32_t)0x00000010) /*!< I/O port C reset */ +#define RCC_APB2RSTR_IOPDRST ((uint32_t)0x00000020) /*!< I/O port D reset */ +#define RCC_APB2RSTR_ADC1RST ((uint32_t)0x00000200) /*!< ADC 1 interface reset */ + +#if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL) +#define RCC_APB2RSTR_ADC2RST ((uint32_t)0x00000400) /*!< ADC 2 interface reset */ +#endif + +#define RCC_APB2RSTR_TIM1RST ((uint32_t)0x00000800) /*!< TIM1 Timer reset */ +#define RCC_APB2RSTR_SPI1RST ((uint32_t)0x00001000) /*!< SPI 1 reset */ +#define RCC_APB2RSTR_USART1RST ((uint32_t)0x00004000) /*!< USART1 reset */ + +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) +#define RCC_APB2RSTR_TIM15RST ((uint32_t)0x00010000) /*!< TIM15 Timer reset */ +#define RCC_APB2RSTR_TIM16RST ((uint32_t)0x00020000) /*!< TIM16 Timer reset */ +#define RCC_APB2RSTR_TIM17RST ((uint32_t)0x00040000) /*!< TIM17 Timer reset */ +#endif + +#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) + #define RCC_APB2RSTR_IOPERST ((uint32_t)0x00000040) /*!< I/O port E reset */ +#endif /* STM32F10X_LD && STM32F10X_LD_VL */ + +#if defined (STM32F10X_HD) || defined (STM32F10X_XL) + #define RCC_APB2RSTR_IOPFRST ((uint32_t)0x00000080) /*!< I/O port F reset */ + #define RCC_APB2RSTR_IOPGRST ((uint32_t)0x00000100) /*!< I/O port G reset */ + #define RCC_APB2RSTR_TIM8RST ((uint32_t)0x00002000) /*!< TIM8 Timer reset */ + #define RCC_APB2RSTR_ADC3RST ((uint32_t)0x00008000) /*!< ADC3 interface reset */ +#endif + +#if defined (STM32F10X_HD_VL) + #define RCC_APB2RSTR_IOPFRST ((uint32_t)0x00000080) /*!< I/O port F reset */ + #define RCC_APB2RSTR_IOPGRST ((uint32_t)0x00000100) /*!< I/O port G reset */ +#endif + +#ifdef STM32F10X_XL + #define RCC_APB2RSTR_TIM9RST ((uint32_t)0x00080000) /*!< TIM9 Timer reset */ + #define RCC_APB2RSTR_TIM10RST ((uint32_t)0x00100000) /*!< TIM10 Timer reset */ + #define RCC_APB2RSTR_TIM11RST ((uint32_t)0x00200000) /*!< TIM11 Timer reset */ +#endif /* STM32F10X_XL */ + +/***************** Bit definition for RCC_APB1RSTR register *****************/ +#define RCC_APB1RSTR_TIM2RST ((uint32_t)0x00000001) /*!< Timer 2 reset */ +#define RCC_APB1RSTR_TIM3RST ((uint32_t)0x00000002) /*!< Timer 3 reset */ +#define RCC_APB1RSTR_WWDGRST ((uint32_t)0x00000800) /*!< Window Watchdog reset */ +#define RCC_APB1RSTR_USART2RST ((uint32_t)0x00020000) /*!< USART 2 reset */ +#define RCC_APB1RSTR_I2C1RST ((uint32_t)0x00200000) /*!< I2C 1 reset */ + +#if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL) +#define RCC_APB1RSTR_CAN1RST ((uint32_t)0x02000000) /*!< CAN1 reset */ +#endif + +#define RCC_APB1RSTR_BKPRST ((uint32_t)0x08000000) /*!< Backup interface reset */ +#define RCC_APB1RSTR_PWRRST ((uint32_t)0x10000000) /*!< Power interface reset */ + +#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) + #define RCC_APB1RSTR_TIM4RST ((uint32_t)0x00000004) /*!< Timer 4 reset */ + #define RCC_APB1RSTR_SPI2RST ((uint32_t)0x00004000) /*!< SPI 2 reset */ + #define RCC_APB1RSTR_USART3RST ((uint32_t)0x00040000) /*!< USART 3 reset */ + #define RCC_APB1RSTR_I2C2RST ((uint32_t)0x00400000) /*!< I2C 2 reset */ +#endif /* STM32F10X_LD && STM32F10X_LD_VL */ + +#if defined (STM32F10X_HD) || defined (STM32F10X_MD) || defined (STM32F10X_LD) || defined (STM32F10X_XL) + #define RCC_APB1RSTR_USBRST ((uint32_t)0x00800000) /*!< USB Device reset */ +#endif + +#if defined (STM32F10X_HD) || defined (STM32F10X_CL) || defined (STM32F10X_XL) + #define RCC_APB1RSTR_TIM5RST ((uint32_t)0x00000008) /*!< Timer 5 reset */ + #define RCC_APB1RSTR_TIM6RST ((uint32_t)0x00000010) /*!< Timer 6 reset */ + #define RCC_APB1RSTR_TIM7RST ((uint32_t)0x00000020) /*!< Timer 7 reset */ + #define RCC_APB1RSTR_SPI3RST ((uint32_t)0x00008000) /*!< SPI 3 reset */ + #define RCC_APB1RSTR_UART4RST ((uint32_t)0x00080000) /*!< UART 4 reset */ + #define RCC_APB1RSTR_UART5RST ((uint32_t)0x00100000) /*!< UART 5 reset */ + #define RCC_APB1RSTR_DACRST ((uint32_t)0x20000000) /*!< DAC interface reset */ +#endif + +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) + #define RCC_APB1RSTR_TIM6RST ((uint32_t)0x00000010) /*!< Timer 6 reset */ + #define RCC_APB1RSTR_TIM7RST ((uint32_t)0x00000020) /*!< Timer 7 reset */ + #define RCC_APB1RSTR_DACRST ((uint32_t)0x20000000) /*!< DAC interface reset */ + #define RCC_APB1RSTR_CECRST ((uint32_t)0x40000000) /*!< CEC interface reset */ +#endif + +#if defined (STM32F10X_HD_VL) + #define RCC_APB1RSTR_TIM5RST ((uint32_t)0x00000008) /*!< Timer 5 reset */ + #define RCC_APB1RSTR_TIM12RST ((uint32_t)0x00000040) /*!< TIM12 Timer reset */ + #define RCC_APB1RSTR_TIM13RST ((uint32_t)0x00000080) /*!< TIM13 Timer reset */ + #define RCC_APB1RSTR_TIM14RST ((uint32_t)0x00000100) /*!< TIM14 Timer reset */ + #define RCC_APB1RSTR_SPI3RST ((uint32_t)0x00008000) /*!< SPI 3 reset */ + #define RCC_APB1RSTR_UART4RST ((uint32_t)0x00080000) /*!< UART 4 reset */ + #define RCC_APB1RSTR_UART5RST ((uint32_t)0x00100000) /*!< UART 5 reset */ +#endif + +#ifdef STM32F10X_CL + #define RCC_APB1RSTR_CAN2RST ((uint32_t)0x04000000) /*!< CAN2 reset */ +#endif /* STM32F10X_CL */ + +#ifdef STM32F10X_XL + #define RCC_APB1RSTR_TIM12RST ((uint32_t)0x00000040) /*!< TIM12 Timer reset */ + #define RCC_APB1RSTR_TIM13RST ((uint32_t)0x00000080) /*!< TIM13 Timer reset */ + #define RCC_APB1RSTR_TIM14RST ((uint32_t)0x00000100) /*!< TIM14 Timer reset */ +#endif /* STM32F10X_XL */ + +/****************** Bit definition for RCC_AHBENR register ******************/ +#define RCC_AHBENR_DMA1EN ((uint16_t)0x0001) /*!< DMA1 clock enable */ +#define RCC_AHBENR_SRAMEN ((uint16_t)0x0004) /*!< SRAM interface clock enable */ +#define RCC_AHBENR_FLITFEN ((uint16_t)0x0010) /*!< FLITF clock enable */ +#define RCC_AHBENR_CRCEN ((uint16_t)0x0040) /*!< CRC clock enable */ + +#if defined (STM32F10X_HD) || defined (STM32F10X_CL) || defined (STM32F10X_HD_VL) + #define RCC_AHBENR_DMA2EN ((uint16_t)0x0002) /*!< DMA2 clock enable */ +#endif + +#if defined (STM32F10X_HD) || defined (STM32F10X_XL) + #define RCC_AHBENR_FSMCEN ((uint16_t)0x0100) /*!< FSMC clock enable */ + #define RCC_AHBENR_SDIOEN ((uint16_t)0x0400) /*!< SDIO clock enable */ +#endif + +#if defined (STM32F10X_HD_VL) + #define RCC_AHBENR_FSMCEN ((uint16_t)0x0100) /*!< FSMC clock enable */ +#endif + +#ifdef STM32F10X_CL + #define RCC_AHBENR_OTGFSEN ((uint32_t)0x00001000) /*!< USB OTG FS clock enable */ + #define RCC_AHBENR_ETHMACEN ((uint32_t)0x00004000) /*!< ETHERNET MAC clock enable */ + #define RCC_AHBENR_ETHMACTXEN ((uint32_t)0x00008000) /*!< ETHERNET MAC Tx clock enable */ + #define RCC_AHBENR_ETHMACRXEN ((uint32_t)0x00010000) /*!< ETHERNET MAC Rx clock enable */ +#endif /* STM32F10X_CL */ + +/****************** Bit definition for RCC_APB2ENR register *****************/ +#define RCC_APB2ENR_AFIOEN ((uint32_t)0x00000001) /*!< Alternate Function I/O clock enable */ +#define RCC_APB2ENR_IOPAEN ((uint32_t)0x00000004) /*!< I/O port A clock enable */ +#define RCC_APB2ENR_IOPBEN ((uint32_t)0x00000008) /*!< I/O port B clock enable */ +#define RCC_APB2ENR_IOPCEN ((uint32_t)0x00000010) /*!< I/O port C clock enable */ +#define RCC_APB2ENR_IOPDEN ((uint32_t)0x00000020) /*!< I/O port D clock enable */ +#define RCC_APB2ENR_ADC1EN ((uint32_t)0x00000200) /*!< ADC 1 interface clock enable */ + +#if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL) +#define RCC_APB2ENR_ADC2EN ((uint32_t)0x00000400) /*!< ADC 2 interface clock enable */ +#endif + +#define RCC_APB2ENR_TIM1EN ((uint32_t)0x00000800) /*!< TIM1 Timer clock enable */ +#define RCC_APB2ENR_SPI1EN ((uint32_t)0x00001000) /*!< SPI 1 clock enable */ +#define RCC_APB2ENR_USART1EN ((uint32_t)0x00004000) /*!< USART1 clock enable */ + +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) +#define RCC_APB2ENR_TIM15EN ((uint32_t)0x00010000) /*!< TIM15 Timer clock enable */ +#define RCC_APB2ENR_TIM16EN ((uint32_t)0x00020000) /*!< TIM16 Timer clock enable */ +#define RCC_APB2ENR_TIM17EN ((uint32_t)0x00040000) /*!< TIM17 Timer clock enable */ +#endif + +#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) + #define RCC_APB2ENR_IOPEEN ((uint32_t)0x00000040) /*!< I/O port E clock enable */ +#endif /* STM32F10X_LD && STM32F10X_LD_VL */ + +#if defined (STM32F10X_HD) || defined (STM32F10X_XL) + #define RCC_APB2ENR_IOPFEN ((uint32_t)0x00000080) /*!< I/O port F clock enable */ + #define RCC_APB2ENR_IOPGEN ((uint32_t)0x00000100) /*!< I/O port G clock enable */ + #define RCC_APB2ENR_TIM8EN ((uint32_t)0x00002000) /*!< TIM8 Timer clock enable */ + #define RCC_APB2ENR_ADC3EN ((uint32_t)0x00008000) /*!< DMA1 clock enable */ +#endif + +#if defined (STM32F10X_HD_VL) + #define RCC_APB2ENR_IOPFEN ((uint32_t)0x00000080) /*!< I/O port F clock enable */ + #define RCC_APB2ENR_IOPGEN ((uint32_t)0x00000100) /*!< I/O port G clock enable */ +#endif + +#ifdef STM32F10X_XL + #define RCC_APB2ENR_TIM9EN ((uint32_t)0x00080000) /*!< TIM9 Timer clock enable */ + #define RCC_APB2ENR_TIM10EN ((uint32_t)0x00100000) /*!< TIM10 Timer clock enable */ + #define RCC_APB2ENR_TIM11EN ((uint32_t)0x00200000) /*!< TIM11 Timer clock enable */ +#endif + +/***************** Bit definition for RCC_APB1ENR register ******************/ +#define RCC_APB1ENR_TIM2EN ((uint32_t)0x00000001) /*!< Timer 2 clock enabled*/ +#define RCC_APB1ENR_TIM3EN ((uint32_t)0x00000002) /*!< Timer 3 clock enable */ +#define RCC_APB1ENR_WWDGEN ((uint32_t)0x00000800) /*!< Window Watchdog clock enable */ +#define RCC_APB1ENR_USART2EN ((uint32_t)0x00020000) /*!< USART 2 clock enable */ +#define RCC_APB1ENR_I2C1EN ((uint32_t)0x00200000) /*!< I2C 1 clock enable */ + +#if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL) +#define RCC_APB1ENR_CAN1EN ((uint32_t)0x02000000) /*!< CAN1 clock enable */ +#endif + +#define RCC_APB1ENR_BKPEN ((uint32_t)0x08000000) /*!< Backup interface clock enable */ +#define RCC_APB1ENR_PWREN ((uint32_t)0x10000000) /*!< Power interface clock enable */ + +#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) + #define RCC_APB1ENR_TIM4EN ((uint32_t)0x00000004) /*!< Timer 4 clock enable */ + #define RCC_APB1ENR_SPI2EN ((uint32_t)0x00004000) /*!< SPI 2 clock enable */ + #define RCC_APB1ENR_USART3EN ((uint32_t)0x00040000) /*!< USART 3 clock enable */ + #define RCC_APB1ENR_I2C2EN ((uint32_t)0x00400000) /*!< I2C 2 clock enable */ +#endif /* STM32F10X_LD && STM32F10X_LD_VL */ + +#if defined (STM32F10X_HD) || defined (STM32F10X_MD) || defined (STM32F10X_LD) + #define RCC_APB1ENR_USBEN ((uint32_t)0x00800000) /*!< USB Device clock enable */ +#endif + +#if defined (STM32F10X_HD) || defined (STM32F10X_CL) + #define RCC_APB1ENR_TIM5EN ((uint32_t)0x00000008) /*!< Timer 5 clock enable */ + #define RCC_APB1ENR_TIM6EN ((uint32_t)0x00000010) /*!< Timer 6 clock enable */ + #define RCC_APB1ENR_TIM7EN ((uint32_t)0x00000020) /*!< Timer 7 clock enable */ + #define RCC_APB1ENR_SPI3EN ((uint32_t)0x00008000) /*!< SPI 3 clock enable */ + #define RCC_APB1ENR_UART4EN ((uint32_t)0x00080000) /*!< UART 4 clock enable */ + #define RCC_APB1ENR_UART5EN ((uint32_t)0x00100000) /*!< UART 5 clock enable */ + #define RCC_APB1ENR_DACEN ((uint32_t)0x20000000) /*!< DAC interface clock enable */ +#endif + +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) + #define RCC_APB1ENR_TIM6EN ((uint32_t)0x00000010) /*!< Timer 6 clock enable */ + #define RCC_APB1ENR_TIM7EN ((uint32_t)0x00000020) /*!< Timer 7 clock enable */ + #define RCC_APB1ENR_DACEN ((uint32_t)0x20000000) /*!< DAC interface clock enable */ + #define RCC_APB1ENR_CECEN ((uint32_t)0x40000000) /*!< CEC interface clock enable */ +#endif + +#ifdef STM32F10X_HD_VL + #define RCC_APB1ENR_TIM5EN ((uint32_t)0x00000008) /*!< Timer 5 clock enable */ + #define RCC_APB1ENR_TIM12EN ((uint32_t)0x00000040) /*!< TIM12 Timer clock enable */ + #define RCC_APB1ENR_TIM13EN ((uint32_t)0x00000080) /*!< TIM13 Timer clock enable */ + #define RCC_APB1ENR_TIM14EN ((uint32_t)0x00000100) /*!< TIM14 Timer clock enable */ + #define RCC_APB1ENR_SPI3EN ((uint32_t)0x00008000) /*!< SPI 3 clock enable */ + #define RCC_APB1ENR_UART4EN ((uint32_t)0x00080000) /*!< UART 4 clock enable */ + #define RCC_APB1ENR_UART5EN ((uint32_t)0x00100000) /*!< UART 5 clock enable */ +#endif /* STM32F10X_HD_VL */ + +#ifdef STM32F10X_CL + #define RCC_APB1ENR_CAN2EN ((uint32_t)0x04000000) /*!< CAN2 clock enable */ +#endif /* STM32F10X_CL */ + +#ifdef STM32F10X_XL + #define RCC_APB1ENR_TIM12EN ((uint32_t)0x00000040) /*!< TIM12 Timer clock enable */ + #define RCC_APB1ENR_TIM13EN ((uint32_t)0x00000080) /*!< TIM13 Timer clock enable */ + #define RCC_APB1ENR_TIM14EN ((uint32_t)0x00000100) /*!< TIM14 Timer clock enable */ +#endif /* STM32F10X_XL */ + +/******************* Bit definition for RCC_BDCR register *******************/ +#define RCC_BDCR_LSEON ((uint32_t)0x00000001) /*!< External Low Speed oscillator enable */ +#define RCC_BDCR_LSERDY ((uint32_t)0x00000002) /*!< External Low Speed oscillator Ready */ +#define RCC_BDCR_LSEBYP ((uint32_t)0x00000004) /*!< External Low Speed oscillator Bypass */ + +#define RCC_BDCR_RTCSEL ((uint32_t)0x00000300) /*!< RTCSEL[1:0] bits (RTC clock source selection) */ +#define RCC_BDCR_RTCSEL_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define RCC_BDCR_RTCSEL_1 ((uint32_t)0x00000200) /*!< Bit 1 */ + +/*!< RTC congiguration */ +#define RCC_BDCR_RTCSEL_NOCLOCK ((uint32_t)0x00000000) /*!< No clock */ +#define RCC_BDCR_RTCSEL_LSE ((uint32_t)0x00000100) /*!< LSE oscillator clock used as RTC clock */ +#define RCC_BDCR_RTCSEL_LSI ((uint32_t)0x00000200) /*!< LSI oscillator clock used as RTC clock */ +#define RCC_BDCR_RTCSEL_HSE ((uint32_t)0x00000300) /*!< HSE oscillator clock divided by 128 used as RTC clock */ + +#define RCC_BDCR_RTCEN ((uint32_t)0x00008000) /*!< RTC clock enable */ +#define RCC_BDCR_BDRST ((uint32_t)0x00010000) /*!< Backup domain software reset */ + +/******************* Bit definition for RCC_CSR register ********************/ +#define RCC_CSR_LSION ((uint32_t)0x00000001) /*!< Internal Low Speed oscillator enable */ +#define RCC_CSR_LSIRDY ((uint32_t)0x00000002) /*!< Internal Low Speed oscillator Ready */ +#define RCC_CSR_RMVF ((uint32_t)0x01000000) /*!< Remove reset flag */ +#define RCC_CSR_PINRSTF ((uint32_t)0x04000000) /*!< PIN reset flag */ +#define RCC_CSR_PORRSTF ((uint32_t)0x08000000) /*!< POR/PDR reset flag */ +#define RCC_CSR_SFTRSTF ((uint32_t)0x10000000) /*!< Software Reset flag */ +#define RCC_CSR_IWDGRSTF ((uint32_t)0x20000000) /*!< Independent Watchdog reset flag */ +#define RCC_CSR_WWDGRSTF ((uint32_t)0x40000000) /*!< Window watchdog reset flag */ +#define RCC_CSR_LPWRRSTF ((uint32_t)0x80000000) /*!< Low-Power reset flag */ + +#ifdef STM32F10X_CL +/******************* Bit definition for RCC_AHBRSTR register ****************/ + #define RCC_AHBRSTR_OTGFSRST ((uint32_t)0x00001000) /*!< USB OTG FS reset */ + #define RCC_AHBRSTR_ETHMACRST ((uint32_t)0x00004000) /*!< ETHERNET MAC reset */ + +/******************* Bit definition for RCC_CFGR2 register ******************/ +/*!< PREDIV1 configuration */ + #define RCC_CFGR2_PREDIV1 ((uint32_t)0x0000000F) /*!< PREDIV1[3:0] bits */ + #define RCC_CFGR2_PREDIV1_0 ((uint32_t)0x00000001) /*!< Bit 0 */ + #define RCC_CFGR2_PREDIV1_1 ((uint32_t)0x00000002) /*!< Bit 1 */ + #define RCC_CFGR2_PREDIV1_2 ((uint32_t)0x00000004) /*!< Bit 2 */ + #define RCC_CFGR2_PREDIV1_3 ((uint32_t)0x00000008) /*!< Bit 3 */ + + #define RCC_CFGR2_PREDIV1_DIV1 ((uint32_t)0x00000000) /*!< PREDIV1 input clock not divided */ + #define RCC_CFGR2_PREDIV1_DIV2 ((uint32_t)0x00000001) /*!< PREDIV1 input clock divided by 2 */ + #define RCC_CFGR2_PREDIV1_DIV3 ((uint32_t)0x00000002) /*!< PREDIV1 input clock divided by 3 */ + #define RCC_CFGR2_PREDIV1_DIV4 ((uint32_t)0x00000003) /*!< PREDIV1 input clock divided by 4 */ + #define RCC_CFGR2_PREDIV1_DIV5 ((uint32_t)0x00000004) /*!< PREDIV1 input clock divided by 5 */ + #define RCC_CFGR2_PREDIV1_DIV6 ((uint32_t)0x00000005) /*!< PREDIV1 input clock divided by 6 */ + #define RCC_CFGR2_PREDIV1_DIV7 ((uint32_t)0x00000006) /*!< PREDIV1 input clock divided by 7 */ + #define RCC_CFGR2_PREDIV1_DIV8 ((uint32_t)0x00000007) /*!< PREDIV1 input clock divided by 8 */ + #define RCC_CFGR2_PREDIV1_DIV9 ((uint32_t)0x00000008) /*!< PREDIV1 input clock divided by 9 */ + #define RCC_CFGR2_PREDIV1_DIV10 ((uint32_t)0x00000009) /*!< PREDIV1 input clock divided by 10 */ + #define RCC_CFGR2_PREDIV1_DIV11 ((uint32_t)0x0000000A) /*!< PREDIV1 input clock divided by 11 */ + #define RCC_CFGR2_PREDIV1_DIV12 ((uint32_t)0x0000000B) /*!< PREDIV1 input clock divided by 12 */ + #define RCC_CFGR2_PREDIV1_DIV13 ((uint32_t)0x0000000C) /*!< PREDIV1 input clock divided by 13 */ + #define RCC_CFGR2_PREDIV1_DIV14 ((uint32_t)0x0000000D) /*!< PREDIV1 input clock divided by 14 */ + #define RCC_CFGR2_PREDIV1_DIV15 ((uint32_t)0x0000000E) /*!< PREDIV1 input clock divided by 15 */ + #define RCC_CFGR2_PREDIV1_DIV16 ((uint32_t)0x0000000F) /*!< PREDIV1 input clock divided by 16 */ + +/*!< PREDIV2 configuration */ + #define RCC_CFGR2_PREDIV2 ((uint32_t)0x000000F0) /*!< PREDIV2[3:0] bits */ + #define RCC_CFGR2_PREDIV2_0 ((uint32_t)0x00000010) /*!< Bit 0 */ + #define RCC_CFGR2_PREDIV2_1 ((uint32_t)0x00000020) /*!< Bit 1 */ + #define RCC_CFGR2_PREDIV2_2 ((uint32_t)0x00000040) /*!< Bit 2 */ + #define RCC_CFGR2_PREDIV2_3 ((uint32_t)0x00000080) /*!< Bit 3 */ + + #define RCC_CFGR2_PREDIV2_DIV1 ((uint32_t)0x00000000) /*!< PREDIV2 input clock not divided */ + #define RCC_CFGR2_PREDIV2_DIV2 ((uint32_t)0x00000010) /*!< PREDIV2 input clock divided by 2 */ + #define RCC_CFGR2_PREDIV2_DIV3 ((uint32_t)0x00000020) /*!< PREDIV2 input clock divided by 3 */ + #define RCC_CFGR2_PREDIV2_DIV4 ((uint32_t)0x00000030) /*!< PREDIV2 input clock divided by 4 */ + #define RCC_CFGR2_PREDIV2_DIV5 ((uint32_t)0x00000040) /*!< PREDIV2 input clock divided by 5 */ + #define RCC_CFGR2_PREDIV2_DIV6 ((uint32_t)0x00000050) /*!< PREDIV2 input clock divided by 6 */ + #define RCC_CFGR2_PREDIV2_DIV7 ((uint32_t)0x00000060) /*!< PREDIV2 input clock divided by 7 */ + #define RCC_CFGR2_PREDIV2_DIV8 ((uint32_t)0x00000070) /*!< PREDIV2 input clock divided by 8 */ + #define RCC_CFGR2_PREDIV2_DIV9 ((uint32_t)0x00000080) /*!< PREDIV2 input clock divided by 9 */ + #define RCC_CFGR2_PREDIV2_DIV10 ((uint32_t)0x00000090) /*!< PREDIV2 input clock divided by 10 */ + #define RCC_CFGR2_PREDIV2_DIV11 ((uint32_t)0x000000A0) /*!< PREDIV2 input clock divided by 11 */ + #define RCC_CFGR2_PREDIV2_DIV12 ((uint32_t)0x000000B0) /*!< PREDIV2 input clock divided by 12 */ + #define RCC_CFGR2_PREDIV2_DIV13 ((uint32_t)0x000000C0) /*!< PREDIV2 input clock divided by 13 */ + #define RCC_CFGR2_PREDIV2_DIV14 ((uint32_t)0x000000D0) /*!< PREDIV2 input clock divided by 14 */ + #define RCC_CFGR2_PREDIV2_DIV15 ((uint32_t)0x000000E0) /*!< PREDIV2 input clock divided by 15 */ + #define RCC_CFGR2_PREDIV2_DIV16 ((uint32_t)0x000000F0) /*!< PREDIV2 input clock divided by 16 */ + +/*!< PLL2MUL configuration */ + #define RCC_CFGR2_PLL2MUL ((uint32_t)0x00000F00) /*!< PLL2MUL[3:0] bits */ + #define RCC_CFGR2_PLL2MUL_0 ((uint32_t)0x00000100) /*!< Bit 0 */ + #define RCC_CFGR2_PLL2MUL_1 ((uint32_t)0x00000200) /*!< Bit 1 */ + #define RCC_CFGR2_PLL2MUL_2 ((uint32_t)0x00000400) /*!< Bit 2 */ + #define RCC_CFGR2_PLL2MUL_3 ((uint32_t)0x00000800) /*!< Bit 3 */ + + #define RCC_CFGR2_PLL2MUL8 ((uint32_t)0x00000600) /*!< PLL2 input clock * 8 */ + #define RCC_CFGR2_PLL2MUL9 ((uint32_t)0x00000700) /*!< PLL2 input clock * 9 */ + #define RCC_CFGR2_PLL2MUL10 ((uint32_t)0x00000800) /*!< PLL2 input clock * 10 */ + #define RCC_CFGR2_PLL2MUL11 ((uint32_t)0x00000900) /*!< PLL2 input clock * 11 */ + #define RCC_CFGR2_PLL2MUL12 ((uint32_t)0x00000A00) /*!< PLL2 input clock * 12 */ + #define RCC_CFGR2_PLL2MUL13 ((uint32_t)0x00000B00) /*!< PLL2 input clock * 13 */ + #define RCC_CFGR2_PLL2MUL14 ((uint32_t)0x00000C00) /*!< PLL2 input clock * 14 */ + #define RCC_CFGR2_PLL2MUL16 ((uint32_t)0x00000E00) /*!< PLL2 input clock * 16 */ + #define RCC_CFGR2_PLL2MUL20 ((uint32_t)0x00000F00) /*!< PLL2 input clock * 20 */ + +/*!< PLL3MUL configuration */ + #define RCC_CFGR2_PLL3MUL ((uint32_t)0x0000F000) /*!< PLL3MUL[3:0] bits */ + #define RCC_CFGR2_PLL3MUL_0 ((uint32_t)0x00001000) /*!< Bit 0 */ + #define RCC_CFGR2_PLL3MUL_1 ((uint32_t)0x00002000) /*!< Bit 1 */ + #define RCC_CFGR2_PLL3MUL_2 ((uint32_t)0x00004000) /*!< Bit 2 */ + #define RCC_CFGR2_PLL3MUL_3 ((uint32_t)0x00008000) /*!< Bit 3 */ + + #define RCC_CFGR2_PLL3MUL8 ((uint32_t)0x00006000) /*!< PLL3 input clock * 8 */ + #define RCC_CFGR2_PLL3MUL9 ((uint32_t)0x00007000) /*!< PLL3 input clock * 9 */ + #define RCC_CFGR2_PLL3MUL10 ((uint32_t)0x00008000) /*!< PLL3 input clock * 10 */ + #define RCC_CFGR2_PLL3MUL11 ((uint32_t)0x00009000) /*!< PLL3 input clock * 11 */ + #define RCC_CFGR2_PLL3MUL12 ((uint32_t)0x0000A000) /*!< PLL3 input clock * 12 */ + #define RCC_CFGR2_PLL3MUL13 ((uint32_t)0x0000B000) /*!< PLL3 input clock * 13 */ + #define RCC_CFGR2_PLL3MUL14 ((uint32_t)0x0000C000) /*!< PLL3 input clock * 14 */ + #define RCC_CFGR2_PLL3MUL16 ((uint32_t)0x0000E000) /*!< PLL3 input clock * 16 */ + #define RCC_CFGR2_PLL3MUL20 ((uint32_t)0x0000F000) /*!< PLL3 input clock * 20 */ + + #define RCC_CFGR2_PREDIV1SRC ((uint32_t)0x00010000) /*!< PREDIV1 entry clock source */ + #define RCC_CFGR2_PREDIV1SRC_PLL2 ((uint32_t)0x00010000) /*!< PLL2 selected as PREDIV1 entry clock source */ + #define RCC_CFGR2_PREDIV1SRC_HSE ((uint32_t)0x00000000) /*!< HSE selected as PREDIV1 entry clock source */ + #define RCC_CFGR2_I2S2SRC ((uint32_t)0x00020000) /*!< I2S2 entry clock source */ + #define RCC_CFGR2_I2S3SRC ((uint32_t)0x00040000) /*!< I2S3 clock source */ +#endif /* STM32F10X_CL */ + +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) +/******************* Bit definition for RCC_CFGR2 register ******************/ +/*!< PREDIV1 configuration */ + #define RCC_CFGR2_PREDIV1 ((uint32_t)0x0000000F) /*!< PREDIV1[3:0] bits */ + #define RCC_CFGR2_PREDIV1_0 ((uint32_t)0x00000001) /*!< Bit 0 */ + #define RCC_CFGR2_PREDIV1_1 ((uint32_t)0x00000002) /*!< Bit 1 */ + #define RCC_CFGR2_PREDIV1_2 ((uint32_t)0x00000004) /*!< Bit 2 */ + #define RCC_CFGR2_PREDIV1_3 ((uint32_t)0x00000008) /*!< Bit 3 */ + + #define RCC_CFGR2_PREDIV1_DIV1 ((uint32_t)0x00000000) /*!< PREDIV1 input clock not divided */ + #define RCC_CFGR2_PREDIV1_DIV2 ((uint32_t)0x00000001) /*!< PREDIV1 input clock divided by 2 */ + #define RCC_CFGR2_PREDIV1_DIV3 ((uint32_t)0x00000002) /*!< PREDIV1 input clock divided by 3 */ + #define RCC_CFGR2_PREDIV1_DIV4 ((uint32_t)0x00000003) /*!< PREDIV1 input clock divided by 4 */ + #define RCC_CFGR2_PREDIV1_DIV5 ((uint32_t)0x00000004) /*!< PREDIV1 input clock divided by 5 */ + #define RCC_CFGR2_PREDIV1_DIV6 ((uint32_t)0x00000005) /*!< PREDIV1 input clock divided by 6 */ + #define RCC_CFGR2_PREDIV1_DIV7 ((uint32_t)0x00000006) /*!< PREDIV1 input clock divided by 7 */ + #define RCC_CFGR2_PREDIV1_DIV8 ((uint32_t)0x00000007) /*!< PREDIV1 input clock divided by 8 */ + #define RCC_CFGR2_PREDIV1_DIV9 ((uint32_t)0x00000008) /*!< PREDIV1 input clock divided by 9 */ + #define RCC_CFGR2_PREDIV1_DIV10 ((uint32_t)0x00000009) /*!< PREDIV1 input clock divided by 10 */ + #define RCC_CFGR2_PREDIV1_DIV11 ((uint32_t)0x0000000A) /*!< PREDIV1 input clock divided by 11 */ + #define RCC_CFGR2_PREDIV1_DIV12 ((uint32_t)0x0000000B) /*!< PREDIV1 input clock divided by 12 */ + #define RCC_CFGR2_PREDIV1_DIV13 ((uint32_t)0x0000000C) /*!< PREDIV1 input clock divided by 13 */ + #define RCC_CFGR2_PREDIV1_DIV14 ((uint32_t)0x0000000D) /*!< PREDIV1 input clock divided by 14 */ + #define RCC_CFGR2_PREDIV1_DIV15 ((uint32_t)0x0000000E) /*!< PREDIV1 input clock divided by 15 */ + #define RCC_CFGR2_PREDIV1_DIV16 ((uint32_t)0x0000000F) /*!< PREDIV1 input clock divided by 16 */ +#endif + +/******************************************************************************/ +/* */ +/* General Purpose and Alternate Function I/O */ +/* */ +/******************************************************************************/ + +/******************* Bit definition for GPIO_CRL register *******************/ +#define GPIO_CRL_MODE ((uint32_t)0x33333333) /*!< Port x mode bits */ + +#define GPIO_CRL_MODE0 ((uint32_t)0x00000003) /*!< MODE0[1:0] bits (Port x mode bits, pin 0) */ +#define GPIO_CRL_MODE0_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define GPIO_CRL_MODE0_1 ((uint32_t)0x00000002) /*!< Bit 1 */ + +#define GPIO_CRL_MODE1 ((uint32_t)0x00000030) /*!< MODE1[1:0] bits (Port x mode bits, pin 1) */ +#define GPIO_CRL_MODE1_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define GPIO_CRL_MODE1_1 ((uint32_t)0x00000020) /*!< Bit 1 */ + +#define GPIO_CRL_MODE2 ((uint32_t)0x00000300) /*!< MODE2[1:0] bits (Port x mode bits, pin 2) */ +#define GPIO_CRL_MODE2_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define GPIO_CRL_MODE2_1 ((uint32_t)0x00000200) /*!< Bit 1 */ + +#define GPIO_CRL_MODE3 ((uint32_t)0x00003000) /*!< MODE3[1:0] bits (Port x mode bits, pin 3) */ +#define GPIO_CRL_MODE3_0 ((uint32_t)0x00001000) /*!< Bit 0 */ +#define GPIO_CRL_MODE3_1 ((uint32_t)0x00002000) /*!< Bit 1 */ + +#define GPIO_CRL_MODE4 ((uint32_t)0x00030000) /*!< MODE4[1:0] bits (Port x mode bits, pin 4) */ +#define GPIO_CRL_MODE4_0 ((uint32_t)0x00010000) /*!< Bit 0 */ +#define GPIO_CRL_MODE4_1 ((uint32_t)0x00020000) /*!< Bit 1 */ + +#define GPIO_CRL_MODE5 ((uint32_t)0x00300000) /*!< MODE5[1:0] bits (Port x mode bits, pin 5) */ +#define GPIO_CRL_MODE5_0 ((uint32_t)0x00100000) /*!< Bit 0 */ +#define GPIO_CRL_MODE5_1 ((uint32_t)0x00200000) /*!< Bit 1 */ + +#define GPIO_CRL_MODE6 ((uint32_t)0x03000000) /*!< MODE6[1:0] bits (Port x mode bits, pin 6) */ +#define GPIO_CRL_MODE6_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define GPIO_CRL_MODE6_1 ((uint32_t)0x02000000) /*!< Bit 1 */ + +#define GPIO_CRL_MODE7 ((uint32_t)0x30000000) /*!< MODE7[1:0] bits (Port x mode bits, pin 7) */ +#define GPIO_CRL_MODE7_0 ((uint32_t)0x10000000) /*!< Bit 0 */ +#define GPIO_CRL_MODE7_1 ((uint32_t)0x20000000) /*!< Bit 1 */ + +#define GPIO_CRL_CNF ((uint32_t)0xCCCCCCCC) /*!< Port x configuration bits */ + +#define GPIO_CRL_CNF0 ((uint32_t)0x0000000C) /*!< CNF0[1:0] bits (Port x configuration bits, pin 0) */ +#define GPIO_CRL_CNF0_0 ((uint32_t)0x00000004) /*!< Bit 0 */ +#define GPIO_CRL_CNF0_1 ((uint32_t)0x00000008) /*!< Bit 1 */ + +#define GPIO_CRL_CNF1 ((uint32_t)0x000000C0) /*!< CNF1[1:0] bits (Port x configuration bits, pin 1) */ +#define GPIO_CRL_CNF1_0 ((uint32_t)0x00000040) /*!< Bit 0 */ +#define GPIO_CRL_CNF1_1 ((uint32_t)0x00000080) /*!< Bit 1 */ + +#define GPIO_CRL_CNF2 ((uint32_t)0x00000C00) /*!< CNF2[1:0] bits (Port x configuration bits, pin 2) */ +#define GPIO_CRL_CNF2_0 ((uint32_t)0x00000400) /*!< Bit 0 */ +#define GPIO_CRL_CNF2_1 ((uint32_t)0x00000800) /*!< Bit 1 */ + +#define GPIO_CRL_CNF3 ((uint32_t)0x0000C000) /*!< CNF3[1:0] bits (Port x configuration bits, pin 3) */ +#define GPIO_CRL_CNF3_0 ((uint32_t)0x00004000) /*!< Bit 0 */ +#define GPIO_CRL_CNF3_1 ((uint32_t)0x00008000) /*!< Bit 1 */ + +#define GPIO_CRL_CNF4 ((uint32_t)0x000C0000) /*!< CNF4[1:0] bits (Port x configuration bits, pin 4) */ +#define GPIO_CRL_CNF4_0 ((uint32_t)0x00040000) /*!< Bit 0 */ +#define GPIO_CRL_CNF4_1 ((uint32_t)0x00080000) /*!< Bit 1 */ + +#define GPIO_CRL_CNF5 ((uint32_t)0x00C00000) /*!< CNF5[1:0] bits (Port x configuration bits, pin 5) */ +#define GPIO_CRL_CNF5_0 ((uint32_t)0x00400000) /*!< Bit 0 */ +#define GPIO_CRL_CNF5_1 ((uint32_t)0x00800000) /*!< Bit 1 */ + +#define GPIO_CRL_CNF6 ((uint32_t)0x0C000000) /*!< CNF6[1:0] bits (Port x configuration bits, pin 6) */ +#define GPIO_CRL_CNF6_0 ((uint32_t)0x04000000) /*!< Bit 0 */ +#define GPIO_CRL_CNF6_1 ((uint32_t)0x08000000) /*!< Bit 1 */ + +#define GPIO_CRL_CNF7 ((uint32_t)0xC0000000) /*!< CNF7[1:0] bits (Port x configuration bits, pin 7) */ +#define GPIO_CRL_CNF7_0 ((uint32_t)0x40000000) /*!< Bit 0 */ +#define GPIO_CRL_CNF7_1 ((uint32_t)0x80000000) /*!< Bit 1 */ + +/******************* Bit definition for GPIO_CRH register *******************/ +#define GPIO_CRH_MODE ((uint32_t)0x33333333) /*!< Port x mode bits */ + +#define GPIO_CRH_MODE8 ((uint32_t)0x00000003) /*!< MODE8[1:0] bits (Port x mode bits, pin 8) */ +#define GPIO_CRH_MODE8_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define GPIO_CRH_MODE8_1 ((uint32_t)0x00000002) /*!< Bit 1 */ + +#define GPIO_CRH_MODE9 ((uint32_t)0x00000030) /*!< MODE9[1:0] bits (Port x mode bits, pin 9) */ +#define GPIO_CRH_MODE9_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define GPIO_CRH_MODE9_1 ((uint32_t)0x00000020) /*!< Bit 1 */ + +#define GPIO_CRH_MODE10 ((uint32_t)0x00000300) /*!< MODE10[1:0] bits (Port x mode bits, pin 10) */ +#define GPIO_CRH_MODE10_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define GPIO_CRH_MODE10_1 ((uint32_t)0x00000200) /*!< Bit 1 */ + +#define GPIO_CRH_MODE11 ((uint32_t)0x00003000) /*!< MODE11[1:0] bits (Port x mode bits, pin 11) */ +#define GPIO_CRH_MODE11_0 ((uint32_t)0x00001000) /*!< Bit 0 */ +#define GPIO_CRH_MODE11_1 ((uint32_t)0x00002000) /*!< Bit 1 */ + +#define GPIO_CRH_MODE12 ((uint32_t)0x00030000) /*!< MODE12[1:0] bits (Port x mode bits, pin 12) */ +#define GPIO_CRH_MODE12_0 ((uint32_t)0x00010000) /*!< Bit 0 */ +#define GPIO_CRH_MODE12_1 ((uint32_t)0x00020000) /*!< Bit 1 */ + +#define GPIO_CRH_MODE13 ((uint32_t)0x00300000) /*!< MODE13[1:0] bits (Port x mode bits, pin 13) */ +#define GPIO_CRH_MODE13_0 ((uint32_t)0x00100000) /*!< Bit 0 */ +#define GPIO_CRH_MODE13_1 ((uint32_t)0x00200000) /*!< Bit 1 */ + +#define GPIO_CRH_MODE14 ((uint32_t)0x03000000) /*!< MODE14[1:0] bits (Port x mode bits, pin 14) */ +#define GPIO_CRH_MODE14_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define GPIO_CRH_MODE14_1 ((uint32_t)0x02000000) /*!< Bit 1 */ + +#define GPIO_CRH_MODE15 ((uint32_t)0x30000000) /*!< MODE15[1:0] bits (Port x mode bits, pin 15) */ +#define GPIO_CRH_MODE15_0 ((uint32_t)0x10000000) /*!< Bit 0 */ +#define GPIO_CRH_MODE15_1 ((uint32_t)0x20000000) /*!< Bit 1 */ + +#define GPIO_CRH_CNF ((uint32_t)0xCCCCCCCC) /*!< Port x configuration bits */ + +#define GPIO_CRH_CNF8 ((uint32_t)0x0000000C) /*!< CNF8[1:0] bits (Port x configuration bits, pin 8) */ +#define GPIO_CRH_CNF8_0 ((uint32_t)0x00000004) /*!< Bit 0 */ +#define GPIO_CRH_CNF8_1 ((uint32_t)0x00000008) /*!< Bit 1 */ + +#define GPIO_CRH_CNF9 ((uint32_t)0x000000C0) /*!< CNF9[1:0] bits (Port x configuration bits, pin 9) */ +#define GPIO_CRH_CNF9_0 ((uint32_t)0x00000040) /*!< Bit 0 */ +#define GPIO_CRH_CNF9_1 ((uint32_t)0x00000080) /*!< Bit 1 */ + +#define GPIO_CRH_CNF10 ((uint32_t)0x00000C00) /*!< CNF10[1:0] bits (Port x configuration bits, pin 10) */ +#define GPIO_CRH_CNF10_0 ((uint32_t)0x00000400) /*!< Bit 0 */ +#define GPIO_CRH_CNF10_1 ((uint32_t)0x00000800) /*!< Bit 1 */ + +#define GPIO_CRH_CNF11 ((uint32_t)0x0000C000) /*!< CNF11[1:0] bits (Port x configuration bits, pin 11) */ +#define GPIO_CRH_CNF11_0 ((uint32_t)0x00004000) /*!< Bit 0 */ +#define GPIO_CRH_CNF11_1 ((uint32_t)0x00008000) /*!< Bit 1 */ + +#define GPIO_CRH_CNF12 ((uint32_t)0x000C0000) /*!< CNF12[1:0] bits (Port x configuration bits, pin 12) */ +#define GPIO_CRH_CNF12_0 ((uint32_t)0x00040000) /*!< Bit 0 */ +#define GPIO_CRH_CNF12_1 ((uint32_t)0x00080000) /*!< Bit 1 */ + +#define GPIO_CRH_CNF13 ((uint32_t)0x00C00000) /*!< CNF13[1:0] bits (Port x configuration bits, pin 13) */ +#define GPIO_CRH_CNF13_0 ((uint32_t)0x00400000) /*!< Bit 0 */ +#define GPIO_CRH_CNF13_1 ((uint32_t)0x00800000) /*!< Bit 1 */ + +#define GPIO_CRH_CNF14 ((uint32_t)0x0C000000) /*!< CNF14[1:0] bits (Port x configuration bits, pin 14) */ +#define GPIO_CRH_CNF14_0 ((uint32_t)0x04000000) /*!< Bit 0 */ +#define GPIO_CRH_CNF14_1 ((uint32_t)0x08000000) /*!< Bit 1 */ + +#define GPIO_CRH_CNF15 ((uint32_t)0xC0000000) /*!< CNF15[1:0] bits (Port x configuration bits, pin 15) */ +#define GPIO_CRH_CNF15_0 ((uint32_t)0x40000000) /*!< Bit 0 */ +#define GPIO_CRH_CNF15_1 ((uint32_t)0x80000000) /*!< Bit 1 */ + +/*!<****************** Bit definition for GPIO_IDR register *******************/ +#define GPIO_IDR_IDR0 ((uint16_t)0x0001) /*!< Port input data, bit 0 */ +#define GPIO_IDR_IDR1 ((uint16_t)0x0002) /*!< Port input data, bit 1 */ +#define GPIO_IDR_IDR2 ((uint16_t)0x0004) /*!< Port input data, bit 2 */ +#define GPIO_IDR_IDR3 ((uint16_t)0x0008) /*!< Port input data, bit 3 */ +#define GPIO_IDR_IDR4 ((uint16_t)0x0010) /*!< Port input data, bit 4 */ +#define GPIO_IDR_IDR5 ((uint16_t)0x0020) /*!< Port input data, bit 5 */ +#define GPIO_IDR_IDR6 ((uint16_t)0x0040) /*!< Port input data, bit 6 */ +#define GPIO_IDR_IDR7 ((uint16_t)0x0080) /*!< Port input data, bit 7 */ +#define GPIO_IDR_IDR8 ((uint16_t)0x0100) /*!< Port input data, bit 8 */ +#define GPIO_IDR_IDR9 ((uint16_t)0x0200) /*!< Port input data, bit 9 */ +#define GPIO_IDR_IDR10 ((uint16_t)0x0400) /*!< Port input data, bit 10 */ +#define GPIO_IDR_IDR11 ((uint16_t)0x0800) /*!< Port input data, bit 11 */ +#define GPIO_IDR_IDR12 ((uint16_t)0x1000) /*!< Port input data, bit 12 */ +#define GPIO_IDR_IDR13 ((uint16_t)0x2000) /*!< Port input data, bit 13 */ +#define GPIO_IDR_IDR14 ((uint16_t)0x4000) /*!< Port input data, bit 14 */ +#define GPIO_IDR_IDR15 ((uint16_t)0x8000) /*!< Port input data, bit 15 */ + +/******************* Bit definition for GPIO_ODR register *******************/ +#define GPIO_ODR_ODR0 ((uint16_t)0x0001) /*!< Port output data, bit 0 */ +#define GPIO_ODR_ODR1 ((uint16_t)0x0002) /*!< Port output data, bit 1 */ +#define GPIO_ODR_ODR2 ((uint16_t)0x0004) /*!< Port output data, bit 2 */ +#define GPIO_ODR_ODR3 ((uint16_t)0x0008) /*!< Port output data, bit 3 */ +#define GPIO_ODR_ODR4 ((uint16_t)0x0010) /*!< Port output data, bit 4 */ +#define GPIO_ODR_ODR5 ((uint16_t)0x0020) /*!< Port output data, bit 5 */ +#define GPIO_ODR_ODR6 ((uint16_t)0x0040) /*!< Port output data, bit 6 */ +#define GPIO_ODR_ODR7 ((uint16_t)0x0080) /*!< Port output data, bit 7 */ +#define GPIO_ODR_ODR8 ((uint16_t)0x0100) /*!< Port output data, bit 8 */ +#define GPIO_ODR_ODR9 ((uint16_t)0x0200) /*!< Port output data, bit 9 */ +#define GPIO_ODR_ODR10 ((uint16_t)0x0400) /*!< Port output data, bit 10 */ +#define GPIO_ODR_ODR11 ((uint16_t)0x0800) /*!< Port output data, bit 11 */ +#define GPIO_ODR_ODR12 ((uint16_t)0x1000) /*!< Port output data, bit 12 */ +#define GPIO_ODR_ODR13 ((uint16_t)0x2000) /*!< Port output data, bit 13 */ +#define GPIO_ODR_ODR14 ((uint16_t)0x4000) /*!< Port output data, bit 14 */ +#define GPIO_ODR_ODR15 ((uint16_t)0x8000) /*!< Port output data, bit 15 */ + +/****************** Bit definition for GPIO_BSRR register *******************/ +#define GPIO_BSRR_BS0 ((uint32_t)0x00000001) /*!< Port x Set bit 0 */ +#define GPIO_BSRR_BS1 ((uint32_t)0x00000002) /*!< Port x Set bit 1 */ +#define GPIO_BSRR_BS2 ((uint32_t)0x00000004) /*!< Port x Set bit 2 */ +#define GPIO_BSRR_BS3 ((uint32_t)0x00000008) /*!< Port x Set bit 3 */ +#define GPIO_BSRR_BS4 ((uint32_t)0x00000010) /*!< Port x Set bit 4 */ +#define GPIO_BSRR_BS5 ((uint32_t)0x00000020) /*!< Port x Set bit 5 */ +#define GPIO_BSRR_BS6 ((uint32_t)0x00000040) /*!< Port x Set bit 6 */ +#define GPIO_BSRR_BS7 ((uint32_t)0x00000080) /*!< Port x Set bit 7 */ +#define GPIO_BSRR_BS8 ((uint32_t)0x00000100) /*!< Port x Set bit 8 */ +#define GPIO_BSRR_BS9 ((uint32_t)0x00000200) /*!< Port x Set bit 9 */ +#define GPIO_BSRR_BS10 ((uint32_t)0x00000400) /*!< Port x Set bit 10 */ +#define GPIO_BSRR_BS11 ((uint32_t)0x00000800) /*!< Port x Set bit 11 */ +#define GPIO_BSRR_BS12 ((uint32_t)0x00001000) /*!< Port x Set bit 12 */ +#define GPIO_BSRR_BS13 ((uint32_t)0x00002000) /*!< Port x Set bit 13 */ +#define GPIO_BSRR_BS14 ((uint32_t)0x00004000) /*!< Port x Set bit 14 */ +#define GPIO_BSRR_BS15 ((uint32_t)0x00008000) /*!< Port x Set bit 15 */ + +#define GPIO_BSRR_BR0 ((uint32_t)0x00010000) /*!< Port x Reset bit 0 */ +#define GPIO_BSRR_BR1 ((uint32_t)0x00020000) /*!< Port x Reset bit 1 */ +#define GPIO_BSRR_BR2 ((uint32_t)0x00040000) /*!< Port x Reset bit 2 */ +#define GPIO_BSRR_BR3 ((uint32_t)0x00080000) /*!< Port x Reset bit 3 */ +#define GPIO_BSRR_BR4 ((uint32_t)0x00100000) /*!< Port x Reset bit 4 */ +#define GPIO_BSRR_BR5 ((uint32_t)0x00200000) /*!< Port x Reset bit 5 */ +#define GPIO_BSRR_BR6 ((uint32_t)0x00400000) /*!< Port x Reset bit 6 */ +#define GPIO_BSRR_BR7 ((uint32_t)0x00800000) /*!< Port x Reset bit 7 */ +#define GPIO_BSRR_BR8 ((uint32_t)0x01000000) /*!< Port x Reset bit 8 */ +#define GPIO_BSRR_BR9 ((uint32_t)0x02000000) /*!< Port x Reset bit 9 */ +#define GPIO_BSRR_BR10 ((uint32_t)0x04000000) /*!< Port x Reset bit 10 */ +#define GPIO_BSRR_BR11 ((uint32_t)0x08000000) /*!< Port x Reset bit 11 */ +#define GPIO_BSRR_BR12 ((uint32_t)0x10000000) /*!< Port x Reset bit 12 */ +#define GPIO_BSRR_BR13 ((uint32_t)0x20000000) /*!< Port x Reset bit 13 */ +#define GPIO_BSRR_BR14 ((uint32_t)0x40000000) /*!< Port x Reset bit 14 */ +#define GPIO_BSRR_BR15 ((uint32_t)0x80000000) /*!< Port x Reset bit 15 */ + +/******************* Bit definition for GPIO_BRR register *******************/ +#define GPIO_BRR_BR0 ((uint16_t)0x0001) /*!< Port x Reset bit 0 */ +#define GPIO_BRR_BR1 ((uint16_t)0x0002) /*!< Port x Reset bit 1 */ +#define GPIO_BRR_BR2 ((uint16_t)0x0004) /*!< Port x Reset bit 2 */ +#define GPIO_BRR_BR3 ((uint16_t)0x0008) /*!< Port x Reset bit 3 */ +#define GPIO_BRR_BR4 ((uint16_t)0x0010) /*!< Port x Reset bit 4 */ +#define GPIO_BRR_BR5 ((uint16_t)0x0020) /*!< Port x Reset bit 5 */ +#define GPIO_BRR_BR6 ((uint16_t)0x0040) /*!< Port x Reset bit 6 */ +#define GPIO_BRR_BR7 ((uint16_t)0x0080) /*!< Port x Reset bit 7 */ +#define GPIO_BRR_BR8 ((uint16_t)0x0100) /*!< Port x Reset bit 8 */ +#define GPIO_BRR_BR9 ((uint16_t)0x0200) /*!< Port x Reset bit 9 */ +#define GPIO_BRR_BR10 ((uint16_t)0x0400) /*!< Port x Reset bit 10 */ +#define GPIO_BRR_BR11 ((uint16_t)0x0800) /*!< Port x Reset bit 11 */ +#define GPIO_BRR_BR12 ((uint16_t)0x1000) /*!< Port x Reset bit 12 */ +#define GPIO_BRR_BR13 ((uint16_t)0x2000) /*!< Port x Reset bit 13 */ +#define GPIO_BRR_BR14 ((uint16_t)0x4000) /*!< Port x Reset bit 14 */ +#define GPIO_BRR_BR15 ((uint16_t)0x8000) /*!< Port x Reset bit 15 */ + +/****************** Bit definition for GPIO_LCKR register *******************/ +#define GPIO_LCKR_LCK0 ((uint32_t)0x00000001) /*!< Port x Lock bit 0 */ +#define GPIO_LCKR_LCK1 ((uint32_t)0x00000002) /*!< Port x Lock bit 1 */ +#define GPIO_LCKR_LCK2 ((uint32_t)0x00000004) /*!< Port x Lock bit 2 */ +#define GPIO_LCKR_LCK3 ((uint32_t)0x00000008) /*!< Port x Lock bit 3 */ +#define GPIO_LCKR_LCK4 ((uint32_t)0x00000010) /*!< Port x Lock bit 4 */ +#define GPIO_LCKR_LCK5 ((uint32_t)0x00000020) /*!< Port x Lock bit 5 */ +#define GPIO_LCKR_LCK6 ((uint32_t)0x00000040) /*!< Port x Lock bit 6 */ +#define GPIO_LCKR_LCK7 ((uint32_t)0x00000080) /*!< Port x Lock bit 7 */ +#define GPIO_LCKR_LCK8 ((uint32_t)0x00000100) /*!< Port x Lock bit 8 */ +#define GPIO_LCKR_LCK9 ((uint32_t)0x00000200) /*!< Port x Lock bit 9 */ +#define GPIO_LCKR_LCK10 ((uint32_t)0x00000400) /*!< Port x Lock bit 10 */ +#define GPIO_LCKR_LCK11 ((uint32_t)0x00000800) /*!< Port x Lock bit 11 */ +#define GPIO_LCKR_LCK12 ((uint32_t)0x00001000) /*!< Port x Lock bit 12 */ +#define GPIO_LCKR_LCK13 ((uint32_t)0x00002000) /*!< Port x Lock bit 13 */ +#define GPIO_LCKR_LCK14 ((uint32_t)0x00004000) /*!< Port x Lock bit 14 */ +#define GPIO_LCKR_LCK15 ((uint32_t)0x00008000) /*!< Port x Lock bit 15 */ +#define GPIO_LCKR_LCKK ((uint32_t)0x00010000) /*!< Lock key */ + +/*----------------------------------------------------------------------------*/ + +/****************** Bit definition for AFIO_EVCR register *******************/ +#define AFIO_EVCR_PIN ((uint8_t)0x0F) /*!< PIN[3:0] bits (Pin selection) */ +#define AFIO_EVCR_PIN_0 ((uint8_t)0x01) /*!< Bit 0 */ +#define AFIO_EVCR_PIN_1 ((uint8_t)0x02) /*!< Bit 1 */ +#define AFIO_EVCR_PIN_2 ((uint8_t)0x04) /*!< Bit 2 */ +#define AFIO_EVCR_PIN_3 ((uint8_t)0x08) /*!< Bit 3 */ + +/*!< PIN configuration */ +#define AFIO_EVCR_PIN_PX0 ((uint8_t)0x00) /*!< Pin 0 selected */ +#define AFIO_EVCR_PIN_PX1 ((uint8_t)0x01) /*!< Pin 1 selected */ +#define AFIO_EVCR_PIN_PX2 ((uint8_t)0x02) /*!< Pin 2 selected */ +#define AFIO_EVCR_PIN_PX3 ((uint8_t)0x03) /*!< Pin 3 selected */ +#define AFIO_EVCR_PIN_PX4 ((uint8_t)0x04) /*!< Pin 4 selected */ +#define AFIO_EVCR_PIN_PX5 ((uint8_t)0x05) /*!< Pin 5 selected */ +#define AFIO_EVCR_PIN_PX6 ((uint8_t)0x06) /*!< Pin 6 selected */ +#define AFIO_EVCR_PIN_PX7 ((uint8_t)0x07) /*!< Pin 7 selected */ +#define AFIO_EVCR_PIN_PX8 ((uint8_t)0x08) /*!< Pin 8 selected */ +#define AFIO_EVCR_PIN_PX9 ((uint8_t)0x09) /*!< Pin 9 selected */ +#define AFIO_EVCR_PIN_PX10 ((uint8_t)0x0A) /*!< Pin 10 selected */ +#define AFIO_EVCR_PIN_PX11 ((uint8_t)0x0B) /*!< Pin 11 selected */ +#define AFIO_EVCR_PIN_PX12 ((uint8_t)0x0C) /*!< Pin 12 selected */ +#define AFIO_EVCR_PIN_PX13 ((uint8_t)0x0D) /*!< Pin 13 selected */ +#define AFIO_EVCR_PIN_PX14 ((uint8_t)0x0E) /*!< Pin 14 selected */ +#define AFIO_EVCR_PIN_PX15 ((uint8_t)0x0F) /*!< Pin 15 selected */ + +#define AFIO_EVCR_PORT ((uint8_t)0x70) /*!< PORT[2:0] bits (Port selection) */ +#define AFIO_EVCR_PORT_0 ((uint8_t)0x10) /*!< Bit 0 */ +#define AFIO_EVCR_PORT_1 ((uint8_t)0x20) /*!< Bit 1 */ +#define AFIO_EVCR_PORT_2 ((uint8_t)0x40) /*!< Bit 2 */ + +/*!< PORT configuration */ +#define AFIO_EVCR_PORT_PA ((uint8_t)0x00) /*!< Port A selected */ +#define AFIO_EVCR_PORT_PB ((uint8_t)0x10) /*!< Port B selected */ +#define AFIO_EVCR_PORT_PC ((uint8_t)0x20) /*!< Port C selected */ +#define AFIO_EVCR_PORT_PD ((uint8_t)0x30) /*!< Port D selected */ +#define AFIO_EVCR_PORT_PE ((uint8_t)0x40) /*!< Port E selected */ + +#define AFIO_EVCR_EVOE ((uint8_t)0x80) /*!< Event Output Enable */ + +/****************** Bit definition for AFIO_MAPR register *******************/ +#define AFIO_MAPR_SPI1_REMAP ((uint32_t)0x00000001) /*!< SPI1 remapping */ +#define AFIO_MAPR_I2C1_REMAP ((uint32_t)0x00000002) /*!< I2C1 remapping */ +#define AFIO_MAPR_USART1_REMAP ((uint32_t)0x00000004) /*!< USART1 remapping */ +#define AFIO_MAPR_USART2_REMAP ((uint32_t)0x00000008) /*!< USART2 remapping */ + +#define AFIO_MAPR_USART3_REMAP ((uint32_t)0x00000030) /*!< USART3_REMAP[1:0] bits (USART3 remapping) */ +#define AFIO_MAPR_USART3_REMAP_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define AFIO_MAPR_USART3_REMAP_1 ((uint32_t)0x00000020) /*!< Bit 1 */ + +/* USART3_REMAP configuration */ +#define AFIO_MAPR_USART3_REMAP_NOREMAP ((uint32_t)0x00000000) /*!< No remap (TX/PB10, RX/PB11, CK/PB12, CTS/PB13, RTS/PB14) */ +#define AFIO_MAPR_USART3_REMAP_PARTIALREMAP ((uint32_t)0x00000010) /*!< Partial remap (TX/PC10, RX/PC11, CK/PC12, CTS/PB13, RTS/PB14) */ +#define AFIO_MAPR_USART3_REMAP_FULLREMAP ((uint32_t)0x00000030) /*!< Full remap (TX/PD8, RX/PD9, CK/PD10, CTS/PD11, RTS/PD12) */ + +#define AFIO_MAPR_TIM1_REMAP ((uint32_t)0x000000C0) /*!< TIM1_REMAP[1:0] bits (TIM1 remapping) */ +#define AFIO_MAPR_TIM1_REMAP_0 ((uint32_t)0x00000040) /*!< Bit 0 */ +#define AFIO_MAPR_TIM1_REMAP_1 ((uint32_t)0x00000080) /*!< Bit 1 */ + +/*!< TIM1_REMAP configuration */ +#define AFIO_MAPR_TIM1_REMAP_NOREMAP ((uint32_t)0x00000000) /*!< No remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PB12, CH1N/PB13, CH2N/PB14, CH3N/PB15) */ +#define AFIO_MAPR_TIM1_REMAP_PARTIALREMAP ((uint32_t)0x00000040) /*!< Partial remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PA6, CH1N/PA7, CH2N/PB0, CH3N/PB1) */ +#define AFIO_MAPR_TIM1_REMAP_FULLREMAP ((uint32_t)0x000000C0) /*!< Full remap (ETR/PE7, CH1/PE9, CH2/PE11, CH3/PE13, CH4/PE14, BKIN/PE15, CH1N/PE8, CH2N/PE10, CH3N/PE12) */ + +#define AFIO_MAPR_TIM2_REMAP ((uint32_t)0x00000300) /*!< TIM2_REMAP[1:0] bits (TIM2 remapping) */ +#define AFIO_MAPR_TIM2_REMAP_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define AFIO_MAPR_TIM2_REMAP_1 ((uint32_t)0x00000200) /*!< Bit 1 */ + +/*!< TIM2_REMAP configuration */ +#define AFIO_MAPR_TIM2_REMAP_NOREMAP ((uint32_t)0x00000000) /*!< No remap (CH1/ETR/PA0, CH2/PA1, CH3/PA2, CH4/PA3) */ +#define AFIO_MAPR_TIM2_REMAP_PARTIALREMAP1 ((uint32_t)0x00000100) /*!< Partial remap (CH1/ETR/PA15, CH2/PB3, CH3/PA2, CH4/PA3) */ +#define AFIO_MAPR_TIM2_REMAP_PARTIALREMAP2 ((uint32_t)0x00000200) /*!< Partial remap (CH1/ETR/PA0, CH2/PA1, CH3/PB10, CH4/PB11) */ +#define AFIO_MAPR_TIM2_REMAP_FULLREMAP ((uint32_t)0x00000300) /*!< Full remap (CH1/ETR/PA15, CH2/PB3, CH3/PB10, CH4/PB11) */ + +#define AFIO_MAPR_TIM3_REMAP ((uint32_t)0x00000C00) /*!< TIM3_REMAP[1:0] bits (TIM3 remapping) */ +#define AFIO_MAPR_TIM3_REMAP_0 ((uint32_t)0x00000400) /*!< Bit 0 */ +#define AFIO_MAPR_TIM3_REMAP_1 ((uint32_t)0x00000800) /*!< Bit 1 */ + +/*!< TIM3_REMAP configuration */ +#define AFIO_MAPR_TIM3_REMAP_NOREMAP ((uint32_t)0x00000000) /*!< No remap (CH1/PA6, CH2/PA7, CH3/PB0, CH4/PB1) */ +#define AFIO_MAPR_TIM3_REMAP_PARTIALREMAP ((uint32_t)0x00000800) /*!< Partial remap (CH1/PB4, CH2/PB5, CH3/PB0, CH4/PB1) */ +#define AFIO_MAPR_TIM3_REMAP_FULLREMAP ((uint32_t)0x00000C00) /*!< Full remap (CH1/PC6, CH2/PC7, CH3/PC8, CH4/PC9) */ + +#define AFIO_MAPR_TIM4_REMAP ((uint32_t)0x00001000) /*!< TIM4_REMAP bit (TIM4 remapping) */ + +#define AFIO_MAPR_CAN_REMAP ((uint32_t)0x00006000) /*!< CAN_REMAP[1:0] bits (CAN Alternate function remapping) */ +#define AFIO_MAPR_CAN_REMAP_0 ((uint32_t)0x00002000) /*!< Bit 0 */ +#define AFIO_MAPR_CAN_REMAP_1 ((uint32_t)0x00004000) /*!< Bit 1 */ + +/*!< CAN_REMAP configuration */ +#define AFIO_MAPR_CAN_REMAP_REMAP1 ((uint32_t)0x00000000) /*!< CANRX mapped to PA11, CANTX mapped to PA12 */ +#define AFIO_MAPR_CAN_REMAP_REMAP2 ((uint32_t)0x00004000) /*!< CANRX mapped to PB8, CANTX mapped to PB9 */ +#define AFIO_MAPR_CAN_REMAP_REMAP3 ((uint32_t)0x00006000) /*!< CANRX mapped to PD0, CANTX mapped to PD1 */ + +#define AFIO_MAPR_PD01_REMAP ((uint32_t)0x00008000) /*!< Port D0/Port D1 mapping on OSC_IN/OSC_OUT */ +#define AFIO_MAPR_TIM5CH4_IREMAP ((uint32_t)0x00010000) /*!< TIM5 Channel4 Internal Remap */ +#define AFIO_MAPR_ADC1_ETRGINJ_REMAP ((uint32_t)0x00020000) /*!< ADC 1 External Trigger Injected Conversion remapping */ +#define AFIO_MAPR_ADC1_ETRGREG_REMAP ((uint32_t)0x00040000) /*!< ADC 1 External Trigger Regular Conversion remapping */ +#define AFIO_MAPR_ADC2_ETRGINJ_REMAP ((uint32_t)0x00080000) /*!< ADC 2 External Trigger Injected Conversion remapping */ +#define AFIO_MAPR_ADC2_ETRGREG_REMAP ((uint32_t)0x00100000) /*!< ADC 2 External Trigger Regular Conversion remapping */ + +/*!< SWJ_CFG configuration */ +#define AFIO_MAPR_SWJ_CFG ((uint32_t)0x07000000) /*!< SWJ_CFG[2:0] bits (Serial Wire JTAG configuration) */ +#define AFIO_MAPR_SWJ_CFG_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define AFIO_MAPR_SWJ_CFG_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define AFIO_MAPR_SWJ_CFG_2 ((uint32_t)0x04000000) /*!< Bit 2 */ + +#define AFIO_MAPR_SWJ_CFG_RESET ((uint32_t)0x00000000) /*!< Full SWJ (JTAG-DP + SW-DP) : Reset State */ +#define AFIO_MAPR_SWJ_CFG_NOJNTRST ((uint32_t)0x01000000) /*!< Full SWJ (JTAG-DP + SW-DP) but without JNTRST */ +#define AFIO_MAPR_SWJ_CFG_JTAGDISABLE ((uint32_t)0x02000000) /*!< JTAG-DP Disabled and SW-DP Enabled */ +#define AFIO_MAPR_SWJ_CFG_DISABLE ((uint32_t)0x04000000) /*!< JTAG-DP Disabled and SW-DP Disabled */ + +#ifdef STM32F10X_CL +/*!< ETH_REMAP configuration */ + #define AFIO_MAPR_ETH_REMAP ((uint32_t)0x00200000) /*!< SPI3_REMAP bit (Ethernet MAC I/O remapping) */ + +/*!< CAN2_REMAP configuration */ + #define AFIO_MAPR_CAN2_REMAP ((uint32_t)0x00400000) /*!< CAN2_REMAP bit (CAN2 I/O remapping) */ + +/*!< MII_RMII_SEL configuration */ + #define AFIO_MAPR_MII_RMII_SEL ((uint32_t)0x00800000) /*!< MII_RMII_SEL bit (Ethernet MII or RMII selection) */ + +/*!< SPI3_REMAP configuration */ + #define AFIO_MAPR_SPI3_REMAP ((uint32_t)0x10000000) /*!< SPI3_REMAP bit (SPI3 remapping) */ + +/*!< TIM2ITR1_IREMAP configuration */ + #define AFIO_MAPR_TIM2ITR1_IREMAP ((uint32_t)0x20000000) /*!< TIM2ITR1_IREMAP bit (TIM2 internal trigger 1 remapping) */ + +/*!< PTP_PPS_REMAP configuration */ + #define AFIO_MAPR_PTP_PPS_REMAP ((uint32_t)0x40000000) /*!< PTP_PPS_REMAP bit (Ethernet PTP PPS remapping) */ +#endif + +/***************** Bit definition for AFIO_EXTICR1 register *****************/ +#define AFIO_EXTICR1_EXTI0 ((uint16_t)0x000F) /*!< EXTI 0 configuration */ +#define AFIO_EXTICR1_EXTI1 ((uint16_t)0x00F0) /*!< EXTI 1 configuration */ +#define AFIO_EXTICR1_EXTI2 ((uint16_t)0x0F00) /*!< EXTI 2 configuration */ +#define AFIO_EXTICR1_EXTI3 ((uint16_t)0xF000) /*!< EXTI 3 configuration */ + +/*!< EXTI0 configuration */ +#define AFIO_EXTICR1_EXTI0_PA ((uint16_t)0x0000) /*!< PA[0] pin */ +#define AFIO_EXTICR1_EXTI0_PB ((uint16_t)0x0001) /*!< PB[0] pin */ +#define AFIO_EXTICR1_EXTI0_PC ((uint16_t)0x0002) /*!< PC[0] pin */ +#define AFIO_EXTICR1_EXTI0_PD ((uint16_t)0x0003) /*!< PD[0] pin */ +#define AFIO_EXTICR1_EXTI0_PE ((uint16_t)0x0004) /*!< PE[0] pin */ +#define AFIO_EXTICR1_EXTI0_PF ((uint16_t)0x0005) /*!< PF[0] pin */ +#define AFIO_EXTICR1_EXTI0_PG ((uint16_t)0x0006) /*!< PG[0] pin */ + +/*!< EXTI1 configuration */ +#define AFIO_EXTICR1_EXTI1_PA ((uint16_t)0x0000) /*!< PA[1] pin */ +#define AFIO_EXTICR1_EXTI1_PB ((uint16_t)0x0010) /*!< PB[1] pin */ +#define AFIO_EXTICR1_EXTI1_PC ((uint16_t)0x0020) /*!< PC[1] pin */ +#define AFIO_EXTICR1_EXTI1_PD ((uint16_t)0x0030) /*!< PD[1] pin */ +#define AFIO_EXTICR1_EXTI1_PE ((uint16_t)0x0040) /*!< PE[1] pin */ +#define AFIO_EXTICR1_EXTI1_PF ((uint16_t)0x0050) /*!< PF[1] pin */ +#define AFIO_EXTICR1_EXTI1_PG ((uint16_t)0x0060) /*!< PG[1] pin */ + +/*!< EXTI2 configuration */ +#define AFIO_EXTICR1_EXTI2_PA ((uint16_t)0x0000) /*!< PA[2] pin */ +#define AFIO_EXTICR1_EXTI2_PB ((uint16_t)0x0100) /*!< PB[2] pin */ +#define AFIO_EXTICR1_EXTI2_PC ((uint16_t)0x0200) /*!< PC[2] pin */ +#define AFIO_EXTICR1_EXTI2_PD ((uint16_t)0x0300) /*!< PD[2] pin */ +#define AFIO_EXTICR1_EXTI2_PE ((uint16_t)0x0400) /*!< PE[2] pin */ +#define AFIO_EXTICR1_EXTI2_PF ((uint16_t)0x0500) /*!< PF[2] pin */ +#define AFIO_EXTICR1_EXTI2_PG ((uint16_t)0x0600) /*!< PG[2] pin */ + +/*!< EXTI3 configuration */ +#define AFIO_EXTICR1_EXTI3_PA ((uint16_t)0x0000) /*!< PA[3] pin */ +#define AFIO_EXTICR1_EXTI3_PB ((uint16_t)0x1000) /*!< PB[3] pin */ +#define AFIO_EXTICR1_EXTI3_PC ((uint16_t)0x2000) /*!< PC[3] pin */ +#define AFIO_EXTICR1_EXTI3_PD ((uint16_t)0x3000) /*!< PD[3] pin */ +#define AFIO_EXTICR1_EXTI3_PE ((uint16_t)0x4000) /*!< PE[3] pin */ +#define AFIO_EXTICR1_EXTI3_PF ((uint16_t)0x5000) /*!< PF[3] pin */ +#define AFIO_EXTICR1_EXTI3_PG ((uint16_t)0x6000) /*!< PG[3] pin */ + +/***************** Bit definition for AFIO_EXTICR2 register *****************/ +#define AFIO_EXTICR2_EXTI4 ((uint16_t)0x000F) /*!< EXTI 4 configuration */ +#define AFIO_EXTICR2_EXTI5 ((uint16_t)0x00F0) /*!< EXTI 5 configuration */ +#define AFIO_EXTICR2_EXTI6 ((uint16_t)0x0F00) /*!< EXTI 6 configuration */ +#define AFIO_EXTICR2_EXTI7 ((uint16_t)0xF000) /*!< EXTI 7 configuration */ + +/*!< EXTI4 configuration */ +#define AFIO_EXTICR2_EXTI4_PA ((uint16_t)0x0000) /*!< PA[4] pin */ +#define AFIO_EXTICR2_EXTI4_PB ((uint16_t)0x0001) /*!< PB[4] pin */ +#define AFIO_EXTICR2_EXTI4_PC ((uint16_t)0x0002) /*!< PC[4] pin */ +#define AFIO_EXTICR2_EXTI4_PD ((uint16_t)0x0003) /*!< PD[4] pin */ +#define AFIO_EXTICR2_EXTI4_PE ((uint16_t)0x0004) /*!< PE[4] pin */ +#define AFIO_EXTICR2_EXTI4_PF ((uint16_t)0x0005) /*!< PF[4] pin */ +#define AFIO_EXTICR2_EXTI4_PG ((uint16_t)0x0006) /*!< PG[4] pin */ + +/* EXTI5 configuration */ +#define AFIO_EXTICR2_EXTI5_PA ((uint16_t)0x0000) /*!< PA[5] pin */ +#define AFIO_EXTICR2_EXTI5_PB ((uint16_t)0x0010) /*!< PB[5] pin */ +#define AFIO_EXTICR2_EXTI5_PC ((uint16_t)0x0020) /*!< PC[5] pin */ +#define AFIO_EXTICR2_EXTI5_PD ((uint16_t)0x0030) /*!< PD[5] pin */ +#define AFIO_EXTICR2_EXTI5_PE ((uint16_t)0x0040) /*!< PE[5] pin */ +#define AFIO_EXTICR2_EXTI5_PF ((uint16_t)0x0050) /*!< PF[5] pin */ +#define AFIO_EXTICR2_EXTI5_PG ((uint16_t)0x0060) /*!< PG[5] pin */ + +/*!< EXTI6 configuration */ +#define AFIO_EXTICR2_EXTI6_PA ((uint16_t)0x0000) /*!< PA[6] pin */ +#define AFIO_EXTICR2_EXTI6_PB ((uint16_t)0x0100) /*!< PB[6] pin */ +#define AFIO_EXTICR2_EXTI6_PC ((uint16_t)0x0200) /*!< PC[6] pin */ +#define AFIO_EXTICR2_EXTI6_PD ((uint16_t)0x0300) /*!< PD[6] pin */ +#define AFIO_EXTICR2_EXTI6_PE ((uint16_t)0x0400) /*!< PE[6] pin */ +#define AFIO_EXTICR2_EXTI6_PF ((uint16_t)0x0500) /*!< PF[6] pin */ +#define AFIO_EXTICR2_EXTI6_PG ((uint16_t)0x0600) /*!< PG[6] pin */ + +/*!< EXTI7 configuration */ +#define AFIO_EXTICR2_EXTI7_PA ((uint16_t)0x0000) /*!< PA[7] pin */ +#define AFIO_EXTICR2_EXTI7_PB ((uint16_t)0x1000) /*!< PB[7] pin */ +#define AFIO_EXTICR2_EXTI7_PC ((uint16_t)0x2000) /*!< PC[7] pin */ +#define AFIO_EXTICR2_EXTI7_PD ((uint16_t)0x3000) /*!< PD[7] pin */ +#define AFIO_EXTICR2_EXTI7_PE ((uint16_t)0x4000) /*!< PE[7] pin */ +#define AFIO_EXTICR2_EXTI7_PF ((uint16_t)0x5000) /*!< PF[7] pin */ +#define AFIO_EXTICR2_EXTI7_PG ((uint16_t)0x6000) /*!< PG[7] pin */ + +/***************** Bit definition for AFIO_EXTICR3 register *****************/ +#define AFIO_EXTICR3_EXTI8 ((uint16_t)0x000F) /*!< EXTI 8 configuration */ +#define AFIO_EXTICR3_EXTI9 ((uint16_t)0x00F0) /*!< EXTI 9 configuration */ +#define AFIO_EXTICR3_EXTI10 ((uint16_t)0x0F00) /*!< EXTI 10 configuration */ +#define AFIO_EXTICR3_EXTI11 ((uint16_t)0xF000) /*!< EXTI 11 configuration */ + +/*!< EXTI8 configuration */ +#define AFIO_EXTICR3_EXTI8_PA ((uint16_t)0x0000) /*!< PA[8] pin */ +#define AFIO_EXTICR3_EXTI8_PB ((uint16_t)0x0001) /*!< PB[8] pin */ +#define AFIO_EXTICR3_EXTI8_PC ((uint16_t)0x0002) /*!< PC[8] pin */ +#define AFIO_EXTICR3_EXTI8_PD ((uint16_t)0x0003) /*!< PD[8] pin */ +#define AFIO_EXTICR3_EXTI8_PE ((uint16_t)0x0004) /*!< PE[8] pin */ +#define AFIO_EXTICR3_EXTI8_PF ((uint16_t)0x0005) /*!< PF[8] pin */ +#define AFIO_EXTICR3_EXTI8_PG ((uint16_t)0x0006) /*!< PG[8] pin */ + +/*!< EXTI9 configuration */ +#define AFIO_EXTICR3_EXTI9_PA ((uint16_t)0x0000) /*!< PA[9] pin */ +#define AFIO_EXTICR3_EXTI9_PB ((uint16_t)0x0010) /*!< PB[9] pin */ +#define AFIO_EXTICR3_EXTI9_PC ((uint16_t)0x0020) /*!< PC[9] pin */ +#define AFIO_EXTICR3_EXTI9_PD ((uint16_t)0x0030) /*!< PD[9] pin */ +#define AFIO_EXTICR3_EXTI9_PE ((uint16_t)0x0040) /*!< PE[9] pin */ +#define AFIO_EXTICR3_EXTI9_PF ((uint16_t)0x0050) /*!< PF[9] pin */ +#define AFIO_EXTICR3_EXTI9_PG ((uint16_t)0x0060) /*!< PG[9] pin */ + +/*!< EXTI10 configuration */ +#define AFIO_EXTICR3_EXTI10_PA ((uint16_t)0x0000) /*!< PA[10] pin */ +#define AFIO_EXTICR3_EXTI10_PB ((uint16_t)0x0100) /*!< PB[10] pin */ +#define AFIO_EXTICR3_EXTI10_PC ((uint16_t)0x0200) /*!< PC[10] pin */ +#define AFIO_EXTICR3_EXTI10_PD ((uint16_t)0x0300) /*!< PD[10] pin */ +#define AFIO_EXTICR3_EXTI10_PE ((uint16_t)0x0400) /*!< PE[10] pin */ +#define AFIO_EXTICR3_EXTI10_PF ((uint16_t)0x0500) /*!< PF[10] pin */ +#define AFIO_EXTICR3_EXTI10_PG ((uint16_t)0x0600) /*!< PG[10] pin */ + +/*!< EXTI11 configuration */ +#define AFIO_EXTICR3_EXTI11_PA ((uint16_t)0x0000) /*!< PA[11] pin */ +#define AFIO_EXTICR3_EXTI11_PB ((uint16_t)0x1000) /*!< PB[11] pin */ +#define AFIO_EXTICR3_EXTI11_PC ((uint16_t)0x2000) /*!< PC[11] pin */ +#define AFIO_EXTICR3_EXTI11_PD ((uint16_t)0x3000) /*!< PD[11] pin */ +#define AFIO_EXTICR3_EXTI11_PE ((uint16_t)0x4000) /*!< PE[11] pin */ +#define AFIO_EXTICR3_EXTI11_PF ((uint16_t)0x5000) /*!< PF[11] pin */ +#define AFIO_EXTICR3_EXTI11_PG ((uint16_t)0x6000) /*!< PG[11] pin */ + +/***************** Bit definition for AFIO_EXTICR4 register *****************/ +#define AFIO_EXTICR4_EXTI12 ((uint16_t)0x000F) /*!< EXTI 12 configuration */ +#define AFIO_EXTICR4_EXTI13 ((uint16_t)0x00F0) /*!< EXTI 13 configuration */ +#define AFIO_EXTICR4_EXTI14 ((uint16_t)0x0F00) /*!< EXTI 14 configuration */ +#define AFIO_EXTICR4_EXTI15 ((uint16_t)0xF000) /*!< EXTI 15 configuration */ + +/* EXTI12 configuration */ +#define AFIO_EXTICR4_EXTI12_PA ((uint16_t)0x0000) /*!< PA[12] pin */ +#define AFIO_EXTICR4_EXTI12_PB ((uint16_t)0x0001) /*!< PB[12] pin */ +#define AFIO_EXTICR4_EXTI12_PC ((uint16_t)0x0002) /*!< PC[12] pin */ +#define AFIO_EXTICR4_EXTI12_PD ((uint16_t)0x0003) /*!< PD[12] pin */ +#define AFIO_EXTICR4_EXTI12_PE ((uint16_t)0x0004) /*!< PE[12] pin */ +#define AFIO_EXTICR4_EXTI12_PF ((uint16_t)0x0005) /*!< PF[12] pin */ +#define AFIO_EXTICR4_EXTI12_PG ((uint16_t)0x0006) /*!< PG[12] pin */ + +/* EXTI13 configuration */ +#define AFIO_EXTICR4_EXTI13_PA ((uint16_t)0x0000) /*!< PA[13] pin */ +#define AFIO_EXTICR4_EXTI13_PB ((uint16_t)0x0010) /*!< PB[13] pin */ +#define AFIO_EXTICR4_EXTI13_PC ((uint16_t)0x0020) /*!< PC[13] pin */ +#define AFIO_EXTICR4_EXTI13_PD ((uint16_t)0x0030) /*!< PD[13] pin */ +#define AFIO_EXTICR4_EXTI13_PE ((uint16_t)0x0040) /*!< PE[13] pin */ +#define AFIO_EXTICR4_EXTI13_PF ((uint16_t)0x0050) /*!< PF[13] pin */ +#define AFIO_EXTICR4_EXTI13_PG ((uint16_t)0x0060) /*!< PG[13] pin */ + +/*!< EXTI14 configuration */ +#define AFIO_EXTICR4_EXTI14_PA ((uint16_t)0x0000) /*!< PA[14] pin */ +#define AFIO_EXTICR4_EXTI14_PB ((uint16_t)0x0100) /*!< PB[14] pin */ +#define AFIO_EXTICR4_EXTI14_PC ((uint16_t)0x0200) /*!< PC[14] pin */ +#define AFIO_EXTICR4_EXTI14_PD ((uint16_t)0x0300) /*!< PD[14] pin */ +#define AFIO_EXTICR4_EXTI14_PE ((uint16_t)0x0400) /*!< PE[14] pin */ +#define AFIO_EXTICR4_EXTI14_PF ((uint16_t)0x0500) /*!< PF[14] pin */ +#define AFIO_EXTICR4_EXTI14_PG ((uint16_t)0x0600) /*!< PG[14] pin */ + +/*!< EXTI15 configuration */ +#define AFIO_EXTICR4_EXTI15_PA ((uint16_t)0x0000) /*!< PA[15] pin */ +#define AFIO_EXTICR4_EXTI15_PB ((uint16_t)0x1000) /*!< PB[15] pin */ +#define AFIO_EXTICR4_EXTI15_PC ((uint16_t)0x2000) /*!< PC[15] pin */ +#define AFIO_EXTICR4_EXTI15_PD ((uint16_t)0x3000) /*!< PD[15] pin */ +#define AFIO_EXTICR4_EXTI15_PE ((uint16_t)0x4000) /*!< PE[15] pin */ +#define AFIO_EXTICR4_EXTI15_PF ((uint16_t)0x5000) /*!< PF[15] pin */ +#define AFIO_EXTICR4_EXTI15_PG ((uint16_t)0x6000) /*!< PG[15] pin */ + +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) +/****************** Bit definition for AFIO_MAPR2 register ******************/ +#define AFIO_MAPR2_TIM15_REMAP ((uint32_t)0x00000001) /*!< TIM15 remapping */ +#define AFIO_MAPR2_TIM16_REMAP ((uint32_t)0x00000002) /*!< TIM16 remapping */ +#define AFIO_MAPR2_TIM17_REMAP ((uint32_t)0x00000004) /*!< TIM17 remapping */ +#define AFIO_MAPR2_CEC_REMAP ((uint32_t)0x00000008) /*!< CEC remapping */ +#define AFIO_MAPR2_TIM1_DMA_REMAP ((uint32_t)0x00000010) /*!< TIM1_DMA remapping */ +#endif + +#ifdef STM32F10X_HD_VL +#define AFIO_MAPR2_TIM13_REMAP ((uint32_t)0x00000100) /*!< TIM13 remapping */ +#define AFIO_MAPR2_TIM14_REMAP ((uint32_t)0x00000200) /*!< TIM14 remapping */ +#define AFIO_MAPR2_FSMC_NADV_REMAP ((uint32_t)0x00000400) /*!< FSMC NADV remapping */ +#define AFIO_MAPR2_TIM67_DAC_DMA_REMAP ((uint32_t)0x00000800) /*!< TIM6/TIM7 and DAC DMA remapping */ +#define AFIO_MAPR2_TIM12_REMAP ((uint32_t)0x00001000) /*!< TIM12 remapping */ +#define AFIO_MAPR2_MISC_REMAP ((uint32_t)0x00002000) /*!< Miscellaneous remapping */ +#endif + +#ifdef STM32F10X_XL +/****************** Bit definition for AFIO_MAPR2 register ******************/ +#define AFIO_MAPR2_TIM9_REMAP ((uint32_t)0x00000020) /*!< TIM9 remapping */ +#define AFIO_MAPR2_TIM10_REMAP ((uint32_t)0x00000040) /*!< TIM10 remapping */ +#define AFIO_MAPR2_TIM11_REMAP ((uint32_t)0x00000080) /*!< TIM11 remapping */ +#define AFIO_MAPR2_TIM13_REMAP ((uint32_t)0x00000100) /*!< TIM13 remapping */ +#define AFIO_MAPR2_TIM14_REMAP ((uint32_t)0x00000200) /*!< TIM14 remapping */ +#define AFIO_MAPR2_FSMC_NADV_REMAP ((uint32_t)0x00000400) /*!< FSMC NADV remapping */ +#endif + +/******************************************************************************/ +/* */ +/* SystemTick */ +/* */ +/******************************************************************************/ + +/***************** Bit definition for SysTick_CTRL register *****************/ +#define SysTick_CTRL_ENABLE ((uint32_t)0x00000001) /*!< Counter enable */ +#define SysTick_CTRL_TICKINT ((uint32_t)0x00000002) /*!< Counting down to 0 pends the SysTick handler */ +#define SysTick_CTRL_CLKSOURCE ((uint32_t)0x00000004) /*!< Clock source */ +#define SysTick_CTRL_COUNTFLAG ((uint32_t)0x00010000) /*!< Count Flag */ + +/***************** Bit definition for SysTick_LOAD register *****************/ +#define SysTick_LOAD_RELOAD ((uint32_t)0x00FFFFFF) /*!< Value to load into the SysTick Current Value Register when the counter reaches 0 */ + +/***************** Bit definition for SysTick_VAL register ******************/ +#define SysTick_VAL_CURRENT ((uint32_t)0x00FFFFFF) /*!< Current value at the time the register is accessed */ + +/***************** Bit definition for SysTick_CALIB register ****************/ +#define SysTick_CALIB_TENMS ((uint32_t)0x00FFFFFF) /*!< Reload value to use for 10ms timing */ +#define SysTick_CALIB_SKEW ((uint32_t)0x40000000) /*!< Calibration value is not exactly 10 ms */ +#define SysTick_CALIB_NOREF ((uint32_t)0x80000000) /*!< The reference clock is not provided */ + +/******************************************************************************/ +/* */ +/* Nested Vectored Interrupt Controller */ +/* */ +/******************************************************************************/ + +/****************** Bit definition for NVIC_ISER register *******************/ +#define NVIC_ISER_SETENA ((uint32_t)0xFFFFFFFF) /*!< Interrupt set enable bits */ +#define NVIC_ISER_SETENA_0 ((uint32_t)0x00000001) /*!< bit 0 */ +#define NVIC_ISER_SETENA_1 ((uint32_t)0x00000002) /*!< bit 1 */ +#define NVIC_ISER_SETENA_2 ((uint32_t)0x00000004) /*!< bit 2 */ +#define NVIC_ISER_SETENA_3 ((uint32_t)0x00000008) /*!< bit 3 */ +#define NVIC_ISER_SETENA_4 ((uint32_t)0x00000010) /*!< bit 4 */ +#define NVIC_ISER_SETENA_5 ((uint32_t)0x00000020) /*!< bit 5 */ +#define NVIC_ISER_SETENA_6 ((uint32_t)0x00000040) /*!< bit 6 */ +#define NVIC_ISER_SETENA_7 ((uint32_t)0x00000080) /*!< bit 7 */ +#define NVIC_ISER_SETENA_8 ((uint32_t)0x00000100) /*!< bit 8 */ +#define NVIC_ISER_SETENA_9 ((uint32_t)0x00000200) /*!< bit 9 */ +#define NVIC_ISER_SETENA_10 ((uint32_t)0x00000400) /*!< bit 10 */ +#define NVIC_ISER_SETENA_11 ((uint32_t)0x00000800) /*!< bit 11 */ +#define NVIC_ISER_SETENA_12 ((uint32_t)0x00001000) /*!< bit 12 */ +#define NVIC_ISER_SETENA_13 ((uint32_t)0x00002000) /*!< bit 13 */ +#define NVIC_ISER_SETENA_14 ((uint32_t)0x00004000) /*!< bit 14 */ +#define NVIC_ISER_SETENA_15 ((uint32_t)0x00008000) /*!< bit 15 */ +#define NVIC_ISER_SETENA_16 ((uint32_t)0x00010000) /*!< bit 16 */ +#define NVIC_ISER_SETENA_17 ((uint32_t)0x00020000) /*!< bit 17 */ +#define NVIC_ISER_SETENA_18 ((uint32_t)0x00040000) /*!< bit 18 */ +#define NVIC_ISER_SETENA_19 ((uint32_t)0x00080000) /*!< bit 19 */ +#define NVIC_ISER_SETENA_20 ((uint32_t)0x00100000) /*!< bit 20 */ +#define NVIC_ISER_SETENA_21 ((uint32_t)0x00200000) /*!< bit 21 */ +#define NVIC_ISER_SETENA_22 ((uint32_t)0x00400000) /*!< bit 22 */ +#define NVIC_ISER_SETENA_23 ((uint32_t)0x00800000) /*!< bit 23 */ +#define NVIC_ISER_SETENA_24 ((uint32_t)0x01000000) /*!< bit 24 */ +#define NVIC_ISER_SETENA_25 ((uint32_t)0x02000000) /*!< bit 25 */ +#define NVIC_ISER_SETENA_26 ((uint32_t)0x04000000) /*!< bit 26 */ +#define NVIC_ISER_SETENA_27 ((uint32_t)0x08000000) /*!< bit 27 */ +#define NVIC_ISER_SETENA_28 ((uint32_t)0x10000000) /*!< bit 28 */ +#define NVIC_ISER_SETENA_29 ((uint32_t)0x20000000) /*!< bit 29 */ +#define NVIC_ISER_SETENA_30 ((uint32_t)0x40000000) /*!< bit 30 */ +#define NVIC_ISER_SETENA_31 ((uint32_t)0x80000000) /*!< bit 31 */ + +/****************** Bit definition for NVIC_ICER register *******************/ +#define NVIC_ICER_CLRENA ((uint32_t)0xFFFFFFFF) /*!< Interrupt clear-enable bits */ +#define NVIC_ICER_CLRENA_0 ((uint32_t)0x00000001) /*!< bit 0 */ +#define NVIC_ICER_CLRENA_1 ((uint32_t)0x00000002) /*!< bit 1 */ +#define NVIC_ICER_CLRENA_2 ((uint32_t)0x00000004) /*!< bit 2 */ +#define NVIC_ICER_CLRENA_3 ((uint32_t)0x00000008) /*!< bit 3 */ +#define NVIC_ICER_CLRENA_4 ((uint32_t)0x00000010) /*!< bit 4 */ +#define NVIC_ICER_CLRENA_5 ((uint32_t)0x00000020) /*!< bit 5 */ +#define NVIC_ICER_CLRENA_6 ((uint32_t)0x00000040) /*!< bit 6 */ +#define NVIC_ICER_CLRENA_7 ((uint32_t)0x00000080) /*!< bit 7 */ +#define NVIC_ICER_CLRENA_8 ((uint32_t)0x00000100) /*!< bit 8 */ +#define NVIC_ICER_CLRENA_9 ((uint32_t)0x00000200) /*!< bit 9 */ +#define NVIC_ICER_CLRENA_10 ((uint32_t)0x00000400) /*!< bit 10 */ +#define NVIC_ICER_CLRENA_11 ((uint32_t)0x00000800) /*!< bit 11 */ +#define NVIC_ICER_CLRENA_12 ((uint32_t)0x00001000) /*!< bit 12 */ +#define NVIC_ICER_CLRENA_13 ((uint32_t)0x00002000) /*!< bit 13 */ +#define NVIC_ICER_CLRENA_14 ((uint32_t)0x00004000) /*!< bit 14 */ +#define NVIC_ICER_CLRENA_15 ((uint32_t)0x00008000) /*!< bit 15 */ +#define NVIC_ICER_CLRENA_16 ((uint32_t)0x00010000) /*!< bit 16 */ +#define NVIC_ICER_CLRENA_17 ((uint32_t)0x00020000) /*!< bit 17 */ +#define NVIC_ICER_CLRENA_18 ((uint32_t)0x00040000) /*!< bit 18 */ +#define NVIC_ICER_CLRENA_19 ((uint32_t)0x00080000) /*!< bit 19 */ +#define NVIC_ICER_CLRENA_20 ((uint32_t)0x00100000) /*!< bit 20 */ +#define NVIC_ICER_CLRENA_21 ((uint32_t)0x00200000) /*!< bit 21 */ +#define NVIC_ICER_CLRENA_22 ((uint32_t)0x00400000) /*!< bit 22 */ +#define NVIC_ICER_CLRENA_23 ((uint32_t)0x00800000) /*!< bit 23 */ +#define NVIC_ICER_CLRENA_24 ((uint32_t)0x01000000) /*!< bit 24 */ +#define NVIC_ICER_CLRENA_25 ((uint32_t)0x02000000) /*!< bit 25 */ +#define NVIC_ICER_CLRENA_26 ((uint32_t)0x04000000) /*!< bit 26 */ +#define NVIC_ICER_CLRENA_27 ((uint32_t)0x08000000) /*!< bit 27 */ +#define NVIC_ICER_CLRENA_28 ((uint32_t)0x10000000) /*!< bit 28 */ +#define NVIC_ICER_CLRENA_29 ((uint32_t)0x20000000) /*!< bit 29 */ +#define NVIC_ICER_CLRENA_30 ((uint32_t)0x40000000) /*!< bit 30 */ +#define NVIC_ICER_CLRENA_31 ((uint32_t)0x80000000) /*!< bit 31 */ + +/****************** Bit definition for NVIC_ISPR register *******************/ +#define NVIC_ISPR_SETPEND ((uint32_t)0xFFFFFFFF) /*!< Interrupt set-pending bits */ +#define NVIC_ISPR_SETPEND_0 ((uint32_t)0x00000001) /*!< bit 0 */ +#define NVIC_ISPR_SETPEND_1 ((uint32_t)0x00000002) /*!< bit 1 */ +#define NVIC_ISPR_SETPEND_2 ((uint32_t)0x00000004) /*!< bit 2 */ +#define NVIC_ISPR_SETPEND_3 ((uint32_t)0x00000008) /*!< bit 3 */ +#define NVIC_ISPR_SETPEND_4 ((uint32_t)0x00000010) /*!< bit 4 */ +#define NVIC_ISPR_SETPEND_5 ((uint32_t)0x00000020) /*!< bit 5 */ +#define NVIC_ISPR_SETPEND_6 ((uint32_t)0x00000040) /*!< bit 6 */ +#define NVIC_ISPR_SETPEND_7 ((uint32_t)0x00000080) /*!< bit 7 */ +#define NVIC_ISPR_SETPEND_8 ((uint32_t)0x00000100) /*!< bit 8 */ +#define NVIC_ISPR_SETPEND_9 ((uint32_t)0x00000200) /*!< bit 9 */ +#define NVIC_ISPR_SETPEND_10 ((uint32_t)0x00000400) /*!< bit 10 */ +#define NVIC_ISPR_SETPEND_11 ((uint32_t)0x00000800) /*!< bit 11 */ +#define NVIC_ISPR_SETPEND_12 ((uint32_t)0x00001000) /*!< bit 12 */ +#define NVIC_ISPR_SETPEND_13 ((uint32_t)0x00002000) /*!< bit 13 */ +#define NVIC_ISPR_SETPEND_14 ((uint32_t)0x00004000) /*!< bit 14 */ +#define NVIC_ISPR_SETPEND_15 ((uint32_t)0x00008000) /*!< bit 15 */ +#define NVIC_ISPR_SETPEND_16 ((uint32_t)0x00010000) /*!< bit 16 */ +#define NVIC_ISPR_SETPEND_17 ((uint32_t)0x00020000) /*!< bit 17 */ +#define NVIC_ISPR_SETPEND_18 ((uint32_t)0x00040000) /*!< bit 18 */ +#define NVIC_ISPR_SETPEND_19 ((uint32_t)0x00080000) /*!< bit 19 */ +#define NVIC_ISPR_SETPEND_20 ((uint32_t)0x00100000) /*!< bit 20 */ +#define NVIC_ISPR_SETPEND_21 ((uint32_t)0x00200000) /*!< bit 21 */ +#define NVIC_ISPR_SETPEND_22 ((uint32_t)0x00400000) /*!< bit 22 */ +#define NVIC_ISPR_SETPEND_23 ((uint32_t)0x00800000) /*!< bit 23 */ +#define NVIC_ISPR_SETPEND_24 ((uint32_t)0x01000000) /*!< bit 24 */ +#define NVIC_ISPR_SETPEND_25 ((uint32_t)0x02000000) /*!< bit 25 */ +#define NVIC_ISPR_SETPEND_26 ((uint32_t)0x04000000) /*!< bit 26 */ +#define NVIC_ISPR_SETPEND_27 ((uint32_t)0x08000000) /*!< bit 27 */ +#define NVIC_ISPR_SETPEND_28 ((uint32_t)0x10000000) /*!< bit 28 */ +#define NVIC_ISPR_SETPEND_29 ((uint32_t)0x20000000) /*!< bit 29 */ +#define NVIC_ISPR_SETPEND_30 ((uint32_t)0x40000000) /*!< bit 30 */ +#define NVIC_ISPR_SETPEND_31 ((uint32_t)0x80000000) /*!< bit 31 */ + +/****************** Bit definition for NVIC_ICPR register *******************/ +#define NVIC_ICPR_CLRPEND ((uint32_t)0xFFFFFFFF) /*!< Interrupt clear-pending bits */ +#define NVIC_ICPR_CLRPEND_0 ((uint32_t)0x00000001) /*!< bit 0 */ +#define NVIC_ICPR_CLRPEND_1 ((uint32_t)0x00000002) /*!< bit 1 */ +#define NVIC_ICPR_CLRPEND_2 ((uint32_t)0x00000004) /*!< bit 2 */ +#define NVIC_ICPR_CLRPEND_3 ((uint32_t)0x00000008) /*!< bit 3 */ +#define NVIC_ICPR_CLRPEND_4 ((uint32_t)0x00000010) /*!< bit 4 */ +#define NVIC_ICPR_CLRPEND_5 ((uint32_t)0x00000020) /*!< bit 5 */ +#define NVIC_ICPR_CLRPEND_6 ((uint32_t)0x00000040) /*!< bit 6 */ +#define NVIC_ICPR_CLRPEND_7 ((uint32_t)0x00000080) /*!< bit 7 */ +#define NVIC_ICPR_CLRPEND_8 ((uint32_t)0x00000100) /*!< bit 8 */ +#define NVIC_ICPR_CLRPEND_9 ((uint32_t)0x00000200) /*!< bit 9 */ +#define NVIC_ICPR_CLRPEND_10 ((uint32_t)0x00000400) /*!< bit 10 */ +#define NVIC_ICPR_CLRPEND_11 ((uint32_t)0x00000800) /*!< bit 11 */ +#define NVIC_ICPR_CLRPEND_12 ((uint32_t)0x00001000) /*!< bit 12 */ +#define NVIC_ICPR_CLRPEND_13 ((uint32_t)0x00002000) /*!< bit 13 */ +#define NVIC_ICPR_CLRPEND_14 ((uint32_t)0x00004000) /*!< bit 14 */ +#define NVIC_ICPR_CLRPEND_15 ((uint32_t)0x00008000) /*!< bit 15 */ +#define NVIC_ICPR_CLRPEND_16 ((uint32_t)0x00010000) /*!< bit 16 */ +#define NVIC_ICPR_CLRPEND_17 ((uint32_t)0x00020000) /*!< bit 17 */ +#define NVIC_ICPR_CLRPEND_18 ((uint32_t)0x00040000) /*!< bit 18 */ +#define NVIC_ICPR_CLRPEND_19 ((uint32_t)0x00080000) /*!< bit 19 */ +#define NVIC_ICPR_CLRPEND_20 ((uint32_t)0x00100000) /*!< bit 20 */ +#define NVIC_ICPR_CLRPEND_21 ((uint32_t)0x00200000) /*!< bit 21 */ +#define NVIC_ICPR_CLRPEND_22 ((uint32_t)0x00400000) /*!< bit 22 */ +#define NVIC_ICPR_CLRPEND_23 ((uint32_t)0x00800000) /*!< bit 23 */ +#define NVIC_ICPR_CLRPEND_24 ((uint32_t)0x01000000) /*!< bit 24 */ +#define NVIC_ICPR_CLRPEND_25 ((uint32_t)0x02000000) /*!< bit 25 */ +#define NVIC_ICPR_CLRPEND_26 ((uint32_t)0x04000000) /*!< bit 26 */ +#define NVIC_ICPR_CLRPEND_27 ((uint32_t)0x08000000) /*!< bit 27 */ +#define NVIC_ICPR_CLRPEND_28 ((uint32_t)0x10000000) /*!< bit 28 */ +#define NVIC_ICPR_CLRPEND_29 ((uint32_t)0x20000000) /*!< bit 29 */ +#define NVIC_ICPR_CLRPEND_30 ((uint32_t)0x40000000) /*!< bit 30 */ +#define NVIC_ICPR_CLRPEND_31 ((uint32_t)0x80000000) /*!< bit 31 */ + +/****************** Bit definition for NVIC_IABR register *******************/ +#define NVIC_IABR_ACTIVE ((uint32_t)0xFFFFFFFF) /*!< Interrupt active flags */ +#define NVIC_IABR_ACTIVE_0 ((uint32_t)0x00000001) /*!< bit 0 */ +#define NVIC_IABR_ACTIVE_1 ((uint32_t)0x00000002) /*!< bit 1 */ +#define NVIC_IABR_ACTIVE_2 ((uint32_t)0x00000004) /*!< bit 2 */ +#define NVIC_IABR_ACTIVE_3 ((uint32_t)0x00000008) /*!< bit 3 */ +#define NVIC_IABR_ACTIVE_4 ((uint32_t)0x00000010) /*!< bit 4 */ +#define NVIC_IABR_ACTIVE_5 ((uint32_t)0x00000020) /*!< bit 5 */ +#define NVIC_IABR_ACTIVE_6 ((uint32_t)0x00000040) /*!< bit 6 */ +#define NVIC_IABR_ACTIVE_7 ((uint32_t)0x00000080) /*!< bit 7 */ +#define NVIC_IABR_ACTIVE_8 ((uint32_t)0x00000100) /*!< bit 8 */ +#define NVIC_IABR_ACTIVE_9 ((uint32_t)0x00000200) /*!< bit 9 */ +#define NVIC_IABR_ACTIVE_10 ((uint32_t)0x00000400) /*!< bit 10 */ +#define NVIC_IABR_ACTIVE_11 ((uint32_t)0x00000800) /*!< bit 11 */ +#define NVIC_IABR_ACTIVE_12 ((uint32_t)0x00001000) /*!< bit 12 */ +#define NVIC_IABR_ACTIVE_13 ((uint32_t)0x00002000) /*!< bit 13 */ +#define NVIC_IABR_ACTIVE_14 ((uint32_t)0x00004000) /*!< bit 14 */ +#define NVIC_IABR_ACTIVE_15 ((uint32_t)0x00008000) /*!< bit 15 */ +#define NVIC_IABR_ACTIVE_16 ((uint32_t)0x00010000) /*!< bit 16 */ +#define NVIC_IABR_ACTIVE_17 ((uint32_t)0x00020000) /*!< bit 17 */ +#define NVIC_IABR_ACTIVE_18 ((uint32_t)0x00040000) /*!< bit 18 */ +#define NVIC_IABR_ACTIVE_19 ((uint32_t)0x00080000) /*!< bit 19 */ +#define NVIC_IABR_ACTIVE_20 ((uint32_t)0x00100000) /*!< bit 20 */ +#define NVIC_IABR_ACTIVE_21 ((uint32_t)0x00200000) /*!< bit 21 */ +#define NVIC_IABR_ACTIVE_22 ((uint32_t)0x00400000) /*!< bit 22 */ +#define NVIC_IABR_ACTIVE_23 ((uint32_t)0x00800000) /*!< bit 23 */ +#define NVIC_IABR_ACTIVE_24 ((uint32_t)0x01000000) /*!< bit 24 */ +#define NVIC_IABR_ACTIVE_25 ((uint32_t)0x02000000) /*!< bit 25 */ +#define NVIC_IABR_ACTIVE_26 ((uint32_t)0x04000000) /*!< bit 26 */ +#define NVIC_IABR_ACTIVE_27 ((uint32_t)0x08000000) /*!< bit 27 */ +#define NVIC_IABR_ACTIVE_28 ((uint32_t)0x10000000) /*!< bit 28 */ +#define NVIC_IABR_ACTIVE_29 ((uint32_t)0x20000000) /*!< bit 29 */ +#define NVIC_IABR_ACTIVE_30 ((uint32_t)0x40000000) /*!< bit 30 */ +#define NVIC_IABR_ACTIVE_31 ((uint32_t)0x80000000) /*!< bit 31 */ + +/****************** Bit definition for NVIC_PRI0 register *******************/ +#define NVIC_IPR0_PRI_0 ((uint32_t)0x000000FF) /*!< Priority of interrupt 0 */ +#define NVIC_IPR0_PRI_1 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 1 */ +#define NVIC_IPR0_PRI_2 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 2 */ +#define NVIC_IPR0_PRI_3 ((uint32_t)0xFF000000) /*!< Priority of interrupt 3 */ + +/****************** Bit definition for NVIC_PRI1 register *******************/ +#define NVIC_IPR1_PRI_4 ((uint32_t)0x000000FF) /*!< Priority of interrupt 4 */ +#define NVIC_IPR1_PRI_5 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 5 */ +#define NVIC_IPR1_PRI_6 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 6 */ +#define NVIC_IPR1_PRI_7 ((uint32_t)0xFF000000) /*!< Priority of interrupt 7 */ + +/****************** Bit definition for NVIC_PRI2 register *******************/ +#define NVIC_IPR2_PRI_8 ((uint32_t)0x000000FF) /*!< Priority of interrupt 8 */ +#define NVIC_IPR2_PRI_9 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 9 */ +#define NVIC_IPR2_PRI_10 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 10 */ +#define NVIC_IPR2_PRI_11 ((uint32_t)0xFF000000) /*!< Priority of interrupt 11 */ + +/****************** Bit definition for NVIC_PRI3 register *******************/ +#define NVIC_IPR3_PRI_12 ((uint32_t)0x000000FF) /*!< Priority of interrupt 12 */ +#define NVIC_IPR3_PRI_13 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 13 */ +#define NVIC_IPR3_PRI_14 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 14 */ +#define NVIC_IPR3_PRI_15 ((uint32_t)0xFF000000) /*!< Priority of interrupt 15 */ + +/****************** Bit definition for NVIC_PRI4 register *******************/ +#define NVIC_IPR4_PRI_16 ((uint32_t)0x000000FF) /*!< Priority of interrupt 16 */ +#define NVIC_IPR4_PRI_17 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 17 */ +#define NVIC_IPR4_PRI_18 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 18 */ +#define NVIC_IPR4_PRI_19 ((uint32_t)0xFF000000) /*!< Priority of interrupt 19 */ + +/****************** Bit definition for NVIC_PRI5 register *******************/ +#define NVIC_IPR5_PRI_20 ((uint32_t)0x000000FF) /*!< Priority of interrupt 20 */ +#define NVIC_IPR5_PRI_21 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 21 */ +#define NVIC_IPR5_PRI_22 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 22 */ +#define NVIC_IPR5_PRI_23 ((uint32_t)0xFF000000) /*!< Priority of interrupt 23 */ + +/****************** Bit definition for NVIC_PRI6 register *******************/ +#define NVIC_IPR6_PRI_24 ((uint32_t)0x000000FF) /*!< Priority of interrupt 24 */ +#define NVIC_IPR6_PRI_25 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 25 */ +#define NVIC_IPR6_PRI_26 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 26 */ +#define NVIC_IPR6_PRI_27 ((uint32_t)0xFF000000) /*!< Priority of interrupt 27 */ + +/****************** Bit definition for NVIC_PRI7 register *******************/ +#define NVIC_IPR7_PRI_28 ((uint32_t)0x000000FF) /*!< Priority of interrupt 28 */ +#define NVIC_IPR7_PRI_29 ((uint32_t)0x0000FF00) /*!< Priority of interrupt 29 */ +#define NVIC_IPR7_PRI_30 ((uint32_t)0x00FF0000) /*!< Priority of interrupt 30 */ +#define NVIC_IPR7_PRI_31 ((uint32_t)0xFF000000) /*!< Priority of interrupt 31 */ + +/****************** Bit definition for SCB_CPUID register *******************/ +#define SCB_CPUID_REVISION ((uint32_t)0x0000000F) /*!< Implementation defined revision number */ +#define SCB_CPUID_PARTNO ((uint32_t)0x0000FFF0) /*!< Number of processor within family */ +#define SCB_CPUID_Constant ((uint32_t)0x000F0000) /*!< Reads as 0x0F */ +#define SCB_CPUID_VARIANT ((uint32_t)0x00F00000) /*!< Implementation defined variant number */ +#define SCB_CPUID_IMPLEMENTER ((uint32_t)0xFF000000) /*!< Implementer code. ARM is 0x41 */ + +/******************* Bit definition for SCB_ICSR register *******************/ +#define SCB_ICSR_VECTACTIVE ((uint32_t)0x000001FF) /*!< Active ISR number field */ +#define SCB_ICSR_RETTOBASE ((uint32_t)0x00000800) /*!< All active exceptions minus the IPSR_current_exception yields the empty set */ +#define SCB_ICSR_VECTPENDING ((uint32_t)0x003FF000) /*!< Pending ISR number field */ +#define SCB_ICSR_ISRPENDING ((uint32_t)0x00400000) /*!< Interrupt pending flag */ +#define SCB_ICSR_ISRPREEMPT ((uint32_t)0x00800000) /*!< It indicates that a pending interrupt becomes active in the next running cycle */ +#define SCB_ICSR_PENDSTCLR ((uint32_t)0x02000000) /*!< Clear pending SysTick bit */ +#define SCB_ICSR_PENDSTSET ((uint32_t)0x04000000) /*!< Set pending SysTick bit */ +#define SCB_ICSR_PENDSVCLR ((uint32_t)0x08000000) /*!< Clear pending pendSV bit */ +#define SCB_ICSR_PENDSVSET ((uint32_t)0x10000000) /*!< Set pending pendSV bit */ +#define SCB_ICSR_NMIPENDSET ((uint32_t)0x80000000) /*!< Set pending NMI bit */ + +/******************* Bit definition for SCB_VTOR register *******************/ +#define SCB_VTOR_TBLOFF ((uint32_t)0x1FFFFF80) /*!< Vector table base offset field */ +#define SCB_VTOR_TBLBASE ((uint32_t)0x20000000) /*!< Table base in code(0) or RAM(1) */ + +/*!<***************** Bit definition for SCB_AIRCR register *******************/ +#define SCB_AIRCR_VECTRESET ((uint32_t)0x00000001) /*!< System Reset bit */ +#define SCB_AIRCR_VECTCLRACTIVE ((uint32_t)0x00000002) /*!< Clear active vector bit */ +#define SCB_AIRCR_SYSRESETREQ ((uint32_t)0x00000004) /*!< Requests chip control logic to generate a reset */ + +#define SCB_AIRCR_PRIGROUP ((uint32_t)0x00000700) /*!< PRIGROUP[2:0] bits (Priority group) */ +#define SCB_AIRCR_PRIGROUP_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define SCB_AIRCR_PRIGROUP_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define SCB_AIRCR_PRIGROUP_2 ((uint32_t)0x00000400) /*!< Bit 2 */ + +/* prority group configuration */ +#define SCB_AIRCR_PRIGROUP0 ((uint32_t)0x00000000) /*!< Priority group=0 (7 bits of pre-emption priority, 1 bit of subpriority) */ +#define SCB_AIRCR_PRIGROUP1 ((uint32_t)0x00000100) /*!< Priority group=1 (6 bits of pre-emption priority, 2 bits of subpriority) */ +#define SCB_AIRCR_PRIGROUP2 ((uint32_t)0x00000200) /*!< Priority group=2 (5 bits of pre-emption priority, 3 bits of subpriority) */ +#define SCB_AIRCR_PRIGROUP3 ((uint32_t)0x00000300) /*!< Priority group=3 (4 bits of pre-emption priority, 4 bits of subpriority) */ +#define SCB_AIRCR_PRIGROUP4 ((uint32_t)0x00000400) /*!< Priority group=4 (3 bits of pre-emption priority, 5 bits of subpriority) */ +#define SCB_AIRCR_PRIGROUP5 ((uint32_t)0x00000500) /*!< Priority group=5 (2 bits of pre-emption priority, 6 bits of subpriority) */ +#define SCB_AIRCR_PRIGROUP6 ((uint32_t)0x00000600) /*!< Priority group=6 (1 bit of pre-emption priority, 7 bits of subpriority) */ +#define SCB_AIRCR_PRIGROUP7 ((uint32_t)0x00000700) /*!< Priority group=7 (no pre-emption priority, 8 bits of subpriority) */ + +#define SCB_AIRCR_ENDIANESS ((uint32_t)0x00008000) /*!< Data endianness bit */ +#define SCB_AIRCR_VECTKEY ((uint32_t)0xFFFF0000) /*!< Register key (VECTKEY) - Reads as 0xFA05 (VECTKEYSTAT) */ + +/******************* Bit definition for SCB_SCR register ********************/ +#define SCB_SCR_SLEEPONEXIT ((uint8_t)0x02) /*!< Sleep on exit bit */ +#define SCB_SCR_SLEEPDEEP ((uint8_t)0x04) /*!< Sleep deep bit */ +#define SCB_SCR_SEVONPEND ((uint8_t)0x10) /*!< Wake up from WFE */ + +/******************** Bit definition for SCB_CCR register *******************/ +#define SCB_CCR_NONBASETHRDENA ((uint16_t)0x0001) /*!< Thread mode can be entered from any level in Handler mode by controlled return value */ +#define SCB_CCR_USERSETMPEND ((uint16_t)0x0002) /*!< Enables user code to write the Software Trigger Interrupt register to trigger (pend) a Main exception */ +#define SCB_CCR_UNALIGN_TRP ((uint16_t)0x0008) /*!< Trap for unaligned access */ +#define SCB_CCR_DIV_0_TRP ((uint16_t)0x0010) /*!< Trap on Divide by 0 */ +#define SCB_CCR_BFHFNMIGN ((uint16_t)0x0100) /*!< Handlers running at priority -1 and -2 */ +#define SCB_CCR_STKALIGN ((uint16_t)0x0200) /*!< On exception entry, the SP used prior to the exception is adjusted to be 8-byte aligned */ + +/******************* Bit definition for SCB_SHPR register ********************/ +#define SCB_SHPR_PRI_N ((uint32_t)0x000000FF) /*!< Priority of system handler 4,8, and 12. Mem Manage, reserved and Debug Monitor */ +#define SCB_SHPR_PRI_N1 ((uint32_t)0x0000FF00) /*!< Priority of system handler 5,9, and 13. Bus Fault, reserved and reserved */ +#define SCB_SHPR_PRI_N2 ((uint32_t)0x00FF0000) /*!< Priority of system handler 6,10, and 14. Usage Fault, reserved and PendSV */ +#define SCB_SHPR_PRI_N3 ((uint32_t)0xFF000000) /*!< Priority of system handler 7,11, and 15. Reserved, SVCall and SysTick */ + +/****************** Bit definition for SCB_SHCSR register *******************/ +#define SCB_SHCSR_MEMFAULTACT ((uint32_t)0x00000001) /*!< MemManage is active */ +#define SCB_SHCSR_BUSFAULTACT ((uint32_t)0x00000002) /*!< BusFault is active */ +#define SCB_SHCSR_USGFAULTACT ((uint32_t)0x00000008) /*!< UsageFault is active */ +#define SCB_SHCSR_SVCALLACT ((uint32_t)0x00000080) /*!< SVCall is active */ +#define SCB_SHCSR_MONITORACT ((uint32_t)0x00000100) /*!< Monitor is active */ +#define SCB_SHCSR_PENDSVACT ((uint32_t)0x00000400) /*!< PendSV is active */ +#define SCB_SHCSR_SYSTICKACT ((uint32_t)0x00000800) /*!< SysTick is active */ +#define SCB_SHCSR_USGFAULTPENDED ((uint32_t)0x00001000) /*!< Usage Fault is pended */ +#define SCB_SHCSR_MEMFAULTPENDED ((uint32_t)0x00002000) /*!< MemManage is pended */ +#define SCB_SHCSR_BUSFAULTPENDED ((uint32_t)0x00004000) /*!< Bus Fault is pended */ +#define SCB_SHCSR_SVCALLPENDED ((uint32_t)0x00008000) /*!< SVCall is pended */ +#define SCB_SHCSR_MEMFAULTENA ((uint32_t)0x00010000) /*!< MemManage enable */ +#define SCB_SHCSR_BUSFAULTENA ((uint32_t)0x00020000) /*!< Bus Fault enable */ +#define SCB_SHCSR_USGFAULTENA ((uint32_t)0x00040000) /*!< UsageFault enable */ + +/******************* Bit definition for SCB_CFSR register *******************/ +/*!< MFSR */ +#define SCB_CFSR_IACCVIOL ((uint32_t)0x00000001) /*!< Instruction access violation */ +#define SCB_CFSR_DACCVIOL ((uint32_t)0x00000002) /*!< Data access violation */ +#define SCB_CFSR_MUNSTKERR ((uint32_t)0x00000008) /*!< Unstacking error */ +#define SCB_CFSR_MSTKERR ((uint32_t)0x00000010) /*!< Stacking error */ +#define SCB_CFSR_MMARVALID ((uint32_t)0x00000080) /*!< Memory Manage Address Register address valid flag */ +/*!< BFSR */ +#define SCB_CFSR_IBUSERR ((uint32_t)0x00000100) /*!< Instruction bus error flag */ +#define SCB_CFSR_PRECISERR ((uint32_t)0x00000200) /*!< Precise data bus error */ +#define SCB_CFSR_IMPRECISERR ((uint32_t)0x00000400) /*!< Imprecise data bus error */ +#define SCB_CFSR_UNSTKERR ((uint32_t)0x00000800) /*!< Unstacking error */ +#define SCB_CFSR_STKERR ((uint32_t)0x00001000) /*!< Stacking error */ +#define SCB_CFSR_BFARVALID ((uint32_t)0x00008000) /*!< Bus Fault Address Register address valid flag */ +/*!< UFSR */ +#define SCB_CFSR_UNDEFINSTR ((uint32_t)0x00010000) /*!< The processor attempt to execute an undefined instruction */ +#define SCB_CFSR_INVSTATE ((uint32_t)0x00020000) /*!< Invalid combination of EPSR and instruction */ +#define SCB_CFSR_INVPC ((uint32_t)0x00040000) /*!< Attempt to load EXC_RETURN into pc illegally */ +#define SCB_CFSR_NOCP ((uint32_t)0x00080000) /*!< Attempt to use a coprocessor instruction */ +#define SCB_CFSR_UNALIGNED ((uint32_t)0x01000000) /*!< Fault occurs when there is an attempt to make an unaligned memory access */ +#define SCB_CFSR_DIVBYZERO ((uint32_t)0x02000000) /*!< Fault occurs when SDIV or DIV instruction is used with a divisor of 0 */ + +/******************* Bit definition for SCB_HFSR register *******************/ +#define SCB_HFSR_VECTTBL ((uint32_t)0x00000002) /*!< Fault occurs because of vector table read on exception processing */ +#define SCB_HFSR_FORCED ((uint32_t)0x40000000) /*!< Hard Fault activated when a configurable Fault was received and cannot activate */ +#define SCB_HFSR_DEBUGEVT ((uint32_t)0x80000000) /*!< Fault related to debug */ + +/******************* Bit definition for SCB_DFSR register *******************/ +#define SCB_DFSR_HALTED ((uint8_t)0x01) /*!< Halt request flag */ +#define SCB_DFSR_BKPT ((uint8_t)0x02) /*!< BKPT flag */ +#define SCB_DFSR_DWTTRAP ((uint8_t)0x04) /*!< Data Watchpoint and Trace (DWT) flag */ +#define SCB_DFSR_VCATCH ((uint8_t)0x08) /*!< Vector catch flag */ +#define SCB_DFSR_EXTERNAL ((uint8_t)0x10) /*!< External debug request flag */ + +/******************* Bit definition for SCB_MMFAR register ******************/ +#define SCB_MMFAR_ADDRESS ((uint32_t)0xFFFFFFFF) /*!< Mem Manage fault address field */ + +/******************* Bit definition for SCB_BFAR register *******************/ +#define SCB_BFAR_ADDRESS ((uint32_t)0xFFFFFFFF) /*!< Bus fault address field */ + +/******************* Bit definition for SCB_afsr register *******************/ +#define SCB_AFSR_IMPDEF ((uint32_t)0xFFFFFFFF) /*!< Implementation defined */ + +/******************************************************************************/ +/* */ +/* External Interrupt/Event Controller */ +/* */ +/******************************************************************************/ + +/******************* Bit definition for EXTI_IMR register *******************/ +#define EXTI_IMR_MR0 ((uint32_t)0x00000001) /*!< Interrupt Mask on line 0 */ +#define EXTI_IMR_MR1 ((uint32_t)0x00000002) /*!< Interrupt Mask on line 1 */ +#define EXTI_IMR_MR2 ((uint32_t)0x00000004) /*!< Interrupt Mask on line 2 */ +#define EXTI_IMR_MR3 ((uint32_t)0x00000008) /*!< Interrupt Mask on line 3 */ +#define EXTI_IMR_MR4 ((uint32_t)0x00000010) /*!< Interrupt Mask on line 4 */ +#define EXTI_IMR_MR5 ((uint32_t)0x00000020) /*!< Interrupt Mask on line 5 */ +#define EXTI_IMR_MR6 ((uint32_t)0x00000040) /*!< Interrupt Mask on line 6 */ +#define EXTI_IMR_MR7 ((uint32_t)0x00000080) /*!< Interrupt Mask on line 7 */ +#define EXTI_IMR_MR8 ((uint32_t)0x00000100) /*!< Interrupt Mask on line 8 */ +#define EXTI_IMR_MR9 ((uint32_t)0x00000200) /*!< Interrupt Mask on line 9 */ +#define EXTI_IMR_MR10 ((uint32_t)0x00000400) /*!< Interrupt Mask on line 10 */ +#define EXTI_IMR_MR11 ((uint32_t)0x00000800) /*!< Interrupt Mask on line 11 */ +#define EXTI_IMR_MR12 ((uint32_t)0x00001000) /*!< Interrupt Mask on line 12 */ +#define EXTI_IMR_MR13 ((uint32_t)0x00002000) /*!< Interrupt Mask on line 13 */ +#define EXTI_IMR_MR14 ((uint32_t)0x00004000) /*!< Interrupt Mask on line 14 */ +#define EXTI_IMR_MR15 ((uint32_t)0x00008000) /*!< Interrupt Mask on line 15 */ +#define EXTI_IMR_MR16 ((uint32_t)0x00010000) /*!< Interrupt Mask on line 16 */ +#define EXTI_IMR_MR17 ((uint32_t)0x00020000) /*!< Interrupt Mask on line 17 */ +#define EXTI_IMR_MR18 ((uint32_t)0x00040000) /*!< Interrupt Mask on line 18 */ +#define EXTI_IMR_MR19 ((uint32_t)0x00080000) /*!< Interrupt Mask on line 19 */ + +/******************* Bit definition for EXTI_EMR register *******************/ +#define EXTI_EMR_MR0 ((uint32_t)0x00000001) /*!< Event Mask on line 0 */ +#define EXTI_EMR_MR1 ((uint32_t)0x00000002) /*!< Event Mask on line 1 */ +#define EXTI_EMR_MR2 ((uint32_t)0x00000004) /*!< Event Mask on line 2 */ +#define EXTI_EMR_MR3 ((uint32_t)0x00000008) /*!< Event Mask on line 3 */ +#define EXTI_EMR_MR4 ((uint32_t)0x00000010) /*!< Event Mask on line 4 */ +#define EXTI_EMR_MR5 ((uint32_t)0x00000020) /*!< Event Mask on line 5 */ +#define EXTI_EMR_MR6 ((uint32_t)0x00000040) /*!< Event Mask on line 6 */ +#define EXTI_EMR_MR7 ((uint32_t)0x00000080) /*!< Event Mask on line 7 */ +#define EXTI_EMR_MR8 ((uint32_t)0x00000100) /*!< Event Mask on line 8 */ +#define EXTI_EMR_MR9 ((uint32_t)0x00000200) /*!< Event Mask on line 9 */ +#define EXTI_EMR_MR10 ((uint32_t)0x00000400) /*!< Event Mask on line 10 */ +#define EXTI_EMR_MR11 ((uint32_t)0x00000800) /*!< Event Mask on line 11 */ +#define EXTI_EMR_MR12 ((uint32_t)0x00001000) /*!< Event Mask on line 12 */ +#define EXTI_EMR_MR13 ((uint32_t)0x00002000) /*!< Event Mask on line 13 */ +#define EXTI_EMR_MR14 ((uint32_t)0x00004000) /*!< Event Mask on line 14 */ +#define EXTI_EMR_MR15 ((uint32_t)0x00008000) /*!< Event Mask on line 15 */ +#define EXTI_EMR_MR16 ((uint32_t)0x00010000) /*!< Event Mask on line 16 */ +#define EXTI_EMR_MR17 ((uint32_t)0x00020000) /*!< Event Mask on line 17 */ +#define EXTI_EMR_MR18 ((uint32_t)0x00040000) /*!< Event Mask on line 18 */ +#define EXTI_EMR_MR19 ((uint32_t)0x00080000) /*!< Event Mask on line 19 */ + +/****************** Bit definition for EXTI_RTSR register *******************/ +#define EXTI_RTSR_TR0 ((uint32_t)0x00000001) /*!< Rising trigger event configuration bit of line 0 */ +#define EXTI_RTSR_TR1 ((uint32_t)0x00000002) /*!< Rising trigger event configuration bit of line 1 */ +#define EXTI_RTSR_TR2 ((uint32_t)0x00000004) /*!< Rising trigger event configuration bit of line 2 */ +#define EXTI_RTSR_TR3 ((uint32_t)0x00000008) /*!< Rising trigger event configuration bit of line 3 */ +#define EXTI_RTSR_TR4 ((uint32_t)0x00000010) /*!< Rising trigger event configuration bit of line 4 */ +#define EXTI_RTSR_TR5 ((uint32_t)0x00000020) /*!< Rising trigger event configuration bit of line 5 */ +#define EXTI_RTSR_TR6 ((uint32_t)0x00000040) /*!< Rising trigger event configuration bit of line 6 */ +#define EXTI_RTSR_TR7 ((uint32_t)0x00000080) /*!< Rising trigger event configuration bit of line 7 */ +#define EXTI_RTSR_TR8 ((uint32_t)0x00000100) /*!< Rising trigger event configuration bit of line 8 */ +#define EXTI_RTSR_TR9 ((uint32_t)0x00000200) /*!< Rising trigger event configuration bit of line 9 */ +#define EXTI_RTSR_TR10 ((uint32_t)0x00000400) /*!< Rising trigger event configuration bit of line 10 */ +#define EXTI_RTSR_TR11 ((uint32_t)0x00000800) /*!< Rising trigger event configuration bit of line 11 */ +#define EXTI_RTSR_TR12 ((uint32_t)0x00001000) /*!< Rising trigger event configuration bit of line 12 */ +#define EXTI_RTSR_TR13 ((uint32_t)0x00002000) /*!< Rising trigger event configuration bit of line 13 */ +#define EXTI_RTSR_TR14 ((uint32_t)0x00004000) /*!< Rising trigger event configuration bit of line 14 */ +#define EXTI_RTSR_TR15 ((uint32_t)0x00008000) /*!< Rising trigger event configuration bit of line 15 */ +#define EXTI_RTSR_TR16 ((uint32_t)0x00010000) /*!< Rising trigger event configuration bit of line 16 */ +#define EXTI_RTSR_TR17 ((uint32_t)0x00020000) /*!< Rising trigger event configuration bit of line 17 */ +#define EXTI_RTSR_TR18 ((uint32_t)0x00040000) /*!< Rising trigger event configuration bit of line 18 */ +#define EXTI_RTSR_TR19 ((uint32_t)0x00080000) /*!< Rising trigger event configuration bit of line 19 */ + +/****************** Bit definition for EXTI_FTSR register *******************/ +#define EXTI_FTSR_TR0 ((uint32_t)0x00000001) /*!< Falling trigger event configuration bit of line 0 */ +#define EXTI_FTSR_TR1 ((uint32_t)0x00000002) /*!< Falling trigger event configuration bit of line 1 */ +#define EXTI_FTSR_TR2 ((uint32_t)0x00000004) /*!< Falling trigger event configuration bit of line 2 */ +#define EXTI_FTSR_TR3 ((uint32_t)0x00000008) /*!< Falling trigger event configuration bit of line 3 */ +#define EXTI_FTSR_TR4 ((uint32_t)0x00000010) /*!< Falling trigger event configuration bit of line 4 */ +#define EXTI_FTSR_TR5 ((uint32_t)0x00000020) /*!< Falling trigger event configuration bit of line 5 */ +#define EXTI_FTSR_TR6 ((uint32_t)0x00000040) /*!< Falling trigger event configuration bit of line 6 */ +#define EXTI_FTSR_TR7 ((uint32_t)0x00000080) /*!< Falling trigger event configuration bit of line 7 */ +#define EXTI_FTSR_TR8 ((uint32_t)0x00000100) /*!< Falling trigger event configuration bit of line 8 */ +#define EXTI_FTSR_TR9 ((uint32_t)0x00000200) /*!< Falling trigger event configuration bit of line 9 */ +#define EXTI_FTSR_TR10 ((uint32_t)0x00000400) /*!< Falling trigger event configuration bit of line 10 */ +#define EXTI_FTSR_TR11 ((uint32_t)0x00000800) /*!< Falling trigger event configuration bit of line 11 */ +#define EXTI_FTSR_TR12 ((uint32_t)0x00001000) /*!< Falling trigger event configuration bit of line 12 */ +#define EXTI_FTSR_TR13 ((uint32_t)0x00002000) /*!< Falling trigger event configuration bit of line 13 */ +#define EXTI_FTSR_TR14 ((uint32_t)0x00004000) /*!< Falling trigger event configuration bit of line 14 */ +#define EXTI_FTSR_TR15 ((uint32_t)0x00008000) /*!< Falling trigger event configuration bit of line 15 */ +#define EXTI_FTSR_TR16 ((uint32_t)0x00010000) /*!< Falling trigger event configuration bit of line 16 */ +#define EXTI_FTSR_TR17 ((uint32_t)0x00020000) /*!< Falling trigger event configuration bit of line 17 */ +#define EXTI_FTSR_TR18 ((uint32_t)0x00040000) /*!< Falling trigger event configuration bit of line 18 */ +#define EXTI_FTSR_TR19 ((uint32_t)0x00080000) /*!< Falling trigger event configuration bit of line 19 */ + +/****************** Bit definition for EXTI_SWIER register ******************/ +#define EXTI_SWIER_SWIER0 ((uint32_t)0x00000001) /*!< Software Interrupt on line 0 */ +#define EXTI_SWIER_SWIER1 ((uint32_t)0x00000002) /*!< Software Interrupt on line 1 */ +#define EXTI_SWIER_SWIER2 ((uint32_t)0x00000004) /*!< Software Interrupt on line 2 */ +#define EXTI_SWIER_SWIER3 ((uint32_t)0x00000008) /*!< Software Interrupt on line 3 */ +#define EXTI_SWIER_SWIER4 ((uint32_t)0x00000010) /*!< Software Interrupt on line 4 */ +#define EXTI_SWIER_SWIER5 ((uint32_t)0x00000020) /*!< Software Interrupt on line 5 */ +#define EXTI_SWIER_SWIER6 ((uint32_t)0x00000040) /*!< Software Interrupt on line 6 */ +#define EXTI_SWIER_SWIER7 ((uint32_t)0x00000080) /*!< Software Interrupt on line 7 */ +#define EXTI_SWIER_SWIER8 ((uint32_t)0x00000100) /*!< Software Interrupt on line 8 */ +#define EXTI_SWIER_SWIER9 ((uint32_t)0x00000200) /*!< Software Interrupt on line 9 */ +#define EXTI_SWIER_SWIER10 ((uint32_t)0x00000400) /*!< Software Interrupt on line 10 */ +#define EXTI_SWIER_SWIER11 ((uint32_t)0x00000800) /*!< Software Interrupt on line 11 */ +#define EXTI_SWIER_SWIER12 ((uint32_t)0x00001000) /*!< Software Interrupt on line 12 */ +#define EXTI_SWIER_SWIER13 ((uint32_t)0x00002000) /*!< Software Interrupt on line 13 */ +#define EXTI_SWIER_SWIER14 ((uint32_t)0x00004000) /*!< Software Interrupt on line 14 */ +#define EXTI_SWIER_SWIER15 ((uint32_t)0x00008000) /*!< Software Interrupt on line 15 */ +#define EXTI_SWIER_SWIER16 ((uint32_t)0x00010000) /*!< Software Interrupt on line 16 */ +#define EXTI_SWIER_SWIER17 ((uint32_t)0x00020000) /*!< Software Interrupt on line 17 */ +#define EXTI_SWIER_SWIER18 ((uint32_t)0x00040000) /*!< Software Interrupt on line 18 */ +#define EXTI_SWIER_SWIER19 ((uint32_t)0x00080000) /*!< Software Interrupt on line 19 */ + +/******************* Bit definition for EXTI_PR register ********************/ +#define EXTI_PR_PR0 ((uint32_t)0x00000001) /*!< Pending bit for line 0 */ +#define EXTI_PR_PR1 ((uint32_t)0x00000002) /*!< Pending bit for line 1 */ +#define EXTI_PR_PR2 ((uint32_t)0x00000004) /*!< Pending bit for line 2 */ +#define EXTI_PR_PR3 ((uint32_t)0x00000008) /*!< Pending bit for line 3 */ +#define EXTI_PR_PR4 ((uint32_t)0x00000010) /*!< Pending bit for line 4 */ +#define EXTI_PR_PR5 ((uint32_t)0x00000020) /*!< Pending bit for line 5 */ +#define EXTI_PR_PR6 ((uint32_t)0x00000040) /*!< Pending bit for line 6 */ +#define EXTI_PR_PR7 ((uint32_t)0x00000080) /*!< Pending bit for line 7 */ +#define EXTI_PR_PR8 ((uint32_t)0x00000100) /*!< Pending bit for line 8 */ +#define EXTI_PR_PR9 ((uint32_t)0x00000200) /*!< Pending bit for line 9 */ +#define EXTI_PR_PR10 ((uint32_t)0x00000400) /*!< Pending bit for line 10 */ +#define EXTI_PR_PR11 ((uint32_t)0x00000800) /*!< Pending bit for line 11 */ +#define EXTI_PR_PR12 ((uint32_t)0x00001000) /*!< Pending bit for line 12 */ +#define EXTI_PR_PR13 ((uint32_t)0x00002000) /*!< Pending bit for line 13 */ +#define EXTI_PR_PR14 ((uint32_t)0x00004000) /*!< Pending bit for line 14 */ +#define EXTI_PR_PR15 ((uint32_t)0x00008000) /*!< Pending bit for line 15 */ +#define EXTI_PR_PR16 ((uint32_t)0x00010000) /*!< Pending bit for line 16 */ +#define EXTI_PR_PR17 ((uint32_t)0x00020000) /*!< Pending bit for line 17 */ +#define EXTI_PR_PR18 ((uint32_t)0x00040000) /*!< Pending bit for line 18 */ +#define EXTI_PR_PR19 ((uint32_t)0x00080000) /*!< Pending bit for line 19 */ + +/******************************************************************************/ +/* */ +/* DMA Controller */ +/* */ +/******************************************************************************/ + +/******************* Bit definition for DMA_ISR register ********************/ +#define DMA_ISR_GIF1 ((uint32_t)0x00000001) /*!< Channel 1 Global interrupt flag */ +#define DMA_ISR_TCIF1 ((uint32_t)0x00000002) /*!< Channel 1 Transfer Complete flag */ +#define DMA_ISR_HTIF1 ((uint32_t)0x00000004) /*!< Channel 1 Half Transfer flag */ +#define DMA_ISR_TEIF1 ((uint32_t)0x00000008) /*!< Channel 1 Transfer Error flag */ +#define DMA_ISR_GIF2 ((uint32_t)0x00000010) /*!< Channel 2 Global interrupt flag */ +#define DMA_ISR_TCIF2 ((uint32_t)0x00000020) /*!< Channel 2 Transfer Complete flag */ +#define DMA_ISR_HTIF2 ((uint32_t)0x00000040) /*!< Channel 2 Half Transfer flag */ +#define DMA_ISR_TEIF2 ((uint32_t)0x00000080) /*!< Channel 2 Transfer Error flag */ +#define DMA_ISR_GIF3 ((uint32_t)0x00000100) /*!< Channel 3 Global interrupt flag */ +#define DMA_ISR_TCIF3 ((uint32_t)0x00000200) /*!< Channel 3 Transfer Complete flag */ +#define DMA_ISR_HTIF3 ((uint32_t)0x00000400) /*!< Channel 3 Half Transfer flag */ +#define DMA_ISR_TEIF3 ((uint32_t)0x00000800) /*!< Channel 3 Transfer Error flag */ +#define DMA_ISR_GIF4 ((uint32_t)0x00001000) /*!< Channel 4 Global interrupt flag */ +#define DMA_ISR_TCIF4 ((uint32_t)0x00002000) /*!< Channel 4 Transfer Complete flag */ +#define DMA_ISR_HTIF4 ((uint32_t)0x00004000) /*!< Channel 4 Half Transfer flag */ +#define DMA_ISR_TEIF4 ((uint32_t)0x00008000) /*!< Channel 4 Transfer Error flag */ +#define DMA_ISR_GIF5 ((uint32_t)0x00010000) /*!< Channel 5 Global interrupt flag */ +#define DMA_ISR_TCIF5 ((uint32_t)0x00020000) /*!< Channel 5 Transfer Complete flag */ +#define DMA_ISR_HTIF5 ((uint32_t)0x00040000) /*!< Channel 5 Half Transfer flag */ +#define DMA_ISR_TEIF5 ((uint32_t)0x00080000) /*!< Channel 5 Transfer Error flag */ +#define DMA_ISR_GIF6 ((uint32_t)0x00100000) /*!< Channel 6 Global interrupt flag */ +#define DMA_ISR_TCIF6 ((uint32_t)0x00200000) /*!< Channel 6 Transfer Complete flag */ +#define DMA_ISR_HTIF6 ((uint32_t)0x00400000) /*!< Channel 6 Half Transfer flag */ +#define DMA_ISR_TEIF6 ((uint32_t)0x00800000) /*!< Channel 6 Transfer Error flag */ +#define DMA_ISR_GIF7 ((uint32_t)0x01000000) /*!< Channel 7 Global interrupt flag */ +#define DMA_ISR_TCIF7 ((uint32_t)0x02000000) /*!< Channel 7 Transfer Complete flag */ +#define DMA_ISR_HTIF7 ((uint32_t)0x04000000) /*!< Channel 7 Half Transfer flag */ +#define DMA_ISR_TEIF7 ((uint32_t)0x08000000) /*!< Channel 7 Transfer Error flag */ + +/******************* Bit definition for DMA_IFCR register *******************/ +#define DMA_IFCR_CGIF1 ((uint32_t)0x00000001) /*!< Channel 1 Global interrupt clear */ +#define DMA_IFCR_CTCIF1 ((uint32_t)0x00000002) /*!< Channel 1 Transfer Complete clear */ +#define DMA_IFCR_CHTIF1 ((uint32_t)0x00000004) /*!< Channel 1 Half Transfer clear */ +#define DMA_IFCR_CTEIF1 ((uint32_t)0x00000008) /*!< Channel 1 Transfer Error clear */ +#define DMA_IFCR_CGIF2 ((uint32_t)0x00000010) /*!< Channel 2 Global interrupt clear */ +#define DMA_IFCR_CTCIF2 ((uint32_t)0x00000020) /*!< Channel 2 Transfer Complete clear */ +#define DMA_IFCR_CHTIF2 ((uint32_t)0x00000040) /*!< Channel 2 Half Transfer clear */ +#define DMA_IFCR_CTEIF2 ((uint32_t)0x00000080) /*!< Channel 2 Transfer Error clear */ +#define DMA_IFCR_CGIF3 ((uint32_t)0x00000100) /*!< Channel 3 Global interrupt clear */ +#define DMA_IFCR_CTCIF3 ((uint32_t)0x00000200) /*!< Channel 3 Transfer Complete clear */ +#define DMA_IFCR_CHTIF3 ((uint32_t)0x00000400) /*!< Channel 3 Half Transfer clear */ +#define DMA_IFCR_CTEIF3 ((uint32_t)0x00000800) /*!< Channel 3 Transfer Error clear */ +#define DMA_IFCR_CGIF4 ((uint32_t)0x00001000) /*!< Channel 4 Global interrupt clear */ +#define DMA_IFCR_CTCIF4 ((uint32_t)0x00002000) /*!< Channel 4 Transfer Complete clear */ +#define DMA_IFCR_CHTIF4 ((uint32_t)0x00004000) /*!< Channel 4 Half Transfer clear */ +#define DMA_IFCR_CTEIF4 ((uint32_t)0x00008000) /*!< Channel 4 Transfer Error clear */ +#define DMA_IFCR_CGIF5 ((uint32_t)0x00010000) /*!< Channel 5 Global interrupt clear */ +#define DMA_IFCR_CTCIF5 ((uint32_t)0x00020000) /*!< Channel 5 Transfer Complete clear */ +#define DMA_IFCR_CHTIF5 ((uint32_t)0x00040000) /*!< Channel 5 Half Transfer clear */ +#define DMA_IFCR_CTEIF5 ((uint32_t)0x00080000) /*!< Channel 5 Transfer Error clear */ +#define DMA_IFCR_CGIF6 ((uint32_t)0x00100000) /*!< Channel 6 Global interrupt clear */ +#define DMA_IFCR_CTCIF6 ((uint32_t)0x00200000) /*!< Channel 6 Transfer Complete clear */ +#define DMA_IFCR_CHTIF6 ((uint32_t)0x00400000) /*!< Channel 6 Half Transfer clear */ +#define DMA_IFCR_CTEIF6 ((uint32_t)0x00800000) /*!< Channel 6 Transfer Error clear */ +#define DMA_IFCR_CGIF7 ((uint32_t)0x01000000) /*!< Channel 7 Global interrupt clear */ +#define DMA_IFCR_CTCIF7 ((uint32_t)0x02000000) /*!< Channel 7 Transfer Complete clear */ +#define DMA_IFCR_CHTIF7 ((uint32_t)0x04000000) /*!< Channel 7 Half Transfer clear */ +#define DMA_IFCR_CTEIF7 ((uint32_t)0x08000000) /*!< Channel 7 Transfer Error clear */ + +/******************* Bit definition for DMA_CCR1 register *******************/ +#define DMA_CCR1_EN ((uint16_t)0x0001) /*!< Channel enable*/ +#define DMA_CCR1_TCIE ((uint16_t)0x0002) /*!< Transfer complete interrupt enable */ +#define DMA_CCR1_HTIE ((uint16_t)0x0004) /*!< Half Transfer interrupt enable */ +#define DMA_CCR1_TEIE ((uint16_t)0x0008) /*!< Transfer error interrupt enable */ +#define DMA_CCR1_DIR ((uint16_t)0x0010) /*!< Data transfer direction */ +#define DMA_CCR1_CIRC ((uint16_t)0x0020) /*!< Circular mode */ +#define DMA_CCR1_PINC ((uint16_t)0x0040) /*!< Peripheral increment mode */ +#define DMA_CCR1_MINC ((uint16_t)0x0080) /*!< Memory increment mode */ + +#define DMA_CCR1_PSIZE ((uint16_t)0x0300) /*!< PSIZE[1:0] bits (Peripheral size) */ +#define DMA_CCR1_PSIZE_0 ((uint16_t)0x0100) /*!< Bit 0 */ +#define DMA_CCR1_PSIZE_1 ((uint16_t)0x0200) /*!< Bit 1 */ + +#define DMA_CCR1_MSIZE ((uint16_t)0x0C00) /*!< MSIZE[1:0] bits (Memory size) */ +#define DMA_CCR1_MSIZE_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define DMA_CCR1_MSIZE_1 ((uint16_t)0x0800) /*!< Bit 1 */ + +#define DMA_CCR1_PL ((uint16_t)0x3000) /*!< PL[1:0] bits(Channel Priority level) */ +#define DMA_CCR1_PL_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define DMA_CCR1_PL_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define DMA_CCR1_MEM2MEM ((uint16_t)0x4000) /*!< Memory to memory mode */ + +/******************* Bit definition for DMA_CCR2 register *******************/ +#define DMA_CCR2_EN ((uint16_t)0x0001) /*!< Channel enable */ +#define DMA_CCR2_TCIE ((uint16_t)0x0002) /*!< Transfer complete interrupt enable */ +#define DMA_CCR2_HTIE ((uint16_t)0x0004) /*!< Half Transfer interrupt enable */ +#define DMA_CCR2_TEIE ((uint16_t)0x0008) /*!< Transfer error interrupt enable */ +#define DMA_CCR2_DIR ((uint16_t)0x0010) /*!< Data transfer direction */ +#define DMA_CCR2_CIRC ((uint16_t)0x0020) /*!< Circular mode */ +#define DMA_CCR2_PINC ((uint16_t)0x0040) /*!< Peripheral increment mode */ +#define DMA_CCR2_MINC ((uint16_t)0x0080) /*!< Memory increment mode */ + +#define DMA_CCR2_PSIZE ((uint16_t)0x0300) /*!< PSIZE[1:0] bits (Peripheral size) */ +#define DMA_CCR2_PSIZE_0 ((uint16_t)0x0100) /*!< Bit 0 */ +#define DMA_CCR2_PSIZE_1 ((uint16_t)0x0200) /*!< Bit 1 */ + +#define DMA_CCR2_MSIZE ((uint16_t)0x0C00) /*!< MSIZE[1:0] bits (Memory size) */ +#define DMA_CCR2_MSIZE_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define DMA_CCR2_MSIZE_1 ((uint16_t)0x0800) /*!< Bit 1 */ + +#define DMA_CCR2_PL ((uint16_t)0x3000) /*!< PL[1:0] bits (Channel Priority level) */ +#define DMA_CCR2_PL_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define DMA_CCR2_PL_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define DMA_CCR2_MEM2MEM ((uint16_t)0x4000) /*!< Memory to memory mode */ + +/******************* Bit definition for DMA_CCR3 register *******************/ +#define DMA_CCR3_EN ((uint16_t)0x0001) /*!< Channel enable */ +#define DMA_CCR3_TCIE ((uint16_t)0x0002) /*!< Transfer complete interrupt enable */ +#define DMA_CCR3_HTIE ((uint16_t)0x0004) /*!< Half Transfer interrupt enable */ +#define DMA_CCR3_TEIE ((uint16_t)0x0008) /*!< Transfer error interrupt enable */ +#define DMA_CCR3_DIR ((uint16_t)0x0010) /*!< Data transfer direction */ +#define DMA_CCR3_CIRC ((uint16_t)0x0020) /*!< Circular mode */ +#define DMA_CCR3_PINC ((uint16_t)0x0040) /*!< Peripheral increment mode */ +#define DMA_CCR3_MINC ((uint16_t)0x0080) /*!< Memory increment mode */ + +#define DMA_CCR3_PSIZE ((uint16_t)0x0300) /*!< PSIZE[1:0] bits (Peripheral size) */ +#define DMA_CCR3_PSIZE_0 ((uint16_t)0x0100) /*!< Bit 0 */ +#define DMA_CCR3_PSIZE_1 ((uint16_t)0x0200) /*!< Bit 1 */ + +#define DMA_CCR3_MSIZE ((uint16_t)0x0C00) /*!< MSIZE[1:0] bits (Memory size) */ +#define DMA_CCR3_MSIZE_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define DMA_CCR3_MSIZE_1 ((uint16_t)0x0800) /*!< Bit 1 */ + +#define DMA_CCR3_PL ((uint16_t)0x3000) /*!< PL[1:0] bits (Channel Priority level) */ +#define DMA_CCR3_PL_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define DMA_CCR3_PL_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define DMA_CCR3_MEM2MEM ((uint16_t)0x4000) /*!< Memory to memory mode */ + +/*!<****************** Bit definition for DMA_CCR4 register *******************/ +#define DMA_CCR4_EN ((uint16_t)0x0001) /*!< Channel enable */ +#define DMA_CCR4_TCIE ((uint16_t)0x0002) /*!< Transfer complete interrupt enable */ +#define DMA_CCR4_HTIE ((uint16_t)0x0004) /*!< Half Transfer interrupt enable */ +#define DMA_CCR4_TEIE ((uint16_t)0x0008) /*!< Transfer error interrupt enable */ +#define DMA_CCR4_DIR ((uint16_t)0x0010) /*!< Data transfer direction */ +#define DMA_CCR4_CIRC ((uint16_t)0x0020) /*!< Circular mode */ +#define DMA_CCR4_PINC ((uint16_t)0x0040) /*!< Peripheral increment mode */ +#define DMA_CCR4_MINC ((uint16_t)0x0080) /*!< Memory increment mode */ + +#define DMA_CCR4_PSIZE ((uint16_t)0x0300) /*!< PSIZE[1:0] bits (Peripheral size) */ +#define DMA_CCR4_PSIZE_0 ((uint16_t)0x0100) /*!< Bit 0 */ +#define DMA_CCR4_PSIZE_1 ((uint16_t)0x0200) /*!< Bit 1 */ + +#define DMA_CCR4_MSIZE ((uint16_t)0x0C00) /*!< MSIZE[1:0] bits (Memory size) */ +#define DMA_CCR4_MSIZE_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define DMA_CCR4_MSIZE_1 ((uint16_t)0x0800) /*!< Bit 1 */ + +#define DMA_CCR4_PL ((uint16_t)0x3000) /*!< PL[1:0] bits (Channel Priority level) */ +#define DMA_CCR4_PL_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define DMA_CCR4_PL_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define DMA_CCR4_MEM2MEM ((uint16_t)0x4000) /*!< Memory to memory mode */ + +/****************** Bit definition for DMA_CCR5 register *******************/ +#define DMA_CCR5_EN ((uint16_t)0x0001) /*!< Channel enable */ +#define DMA_CCR5_TCIE ((uint16_t)0x0002) /*!< Transfer complete interrupt enable */ +#define DMA_CCR5_HTIE ((uint16_t)0x0004) /*!< Half Transfer interrupt enable */ +#define DMA_CCR5_TEIE ((uint16_t)0x0008) /*!< Transfer error interrupt enable */ +#define DMA_CCR5_DIR ((uint16_t)0x0010) /*!< Data transfer direction */ +#define DMA_CCR5_CIRC ((uint16_t)0x0020) /*!< Circular mode */ +#define DMA_CCR5_PINC ((uint16_t)0x0040) /*!< Peripheral increment mode */ +#define DMA_CCR5_MINC ((uint16_t)0x0080) /*!< Memory increment mode */ + +#define DMA_CCR5_PSIZE ((uint16_t)0x0300) /*!< PSIZE[1:0] bits (Peripheral size) */ +#define DMA_CCR5_PSIZE_0 ((uint16_t)0x0100) /*!< Bit 0 */ +#define DMA_CCR5_PSIZE_1 ((uint16_t)0x0200) /*!< Bit 1 */ + +#define DMA_CCR5_MSIZE ((uint16_t)0x0C00) /*!< MSIZE[1:0] bits (Memory size) */ +#define DMA_CCR5_MSIZE_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define DMA_CCR5_MSIZE_1 ((uint16_t)0x0800) /*!< Bit 1 */ + +#define DMA_CCR5_PL ((uint16_t)0x3000) /*!< PL[1:0] bits (Channel Priority level) */ +#define DMA_CCR5_PL_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define DMA_CCR5_PL_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define DMA_CCR5_MEM2MEM ((uint16_t)0x4000) /*!< Memory to memory mode enable */ + +/******************* Bit definition for DMA_CCR6 register *******************/ +#define DMA_CCR6_EN ((uint16_t)0x0001) /*!< Channel enable */ +#define DMA_CCR6_TCIE ((uint16_t)0x0002) /*!< Transfer complete interrupt enable */ +#define DMA_CCR6_HTIE ((uint16_t)0x0004) /*!< Half Transfer interrupt enable */ +#define DMA_CCR6_TEIE ((uint16_t)0x0008) /*!< Transfer error interrupt enable */ +#define DMA_CCR6_DIR ((uint16_t)0x0010) /*!< Data transfer direction */ +#define DMA_CCR6_CIRC ((uint16_t)0x0020) /*!< Circular mode */ +#define DMA_CCR6_PINC ((uint16_t)0x0040) /*!< Peripheral increment mode */ +#define DMA_CCR6_MINC ((uint16_t)0x0080) /*!< Memory increment mode */ + +#define DMA_CCR6_PSIZE ((uint16_t)0x0300) /*!< PSIZE[1:0] bits (Peripheral size) */ +#define DMA_CCR6_PSIZE_0 ((uint16_t)0x0100) /*!< Bit 0 */ +#define DMA_CCR6_PSIZE_1 ((uint16_t)0x0200) /*!< Bit 1 */ + +#define DMA_CCR6_MSIZE ((uint16_t)0x0C00) /*!< MSIZE[1:0] bits (Memory size) */ +#define DMA_CCR6_MSIZE_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define DMA_CCR6_MSIZE_1 ((uint16_t)0x0800) /*!< Bit 1 */ + +#define DMA_CCR6_PL ((uint16_t)0x3000) /*!< PL[1:0] bits (Channel Priority level) */ +#define DMA_CCR6_PL_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define DMA_CCR6_PL_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define DMA_CCR6_MEM2MEM ((uint16_t)0x4000) /*!< Memory to memory mode */ + +/******************* Bit definition for DMA_CCR7 register *******************/ +#define DMA_CCR7_EN ((uint16_t)0x0001) /*!< Channel enable */ +#define DMA_CCR7_TCIE ((uint16_t)0x0002) /*!< Transfer complete interrupt enable */ +#define DMA_CCR7_HTIE ((uint16_t)0x0004) /*!< Half Transfer interrupt enable */ +#define DMA_CCR7_TEIE ((uint16_t)0x0008) /*!< Transfer error interrupt enable */ +#define DMA_CCR7_DIR ((uint16_t)0x0010) /*!< Data transfer direction */ +#define DMA_CCR7_CIRC ((uint16_t)0x0020) /*!< Circular mode */ +#define DMA_CCR7_PINC ((uint16_t)0x0040) /*!< Peripheral increment mode */ +#define DMA_CCR7_MINC ((uint16_t)0x0080) /*!< Memory increment mode */ + +#define DMA_CCR7_PSIZE , ((uint16_t)0x0300) /*!< PSIZE[1:0] bits (Peripheral size) */ +#define DMA_CCR7_PSIZE_0 ((uint16_t)0x0100) /*!< Bit 0 */ +#define DMA_CCR7_PSIZE_1 ((uint16_t)0x0200) /*!< Bit 1 */ + +#define DMA_CCR7_MSIZE ((uint16_t)0x0C00) /*!< MSIZE[1:0] bits (Memory size) */ +#define DMA_CCR7_MSIZE_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define DMA_CCR7_MSIZE_1 ((uint16_t)0x0800) /*!< Bit 1 */ + +#define DMA_CCR7_PL ((uint16_t)0x3000) /*!< PL[1:0] bits (Channel Priority level) */ +#define DMA_CCR7_PL_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define DMA_CCR7_PL_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define DMA_CCR7_MEM2MEM ((uint16_t)0x4000) /*!< Memory to memory mode enable */ + +/****************** Bit definition for DMA_CNDTR1 register ******************/ +#define DMA_CNDTR1_NDT ((uint16_t)0xFFFF) /*!< Number of data to Transfer */ + +/****************** Bit definition for DMA_CNDTR2 register ******************/ +#define DMA_CNDTR2_NDT ((uint16_t)0xFFFF) /*!< Number of data to Transfer */ + +/****************** Bit definition for DMA_CNDTR3 register ******************/ +#define DMA_CNDTR3_NDT ((uint16_t)0xFFFF) /*!< Number of data to Transfer */ + +/****************** Bit definition for DMA_CNDTR4 register ******************/ +#define DMA_CNDTR4_NDT ((uint16_t)0xFFFF) /*!< Number of data to Transfer */ + +/****************** Bit definition for DMA_CNDTR5 register ******************/ +#define DMA_CNDTR5_NDT ((uint16_t)0xFFFF) /*!< Number of data to Transfer */ + +/****************** Bit definition for DMA_CNDTR6 register ******************/ +#define DMA_CNDTR6_NDT ((uint16_t)0xFFFF) /*!< Number of data to Transfer */ + +/****************** Bit definition for DMA_CNDTR7 register ******************/ +#define DMA_CNDTR7_NDT ((uint16_t)0xFFFF) /*!< Number of data to Transfer */ + +/****************** Bit definition for DMA_CPAR1 register *******************/ +#define DMA_CPAR1_PA ((uint32_t)0xFFFFFFFF) /*!< Peripheral Address */ + +/****************** Bit definition for DMA_CPAR2 register *******************/ +#define DMA_CPAR2_PA ((uint32_t)0xFFFFFFFF) /*!< Peripheral Address */ + +/****************** Bit definition for DMA_CPAR3 register *******************/ +#define DMA_CPAR3_PA ((uint32_t)0xFFFFFFFF) /*!< Peripheral Address */ + + +/****************** Bit definition for DMA_CPAR4 register *******************/ +#define DMA_CPAR4_PA ((uint32_t)0xFFFFFFFF) /*!< Peripheral Address */ + +/****************** Bit definition for DMA_CPAR5 register *******************/ +#define DMA_CPAR5_PA ((uint32_t)0xFFFFFFFF) /*!< Peripheral Address */ + +/****************** Bit definition for DMA_CPAR6 register *******************/ +#define DMA_CPAR6_PA ((uint32_t)0xFFFFFFFF) /*!< Peripheral Address */ + + +/****************** Bit definition for DMA_CPAR7 register *******************/ +#define DMA_CPAR7_PA ((uint32_t)0xFFFFFFFF) /*!< Peripheral Address */ + +/****************** Bit definition for DMA_CMAR1 register *******************/ +#define DMA_CMAR1_MA ((uint32_t)0xFFFFFFFF) /*!< Memory Address */ + +/****************** Bit definition for DMA_CMAR2 register *******************/ +#define DMA_CMAR2_MA ((uint32_t)0xFFFFFFFF) /*!< Memory Address */ + +/****************** Bit definition for DMA_CMAR3 register *******************/ +#define DMA_CMAR3_MA ((uint32_t)0xFFFFFFFF) /*!< Memory Address */ + + +/****************** Bit definition for DMA_CMAR4 register *******************/ +#define DMA_CMAR4_MA ((uint32_t)0xFFFFFFFF) /*!< Memory Address */ + +/****************** Bit definition for DMA_CMAR5 register *******************/ +#define DMA_CMAR5_MA ((uint32_t)0xFFFFFFFF) /*!< Memory Address */ + +/****************** Bit definition for DMA_CMAR6 register *******************/ +#define DMA_CMAR6_MA ((uint32_t)0xFFFFFFFF) /*!< Memory Address */ + +/****************** Bit definition for DMA_CMAR7 register *******************/ +#define DMA_CMAR7_MA ((uint32_t)0xFFFFFFFF) /*!< Memory Address */ + +/******************************************************************************/ +/* */ +/* Analog to Digital Converter */ +/* */ +/******************************************************************************/ + +/******************** Bit definition for ADC_SR register ********************/ +#define ADC_SR_AWD ((uint8_t)0x01) /*!< Analog watchdog flag */ +#define ADC_SR_EOC ((uint8_t)0x02) /*!< End of conversion */ +#define ADC_SR_JEOC ((uint8_t)0x04) /*!< Injected channel end of conversion */ +#define ADC_SR_JSTRT ((uint8_t)0x08) /*!< Injected channel Start flag */ +#define ADC_SR_STRT ((uint8_t)0x10) /*!< Regular channel Start flag */ + +/******************* Bit definition for ADC_CR1 register ********************/ +#define ADC_CR1_AWDCH ((uint32_t)0x0000001F) /*!< AWDCH[4:0] bits (Analog watchdog channel select bits) */ +#define ADC_CR1_AWDCH_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define ADC_CR1_AWDCH_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define ADC_CR1_AWDCH_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define ADC_CR1_AWDCH_3 ((uint32_t)0x00000008) /*!< Bit 3 */ +#define ADC_CR1_AWDCH_4 ((uint32_t)0x00000010) /*!< Bit 4 */ + +#define ADC_CR1_EOCIE ((uint32_t)0x00000020) /*!< Interrupt enable for EOC */ +#define ADC_CR1_AWDIE ((uint32_t)0x00000040) /*!< Analog Watchdog interrupt enable */ +#define ADC_CR1_JEOCIE ((uint32_t)0x00000080) /*!< Interrupt enable for injected channels */ +#define ADC_CR1_SCAN ((uint32_t)0x00000100) /*!< Scan mode */ +#define ADC_CR1_AWDSGL ((uint32_t)0x00000200) /*!< Enable the watchdog on a single channel in scan mode */ +#define ADC_CR1_JAUTO ((uint32_t)0x00000400) /*!< Automatic injected group conversion */ +#define ADC_CR1_DISCEN ((uint32_t)0x00000800) /*!< Discontinuous mode on regular channels */ +#define ADC_CR1_JDISCEN ((uint32_t)0x00001000) /*!< Discontinuous mode on injected channels */ + +#define ADC_CR1_DISCNUM ((uint32_t)0x0000E000) /*!< DISCNUM[2:0] bits (Discontinuous mode channel count) */ +#define ADC_CR1_DISCNUM_0 ((uint32_t)0x00002000) /*!< Bit 0 */ +#define ADC_CR1_DISCNUM_1 ((uint32_t)0x00004000) /*!< Bit 1 */ +#define ADC_CR1_DISCNUM_2 ((uint32_t)0x00008000) /*!< Bit 2 */ + +#define ADC_CR1_DUALMOD ((uint32_t)0x000F0000) /*!< DUALMOD[3:0] bits (Dual mode selection) */ +#define ADC_CR1_DUALMOD_0 ((uint32_t)0x00010000) /*!< Bit 0 */ +#define ADC_CR1_DUALMOD_1 ((uint32_t)0x00020000) /*!< Bit 1 */ +#define ADC_CR1_DUALMOD_2 ((uint32_t)0x00040000) /*!< Bit 2 */ +#define ADC_CR1_DUALMOD_3 ((uint32_t)0x00080000) /*!< Bit 3 */ + +#define ADC_CR1_JAWDEN ((uint32_t)0x00400000) /*!< Analog watchdog enable on injected channels */ +#define ADC_CR1_AWDEN ((uint32_t)0x00800000) /*!< Analog watchdog enable on regular channels */ + + +/******************* Bit definition for ADC_CR2 register ********************/ +#define ADC_CR2_ADON ((uint32_t)0x00000001) /*!< A/D Converter ON / OFF */ +#define ADC_CR2_CONT ((uint32_t)0x00000002) /*!< Continuous Conversion */ +#define ADC_CR2_CAL ((uint32_t)0x00000004) /*!< A/D Calibration */ +#define ADC_CR2_RSTCAL ((uint32_t)0x00000008) /*!< Reset Calibration */ +#define ADC_CR2_DMA ((uint32_t)0x00000100) /*!< Direct Memory access mode */ +#define ADC_CR2_ALIGN ((uint32_t)0x00000800) /*!< Data Alignment */ + +#define ADC_CR2_JEXTSEL ((uint32_t)0x00007000) /*!< JEXTSEL[2:0] bits (External event select for injected group) */ +#define ADC_CR2_JEXTSEL_0 ((uint32_t)0x00001000) /*!< Bit 0 */ +#define ADC_CR2_JEXTSEL_1 ((uint32_t)0x00002000) /*!< Bit 1 */ +#define ADC_CR2_JEXTSEL_2 ((uint32_t)0x00004000) /*!< Bit 2 */ + +#define ADC_CR2_JEXTTRIG ((uint32_t)0x00008000) /*!< External Trigger Conversion mode for injected channels */ + +#define ADC_CR2_EXTSEL ((uint32_t)0x000E0000) /*!< EXTSEL[2:0] bits (External Event Select for regular group) */ +#define ADC_CR2_EXTSEL_0 ((uint32_t)0x00020000) /*!< Bit 0 */ +#define ADC_CR2_EXTSEL_1 ((uint32_t)0x00040000) /*!< Bit 1 */ +#define ADC_CR2_EXTSEL_2 ((uint32_t)0x00080000) /*!< Bit 2 */ + +#define ADC_CR2_EXTTRIG ((uint32_t)0x00100000) /*!< External Trigger Conversion mode for regular channels */ +#define ADC_CR2_JSWSTART ((uint32_t)0x00200000) /*!< Start Conversion of injected channels */ +#define ADC_CR2_SWSTART ((uint32_t)0x00400000) /*!< Start Conversion of regular channels */ +#define ADC_CR2_TSVREFE ((uint32_t)0x00800000) /*!< Temperature Sensor and VREFINT Enable */ + +/****************** Bit definition for ADC_SMPR1 register *******************/ +#define ADC_SMPR1_SMP10 ((uint32_t)0x00000007) /*!< SMP10[2:0] bits (Channel 10 Sample time selection) */ +#define ADC_SMPR1_SMP10_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define ADC_SMPR1_SMP10_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define ADC_SMPR1_SMP10_2 ((uint32_t)0x00000004) /*!< Bit 2 */ + +#define ADC_SMPR1_SMP11 ((uint32_t)0x00000038) /*!< SMP11[2:0] bits (Channel 11 Sample time selection) */ +#define ADC_SMPR1_SMP11_0 ((uint32_t)0x00000008) /*!< Bit 0 */ +#define ADC_SMPR1_SMP11_1 ((uint32_t)0x00000010) /*!< Bit 1 */ +#define ADC_SMPR1_SMP11_2 ((uint32_t)0x00000020) /*!< Bit 2 */ + +#define ADC_SMPR1_SMP12 ((uint32_t)0x000001C0) /*!< SMP12[2:0] bits (Channel 12 Sample time selection) */ +#define ADC_SMPR1_SMP12_0 ((uint32_t)0x00000040) /*!< Bit 0 */ +#define ADC_SMPR1_SMP12_1 ((uint32_t)0x00000080) /*!< Bit 1 */ +#define ADC_SMPR1_SMP12_2 ((uint32_t)0x00000100) /*!< Bit 2 */ + +#define ADC_SMPR1_SMP13 ((uint32_t)0x00000E00) /*!< SMP13[2:0] bits (Channel 13 Sample time selection) */ +#define ADC_SMPR1_SMP13_0 ((uint32_t)0x00000200) /*!< Bit 0 */ +#define ADC_SMPR1_SMP13_1 ((uint32_t)0x00000400) /*!< Bit 1 */ +#define ADC_SMPR1_SMP13_2 ((uint32_t)0x00000800) /*!< Bit 2 */ + +#define ADC_SMPR1_SMP14 ((uint32_t)0x00007000) /*!< SMP14[2:0] bits (Channel 14 Sample time selection) */ +#define ADC_SMPR1_SMP14_0 ((uint32_t)0x00001000) /*!< Bit 0 */ +#define ADC_SMPR1_SMP14_1 ((uint32_t)0x00002000) /*!< Bit 1 */ +#define ADC_SMPR1_SMP14_2 ((uint32_t)0x00004000) /*!< Bit 2 */ + +#define ADC_SMPR1_SMP15 ((uint32_t)0x00038000) /*!< SMP15[2:0] bits (Channel 15 Sample time selection) */ +#define ADC_SMPR1_SMP15_0 ((uint32_t)0x00008000) /*!< Bit 0 */ +#define ADC_SMPR1_SMP15_1 ((uint32_t)0x00010000) /*!< Bit 1 */ +#define ADC_SMPR1_SMP15_2 ((uint32_t)0x00020000) /*!< Bit 2 */ + +#define ADC_SMPR1_SMP16 ((uint32_t)0x001C0000) /*!< SMP16[2:0] bits (Channel 16 Sample time selection) */ +#define ADC_SMPR1_SMP16_0 ((uint32_t)0x00040000) /*!< Bit 0 */ +#define ADC_SMPR1_SMP16_1 ((uint32_t)0x00080000) /*!< Bit 1 */ +#define ADC_SMPR1_SMP16_2 ((uint32_t)0x00100000) /*!< Bit 2 */ + +#define ADC_SMPR1_SMP17 ((uint32_t)0x00E00000) /*!< SMP17[2:0] bits (Channel 17 Sample time selection) */ +#define ADC_SMPR1_SMP17_0 ((uint32_t)0x00200000) /*!< Bit 0 */ +#define ADC_SMPR1_SMP17_1 ((uint32_t)0x00400000) /*!< Bit 1 */ +#define ADC_SMPR1_SMP17_2 ((uint32_t)0x00800000) /*!< Bit 2 */ + +/****************** Bit definition for ADC_SMPR2 register *******************/ +#define ADC_SMPR2_SMP0 ((uint32_t)0x00000007) /*!< SMP0[2:0] bits (Channel 0 Sample time selection) */ +#define ADC_SMPR2_SMP0_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define ADC_SMPR2_SMP0_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define ADC_SMPR2_SMP0_2 ((uint32_t)0x00000004) /*!< Bit 2 */ + +#define ADC_SMPR2_SMP1 ((uint32_t)0x00000038) /*!< SMP1[2:0] bits (Channel 1 Sample time selection) */ +#define ADC_SMPR2_SMP1_0 ((uint32_t)0x00000008) /*!< Bit 0 */ +#define ADC_SMPR2_SMP1_1 ((uint32_t)0x00000010) /*!< Bit 1 */ +#define ADC_SMPR2_SMP1_2 ((uint32_t)0x00000020) /*!< Bit 2 */ + +#define ADC_SMPR2_SMP2 ((uint32_t)0x000001C0) /*!< SMP2[2:0] bits (Channel 2 Sample time selection) */ +#define ADC_SMPR2_SMP2_0 ((uint32_t)0x00000040) /*!< Bit 0 */ +#define ADC_SMPR2_SMP2_1 ((uint32_t)0x00000080) /*!< Bit 1 */ +#define ADC_SMPR2_SMP2_2 ((uint32_t)0x00000100) /*!< Bit 2 */ + +#define ADC_SMPR2_SMP3 ((uint32_t)0x00000E00) /*!< SMP3[2:0] bits (Channel 3 Sample time selection) */ +#define ADC_SMPR2_SMP3_0 ((uint32_t)0x00000200) /*!< Bit 0 */ +#define ADC_SMPR2_SMP3_1 ((uint32_t)0x00000400) /*!< Bit 1 */ +#define ADC_SMPR2_SMP3_2 ((uint32_t)0x00000800) /*!< Bit 2 */ + +#define ADC_SMPR2_SMP4 ((uint32_t)0x00007000) /*!< SMP4[2:0] bits (Channel 4 Sample time selection) */ +#define ADC_SMPR2_SMP4_0 ((uint32_t)0x00001000) /*!< Bit 0 */ +#define ADC_SMPR2_SMP4_1 ((uint32_t)0x00002000) /*!< Bit 1 */ +#define ADC_SMPR2_SMP4_2 ((uint32_t)0x00004000) /*!< Bit 2 */ + +#define ADC_SMPR2_SMP5 ((uint32_t)0x00038000) /*!< SMP5[2:0] bits (Channel 5 Sample time selection) */ +#define ADC_SMPR2_SMP5_0 ((uint32_t)0x00008000) /*!< Bit 0 */ +#define ADC_SMPR2_SMP5_1 ((uint32_t)0x00010000) /*!< Bit 1 */ +#define ADC_SMPR2_SMP5_2 ((uint32_t)0x00020000) /*!< Bit 2 */ + +#define ADC_SMPR2_SMP6 ((uint32_t)0x001C0000) /*!< SMP6[2:0] bits (Channel 6 Sample time selection) */ +#define ADC_SMPR2_SMP6_0 ((uint32_t)0x00040000) /*!< Bit 0 */ +#define ADC_SMPR2_SMP6_1 ((uint32_t)0x00080000) /*!< Bit 1 */ +#define ADC_SMPR2_SMP6_2 ((uint32_t)0x00100000) /*!< Bit 2 */ + +#define ADC_SMPR2_SMP7 ((uint32_t)0x00E00000) /*!< SMP7[2:0] bits (Channel 7 Sample time selection) */ +#define ADC_SMPR2_SMP7_0 ((uint32_t)0x00200000) /*!< Bit 0 */ +#define ADC_SMPR2_SMP7_1 ((uint32_t)0x00400000) /*!< Bit 1 */ +#define ADC_SMPR2_SMP7_2 ((uint32_t)0x00800000) /*!< Bit 2 */ + +#define ADC_SMPR2_SMP8 ((uint32_t)0x07000000) /*!< SMP8[2:0] bits (Channel 8 Sample time selection) */ +#define ADC_SMPR2_SMP8_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define ADC_SMPR2_SMP8_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define ADC_SMPR2_SMP8_2 ((uint32_t)0x04000000) /*!< Bit 2 */ + +#define ADC_SMPR2_SMP9 ((uint32_t)0x38000000) /*!< SMP9[2:0] bits (Channel 9 Sample time selection) */ +#define ADC_SMPR2_SMP9_0 ((uint32_t)0x08000000) /*!< Bit 0 */ +#define ADC_SMPR2_SMP9_1 ((uint32_t)0x10000000) /*!< Bit 1 */ +#define ADC_SMPR2_SMP9_2 ((uint32_t)0x20000000) /*!< Bit 2 */ + +/****************** Bit definition for ADC_JOFR1 register *******************/ +#define ADC_JOFR1_JOFFSET1 ((uint16_t)0x0FFF) /*!< Data offset for injected channel 1 */ + +/****************** Bit definition for ADC_JOFR2 register *******************/ +#define ADC_JOFR2_JOFFSET2 ((uint16_t)0x0FFF) /*!< Data offset for injected channel 2 */ + +/****************** Bit definition for ADC_JOFR3 register *******************/ +#define ADC_JOFR3_JOFFSET3 ((uint16_t)0x0FFF) /*!< Data offset for injected channel 3 */ + +/****************** Bit definition for ADC_JOFR4 register *******************/ +#define ADC_JOFR4_JOFFSET4 ((uint16_t)0x0FFF) /*!< Data offset for injected channel 4 */ + +/******************* Bit definition for ADC_HTR register ********************/ +#define ADC_HTR_HT ((uint16_t)0x0FFF) /*!< Analog watchdog high threshold */ + +/******************* Bit definition for ADC_LTR register ********************/ +#define ADC_LTR_LT ((uint16_t)0x0FFF) /*!< Analog watchdog low threshold */ + +/******************* Bit definition for ADC_SQR1 register *******************/ +#define ADC_SQR1_SQ13 ((uint32_t)0x0000001F) /*!< SQ13[4:0] bits (13th conversion in regular sequence) */ +#define ADC_SQR1_SQ13_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define ADC_SQR1_SQ13_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define ADC_SQR1_SQ13_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define ADC_SQR1_SQ13_3 ((uint32_t)0x00000008) /*!< Bit 3 */ +#define ADC_SQR1_SQ13_4 ((uint32_t)0x00000010) /*!< Bit 4 */ + +#define ADC_SQR1_SQ14 ((uint32_t)0x000003E0) /*!< SQ14[4:0] bits (14th conversion in regular sequence) */ +#define ADC_SQR1_SQ14_0 ((uint32_t)0x00000020) /*!< Bit 0 */ +#define ADC_SQR1_SQ14_1 ((uint32_t)0x00000040) /*!< Bit 1 */ +#define ADC_SQR1_SQ14_2 ((uint32_t)0x00000080) /*!< Bit 2 */ +#define ADC_SQR1_SQ14_3 ((uint32_t)0x00000100) /*!< Bit 3 */ +#define ADC_SQR1_SQ14_4 ((uint32_t)0x00000200) /*!< Bit 4 */ + +#define ADC_SQR1_SQ15 ((uint32_t)0x00007C00) /*!< SQ15[4:0] bits (15th conversion in regular sequence) */ +#define ADC_SQR1_SQ15_0 ((uint32_t)0x00000400) /*!< Bit 0 */ +#define ADC_SQR1_SQ15_1 ((uint32_t)0x00000800) /*!< Bit 1 */ +#define ADC_SQR1_SQ15_2 ((uint32_t)0x00001000) /*!< Bit 2 */ +#define ADC_SQR1_SQ15_3 ((uint32_t)0x00002000) /*!< Bit 3 */ +#define ADC_SQR1_SQ15_4 ((uint32_t)0x00004000) /*!< Bit 4 */ + +#define ADC_SQR1_SQ16 ((uint32_t)0x000F8000) /*!< SQ16[4:0] bits (16th conversion in regular sequence) */ +#define ADC_SQR1_SQ16_0 ((uint32_t)0x00008000) /*!< Bit 0 */ +#define ADC_SQR1_SQ16_1 ((uint32_t)0x00010000) /*!< Bit 1 */ +#define ADC_SQR1_SQ16_2 ((uint32_t)0x00020000) /*!< Bit 2 */ +#define ADC_SQR1_SQ16_3 ((uint32_t)0x00040000) /*!< Bit 3 */ +#define ADC_SQR1_SQ16_4 ((uint32_t)0x00080000) /*!< Bit 4 */ + +#define ADC_SQR1_L ((uint32_t)0x00F00000) /*!< L[3:0] bits (Regular channel sequence length) */ +#define ADC_SQR1_L_0 ((uint32_t)0x00100000) /*!< Bit 0 */ +#define ADC_SQR1_L_1 ((uint32_t)0x00200000) /*!< Bit 1 */ +#define ADC_SQR1_L_2 ((uint32_t)0x00400000) /*!< Bit 2 */ +#define ADC_SQR1_L_3 ((uint32_t)0x00800000) /*!< Bit 3 */ + +/******************* Bit definition for ADC_SQR2 register *******************/ +#define ADC_SQR2_SQ7 ((uint32_t)0x0000001F) /*!< SQ7[4:0] bits (7th conversion in regular sequence) */ +#define ADC_SQR2_SQ7_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define ADC_SQR2_SQ7_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define ADC_SQR2_SQ7_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define ADC_SQR2_SQ7_3 ((uint32_t)0x00000008) /*!< Bit 3 */ +#define ADC_SQR2_SQ7_4 ((uint32_t)0x00000010) /*!< Bit 4 */ + +#define ADC_SQR2_SQ8 ((uint32_t)0x000003E0) /*!< SQ8[4:0] bits (8th conversion in regular sequence) */ +#define ADC_SQR2_SQ8_0 ((uint32_t)0x00000020) /*!< Bit 0 */ +#define ADC_SQR2_SQ8_1 ((uint32_t)0x00000040) /*!< Bit 1 */ +#define ADC_SQR2_SQ8_2 ((uint32_t)0x00000080) /*!< Bit 2 */ +#define ADC_SQR2_SQ8_3 ((uint32_t)0x00000100) /*!< Bit 3 */ +#define ADC_SQR2_SQ8_4 ((uint32_t)0x00000200) /*!< Bit 4 */ + +#define ADC_SQR2_SQ9 ((uint32_t)0x00007C00) /*!< SQ9[4:0] bits (9th conversion in regular sequence) */ +#define ADC_SQR2_SQ9_0 ((uint32_t)0x00000400) /*!< Bit 0 */ +#define ADC_SQR2_SQ9_1 ((uint32_t)0x00000800) /*!< Bit 1 */ +#define ADC_SQR2_SQ9_2 ((uint32_t)0x00001000) /*!< Bit 2 */ +#define ADC_SQR2_SQ9_3 ((uint32_t)0x00002000) /*!< Bit 3 */ +#define ADC_SQR2_SQ9_4 ((uint32_t)0x00004000) /*!< Bit 4 */ + +#define ADC_SQR2_SQ10 ((uint32_t)0x000F8000) /*!< SQ10[4:0] bits (10th conversion in regular sequence) */ +#define ADC_SQR2_SQ10_0 ((uint32_t)0x00008000) /*!< Bit 0 */ +#define ADC_SQR2_SQ10_1 ((uint32_t)0x00010000) /*!< Bit 1 */ +#define ADC_SQR2_SQ10_2 ((uint32_t)0x00020000) /*!< Bit 2 */ +#define ADC_SQR2_SQ10_3 ((uint32_t)0x00040000) /*!< Bit 3 */ +#define ADC_SQR2_SQ10_4 ((uint32_t)0x00080000) /*!< Bit 4 */ + +#define ADC_SQR2_SQ11 ((uint32_t)0x01F00000) /*!< SQ11[4:0] bits (11th conversion in regular sequence) */ +#define ADC_SQR2_SQ11_0 ((uint32_t)0x00100000) /*!< Bit 0 */ +#define ADC_SQR2_SQ11_1 ((uint32_t)0x00200000) /*!< Bit 1 */ +#define ADC_SQR2_SQ11_2 ((uint32_t)0x00400000) /*!< Bit 2 */ +#define ADC_SQR2_SQ11_3 ((uint32_t)0x00800000) /*!< Bit 3 */ +#define ADC_SQR2_SQ11_4 ((uint32_t)0x01000000) /*!< Bit 4 */ + +#define ADC_SQR2_SQ12 ((uint32_t)0x3E000000) /*!< SQ12[4:0] bits (12th conversion in regular sequence) */ +#define ADC_SQR2_SQ12_0 ((uint32_t)0x02000000) /*!< Bit 0 */ +#define ADC_SQR2_SQ12_1 ((uint32_t)0x04000000) /*!< Bit 1 */ +#define ADC_SQR2_SQ12_2 ((uint32_t)0x08000000) /*!< Bit 2 */ +#define ADC_SQR2_SQ12_3 ((uint32_t)0x10000000) /*!< Bit 3 */ +#define ADC_SQR2_SQ12_4 ((uint32_t)0x20000000) /*!< Bit 4 */ + +/******************* Bit definition for ADC_SQR3 register *******************/ +#define ADC_SQR3_SQ1 ((uint32_t)0x0000001F) /*!< SQ1[4:0] bits (1st conversion in regular sequence) */ +#define ADC_SQR3_SQ1_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define ADC_SQR3_SQ1_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define ADC_SQR3_SQ1_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define ADC_SQR3_SQ1_3 ((uint32_t)0x00000008) /*!< Bit 3 */ +#define ADC_SQR3_SQ1_4 ((uint32_t)0x00000010) /*!< Bit 4 */ + +#define ADC_SQR3_SQ2 ((uint32_t)0x000003E0) /*!< SQ2[4:0] bits (2nd conversion in regular sequence) */ +#define ADC_SQR3_SQ2_0 ((uint32_t)0x00000020) /*!< Bit 0 */ +#define ADC_SQR3_SQ2_1 ((uint32_t)0x00000040) /*!< Bit 1 */ +#define ADC_SQR3_SQ2_2 ((uint32_t)0x00000080) /*!< Bit 2 */ +#define ADC_SQR3_SQ2_3 ((uint32_t)0x00000100) /*!< Bit 3 */ +#define ADC_SQR3_SQ2_4 ((uint32_t)0x00000200) /*!< Bit 4 */ + +#define ADC_SQR3_SQ3 ((uint32_t)0x00007C00) /*!< SQ3[4:0] bits (3rd conversion in regular sequence) */ +#define ADC_SQR3_SQ3_0 ((uint32_t)0x00000400) /*!< Bit 0 */ +#define ADC_SQR3_SQ3_1 ((uint32_t)0x00000800) /*!< Bit 1 */ +#define ADC_SQR3_SQ3_2 ((uint32_t)0x00001000) /*!< Bit 2 */ +#define ADC_SQR3_SQ3_3 ((uint32_t)0x00002000) /*!< Bit 3 */ +#define ADC_SQR3_SQ3_4 ((uint32_t)0x00004000) /*!< Bit 4 */ + +#define ADC_SQR3_SQ4 ((uint32_t)0x000F8000) /*!< SQ4[4:0] bits (4th conversion in regular sequence) */ +#define ADC_SQR3_SQ4_0 ((uint32_t)0x00008000) /*!< Bit 0 */ +#define ADC_SQR3_SQ4_1 ((uint32_t)0x00010000) /*!< Bit 1 */ +#define ADC_SQR3_SQ4_2 ((uint32_t)0x00020000) /*!< Bit 2 */ +#define ADC_SQR3_SQ4_3 ((uint32_t)0x00040000) /*!< Bit 3 */ +#define ADC_SQR3_SQ4_4 ((uint32_t)0x00080000) /*!< Bit 4 */ + +#define ADC_SQR3_SQ5 ((uint32_t)0x01F00000) /*!< SQ5[4:0] bits (5th conversion in regular sequence) */ +#define ADC_SQR3_SQ5_0 ((uint32_t)0x00100000) /*!< Bit 0 */ +#define ADC_SQR3_SQ5_1 ((uint32_t)0x00200000) /*!< Bit 1 */ +#define ADC_SQR3_SQ5_2 ((uint32_t)0x00400000) /*!< Bit 2 */ +#define ADC_SQR3_SQ5_3 ((uint32_t)0x00800000) /*!< Bit 3 */ +#define ADC_SQR3_SQ5_4 ((uint32_t)0x01000000) /*!< Bit 4 */ + +#define ADC_SQR3_SQ6 ((uint32_t)0x3E000000) /*!< SQ6[4:0] bits (6th conversion in regular sequence) */ +#define ADC_SQR3_SQ6_0 ((uint32_t)0x02000000) /*!< Bit 0 */ +#define ADC_SQR3_SQ6_1 ((uint32_t)0x04000000) /*!< Bit 1 */ +#define ADC_SQR3_SQ6_2 ((uint32_t)0x08000000) /*!< Bit 2 */ +#define ADC_SQR3_SQ6_3 ((uint32_t)0x10000000) /*!< Bit 3 */ +#define ADC_SQR3_SQ6_4 ((uint32_t)0x20000000) /*!< Bit 4 */ + +/******************* Bit definition for ADC_JSQR register *******************/ +#define ADC_JSQR_JSQ1 ((uint32_t)0x0000001F) /*!< JSQ1[4:0] bits (1st conversion in injected sequence) */ +#define ADC_JSQR_JSQ1_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define ADC_JSQR_JSQ1_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define ADC_JSQR_JSQ1_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define ADC_JSQR_JSQ1_3 ((uint32_t)0x00000008) /*!< Bit 3 */ +#define ADC_JSQR_JSQ1_4 ((uint32_t)0x00000010) /*!< Bit 4 */ + +#define ADC_JSQR_JSQ2 ((uint32_t)0x000003E0) /*!< JSQ2[4:0] bits (2nd conversion in injected sequence) */ +#define ADC_JSQR_JSQ2_0 ((uint32_t)0x00000020) /*!< Bit 0 */ +#define ADC_JSQR_JSQ2_1 ((uint32_t)0x00000040) /*!< Bit 1 */ +#define ADC_JSQR_JSQ2_2 ((uint32_t)0x00000080) /*!< Bit 2 */ +#define ADC_JSQR_JSQ2_3 ((uint32_t)0x00000100) /*!< Bit 3 */ +#define ADC_JSQR_JSQ2_4 ((uint32_t)0x00000200) /*!< Bit 4 */ + +#define ADC_JSQR_JSQ3 ((uint32_t)0x00007C00) /*!< JSQ3[4:0] bits (3rd conversion in injected sequence) */ +#define ADC_JSQR_JSQ3_0 ((uint32_t)0x00000400) /*!< Bit 0 */ +#define ADC_JSQR_JSQ3_1 ((uint32_t)0x00000800) /*!< Bit 1 */ +#define ADC_JSQR_JSQ3_2 ((uint32_t)0x00001000) /*!< Bit 2 */ +#define ADC_JSQR_JSQ3_3 ((uint32_t)0x00002000) /*!< Bit 3 */ +#define ADC_JSQR_JSQ3_4 ((uint32_t)0x00004000) /*!< Bit 4 */ + +#define ADC_JSQR_JSQ4 ((uint32_t)0x000F8000) /*!< JSQ4[4:0] bits (4th conversion in injected sequence) */ +#define ADC_JSQR_JSQ4_0 ((uint32_t)0x00008000) /*!< Bit 0 */ +#define ADC_JSQR_JSQ4_1 ((uint32_t)0x00010000) /*!< Bit 1 */ +#define ADC_JSQR_JSQ4_2 ((uint32_t)0x00020000) /*!< Bit 2 */ +#define ADC_JSQR_JSQ4_3 ((uint32_t)0x00040000) /*!< Bit 3 */ +#define ADC_JSQR_JSQ4_4 ((uint32_t)0x00080000) /*!< Bit 4 */ + +#define ADC_JSQR_JL ((uint32_t)0x00300000) /*!< JL[1:0] bits (Injected Sequence length) */ +#define ADC_JSQR_JL_0 ((uint32_t)0x00100000) /*!< Bit 0 */ +#define ADC_JSQR_JL_1 ((uint32_t)0x00200000) /*!< Bit 1 */ + +/******************* Bit definition for ADC_JDR1 register *******************/ +#define ADC_JDR1_JDATA ((uint16_t)0xFFFF) /*!< Injected data */ + +/******************* Bit definition for ADC_JDR2 register *******************/ +#define ADC_JDR2_JDATA ((uint16_t)0xFFFF) /*!< Injected data */ + +/******************* Bit definition for ADC_JDR3 register *******************/ +#define ADC_JDR3_JDATA ((uint16_t)0xFFFF) /*!< Injected data */ + +/******************* Bit definition for ADC_JDR4 register *******************/ +#define ADC_JDR4_JDATA ((uint16_t)0xFFFF) /*!< Injected data */ + +/******************** Bit definition for ADC_DR register ********************/ +#define ADC_DR_DATA ((uint32_t)0x0000FFFF) /*!< Regular data */ +#define ADC_DR_ADC2DATA ((uint32_t)0xFFFF0000) /*!< ADC2 data */ + +/******************************************************************************/ +/* */ +/* Digital to Analog Converter */ +/* */ +/******************************************************************************/ + +/******************** Bit definition for DAC_CR register ********************/ +#define DAC_CR_EN1 ((uint32_t)0x00000001) /*!< DAC channel1 enable */ +#define DAC_CR_BOFF1 ((uint32_t)0x00000002) /*!< DAC channel1 output buffer disable */ +#define DAC_CR_TEN1 ((uint32_t)0x00000004) /*!< DAC channel1 Trigger enable */ + +#define DAC_CR_TSEL1 ((uint32_t)0x00000038) /*!< TSEL1[2:0] (DAC channel1 Trigger selection) */ +#define DAC_CR_TSEL1_0 ((uint32_t)0x00000008) /*!< Bit 0 */ +#define DAC_CR_TSEL1_1 ((uint32_t)0x00000010) /*!< Bit 1 */ +#define DAC_CR_TSEL1_2 ((uint32_t)0x00000020) /*!< Bit 2 */ + +#define DAC_CR_WAVE1 ((uint32_t)0x000000C0) /*!< WAVE1[1:0] (DAC channel1 noise/triangle wave generation enable) */ +#define DAC_CR_WAVE1_0 ((uint32_t)0x00000040) /*!< Bit 0 */ +#define DAC_CR_WAVE1_1 ((uint32_t)0x00000080) /*!< Bit 1 */ + +#define DAC_CR_MAMP1 ((uint32_t)0x00000F00) /*!< MAMP1[3:0] (DAC channel1 Mask/Amplitude selector) */ +#define DAC_CR_MAMP1_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define DAC_CR_MAMP1_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define DAC_CR_MAMP1_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define DAC_CR_MAMP1_3 ((uint32_t)0x00000800) /*!< Bit 3 */ + +#define DAC_CR_DMAEN1 ((uint32_t)0x00001000) /*!< DAC channel1 DMA enable */ +#define DAC_CR_EN2 ((uint32_t)0x00010000) /*!< DAC channel2 enable */ +#define DAC_CR_BOFF2 ((uint32_t)0x00020000) /*!< DAC channel2 output buffer disable */ +#define DAC_CR_TEN2 ((uint32_t)0x00040000) /*!< DAC channel2 Trigger enable */ + +#define DAC_CR_TSEL2 ((uint32_t)0x00380000) /*!< TSEL2[2:0] (DAC channel2 Trigger selection) */ +#define DAC_CR_TSEL2_0 ((uint32_t)0x00080000) /*!< Bit 0 */ +#define DAC_CR_TSEL2_1 ((uint32_t)0x00100000) /*!< Bit 1 */ +#define DAC_CR_TSEL2_2 ((uint32_t)0x00200000) /*!< Bit 2 */ + +#define DAC_CR_WAVE2 ((uint32_t)0x00C00000) /*!< WAVE2[1:0] (DAC channel2 noise/triangle wave generation enable) */ +#define DAC_CR_WAVE2_0 ((uint32_t)0x00400000) /*!< Bit 0 */ +#define DAC_CR_WAVE2_1 ((uint32_t)0x00800000) /*!< Bit 1 */ + +#define DAC_CR_MAMP2 ((uint32_t)0x0F000000) /*!< MAMP2[3:0] (DAC channel2 Mask/Amplitude selector) */ +#define DAC_CR_MAMP2_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define DAC_CR_MAMP2_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define DAC_CR_MAMP2_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define DAC_CR_MAMP2_3 ((uint32_t)0x08000000) /*!< Bit 3 */ + +#define DAC_CR_DMAEN2 ((uint32_t)0x10000000) /*!< DAC channel2 DMA enabled */ + +/***************** Bit definition for DAC_SWTRIGR register ******************/ +#define DAC_SWTRIGR_SWTRIG1 ((uint8_t)0x01) /*!< DAC channel1 software trigger */ +#define DAC_SWTRIGR_SWTRIG2 ((uint8_t)0x02) /*!< DAC channel2 software trigger */ + +/***************** Bit definition for DAC_DHR12R1 register ******************/ +#define DAC_DHR12R1_DACC1DHR ((uint16_t)0x0FFF) /*!< DAC channel1 12-bit Right aligned data */ + +/***************** Bit definition for DAC_DHR12L1 register ******************/ +#define DAC_DHR12L1_DACC1DHR ((uint16_t)0xFFF0) /*!< DAC channel1 12-bit Left aligned data */ + +/****************** Bit definition for DAC_DHR8R1 register ******************/ +#define DAC_DHR8R1_DACC1DHR ((uint8_t)0xFF) /*!< DAC channel1 8-bit Right aligned data */ + +/***************** Bit definition for DAC_DHR12R2 register ******************/ +#define DAC_DHR12R2_DACC2DHR ((uint16_t)0x0FFF) /*!< DAC channel2 12-bit Right aligned data */ + +/***************** Bit definition for DAC_DHR12L2 register ******************/ +#define DAC_DHR12L2_DACC2DHR ((uint16_t)0xFFF0) /*!< DAC channel2 12-bit Left aligned data */ + +/****************** Bit definition for DAC_DHR8R2 register ******************/ +#define DAC_DHR8R2_DACC2DHR ((uint8_t)0xFF) /*!< DAC channel2 8-bit Right aligned data */ + +/***************** Bit definition for DAC_DHR12RD register ******************/ +#define DAC_DHR12RD_DACC1DHR ((uint32_t)0x00000FFF) /*!< DAC channel1 12-bit Right aligned data */ +#define DAC_DHR12RD_DACC2DHR ((uint32_t)0x0FFF0000) /*!< DAC channel2 12-bit Right aligned data */ + +/***************** Bit definition for DAC_DHR12LD register ******************/ +#define DAC_DHR12LD_DACC1DHR ((uint32_t)0x0000FFF0) /*!< DAC channel1 12-bit Left aligned data */ +#define DAC_DHR12LD_DACC2DHR ((uint32_t)0xFFF00000) /*!< DAC channel2 12-bit Left aligned data */ + +/****************** Bit definition for DAC_DHR8RD register ******************/ +#define DAC_DHR8RD_DACC1DHR ((uint16_t)0x00FF) /*!< DAC channel1 8-bit Right aligned data */ +#define DAC_DHR8RD_DACC2DHR ((uint16_t)0xFF00) /*!< DAC channel2 8-bit Right aligned data */ + +/******************* Bit definition for DAC_DOR1 register *******************/ +#define DAC_DOR1_DACC1DOR ((uint16_t)0x0FFF) /*!< DAC channel1 data output */ + +/******************* Bit definition for DAC_DOR2 register *******************/ +#define DAC_DOR2_DACC2DOR ((uint16_t)0x0FFF) /*!< DAC channel2 data output */ + +/******************** Bit definition for DAC_SR register ********************/ +#define DAC_SR_DMAUDR1 ((uint32_t)0x00002000) /*!< DAC channel1 DMA underrun flag */ +#define DAC_SR_DMAUDR2 ((uint32_t)0x20000000) /*!< DAC channel2 DMA underrun flag */ + +/******************************************************************************/ +/* */ +/* CEC */ +/* */ +/******************************************************************************/ +/******************** Bit definition for CEC_CFGR register ******************/ +#define CEC_CFGR_PE ((uint16_t)0x0001) /*!< Peripheral Enable */ +#define CEC_CFGR_IE ((uint16_t)0x0002) /*!< Interrupt Enable */ +#define CEC_CFGR_BTEM ((uint16_t)0x0004) /*!< Bit Timing Error Mode */ +#define CEC_CFGR_BPEM ((uint16_t)0x0008) /*!< Bit Period Error Mode */ + +/******************** Bit definition for CEC_OAR register ******************/ +#define CEC_OAR_OA ((uint16_t)0x000F) /*!< OA[3:0]: Own Address */ +#define CEC_OAR_OA_0 ((uint16_t)0x0001) /*!< Bit 0 */ +#define CEC_OAR_OA_1 ((uint16_t)0x0002) /*!< Bit 1 */ +#define CEC_OAR_OA_2 ((uint16_t)0x0004) /*!< Bit 2 */ +#define CEC_OAR_OA_3 ((uint16_t)0x0008) /*!< Bit 3 */ + +/******************** Bit definition for CEC_PRES register ******************/ +#define CEC_PRES_PRES ((uint16_t)0x3FFF) /*!< Prescaler Counter Value */ + +/******************** Bit definition for CEC_ESR register ******************/ +#define CEC_ESR_BTE ((uint16_t)0x0001) /*!< Bit Timing Error */ +#define CEC_ESR_BPE ((uint16_t)0x0002) /*!< Bit Period Error */ +#define CEC_ESR_RBTFE ((uint16_t)0x0004) /*!< Rx Block Transfer Finished Error */ +#define CEC_ESR_SBE ((uint16_t)0x0008) /*!< Start Bit Error */ +#define CEC_ESR_ACKE ((uint16_t)0x0010) /*!< Block Acknowledge Error */ +#define CEC_ESR_LINE ((uint16_t)0x0020) /*!< Line Error */ +#define CEC_ESR_TBTFE ((uint16_t)0x0040) /*!< Tx Block Transfer Finished Error */ + +/******************** Bit definition for CEC_CSR register ******************/ +#define CEC_CSR_TSOM ((uint16_t)0x0001) /*!< Tx Start Of Message */ +#define CEC_CSR_TEOM ((uint16_t)0x0002) /*!< Tx End Of Message */ +#define CEC_CSR_TERR ((uint16_t)0x0004) /*!< Tx Error */ +#define CEC_CSR_TBTRF ((uint16_t)0x0008) /*!< Tx Byte Transfer Request or Block Transfer Finished */ +#define CEC_CSR_RSOM ((uint16_t)0x0010) /*!< Rx Start Of Message */ +#define CEC_CSR_REOM ((uint16_t)0x0020) /*!< Rx End Of Message */ +#define CEC_CSR_RERR ((uint16_t)0x0040) /*!< Rx Error */ +#define CEC_CSR_RBTF ((uint16_t)0x0080) /*!< Rx Block Transfer Finished */ + +/******************** Bit definition for CEC_TXD register ******************/ +#define CEC_TXD_TXD ((uint16_t)0x00FF) /*!< Tx Data register */ + +/******************** Bit definition for CEC_RXD register ******************/ +#define CEC_RXD_RXD ((uint16_t)0x00FF) /*!< Rx Data register */ + +/******************************************************************************/ +/* */ +/* TIM */ +/* */ +/******************************************************************************/ + +/******************* Bit definition for TIM_CR1 register ********************/ +#define TIM_CR1_CEN ((uint16_t)0x0001) /*!< Counter enable */ +#define TIM_CR1_UDIS ((uint16_t)0x0002) /*!< Update disable */ +#define TIM_CR1_URS ((uint16_t)0x0004) /*!< Update request source */ +#define TIM_CR1_OPM ((uint16_t)0x0008) /*!< One pulse mode */ +#define TIM_CR1_DIR ((uint16_t)0x0010) /*!< Direction */ + +#define TIM_CR1_CMS ((uint16_t)0x0060) /*!< CMS[1:0] bits (Center-aligned mode selection) */ +#define TIM_CR1_CMS_0 ((uint16_t)0x0020) /*!< Bit 0 */ +#define TIM_CR1_CMS_1 ((uint16_t)0x0040) /*!< Bit 1 */ + +#define TIM_CR1_ARPE ((uint16_t)0x0080) /*!< Auto-reload preload enable */ + +#define TIM_CR1_CKD ((uint16_t)0x0300) /*!< CKD[1:0] bits (clock division) */ +#define TIM_CR1_CKD_0 ((uint16_t)0x0100) /*!< Bit 0 */ +#define TIM_CR1_CKD_1 ((uint16_t)0x0200) /*!< Bit 1 */ + +/******************* Bit definition for TIM_CR2 register ********************/ +#define TIM_CR2_CCPC ((uint16_t)0x0001) /*!< Capture/Compare Preloaded Control */ +#define TIM_CR2_CCUS ((uint16_t)0x0004) /*!< Capture/Compare Control Update Selection */ +#define TIM_CR2_CCDS ((uint16_t)0x0008) /*!< Capture/Compare DMA Selection */ + +#define TIM_CR2_MMS ((uint16_t)0x0070) /*!< MMS[2:0] bits (Master Mode Selection) */ +#define TIM_CR2_MMS_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define TIM_CR2_MMS_1 ((uint16_t)0x0020) /*!< Bit 1 */ +#define TIM_CR2_MMS_2 ((uint16_t)0x0040) /*!< Bit 2 */ + +#define TIM_CR2_TI1S ((uint16_t)0x0080) /*!< TI1 Selection */ +#define TIM_CR2_OIS1 ((uint16_t)0x0100) /*!< Output Idle state 1 (OC1 output) */ +#define TIM_CR2_OIS1N ((uint16_t)0x0200) /*!< Output Idle state 1 (OC1N output) */ +#define TIM_CR2_OIS2 ((uint16_t)0x0400) /*!< Output Idle state 2 (OC2 output) */ +#define TIM_CR2_OIS2N ((uint16_t)0x0800) /*!< Output Idle state 2 (OC2N output) */ +#define TIM_CR2_OIS3 ((uint16_t)0x1000) /*!< Output Idle state 3 (OC3 output) */ +#define TIM_CR2_OIS3N ((uint16_t)0x2000) /*!< Output Idle state 3 (OC3N output) */ +#define TIM_CR2_OIS4 ((uint16_t)0x4000) /*!< Output Idle state 4 (OC4 output) */ + +/******************* Bit definition for TIM_SMCR register *******************/ +#define TIM_SMCR_SMS ((uint16_t)0x0007) /*!< SMS[2:0] bits (Slave mode selection) */ +#define TIM_SMCR_SMS_0 ((uint16_t)0x0001) /*!< Bit 0 */ +#define TIM_SMCR_SMS_1 ((uint16_t)0x0002) /*!< Bit 1 */ +#define TIM_SMCR_SMS_2 ((uint16_t)0x0004) /*!< Bit 2 */ + +#define TIM_SMCR_TS ((uint16_t)0x0070) /*!< TS[2:0] bits (Trigger selection) */ +#define TIM_SMCR_TS_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define TIM_SMCR_TS_1 ((uint16_t)0x0020) /*!< Bit 1 */ +#define TIM_SMCR_TS_2 ((uint16_t)0x0040) /*!< Bit 2 */ + +#define TIM_SMCR_MSM ((uint16_t)0x0080) /*!< Master/slave mode */ + +#define TIM_SMCR_ETF ((uint16_t)0x0F00) /*!< ETF[3:0] bits (External trigger filter) */ +#define TIM_SMCR_ETF_0 ((uint16_t)0x0100) /*!< Bit 0 */ +#define TIM_SMCR_ETF_1 ((uint16_t)0x0200) /*!< Bit 1 */ +#define TIM_SMCR_ETF_2 ((uint16_t)0x0400) /*!< Bit 2 */ +#define TIM_SMCR_ETF_3 ((uint16_t)0x0800) /*!< Bit 3 */ + +#define TIM_SMCR_ETPS ((uint16_t)0x3000) /*!< ETPS[1:0] bits (External trigger prescaler) */ +#define TIM_SMCR_ETPS_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define TIM_SMCR_ETPS_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define TIM_SMCR_ECE ((uint16_t)0x4000) /*!< External clock enable */ +#define TIM_SMCR_ETP ((uint16_t)0x8000) /*!< External trigger polarity */ + +/******************* Bit definition for TIM_DIER register *******************/ +#define TIM_DIER_UIE ((uint16_t)0x0001) /*!< Update interrupt enable */ +#define TIM_DIER_CC1IE ((uint16_t)0x0002) /*!< Capture/Compare 1 interrupt enable */ +#define TIM_DIER_CC2IE ((uint16_t)0x0004) /*!< Capture/Compare 2 interrupt enable */ +#define TIM_DIER_CC3IE ((uint16_t)0x0008) /*!< Capture/Compare 3 interrupt enable */ +#define TIM_DIER_CC4IE ((uint16_t)0x0010) /*!< Capture/Compare 4 interrupt enable */ +#define TIM_DIER_COMIE ((uint16_t)0x0020) /*!< COM interrupt enable */ +#define TIM_DIER_TIE ((uint16_t)0x0040) /*!< Trigger interrupt enable */ +#define TIM_DIER_BIE ((uint16_t)0x0080) /*!< Break interrupt enable */ +#define TIM_DIER_UDE ((uint16_t)0x0100) /*!< Update DMA request enable */ +#define TIM_DIER_CC1DE ((uint16_t)0x0200) /*!< Capture/Compare 1 DMA request enable */ +#define TIM_DIER_CC2DE ((uint16_t)0x0400) /*!< Capture/Compare 2 DMA request enable */ +#define TIM_DIER_CC3DE ((uint16_t)0x0800) /*!< Capture/Compare 3 DMA request enable */ +#define TIM_DIER_CC4DE ((uint16_t)0x1000) /*!< Capture/Compare 4 DMA request enable */ +#define TIM_DIER_COMDE ((uint16_t)0x2000) /*!< COM DMA request enable */ +#define TIM_DIER_TDE ((uint16_t)0x4000) /*!< Trigger DMA request enable */ + +/******************** Bit definition for TIM_SR register ********************/ +#define TIM_SR_UIF ((uint16_t)0x0001) /*!< Update interrupt Flag */ +#define TIM_SR_CC1IF ((uint16_t)0x0002) /*!< Capture/Compare 1 interrupt Flag */ +#define TIM_SR_CC2IF ((uint16_t)0x0004) /*!< Capture/Compare 2 interrupt Flag */ +#define TIM_SR_CC3IF ((uint16_t)0x0008) /*!< Capture/Compare 3 interrupt Flag */ +#define TIM_SR_CC4IF ((uint16_t)0x0010) /*!< Capture/Compare 4 interrupt Flag */ +#define TIM_SR_COMIF ((uint16_t)0x0020) /*!< COM interrupt Flag */ +#define TIM_SR_TIF ((uint16_t)0x0040) /*!< Trigger interrupt Flag */ +#define TIM_SR_BIF ((uint16_t)0x0080) /*!< Break interrupt Flag */ +#define TIM_SR_CC1OF ((uint16_t)0x0200) /*!< Capture/Compare 1 Overcapture Flag */ +#define TIM_SR_CC2OF ((uint16_t)0x0400) /*!< Capture/Compare 2 Overcapture Flag */ +#define TIM_SR_CC3OF ((uint16_t)0x0800) /*!< Capture/Compare 3 Overcapture Flag */ +#define TIM_SR_CC4OF ((uint16_t)0x1000) /*!< Capture/Compare 4 Overcapture Flag */ + +/******************* Bit definition for TIM_EGR register ********************/ +#define TIM_EGR_UG ((uint8_t)0x01) /*!< Update Generation */ +#define TIM_EGR_CC1G ((uint8_t)0x02) /*!< Capture/Compare 1 Generation */ +#define TIM_EGR_CC2G ((uint8_t)0x04) /*!< Capture/Compare 2 Generation */ +#define TIM_EGR_CC3G ((uint8_t)0x08) /*!< Capture/Compare 3 Generation */ +#define TIM_EGR_CC4G ((uint8_t)0x10) /*!< Capture/Compare 4 Generation */ +#define TIM_EGR_COMG ((uint8_t)0x20) /*!< Capture/Compare Control Update Generation */ +#define TIM_EGR_TG ((uint8_t)0x40) /*!< Trigger Generation */ +#define TIM_EGR_BG ((uint8_t)0x80) /*!< Break Generation */ + +/****************** Bit definition for TIM_CCMR1 register *******************/ +#define TIM_CCMR1_CC1S ((uint16_t)0x0003) /*!< CC1S[1:0] bits (Capture/Compare 1 Selection) */ +#define TIM_CCMR1_CC1S_0 ((uint16_t)0x0001) /*!< Bit 0 */ +#define TIM_CCMR1_CC1S_1 ((uint16_t)0x0002) /*!< Bit 1 */ + +#define TIM_CCMR1_OC1FE ((uint16_t)0x0004) /*!< Output Compare 1 Fast enable */ +#define TIM_CCMR1_OC1PE ((uint16_t)0x0008) /*!< Output Compare 1 Preload enable */ + +#define TIM_CCMR1_OC1M ((uint16_t)0x0070) /*!< OC1M[2:0] bits (Output Compare 1 Mode) */ +#define TIM_CCMR1_OC1M_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define TIM_CCMR1_OC1M_1 ((uint16_t)0x0020) /*!< Bit 1 */ +#define TIM_CCMR1_OC1M_2 ((uint16_t)0x0040) /*!< Bit 2 */ + +#define TIM_CCMR1_OC1CE ((uint16_t)0x0080) /*!< Output Compare 1Clear Enable */ + +#define TIM_CCMR1_CC2S ((uint16_t)0x0300) /*!< CC2S[1:0] bits (Capture/Compare 2 Selection) */ +#define TIM_CCMR1_CC2S_0 ((uint16_t)0x0100) /*!< Bit 0 */ +#define TIM_CCMR1_CC2S_1 ((uint16_t)0x0200) /*!< Bit 1 */ + +#define TIM_CCMR1_OC2FE ((uint16_t)0x0400) /*!< Output Compare 2 Fast enable */ +#define TIM_CCMR1_OC2PE ((uint16_t)0x0800) /*!< Output Compare 2 Preload enable */ + +#define TIM_CCMR1_OC2M ((uint16_t)0x7000) /*!< OC2M[2:0] bits (Output Compare 2 Mode) */ +#define TIM_CCMR1_OC2M_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define TIM_CCMR1_OC2M_1 ((uint16_t)0x2000) /*!< Bit 1 */ +#define TIM_CCMR1_OC2M_2 ((uint16_t)0x4000) /*!< Bit 2 */ + +#define TIM_CCMR1_OC2CE ((uint16_t)0x8000) /*!< Output Compare 2 Clear Enable */ + +/*----------------------------------------------------------------------------*/ + +#define TIM_CCMR1_IC1PSC ((uint16_t)0x000C) /*!< IC1PSC[1:0] bits (Input Capture 1 Prescaler) */ +#define TIM_CCMR1_IC1PSC_0 ((uint16_t)0x0004) /*!< Bit 0 */ +#define TIM_CCMR1_IC1PSC_1 ((uint16_t)0x0008) /*!< Bit 1 */ + +#define TIM_CCMR1_IC1F ((uint16_t)0x00F0) /*!< IC1F[3:0] bits (Input Capture 1 Filter) */ +#define TIM_CCMR1_IC1F_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define TIM_CCMR1_IC1F_1 ((uint16_t)0x0020) /*!< Bit 1 */ +#define TIM_CCMR1_IC1F_2 ((uint16_t)0x0040) /*!< Bit 2 */ +#define TIM_CCMR1_IC1F_3 ((uint16_t)0x0080) /*!< Bit 3 */ + +#define TIM_CCMR1_IC2PSC ((uint16_t)0x0C00) /*!< IC2PSC[1:0] bits (Input Capture 2 Prescaler) */ +#define TIM_CCMR1_IC2PSC_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define TIM_CCMR1_IC2PSC_1 ((uint16_t)0x0800) /*!< Bit 1 */ + +#define TIM_CCMR1_IC2F ((uint16_t)0xF000) /*!< IC2F[3:0] bits (Input Capture 2 Filter) */ +#define TIM_CCMR1_IC2F_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define TIM_CCMR1_IC2F_1 ((uint16_t)0x2000) /*!< Bit 1 */ +#define TIM_CCMR1_IC2F_2 ((uint16_t)0x4000) /*!< Bit 2 */ +#define TIM_CCMR1_IC2F_3 ((uint16_t)0x8000) /*!< Bit 3 */ + +/****************** Bit definition for TIM_CCMR2 register *******************/ +#define TIM_CCMR2_CC3S ((uint16_t)0x0003) /*!< CC3S[1:0] bits (Capture/Compare 3 Selection) */ +#define TIM_CCMR2_CC3S_0 ((uint16_t)0x0001) /*!< Bit 0 */ +#define TIM_CCMR2_CC3S_1 ((uint16_t)0x0002) /*!< Bit 1 */ + +#define TIM_CCMR2_OC3FE ((uint16_t)0x0004) /*!< Output Compare 3 Fast enable */ +#define TIM_CCMR2_OC3PE ((uint16_t)0x0008) /*!< Output Compare 3 Preload enable */ + +#define TIM_CCMR2_OC3M ((uint16_t)0x0070) /*!< OC3M[2:0] bits (Output Compare 3 Mode) */ +#define TIM_CCMR2_OC3M_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define TIM_CCMR2_OC3M_1 ((uint16_t)0x0020) /*!< Bit 1 */ +#define TIM_CCMR2_OC3M_2 ((uint16_t)0x0040) /*!< Bit 2 */ + +#define TIM_CCMR2_OC3CE ((uint16_t)0x0080) /*!< Output Compare 3 Clear Enable */ + +#define TIM_CCMR2_CC4S ((uint16_t)0x0300) /*!< CC4S[1:0] bits (Capture/Compare 4 Selection) */ +#define TIM_CCMR2_CC4S_0 ((uint16_t)0x0100) /*!< Bit 0 */ +#define TIM_CCMR2_CC4S_1 ((uint16_t)0x0200) /*!< Bit 1 */ + +#define TIM_CCMR2_OC4FE ((uint16_t)0x0400) /*!< Output Compare 4 Fast enable */ +#define TIM_CCMR2_OC4PE ((uint16_t)0x0800) /*!< Output Compare 4 Preload enable */ + +#define TIM_CCMR2_OC4M ((uint16_t)0x7000) /*!< OC4M[2:0] bits (Output Compare 4 Mode) */ +#define TIM_CCMR2_OC4M_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define TIM_CCMR2_OC4M_1 ((uint16_t)0x2000) /*!< Bit 1 */ +#define TIM_CCMR2_OC4M_2 ((uint16_t)0x4000) /*!< Bit 2 */ + +#define TIM_CCMR2_OC4CE ((uint16_t)0x8000) /*!< Output Compare 4 Clear Enable */ + +/*----------------------------------------------------------------------------*/ + +#define TIM_CCMR2_IC3PSC ((uint16_t)0x000C) /*!< IC3PSC[1:0] bits (Input Capture 3 Prescaler) */ +#define TIM_CCMR2_IC3PSC_0 ((uint16_t)0x0004) /*!< Bit 0 */ +#define TIM_CCMR2_IC3PSC_1 ((uint16_t)0x0008) /*!< Bit 1 */ + +#define TIM_CCMR2_IC3F ((uint16_t)0x00F0) /*!< IC3F[3:0] bits (Input Capture 3 Filter) */ +#define TIM_CCMR2_IC3F_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define TIM_CCMR2_IC3F_1 ((uint16_t)0x0020) /*!< Bit 1 */ +#define TIM_CCMR2_IC3F_2 ((uint16_t)0x0040) /*!< Bit 2 */ +#define TIM_CCMR2_IC3F_3 ((uint16_t)0x0080) /*!< Bit 3 */ + +#define TIM_CCMR2_IC4PSC ((uint16_t)0x0C00) /*!< IC4PSC[1:0] bits (Input Capture 4 Prescaler) */ +#define TIM_CCMR2_IC4PSC_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define TIM_CCMR2_IC4PSC_1 ((uint16_t)0x0800) /*!< Bit 1 */ + +#define TIM_CCMR2_IC4F ((uint16_t)0xF000) /*!< IC4F[3:0] bits (Input Capture 4 Filter) */ +#define TIM_CCMR2_IC4F_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define TIM_CCMR2_IC4F_1 ((uint16_t)0x2000) /*!< Bit 1 */ +#define TIM_CCMR2_IC4F_2 ((uint16_t)0x4000) /*!< Bit 2 */ +#define TIM_CCMR2_IC4F_3 ((uint16_t)0x8000) /*!< Bit 3 */ + +/******************* Bit definition for TIM_CCER register *******************/ +#define TIM_CCER_CC1E ((uint16_t)0x0001) /*!< Capture/Compare 1 output enable */ +#define TIM_CCER_CC1P ((uint16_t)0x0002) /*!< Capture/Compare 1 output Polarity */ +#define TIM_CCER_CC1NE ((uint16_t)0x0004) /*!< Capture/Compare 1 Complementary output enable */ +#define TIM_CCER_CC1NP ((uint16_t)0x0008) /*!< Capture/Compare 1 Complementary output Polarity */ +#define TIM_CCER_CC2E ((uint16_t)0x0010) /*!< Capture/Compare 2 output enable */ +#define TIM_CCER_CC2P ((uint16_t)0x0020) /*!< Capture/Compare 2 output Polarity */ +#define TIM_CCER_CC2NE ((uint16_t)0x0040) /*!< Capture/Compare 2 Complementary output enable */ +#define TIM_CCER_CC2NP ((uint16_t)0x0080) /*!< Capture/Compare 2 Complementary output Polarity */ +#define TIM_CCER_CC3E ((uint16_t)0x0100) /*!< Capture/Compare 3 output enable */ +#define TIM_CCER_CC3P ((uint16_t)0x0200) /*!< Capture/Compare 3 output Polarity */ +#define TIM_CCER_CC3NE ((uint16_t)0x0400) /*!< Capture/Compare 3 Complementary output enable */ +#define TIM_CCER_CC3NP ((uint16_t)0x0800) /*!< Capture/Compare 3 Complementary output Polarity */ +#define TIM_CCER_CC4E ((uint16_t)0x1000) /*!< Capture/Compare 4 output enable */ +#define TIM_CCER_CC4P ((uint16_t)0x2000) /*!< Capture/Compare 4 output Polarity */ +#define TIM_CCER_CC4NP ((uint16_t)0x8000) /*!< Capture/Compare 4 Complementary output Polarity */ + +/******************* Bit definition for TIM_CNT register ********************/ +#define TIM_CNT_CNT ((uint16_t)0xFFFF) /*!< Counter Value */ + +/******************* Bit definition for TIM_PSC register ********************/ +#define TIM_PSC_PSC ((uint16_t)0xFFFF) /*!< Prescaler Value */ + +/******************* Bit definition for TIM_ARR register ********************/ +#define TIM_ARR_ARR ((uint16_t)0xFFFF) /*!< actual auto-reload Value */ + +/******************* Bit definition for TIM_RCR register ********************/ +#define TIM_RCR_REP ((uint8_t)0xFF) /*!< Repetition Counter Value */ + +/******************* Bit definition for TIM_CCR1 register *******************/ +#define TIM_CCR1_CCR1 ((uint16_t)0xFFFF) /*!< Capture/Compare 1 Value */ + +/******************* Bit definition for TIM_CCR2 register *******************/ +#define TIM_CCR2_CCR2 ((uint16_t)0xFFFF) /*!< Capture/Compare 2 Value */ + +/******************* Bit definition for TIM_CCR3 register *******************/ +#define TIM_CCR3_CCR3 ((uint16_t)0xFFFF) /*!< Capture/Compare 3 Value */ + +/******************* Bit definition for TIM_CCR4 register *******************/ +#define TIM_CCR4_CCR4 ((uint16_t)0xFFFF) /*!< Capture/Compare 4 Value */ + +/******************* Bit definition for TIM_BDTR register *******************/ +#define TIM_BDTR_DTG ((uint16_t)0x00FF) /*!< DTG[0:7] bits (Dead-Time Generator set-up) */ +#define TIM_BDTR_DTG_0 ((uint16_t)0x0001) /*!< Bit 0 */ +#define TIM_BDTR_DTG_1 ((uint16_t)0x0002) /*!< Bit 1 */ +#define TIM_BDTR_DTG_2 ((uint16_t)0x0004) /*!< Bit 2 */ +#define TIM_BDTR_DTG_3 ((uint16_t)0x0008) /*!< Bit 3 */ +#define TIM_BDTR_DTG_4 ((uint16_t)0x0010) /*!< Bit 4 */ +#define TIM_BDTR_DTG_5 ((uint16_t)0x0020) /*!< Bit 5 */ +#define TIM_BDTR_DTG_6 ((uint16_t)0x0040) /*!< Bit 6 */ +#define TIM_BDTR_DTG_7 ((uint16_t)0x0080) /*!< Bit 7 */ + +#define TIM_BDTR_LOCK ((uint16_t)0x0300) /*!< LOCK[1:0] bits (Lock Configuration) */ +#define TIM_BDTR_LOCK_0 ((uint16_t)0x0100) /*!< Bit 0 */ +#define TIM_BDTR_LOCK_1 ((uint16_t)0x0200) /*!< Bit 1 */ + +#define TIM_BDTR_OSSI ((uint16_t)0x0400) /*!< Off-State Selection for Idle mode */ +#define TIM_BDTR_OSSR ((uint16_t)0x0800) /*!< Off-State Selection for Run mode */ +#define TIM_BDTR_BKE ((uint16_t)0x1000) /*!< Break enable */ +#define TIM_BDTR_BKP ((uint16_t)0x2000) /*!< Break Polarity */ +#define TIM_BDTR_AOE ((uint16_t)0x4000) /*!< Automatic Output enable */ +#define TIM_BDTR_MOE ((uint16_t)0x8000) /*!< Main Output enable */ + +/******************* Bit definition for TIM_DCR register ********************/ +#define TIM_DCR_DBA ((uint16_t)0x001F) /*!< DBA[4:0] bits (DMA Base Address) */ +#define TIM_DCR_DBA_0 ((uint16_t)0x0001) /*!< Bit 0 */ +#define TIM_DCR_DBA_1 ((uint16_t)0x0002) /*!< Bit 1 */ +#define TIM_DCR_DBA_2 ((uint16_t)0x0004) /*!< Bit 2 */ +#define TIM_DCR_DBA_3 ((uint16_t)0x0008) /*!< Bit 3 */ +#define TIM_DCR_DBA_4 ((uint16_t)0x0010) /*!< Bit 4 */ + +#define TIM_DCR_DBL ((uint16_t)0x1F00) /*!< DBL[4:0] bits (DMA Burst Length) */ +#define TIM_DCR_DBL_0 ((uint16_t)0x0100) /*!< Bit 0 */ +#define TIM_DCR_DBL_1 ((uint16_t)0x0200) /*!< Bit 1 */ +#define TIM_DCR_DBL_2 ((uint16_t)0x0400) /*!< Bit 2 */ +#define TIM_DCR_DBL_3 ((uint16_t)0x0800) /*!< Bit 3 */ +#define TIM_DCR_DBL_4 ((uint16_t)0x1000) /*!< Bit 4 */ + +/******************* Bit definition for TIM_DMAR register *******************/ +#define TIM_DMAR_DMAB ((uint16_t)0xFFFF) /*!< DMA register for burst accesses */ + +/******************************************************************************/ +/* */ +/* Real-Time Clock */ +/* */ +/******************************************************************************/ + +/******************* Bit definition for RTC_CRH register ********************/ +#define RTC_CRH_SECIE ((uint8_t)0x01) /*!< Second Interrupt Enable */ +#define RTC_CRH_ALRIE ((uint8_t)0x02) /*!< Alarm Interrupt Enable */ +#define RTC_CRH_OWIE ((uint8_t)0x04) /*!< OverfloW Interrupt Enable */ + +/******************* Bit definition for RTC_CRL register ********************/ +#define RTC_CRL_SECF ((uint8_t)0x01) /*!< Second Flag */ +#define RTC_CRL_ALRF ((uint8_t)0x02) /*!< Alarm Flag */ +#define RTC_CRL_OWF ((uint8_t)0x04) /*!< OverfloW Flag */ +#define RTC_CRL_RSF ((uint8_t)0x08) /*!< Registers Synchronized Flag */ +#define RTC_CRL_CNF ((uint8_t)0x10) /*!< Configuration Flag */ +#define RTC_CRL_RTOFF ((uint8_t)0x20) /*!< RTC operation OFF */ + +/******************* Bit definition for RTC_PRLH register *******************/ +#define RTC_PRLH_PRL ((uint16_t)0x000F) /*!< RTC Prescaler Reload Value High */ + +/******************* Bit definition for RTC_PRLL register *******************/ +#define RTC_PRLL_PRL ((uint16_t)0xFFFF) /*!< RTC Prescaler Reload Value Low */ + +/******************* Bit definition for RTC_DIVH register *******************/ +#define RTC_DIVH_RTC_DIV ((uint16_t)0x000F) /*!< RTC Clock Divider High */ + +/******************* Bit definition for RTC_DIVL register *******************/ +#define RTC_DIVL_RTC_DIV ((uint16_t)0xFFFF) /*!< RTC Clock Divider Low */ + +/******************* Bit definition for RTC_CNTH register *******************/ +#define RTC_CNTH_RTC_CNT ((uint16_t)0xFFFF) /*!< RTC Counter High */ + +/******************* Bit definition for RTC_CNTL register *******************/ +#define RTC_CNTL_RTC_CNT ((uint16_t)0xFFFF) /*!< RTC Counter Low */ + +/******************* Bit definition for RTC_ALRH register *******************/ +#define RTC_ALRH_RTC_ALR ((uint16_t)0xFFFF) /*!< RTC Alarm High */ + +/******************* Bit definition for RTC_ALRL register *******************/ +#define RTC_ALRL_RTC_ALR ((uint16_t)0xFFFF) /*!< RTC Alarm Low */ + +/******************************************************************************/ +/* */ +/* Independent WATCHDOG */ +/* */ +/******************************************************************************/ + +/******************* Bit definition for IWDG_KR register ********************/ +#define IWDG_KR_KEY ((uint16_t)0xFFFF) /*!< Key value (write only, read 0000h) */ + +/******************* Bit definition for IWDG_PR register ********************/ +#define IWDG_PR_PR ((uint8_t)0x07) /*!< PR[2:0] (Prescaler divider) */ +#define IWDG_PR_PR_0 ((uint8_t)0x01) /*!< Bit 0 */ +#define IWDG_PR_PR_1 ((uint8_t)0x02) /*!< Bit 1 */ +#define IWDG_PR_PR_2 ((uint8_t)0x04) /*!< Bit 2 */ + +/******************* Bit definition for IWDG_RLR register *******************/ +#define IWDG_RLR_RL ((uint16_t)0x0FFF) /*!< Watchdog counter reload value */ + +/******************* Bit definition for IWDG_SR register ********************/ +#define IWDG_SR_PVU ((uint8_t)0x01) /*!< Watchdog prescaler value update */ +#define IWDG_SR_RVU ((uint8_t)0x02) /*!< Watchdog counter reload value update */ + +/******************************************************************************/ +/* */ +/* Window WATCHDOG */ +/* */ +/******************************************************************************/ + +/******************* Bit definition for WWDG_CR register ********************/ +#define WWDG_CR_T ((uint8_t)0x7F) /*!< T[6:0] bits (7-Bit counter (MSB to LSB)) */ +#define WWDG_CR_T0 ((uint8_t)0x01) /*!< Bit 0 */ +#define WWDG_CR_T1 ((uint8_t)0x02) /*!< Bit 1 */ +#define WWDG_CR_T2 ((uint8_t)0x04) /*!< Bit 2 */ +#define WWDG_CR_T3 ((uint8_t)0x08) /*!< Bit 3 */ +#define WWDG_CR_T4 ((uint8_t)0x10) /*!< Bit 4 */ +#define WWDG_CR_T5 ((uint8_t)0x20) /*!< Bit 5 */ +#define WWDG_CR_T6 ((uint8_t)0x40) /*!< Bit 6 */ + +#define WWDG_CR_WDGA ((uint8_t)0x80) /*!< Activation bit */ + +/******************* Bit definition for WWDG_CFR register *******************/ +#define WWDG_CFR_W ((uint16_t)0x007F) /*!< W[6:0] bits (7-bit window value) */ +#define WWDG_CFR_W0 ((uint16_t)0x0001) /*!< Bit 0 */ +#define WWDG_CFR_W1 ((uint16_t)0x0002) /*!< Bit 1 */ +#define WWDG_CFR_W2 ((uint16_t)0x0004) /*!< Bit 2 */ +#define WWDG_CFR_W3 ((uint16_t)0x0008) /*!< Bit 3 */ +#define WWDG_CFR_W4 ((uint16_t)0x0010) /*!< Bit 4 */ +#define WWDG_CFR_W5 ((uint16_t)0x0020) /*!< Bit 5 */ +#define WWDG_CFR_W6 ((uint16_t)0x0040) /*!< Bit 6 */ + +#define WWDG_CFR_WDGTB ((uint16_t)0x0180) /*!< WDGTB[1:0] bits (Timer Base) */ +#define WWDG_CFR_WDGTB0 ((uint16_t)0x0080) /*!< Bit 0 */ +#define WWDG_CFR_WDGTB1 ((uint16_t)0x0100) /*!< Bit 1 */ + +#define WWDG_CFR_EWI ((uint16_t)0x0200) /*!< Early Wakeup Interrupt */ + +/******************* Bit definition for WWDG_SR register ********************/ +#define WWDG_SR_EWIF ((uint8_t)0x01) /*!< Early Wakeup Interrupt Flag */ + +/******************************************************************************/ +/* */ +/* Flexible Static Memory Controller */ +/* */ +/******************************************************************************/ + +/****************** Bit definition for FSMC_BCR1 register *******************/ +#define FSMC_BCR1_MBKEN ((uint32_t)0x00000001) /*!< Memory bank enable bit */ +#define FSMC_BCR1_MUXEN ((uint32_t)0x00000002) /*!< Address/data multiplexing enable bit */ + +#define FSMC_BCR1_MTYP ((uint32_t)0x0000000C) /*!< MTYP[1:0] bits (Memory type) */ +#define FSMC_BCR1_MTYP_0 ((uint32_t)0x00000004) /*!< Bit 0 */ +#define FSMC_BCR1_MTYP_1 ((uint32_t)0x00000008) /*!< Bit 1 */ + +#define FSMC_BCR1_MWID ((uint32_t)0x00000030) /*!< MWID[1:0] bits (Memory data bus width) */ +#define FSMC_BCR1_MWID_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define FSMC_BCR1_MWID_1 ((uint32_t)0x00000020) /*!< Bit 1 */ + +#define FSMC_BCR1_FACCEN ((uint32_t)0x00000040) /*!< Flash access enable */ +#define FSMC_BCR1_BURSTEN ((uint32_t)0x00000100) /*!< Burst enable bit */ +#define FSMC_BCR1_WAITPOL ((uint32_t)0x00000200) /*!< Wait signal polarity bit */ +#define FSMC_BCR1_WRAPMOD ((uint32_t)0x00000400) /*!< Wrapped burst mode support */ +#define FSMC_BCR1_WAITCFG ((uint32_t)0x00000800) /*!< Wait timing configuration */ +#define FSMC_BCR1_WREN ((uint32_t)0x00001000) /*!< Write enable bit */ +#define FSMC_BCR1_WAITEN ((uint32_t)0x00002000) /*!< Wait enable bit */ +#define FSMC_BCR1_EXTMOD ((uint32_t)0x00004000) /*!< Extended mode enable */ +#define FSMC_BCR1_ASYNCWAIT ((uint32_t)0x00008000) /*!< Asynchronous wait */ +#define FSMC_BCR1_CBURSTRW ((uint32_t)0x00080000) /*!< Write burst enable */ + +/****************** Bit definition for FSMC_BCR2 register *******************/ +#define FSMC_BCR2_MBKEN ((uint32_t)0x00000001) /*!< Memory bank enable bit */ +#define FSMC_BCR2_MUXEN ((uint32_t)0x00000002) /*!< Address/data multiplexing enable bit */ + +#define FSMC_BCR2_MTYP ((uint32_t)0x0000000C) /*!< MTYP[1:0] bits (Memory type) */ +#define FSMC_BCR2_MTYP_0 ((uint32_t)0x00000004) /*!< Bit 0 */ +#define FSMC_BCR2_MTYP_1 ((uint32_t)0x00000008) /*!< Bit 1 */ + +#define FSMC_BCR2_MWID ((uint32_t)0x00000030) /*!< MWID[1:0] bits (Memory data bus width) */ +#define FSMC_BCR2_MWID_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define FSMC_BCR2_MWID_1 ((uint32_t)0x00000020) /*!< Bit 1 */ + +#define FSMC_BCR2_FACCEN ((uint32_t)0x00000040) /*!< Flash access enable */ +#define FSMC_BCR2_BURSTEN ((uint32_t)0x00000100) /*!< Burst enable bit */ +#define FSMC_BCR2_WAITPOL ((uint32_t)0x00000200) /*!< Wait signal polarity bit */ +#define FSMC_BCR2_WRAPMOD ((uint32_t)0x00000400) /*!< Wrapped burst mode support */ +#define FSMC_BCR2_WAITCFG ((uint32_t)0x00000800) /*!< Wait timing configuration */ +#define FSMC_BCR2_WREN ((uint32_t)0x00001000) /*!< Write enable bit */ +#define FSMC_BCR2_WAITEN ((uint32_t)0x00002000) /*!< Wait enable bit */ +#define FSMC_BCR2_EXTMOD ((uint32_t)0x00004000) /*!< Extended mode enable */ +#define FSMC_BCR2_ASYNCWAIT ((uint32_t)0x00008000) /*!< Asynchronous wait */ +#define FSMC_BCR2_CBURSTRW ((uint32_t)0x00080000) /*!< Write burst enable */ + +/****************** Bit definition for FSMC_BCR3 register *******************/ +#define FSMC_BCR3_MBKEN ((uint32_t)0x00000001) /*!< Memory bank enable bit */ +#define FSMC_BCR3_MUXEN ((uint32_t)0x00000002) /*!< Address/data multiplexing enable bit */ + +#define FSMC_BCR3_MTYP ((uint32_t)0x0000000C) /*!< MTYP[1:0] bits (Memory type) */ +#define FSMC_BCR3_MTYP_0 ((uint32_t)0x00000004) /*!< Bit 0 */ +#define FSMC_BCR3_MTYP_1 ((uint32_t)0x00000008) /*!< Bit 1 */ + +#define FSMC_BCR3_MWID ((uint32_t)0x00000030) /*!< MWID[1:0] bits (Memory data bus width) */ +#define FSMC_BCR3_MWID_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define FSMC_BCR3_MWID_1 ((uint32_t)0x00000020) /*!< Bit 1 */ + +#define FSMC_BCR3_FACCEN ((uint32_t)0x00000040) /*!< Flash access enable */ +#define FSMC_BCR3_BURSTEN ((uint32_t)0x00000100) /*!< Burst enable bit */ +#define FSMC_BCR3_WAITPOL ((uint32_t)0x00000200) /*!< Wait signal polarity bit. */ +#define FSMC_BCR3_WRAPMOD ((uint32_t)0x00000400) /*!< Wrapped burst mode support */ +#define FSMC_BCR3_WAITCFG ((uint32_t)0x00000800) /*!< Wait timing configuration */ +#define FSMC_BCR3_WREN ((uint32_t)0x00001000) /*!< Write enable bit */ +#define FSMC_BCR3_WAITEN ((uint32_t)0x00002000) /*!< Wait enable bit */ +#define FSMC_BCR3_EXTMOD ((uint32_t)0x00004000) /*!< Extended mode enable */ +#define FSMC_BCR3_ASYNCWAIT ((uint32_t)0x00008000) /*!< Asynchronous wait */ +#define FSMC_BCR3_CBURSTRW ((uint32_t)0x00080000) /*!< Write burst enable */ + +/****************** Bit definition for FSMC_BCR4 register *******************/ +#define FSMC_BCR4_MBKEN ((uint32_t)0x00000001) /*!< Memory bank enable bit */ +#define FSMC_BCR4_MUXEN ((uint32_t)0x00000002) /*!< Address/data multiplexing enable bit */ + +#define FSMC_BCR4_MTYP ((uint32_t)0x0000000C) /*!< MTYP[1:0] bits (Memory type) */ +#define FSMC_BCR4_MTYP_0 ((uint32_t)0x00000004) /*!< Bit 0 */ +#define FSMC_BCR4_MTYP_1 ((uint32_t)0x00000008) /*!< Bit 1 */ + +#define FSMC_BCR4_MWID ((uint32_t)0x00000030) /*!< MWID[1:0] bits (Memory data bus width) */ +#define FSMC_BCR4_MWID_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define FSMC_BCR4_MWID_1 ((uint32_t)0x00000020) /*!< Bit 1 */ + +#define FSMC_BCR4_FACCEN ((uint32_t)0x00000040) /*!< Flash access enable */ +#define FSMC_BCR4_BURSTEN ((uint32_t)0x00000100) /*!< Burst enable bit */ +#define FSMC_BCR4_WAITPOL ((uint32_t)0x00000200) /*!< Wait signal polarity bit */ +#define FSMC_BCR4_WRAPMOD ((uint32_t)0x00000400) /*!< Wrapped burst mode support */ +#define FSMC_BCR4_WAITCFG ((uint32_t)0x00000800) /*!< Wait timing configuration */ +#define FSMC_BCR4_WREN ((uint32_t)0x00001000) /*!< Write enable bit */ +#define FSMC_BCR4_WAITEN ((uint32_t)0x00002000) /*!< Wait enable bit */ +#define FSMC_BCR4_EXTMOD ((uint32_t)0x00004000) /*!< Extended mode enable */ +#define FSMC_BCR4_ASYNCWAIT ((uint32_t)0x00008000) /*!< Asynchronous wait */ +#define FSMC_BCR4_CBURSTRW ((uint32_t)0x00080000) /*!< Write burst enable */ + +/****************** Bit definition for FSMC_BTR1 register ******************/ +#define FSMC_BTR1_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */ +#define FSMC_BTR1_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define FSMC_BTR1_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define FSMC_BTR1_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define FSMC_BTR1_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */ + +#define FSMC_BTR1_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */ +#define FSMC_BTR1_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define FSMC_BTR1_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */ +#define FSMC_BTR1_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */ +#define FSMC_BTR1_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */ + +#define FSMC_BTR1_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */ +#define FSMC_BTR1_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define FSMC_BTR1_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define FSMC_BTR1_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define FSMC_BTR1_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */ + +#define FSMC_BTR1_BUSTURN ((uint32_t)0x000F0000) /*!< BUSTURN[3:0] bits (Bus turnaround phase duration) */ +#define FSMC_BTR1_BUSTURN_0 ((uint32_t)0x00010000) /*!< Bit 0 */ +#define FSMC_BTR1_BUSTURN_1 ((uint32_t)0x00020000) /*!< Bit 1 */ +#define FSMC_BTR1_BUSTURN_2 ((uint32_t)0x00040000) /*!< Bit 2 */ +#define FSMC_BTR1_BUSTURN_3 ((uint32_t)0x00080000) /*!< Bit 3 */ + +#define FSMC_BTR1_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */ +#define FSMC_BTR1_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */ +#define FSMC_BTR1_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1 */ +#define FSMC_BTR1_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */ +#define FSMC_BTR1_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */ + +#define FSMC_BTR1_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */ +#define FSMC_BTR1_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define FSMC_BTR1_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define FSMC_BTR1_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define FSMC_BTR1_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */ + +#define FSMC_BTR1_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */ +#define FSMC_BTR1_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */ +#define FSMC_BTR1_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */ + +/****************** Bit definition for FSMC_BTR2 register *******************/ +#define FSMC_BTR2_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */ +#define FSMC_BTR2_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define FSMC_BTR2_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define FSMC_BTR2_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define FSMC_BTR2_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */ + +#define FSMC_BTR2_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */ +#define FSMC_BTR2_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define FSMC_BTR2_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */ +#define FSMC_BTR2_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */ +#define FSMC_BTR2_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */ + +#define FSMC_BTR2_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */ +#define FSMC_BTR2_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define FSMC_BTR2_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define FSMC_BTR2_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define FSMC_BTR2_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */ + +#define FSMC_BTR2_BUSTURN ((uint32_t)0x000F0000) /*!< BUSTURN[3:0] bits (Bus turnaround phase duration) */ +#define FSMC_BTR2_BUSTURN_0 ((uint32_t)0x00010000) /*!< Bit 0 */ +#define FSMC_BTR2_BUSTURN_1 ((uint32_t)0x00020000) /*!< Bit 1 */ +#define FSMC_BTR2_BUSTURN_2 ((uint32_t)0x00040000) /*!< Bit 2 */ +#define FSMC_BTR2_BUSTURN_3 ((uint32_t)0x00080000) /*!< Bit 3 */ + +#define FSMC_BTR2_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */ +#define FSMC_BTR2_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */ +#define FSMC_BTR2_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1 */ +#define FSMC_BTR2_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */ +#define FSMC_BTR2_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */ + +#define FSMC_BTR2_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */ +#define FSMC_BTR2_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define FSMC_BTR2_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define FSMC_BTR2_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define FSMC_BTR2_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */ + +#define FSMC_BTR2_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */ +#define FSMC_BTR2_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */ +#define FSMC_BTR2_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */ + +/******************* Bit definition for FSMC_BTR3 register *******************/ +#define FSMC_BTR3_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */ +#define FSMC_BTR3_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define FSMC_BTR3_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define FSMC_BTR3_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define FSMC_BTR3_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */ + +#define FSMC_BTR3_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */ +#define FSMC_BTR3_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define FSMC_BTR3_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */ +#define FSMC_BTR3_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */ +#define FSMC_BTR3_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */ + +#define FSMC_BTR3_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */ +#define FSMC_BTR3_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define FSMC_BTR3_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define FSMC_BTR3_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define FSMC_BTR3_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */ + +#define FSMC_BTR3_BUSTURN ((uint32_t)0x000F0000) /*!< BUSTURN[3:0] bits (Bus turnaround phase duration) */ +#define FSMC_BTR3_BUSTURN_0 ((uint32_t)0x00010000) /*!< Bit 0 */ +#define FSMC_BTR3_BUSTURN_1 ((uint32_t)0x00020000) /*!< Bit 1 */ +#define FSMC_BTR3_BUSTURN_2 ((uint32_t)0x00040000) /*!< Bit 2 */ +#define FSMC_BTR3_BUSTURN_3 ((uint32_t)0x00080000) /*!< Bit 3 */ + +#define FSMC_BTR3_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */ +#define FSMC_BTR3_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */ +#define FSMC_BTR3_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1 */ +#define FSMC_BTR3_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */ +#define FSMC_BTR3_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */ + +#define FSMC_BTR3_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */ +#define FSMC_BTR3_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define FSMC_BTR3_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define FSMC_BTR3_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define FSMC_BTR3_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */ + +#define FSMC_BTR3_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */ +#define FSMC_BTR3_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */ +#define FSMC_BTR3_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */ + +/****************** Bit definition for FSMC_BTR4 register *******************/ +#define FSMC_BTR4_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */ +#define FSMC_BTR4_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define FSMC_BTR4_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define FSMC_BTR4_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define FSMC_BTR4_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */ + +#define FSMC_BTR4_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */ +#define FSMC_BTR4_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define FSMC_BTR4_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */ +#define FSMC_BTR4_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */ +#define FSMC_BTR4_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */ + +#define FSMC_BTR4_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */ +#define FSMC_BTR4_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define FSMC_BTR4_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define FSMC_BTR4_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define FSMC_BTR4_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */ + +#define FSMC_BTR4_BUSTURN ((uint32_t)0x000F0000) /*!< BUSTURN[3:0] bits (Bus turnaround phase duration) */ +#define FSMC_BTR4_BUSTURN_0 ((uint32_t)0x00010000) /*!< Bit 0 */ +#define FSMC_BTR4_BUSTURN_1 ((uint32_t)0x00020000) /*!< Bit 1 */ +#define FSMC_BTR4_BUSTURN_2 ((uint32_t)0x00040000) /*!< Bit 2 */ +#define FSMC_BTR4_BUSTURN_3 ((uint32_t)0x00080000) /*!< Bit 3 */ + +#define FSMC_BTR4_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */ +#define FSMC_BTR4_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */ +#define FSMC_BTR4_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1 */ +#define FSMC_BTR4_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */ +#define FSMC_BTR4_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */ + +#define FSMC_BTR4_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */ +#define FSMC_BTR4_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define FSMC_BTR4_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define FSMC_BTR4_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define FSMC_BTR4_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */ + +#define FSMC_BTR4_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */ +#define FSMC_BTR4_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */ +#define FSMC_BTR4_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */ + +/****************** Bit definition for FSMC_BWTR1 register ******************/ +#define FSMC_BWTR1_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */ +#define FSMC_BWTR1_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define FSMC_BWTR1_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define FSMC_BWTR1_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define FSMC_BWTR1_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */ + +#define FSMC_BWTR1_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */ +#define FSMC_BWTR1_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define FSMC_BWTR1_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */ +#define FSMC_BWTR1_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */ +#define FSMC_BWTR1_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */ + +#define FSMC_BWTR1_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */ +#define FSMC_BWTR1_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define FSMC_BWTR1_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define FSMC_BWTR1_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define FSMC_BWTR1_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */ + +#define FSMC_BWTR1_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */ +#define FSMC_BWTR1_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */ +#define FSMC_BWTR1_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1 */ +#define FSMC_BWTR1_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */ +#define FSMC_BWTR1_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */ + +#define FSMC_BWTR1_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */ +#define FSMC_BWTR1_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define FSMC_BWTR1_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define FSMC_BWTR1_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define FSMC_BWTR1_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */ + +#define FSMC_BWTR1_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */ +#define FSMC_BWTR1_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */ +#define FSMC_BWTR1_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */ + +/****************** Bit definition for FSMC_BWTR2 register ******************/ +#define FSMC_BWTR2_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */ +#define FSMC_BWTR2_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define FSMC_BWTR2_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define FSMC_BWTR2_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define FSMC_BWTR2_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */ + +#define FSMC_BWTR2_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */ +#define FSMC_BWTR2_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define FSMC_BWTR2_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */ +#define FSMC_BWTR2_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */ +#define FSMC_BWTR2_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */ + +#define FSMC_BWTR2_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */ +#define FSMC_BWTR2_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define FSMC_BWTR2_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define FSMC_BWTR2_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define FSMC_BWTR2_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */ + +#define FSMC_BWTR2_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */ +#define FSMC_BWTR2_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */ +#define FSMC_BWTR2_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1*/ +#define FSMC_BWTR2_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */ +#define FSMC_BWTR2_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */ + +#define FSMC_BWTR2_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */ +#define FSMC_BWTR2_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define FSMC_BWTR2_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define FSMC_BWTR2_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define FSMC_BWTR2_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */ + +#define FSMC_BWTR2_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */ +#define FSMC_BWTR2_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */ +#define FSMC_BWTR2_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */ + +/****************** Bit definition for FSMC_BWTR3 register ******************/ +#define FSMC_BWTR3_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */ +#define FSMC_BWTR3_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define FSMC_BWTR3_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define FSMC_BWTR3_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define FSMC_BWTR3_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */ + +#define FSMC_BWTR3_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */ +#define FSMC_BWTR3_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define FSMC_BWTR3_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */ +#define FSMC_BWTR3_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */ +#define FSMC_BWTR3_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */ + +#define FSMC_BWTR3_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */ +#define FSMC_BWTR3_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define FSMC_BWTR3_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define FSMC_BWTR3_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define FSMC_BWTR3_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */ + +#define FSMC_BWTR3_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */ +#define FSMC_BWTR3_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */ +#define FSMC_BWTR3_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1 */ +#define FSMC_BWTR3_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */ +#define FSMC_BWTR3_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */ + +#define FSMC_BWTR3_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */ +#define FSMC_BWTR3_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define FSMC_BWTR3_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define FSMC_BWTR3_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define FSMC_BWTR3_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */ + +#define FSMC_BWTR3_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */ +#define FSMC_BWTR3_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */ +#define FSMC_BWTR3_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */ + +/****************** Bit definition for FSMC_BWTR4 register ******************/ +#define FSMC_BWTR4_ADDSET ((uint32_t)0x0000000F) /*!< ADDSET[3:0] bits (Address setup phase duration) */ +#define FSMC_BWTR4_ADDSET_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define FSMC_BWTR4_ADDSET_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define FSMC_BWTR4_ADDSET_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define FSMC_BWTR4_ADDSET_3 ((uint32_t)0x00000008) /*!< Bit 3 */ + +#define FSMC_BWTR4_ADDHLD ((uint32_t)0x000000F0) /*!< ADDHLD[3:0] bits (Address-hold phase duration) */ +#define FSMC_BWTR4_ADDHLD_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define FSMC_BWTR4_ADDHLD_1 ((uint32_t)0x00000020) /*!< Bit 1 */ +#define FSMC_BWTR4_ADDHLD_2 ((uint32_t)0x00000040) /*!< Bit 2 */ +#define FSMC_BWTR4_ADDHLD_3 ((uint32_t)0x00000080) /*!< Bit 3 */ + +#define FSMC_BWTR4_DATAST ((uint32_t)0x0000FF00) /*!< DATAST [3:0] bits (Data-phase duration) */ +#define FSMC_BWTR4_DATAST_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define FSMC_BWTR4_DATAST_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define FSMC_BWTR4_DATAST_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define FSMC_BWTR4_DATAST_3 ((uint32_t)0x00000800) /*!< Bit 3 */ + +#define FSMC_BWTR4_CLKDIV ((uint32_t)0x00F00000) /*!< CLKDIV[3:0] bits (Clock divide ratio) */ +#define FSMC_BWTR4_CLKDIV_0 ((uint32_t)0x00100000) /*!< Bit 0 */ +#define FSMC_BWTR4_CLKDIV_1 ((uint32_t)0x00200000) /*!< Bit 1 */ +#define FSMC_BWTR4_CLKDIV_2 ((uint32_t)0x00400000) /*!< Bit 2 */ +#define FSMC_BWTR4_CLKDIV_3 ((uint32_t)0x00800000) /*!< Bit 3 */ + +#define FSMC_BWTR4_DATLAT ((uint32_t)0x0F000000) /*!< DATLA[3:0] bits (Data latency) */ +#define FSMC_BWTR4_DATLAT_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define FSMC_BWTR4_DATLAT_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define FSMC_BWTR4_DATLAT_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define FSMC_BWTR4_DATLAT_3 ((uint32_t)0x08000000) /*!< Bit 3 */ + +#define FSMC_BWTR4_ACCMOD ((uint32_t)0x30000000) /*!< ACCMOD[1:0] bits (Access mode) */ +#define FSMC_BWTR4_ACCMOD_0 ((uint32_t)0x10000000) /*!< Bit 0 */ +#define FSMC_BWTR4_ACCMOD_1 ((uint32_t)0x20000000) /*!< Bit 1 */ + +/****************** Bit definition for FSMC_PCR2 register *******************/ +#define FSMC_PCR2_PWAITEN ((uint32_t)0x00000002) /*!< Wait feature enable bit */ +#define FSMC_PCR2_PBKEN ((uint32_t)0x00000004) /*!< PC Card/NAND Flash memory bank enable bit */ +#define FSMC_PCR2_PTYP ((uint32_t)0x00000008) /*!< Memory type */ + +#define FSMC_PCR2_PWID ((uint32_t)0x00000030) /*!< PWID[1:0] bits (NAND Flash databus width) */ +#define FSMC_PCR2_PWID_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define FSMC_PCR2_PWID_1 ((uint32_t)0x00000020) /*!< Bit 1 */ + +#define FSMC_PCR2_ECCEN ((uint32_t)0x00000040) /*!< ECC computation logic enable bit */ + +#define FSMC_PCR2_TCLR ((uint32_t)0x00001E00) /*!< TCLR[3:0] bits (CLE to RE delay) */ +#define FSMC_PCR2_TCLR_0 ((uint32_t)0x00000200) /*!< Bit 0 */ +#define FSMC_PCR2_TCLR_1 ((uint32_t)0x00000400) /*!< Bit 1 */ +#define FSMC_PCR2_TCLR_2 ((uint32_t)0x00000800) /*!< Bit 2 */ +#define FSMC_PCR2_TCLR_3 ((uint32_t)0x00001000) /*!< Bit 3 */ + +#define FSMC_PCR2_TAR ((uint32_t)0x0001E000) /*!< TAR[3:0] bits (ALE to RE delay) */ +#define FSMC_PCR2_TAR_0 ((uint32_t)0x00002000) /*!< Bit 0 */ +#define FSMC_PCR2_TAR_1 ((uint32_t)0x00004000) /*!< Bit 1 */ +#define FSMC_PCR2_TAR_2 ((uint32_t)0x00008000) /*!< Bit 2 */ +#define FSMC_PCR2_TAR_3 ((uint32_t)0x00010000) /*!< Bit 3 */ + +#define FSMC_PCR2_ECCPS ((uint32_t)0x000E0000) /*!< ECCPS[1:0] bits (ECC page size) */ +#define FSMC_PCR2_ECCPS_0 ((uint32_t)0x00020000) /*!< Bit 0 */ +#define FSMC_PCR2_ECCPS_1 ((uint32_t)0x00040000) /*!< Bit 1 */ +#define FSMC_PCR2_ECCPS_2 ((uint32_t)0x00080000) /*!< Bit 2 */ + +/****************** Bit definition for FSMC_PCR3 register *******************/ +#define FSMC_PCR3_PWAITEN ((uint32_t)0x00000002) /*!< Wait feature enable bit */ +#define FSMC_PCR3_PBKEN ((uint32_t)0x00000004) /*!< PC Card/NAND Flash memory bank enable bit */ +#define FSMC_PCR3_PTYP ((uint32_t)0x00000008) /*!< Memory type */ + +#define FSMC_PCR3_PWID ((uint32_t)0x00000030) /*!< PWID[1:0] bits (NAND Flash databus width) */ +#define FSMC_PCR3_PWID_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define FSMC_PCR3_PWID_1 ((uint32_t)0x00000020) /*!< Bit 1 */ + +#define FSMC_PCR3_ECCEN ((uint32_t)0x00000040) /*!< ECC computation logic enable bit */ + +#define FSMC_PCR3_TCLR ((uint32_t)0x00001E00) /*!< TCLR[3:0] bits (CLE to RE delay) */ +#define FSMC_PCR3_TCLR_0 ((uint32_t)0x00000200) /*!< Bit 0 */ +#define FSMC_PCR3_TCLR_1 ((uint32_t)0x00000400) /*!< Bit 1 */ +#define FSMC_PCR3_TCLR_2 ((uint32_t)0x00000800) /*!< Bit 2 */ +#define FSMC_PCR3_TCLR_3 ((uint32_t)0x00001000) /*!< Bit 3 */ + +#define FSMC_PCR3_TAR ((uint32_t)0x0001E000) /*!< TAR[3:0] bits (ALE to RE delay) */ +#define FSMC_PCR3_TAR_0 ((uint32_t)0x00002000) /*!< Bit 0 */ +#define FSMC_PCR3_TAR_1 ((uint32_t)0x00004000) /*!< Bit 1 */ +#define FSMC_PCR3_TAR_2 ((uint32_t)0x00008000) /*!< Bit 2 */ +#define FSMC_PCR3_TAR_3 ((uint32_t)0x00010000) /*!< Bit 3 */ + +#define FSMC_PCR3_ECCPS ((uint32_t)0x000E0000) /*!< ECCPS[2:0] bits (ECC page size) */ +#define FSMC_PCR3_ECCPS_0 ((uint32_t)0x00020000) /*!< Bit 0 */ +#define FSMC_PCR3_ECCPS_1 ((uint32_t)0x00040000) /*!< Bit 1 */ +#define FSMC_PCR3_ECCPS_2 ((uint32_t)0x00080000) /*!< Bit 2 */ + +/****************** Bit definition for FSMC_PCR4 register *******************/ +#define FSMC_PCR4_PWAITEN ((uint32_t)0x00000002) /*!< Wait feature enable bit */ +#define FSMC_PCR4_PBKEN ((uint32_t)0x00000004) /*!< PC Card/NAND Flash memory bank enable bit */ +#define FSMC_PCR4_PTYP ((uint32_t)0x00000008) /*!< Memory type */ + +#define FSMC_PCR4_PWID ((uint32_t)0x00000030) /*!< PWID[1:0] bits (NAND Flash databus width) */ +#define FSMC_PCR4_PWID_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define FSMC_PCR4_PWID_1 ((uint32_t)0x00000020) /*!< Bit 1 */ + +#define FSMC_PCR4_ECCEN ((uint32_t)0x00000040) /*!< ECC computation logic enable bit */ + +#define FSMC_PCR4_TCLR ((uint32_t)0x00001E00) /*!< TCLR[3:0] bits (CLE to RE delay) */ +#define FSMC_PCR4_TCLR_0 ((uint32_t)0x00000200) /*!< Bit 0 */ +#define FSMC_PCR4_TCLR_1 ((uint32_t)0x00000400) /*!< Bit 1 */ +#define FSMC_PCR4_TCLR_2 ((uint32_t)0x00000800) /*!< Bit 2 */ +#define FSMC_PCR4_TCLR_3 ((uint32_t)0x00001000) /*!< Bit 3 */ + +#define FSMC_PCR4_TAR ((uint32_t)0x0001E000) /*!< TAR[3:0] bits (ALE to RE delay) */ +#define FSMC_PCR4_TAR_0 ((uint32_t)0x00002000) /*!< Bit 0 */ +#define FSMC_PCR4_TAR_1 ((uint32_t)0x00004000) /*!< Bit 1 */ +#define FSMC_PCR4_TAR_2 ((uint32_t)0x00008000) /*!< Bit 2 */ +#define FSMC_PCR4_TAR_3 ((uint32_t)0x00010000) /*!< Bit 3 */ + +#define FSMC_PCR4_ECCPS ((uint32_t)0x000E0000) /*!< ECCPS[2:0] bits (ECC page size) */ +#define FSMC_PCR4_ECCPS_0 ((uint32_t)0x00020000) /*!< Bit 0 */ +#define FSMC_PCR4_ECCPS_1 ((uint32_t)0x00040000) /*!< Bit 1 */ +#define FSMC_PCR4_ECCPS_2 ((uint32_t)0x00080000) /*!< Bit 2 */ + +/******************* Bit definition for FSMC_SR2 register *******************/ +#define FSMC_SR2_IRS ((uint8_t)0x01) /*!< Interrupt Rising Edge status */ +#define FSMC_SR2_ILS ((uint8_t)0x02) /*!< Interrupt Level status */ +#define FSMC_SR2_IFS ((uint8_t)0x04) /*!< Interrupt Falling Edge status */ +#define FSMC_SR2_IREN ((uint8_t)0x08) /*!< Interrupt Rising Edge detection Enable bit */ +#define FSMC_SR2_ILEN ((uint8_t)0x10) /*!< Interrupt Level detection Enable bit */ +#define FSMC_SR2_IFEN ((uint8_t)0x20) /*!< Interrupt Falling Edge detection Enable bit */ +#define FSMC_SR2_FEMPT ((uint8_t)0x40) /*!< FIFO empty */ + +/******************* Bit definition for FSMC_SR3 register *******************/ +#define FSMC_SR3_IRS ((uint8_t)0x01) /*!< Interrupt Rising Edge status */ +#define FSMC_SR3_ILS ((uint8_t)0x02) /*!< Interrupt Level status */ +#define FSMC_SR3_IFS ((uint8_t)0x04) /*!< Interrupt Falling Edge status */ +#define FSMC_SR3_IREN ((uint8_t)0x08) /*!< Interrupt Rising Edge detection Enable bit */ +#define FSMC_SR3_ILEN ((uint8_t)0x10) /*!< Interrupt Level detection Enable bit */ +#define FSMC_SR3_IFEN ((uint8_t)0x20) /*!< Interrupt Falling Edge detection Enable bit */ +#define FSMC_SR3_FEMPT ((uint8_t)0x40) /*!< FIFO empty */ + +/******************* Bit definition for FSMC_SR4 register *******************/ +#define FSMC_SR4_IRS ((uint8_t)0x01) /*!< Interrupt Rising Edge status */ +#define FSMC_SR4_ILS ((uint8_t)0x02) /*!< Interrupt Level status */ +#define FSMC_SR4_IFS ((uint8_t)0x04) /*!< Interrupt Falling Edge status */ +#define FSMC_SR4_IREN ((uint8_t)0x08) /*!< Interrupt Rising Edge detection Enable bit */ +#define FSMC_SR4_ILEN ((uint8_t)0x10) /*!< Interrupt Level detection Enable bit */ +#define FSMC_SR4_IFEN ((uint8_t)0x20) /*!< Interrupt Falling Edge detection Enable bit */ +#define FSMC_SR4_FEMPT ((uint8_t)0x40) /*!< FIFO empty */ + +/****************** Bit definition for FSMC_PMEM2 register ******************/ +#define FSMC_PMEM2_MEMSET2 ((uint32_t)0x000000FF) /*!< MEMSET2[7:0] bits (Common memory 2 setup time) */ +#define FSMC_PMEM2_MEMSET2_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define FSMC_PMEM2_MEMSET2_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define FSMC_PMEM2_MEMSET2_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define FSMC_PMEM2_MEMSET2_3 ((uint32_t)0x00000008) /*!< Bit 3 */ +#define FSMC_PMEM2_MEMSET2_4 ((uint32_t)0x00000010) /*!< Bit 4 */ +#define FSMC_PMEM2_MEMSET2_5 ((uint32_t)0x00000020) /*!< Bit 5 */ +#define FSMC_PMEM2_MEMSET2_6 ((uint32_t)0x00000040) /*!< Bit 6 */ +#define FSMC_PMEM2_MEMSET2_7 ((uint32_t)0x00000080) /*!< Bit 7 */ + +#define FSMC_PMEM2_MEMWAIT2 ((uint32_t)0x0000FF00) /*!< MEMWAIT2[7:0] bits (Common memory 2 wait time) */ +#define FSMC_PMEM2_MEMWAIT2_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define FSMC_PMEM2_MEMWAIT2_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define FSMC_PMEM2_MEMWAIT2_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define FSMC_PMEM2_MEMWAIT2_3 ((uint32_t)0x00000800) /*!< Bit 3 */ +#define FSMC_PMEM2_MEMWAIT2_4 ((uint32_t)0x00001000) /*!< Bit 4 */ +#define FSMC_PMEM2_MEMWAIT2_5 ((uint32_t)0x00002000) /*!< Bit 5 */ +#define FSMC_PMEM2_MEMWAIT2_6 ((uint32_t)0x00004000) /*!< Bit 6 */ +#define FSMC_PMEM2_MEMWAIT2_7 ((uint32_t)0x00008000) /*!< Bit 7 */ + +#define FSMC_PMEM2_MEMHOLD2 ((uint32_t)0x00FF0000) /*!< MEMHOLD2[7:0] bits (Common memory 2 hold time) */ +#define FSMC_PMEM2_MEMHOLD2_0 ((uint32_t)0x00010000) /*!< Bit 0 */ +#define FSMC_PMEM2_MEMHOLD2_1 ((uint32_t)0x00020000) /*!< Bit 1 */ +#define FSMC_PMEM2_MEMHOLD2_2 ((uint32_t)0x00040000) /*!< Bit 2 */ +#define FSMC_PMEM2_MEMHOLD2_3 ((uint32_t)0x00080000) /*!< Bit 3 */ +#define FSMC_PMEM2_MEMHOLD2_4 ((uint32_t)0x00100000) /*!< Bit 4 */ +#define FSMC_PMEM2_MEMHOLD2_5 ((uint32_t)0x00200000) /*!< Bit 5 */ +#define FSMC_PMEM2_MEMHOLD2_6 ((uint32_t)0x00400000) /*!< Bit 6 */ +#define FSMC_PMEM2_MEMHOLD2_7 ((uint32_t)0x00800000) /*!< Bit 7 */ + +#define FSMC_PMEM2_MEMHIZ2 ((uint32_t)0xFF000000) /*!< MEMHIZ2[7:0] bits (Common memory 2 databus HiZ time) */ +#define FSMC_PMEM2_MEMHIZ2_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define FSMC_PMEM2_MEMHIZ2_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define FSMC_PMEM2_MEMHIZ2_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define FSMC_PMEM2_MEMHIZ2_3 ((uint32_t)0x08000000) /*!< Bit 3 */ +#define FSMC_PMEM2_MEMHIZ2_4 ((uint32_t)0x10000000) /*!< Bit 4 */ +#define FSMC_PMEM2_MEMHIZ2_5 ((uint32_t)0x20000000) /*!< Bit 5 */ +#define FSMC_PMEM2_MEMHIZ2_6 ((uint32_t)0x40000000) /*!< Bit 6 */ +#define FSMC_PMEM2_MEMHIZ2_7 ((uint32_t)0x80000000) /*!< Bit 7 */ + +/****************** Bit definition for FSMC_PMEM3 register ******************/ +#define FSMC_PMEM3_MEMSET3 ((uint32_t)0x000000FF) /*!< MEMSET3[7:0] bits (Common memory 3 setup time) */ +#define FSMC_PMEM3_MEMSET3_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define FSMC_PMEM3_MEMSET3_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define FSMC_PMEM3_MEMSET3_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define FSMC_PMEM3_MEMSET3_3 ((uint32_t)0x00000008) /*!< Bit 3 */ +#define FSMC_PMEM3_MEMSET3_4 ((uint32_t)0x00000010) /*!< Bit 4 */ +#define FSMC_PMEM3_MEMSET3_5 ((uint32_t)0x00000020) /*!< Bit 5 */ +#define FSMC_PMEM3_MEMSET3_6 ((uint32_t)0x00000040) /*!< Bit 6 */ +#define FSMC_PMEM3_MEMSET3_7 ((uint32_t)0x00000080) /*!< Bit 7 */ + +#define FSMC_PMEM3_MEMWAIT3 ((uint32_t)0x0000FF00) /*!< MEMWAIT3[7:0] bits (Common memory 3 wait time) */ +#define FSMC_PMEM3_MEMWAIT3_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define FSMC_PMEM3_MEMWAIT3_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define FSMC_PMEM3_MEMWAIT3_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define FSMC_PMEM3_MEMWAIT3_3 ((uint32_t)0x00000800) /*!< Bit 3 */ +#define FSMC_PMEM3_MEMWAIT3_4 ((uint32_t)0x00001000) /*!< Bit 4 */ +#define FSMC_PMEM3_MEMWAIT3_5 ((uint32_t)0x00002000) /*!< Bit 5 */ +#define FSMC_PMEM3_MEMWAIT3_6 ((uint32_t)0x00004000) /*!< Bit 6 */ +#define FSMC_PMEM3_MEMWAIT3_7 ((uint32_t)0x00008000) /*!< Bit 7 */ + +#define FSMC_PMEM3_MEMHOLD3 ((uint32_t)0x00FF0000) /*!< MEMHOLD3[7:0] bits (Common memory 3 hold time) */ +#define FSMC_PMEM3_MEMHOLD3_0 ((uint32_t)0x00010000) /*!< Bit 0 */ +#define FSMC_PMEM3_MEMHOLD3_1 ((uint32_t)0x00020000) /*!< Bit 1 */ +#define FSMC_PMEM3_MEMHOLD3_2 ((uint32_t)0x00040000) /*!< Bit 2 */ +#define FSMC_PMEM3_MEMHOLD3_3 ((uint32_t)0x00080000) /*!< Bit 3 */ +#define FSMC_PMEM3_MEMHOLD3_4 ((uint32_t)0x00100000) /*!< Bit 4 */ +#define FSMC_PMEM3_MEMHOLD3_5 ((uint32_t)0x00200000) /*!< Bit 5 */ +#define FSMC_PMEM3_MEMHOLD3_6 ((uint32_t)0x00400000) /*!< Bit 6 */ +#define FSMC_PMEM3_MEMHOLD3_7 ((uint32_t)0x00800000) /*!< Bit 7 */ + +#define FSMC_PMEM3_MEMHIZ3 ((uint32_t)0xFF000000) /*!< MEMHIZ3[7:0] bits (Common memory 3 databus HiZ time) */ +#define FSMC_PMEM3_MEMHIZ3_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define FSMC_PMEM3_MEMHIZ3_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define FSMC_PMEM3_MEMHIZ3_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define FSMC_PMEM3_MEMHIZ3_3 ((uint32_t)0x08000000) /*!< Bit 3 */ +#define FSMC_PMEM3_MEMHIZ3_4 ((uint32_t)0x10000000) /*!< Bit 4 */ +#define FSMC_PMEM3_MEMHIZ3_5 ((uint32_t)0x20000000) /*!< Bit 5 */ +#define FSMC_PMEM3_MEMHIZ3_6 ((uint32_t)0x40000000) /*!< Bit 6 */ +#define FSMC_PMEM3_MEMHIZ3_7 ((uint32_t)0x80000000) /*!< Bit 7 */ + +/****************** Bit definition for FSMC_PMEM4 register ******************/ +#define FSMC_PMEM4_MEMSET4 ((uint32_t)0x000000FF) /*!< MEMSET4[7:0] bits (Common memory 4 setup time) */ +#define FSMC_PMEM4_MEMSET4_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define FSMC_PMEM4_MEMSET4_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define FSMC_PMEM4_MEMSET4_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define FSMC_PMEM4_MEMSET4_3 ((uint32_t)0x00000008) /*!< Bit 3 */ +#define FSMC_PMEM4_MEMSET4_4 ((uint32_t)0x00000010) /*!< Bit 4 */ +#define FSMC_PMEM4_MEMSET4_5 ((uint32_t)0x00000020) /*!< Bit 5 */ +#define FSMC_PMEM4_MEMSET4_6 ((uint32_t)0x00000040) /*!< Bit 6 */ +#define FSMC_PMEM4_MEMSET4_7 ((uint32_t)0x00000080) /*!< Bit 7 */ + +#define FSMC_PMEM4_MEMWAIT4 ((uint32_t)0x0000FF00) /*!< MEMWAIT4[7:0] bits (Common memory 4 wait time) */ +#define FSMC_PMEM4_MEMWAIT4_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define FSMC_PMEM4_MEMWAIT4_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define FSMC_PMEM4_MEMWAIT4_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define FSMC_PMEM4_MEMWAIT4_3 ((uint32_t)0x00000800) /*!< Bit 3 */ +#define FSMC_PMEM4_MEMWAIT4_4 ((uint32_t)0x00001000) /*!< Bit 4 */ +#define FSMC_PMEM4_MEMWAIT4_5 ((uint32_t)0x00002000) /*!< Bit 5 */ +#define FSMC_PMEM4_MEMWAIT4_6 ((uint32_t)0x00004000) /*!< Bit 6 */ +#define FSMC_PMEM4_MEMWAIT4_7 ((uint32_t)0x00008000) /*!< Bit 7 */ + +#define FSMC_PMEM4_MEMHOLD4 ((uint32_t)0x00FF0000) /*!< MEMHOLD4[7:0] bits (Common memory 4 hold time) */ +#define FSMC_PMEM4_MEMHOLD4_0 ((uint32_t)0x00010000) /*!< Bit 0 */ +#define FSMC_PMEM4_MEMHOLD4_1 ((uint32_t)0x00020000) /*!< Bit 1 */ +#define FSMC_PMEM4_MEMHOLD4_2 ((uint32_t)0x00040000) /*!< Bit 2 */ +#define FSMC_PMEM4_MEMHOLD4_3 ((uint32_t)0x00080000) /*!< Bit 3 */ +#define FSMC_PMEM4_MEMHOLD4_4 ((uint32_t)0x00100000) /*!< Bit 4 */ +#define FSMC_PMEM4_MEMHOLD4_5 ((uint32_t)0x00200000) /*!< Bit 5 */ +#define FSMC_PMEM4_MEMHOLD4_6 ((uint32_t)0x00400000) /*!< Bit 6 */ +#define FSMC_PMEM4_MEMHOLD4_7 ((uint32_t)0x00800000) /*!< Bit 7 */ + +#define FSMC_PMEM4_MEMHIZ4 ((uint32_t)0xFF000000) /*!< MEMHIZ4[7:0] bits (Common memory 4 databus HiZ time) */ +#define FSMC_PMEM4_MEMHIZ4_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define FSMC_PMEM4_MEMHIZ4_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define FSMC_PMEM4_MEMHIZ4_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define FSMC_PMEM4_MEMHIZ4_3 ((uint32_t)0x08000000) /*!< Bit 3 */ +#define FSMC_PMEM4_MEMHIZ4_4 ((uint32_t)0x10000000) /*!< Bit 4 */ +#define FSMC_PMEM4_MEMHIZ4_5 ((uint32_t)0x20000000) /*!< Bit 5 */ +#define FSMC_PMEM4_MEMHIZ4_6 ((uint32_t)0x40000000) /*!< Bit 6 */ +#define FSMC_PMEM4_MEMHIZ4_7 ((uint32_t)0x80000000) /*!< Bit 7 */ + +/****************** Bit definition for FSMC_PATT2 register ******************/ +#define FSMC_PATT2_ATTSET2 ((uint32_t)0x000000FF) /*!< ATTSET2[7:0] bits (Attribute memory 2 setup time) */ +#define FSMC_PATT2_ATTSET2_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define FSMC_PATT2_ATTSET2_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define FSMC_PATT2_ATTSET2_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define FSMC_PATT2_ATTSET2_3 ((uint32_t)0x00000008) /*!< Bit 3 */ +#define FSMC_PATT2_ATTSET2_4 ((uint32_t)0x00000010) /*!< Bit 4 */ +#define FSMC_PATT2_ATTSET2_5 ((uint32_t)0x00000020) /*!< Bit 5 */ +#define FSMC_PATT2_ATTSET2_6 ((uint32_t)0x00000040) /*!< Bit 6 */ +#define FSMC_PATT2_ATTSET2_7 ((uint32_t)0x00000080) /*!< Bit 7 */ + +#define FSMC_PATT2_ATTWAIT2 ((uint32_t)0x0000FF00) /*!< ATTWAIT2[7:0] bits (Attribute memory 2 wait time) */ +#define FSMC_PATT2_ATTWAIT2_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define FSMC_PATT2_ATTWAIT2_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define FSMC_PATT2_ATTWAIT2_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define FSMC_PATT2_ATTWAIT2_3 ((uint32_t)0x00000800) /*!< Bit 3 */ +#define FSMC_PATT2_ATTWAIT2_4 ((uint32_t)0x00001000) /*!< Bit 4 */ +#define FSMC_PATT2_ATTWAIT2_5 ((uint32_t)0x00002000) /*!< Bit 5 */ +#define FSMC_PATT2_ATTWAIT2_6 ((uint32_t)0x00004000) /*!< Bit 6 */ +#define FSMC_PATT2_ATTWAIT2_7 ((uint32_t)0x00008000) /*!< Bit 7 */ + +#define FSMC_PATT2_ATTHOLD2 ((uint32_t)0x00FF0000) /*!< ATTHOLD2[7:0] bits (Attribute memory 2 hold time) */ +#define FSMC_PATT2_ATTHOLD2_0 ((uint32_t)0x00010000) /*!< Bit 0 */ +#define FSMC_PATT2_ATTHOLD2_1 ((uint32_t)0x00020000) /*!< Bit 1 */ +#define FSMC_PATT2_ATTHOLD2_2 ((uint32_t)0x00040000) /*!< Bit 2 */ +#define FSMC_PATT2_ATTHOLD2_3 ((uint32_t)0x00080000) /*!< Bit 3 */ +#define FSMC_PATT2_ATTHOLD2_4 ((uint32_t)0x00100000) /*!< Bit 4 */ +#define FSMC_PATT2_ATTHOLD2_5 ((uint32_t)0x00200000) /*!< Bit 5 */ +#define FSMC_PATT2_ATTHOLD2_6 ((uint32_t)0x00400000) /*!< Bit 6 */ +#define FSMC_PATT2_ATTHOLD2_7 ((uint32_t)0x00800000) /*!< Bit 7 */ + +#define FSMC_PATT2_ATTHIZ2 ((uint32_t)0xFF000000) /*!< ATTHIZ2[7:0] bits (Attribute memory 2 databus HiZ time) */ +#define FSMC_PATT2_ATTHIZ2_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define FSMC_PATT2_ATTHIZ2_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define FSMC_PATT2_ATTHIZ2_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define FSMC_PATT2_ATTHIZ2_3 ((uint32_t)0x08000000) /*!< Bit 3 */ +#define FSMC_PATT2_ATTHIZ2_4 ((uint32_t)0x10000000) /*!< Bit 4 */ +#define FSMC_PATT2_ATTHIZ2_5 ((uint32_t)0x20000000) /*!< Bit 5 */ +#define FSMC_PATT2_ATTHIZ2_6 ((uint32_t)0x40000000) /*!< Bit 6 */ +#define FSMC_PATT2_ATTHIZ2_7 ((uint32_t)0x80000000) /*!< Bit 7 */ + +/****************** Bit definition for FSMC_PATT3 register ******************/ +#define FSMC_PATT3_ATTSET3 ((uint32_t)0x000000FF) /*!< ATTSET3[7:0] bits (Attribute memory 3 setup time) */ +#define FSMC_PATT3_ATTSET3_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define FSMC_PATT3_ATTSET3_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define FSMC_PATT3_ATTSET3_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define FSMC_PATT3_ATTSET3_3 ((uint32_t)0x00000008) /*!< Bit 3 */ +#define FSMC_PATT3_ATTSET3_4 ((uint32_t)0x00000010) /*!< Bit 4 */ +#define FSMC_PATT3_ATTSET3_5 ((uint32_t)0x00000020) /*!< Bit 5 */ +#define FSMC_PATT3_ATTSET3_6 ((uint32_t)0x00000040) /*!< Bit 6 */ +#define FSMC_PATT3_ATTSET3_7 ((uint32_t)0x00000080) /*!< Bit 7 */ + +#define FSMC_PATT3_ATTWAIT3 ((uint32_t)0x0000FF00) /*!< ATTWAIT3[7:0] bits (Attribute memory 3 wait time) */ +#define FSMC_PATT3_ATTWAIT3_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define FSMC_PATT3_ATTWAIT3_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define FSMC_PATT3_ATTWAIT3_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define FSMC_PATT3_ATTWAIT3_3 ((uint32_t)0x00000800) /*!< Bit 3 */ +#define FSMC_PATT3_ATTWAIT3_4 ((uint32_t)0x00001000) /*!< Bit 4 */ +#define FSMC_PATT3_ATTWAIT3_5 ((uint32_t)0x00002000) /*!< Bit 5 */ +#define FSMC_PATT3_ATTWAIT3_6 ((uint32_t)0x00004000) /*!< Bit 6 */ +#define FSMC_PATT3_ATTWAIT3_7 ((uint32_t)0x00008000) /*!< Bit 7 */ + +#define FSMC_PATT3_ATTHOLD3 ((uint32_t)0x00FF0000) /*!< ATTHOLD3[7:0] bits (Attribute memory 3 hold time) */ +#define FSMC_PATT3_ATTHOLD3_0 ((uint32_t)0x00010000) /*!< Bit 0 */ +#define FSMC_PATT3_ATTHOLD3_1 ((uint32_t)0x00020000) /*!< Bit 1 */ +#define FSMC_PATT3_ATTHOLD3_2 ((uint32_t)0x00040000) /*!< Bit 2 */ +#define FSMC_PATT3_ATTHOLD3_3 ((uint32_t)0x00080000) /*!< Bit 3 */ +#define FSMC_PATT3_ATTHOLD3_4 ((uint32_t)0x00100000) /*!< Bit 4 */ +#define FSMC_PATT3_ATTHOLD3_5 ((uint32_t)0x00200000) /*!< Bit 5 */ +#define FSMC_PATT3_ATTHOLD3_6 ((uint32_t)0x00400000) /*!< Bit 6 */ +#define FSMC_PATT3_ATTHOLD3_7 ((uint32_t)0x00800000) /*!< Bit 7 */ + +#define FSMC_PATT3_ATTHIZ3 ((uint32_t)0xFF000000) /*!< ATTHIZ3[7:0] bits (Attribute memory 3 databus HiZ time) */ +#define FSMC_PATT3_ATTHIZ3_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define FSMC_PATT3_ATTHIZ3_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define FSMC_PATT3_ATTHIZ3_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define FSMC_PATT3_ATTHIZ3_3 ((uint32_t)0x08000000) /*!< Bit 3 */ +#define FSMC_PATT3_ATTHIZ3_4 ((uint32_t)0x10000000) /*!< Bit 4 */ +#define FSMC_PATT3_ATTHIZ3_5 ((uint32_t)0x20000000) /*!< Bit 5 */ +#define FSMC_PATT3_ATTHIZ3_6 ((uint32_t)0x40000000) /*!< Bit 6 */ +#define FSMC_PATT3_ATTHIZ3_7 ((uint32_t)0x80000000) /*!< Bit 7 */ + +/****************** Bit definition for FSMC_PATT4 register ******************/ +#define FSMC_PATT4_ATTSET4 ((uint32_t)0x000000FF) /*!< ATTSET4[7:0] bits (Attribute memory 4 setup time) */ +#define FSMC_PATT4_ATTSET4_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define FSMC_PATT4_ATTSET4_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define FSMC_PATT4_ATTSET4_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define FSMC_PATT4_ATTSET4_3 ((uint32_t)0x00000008) /*!< Bit 3 */ +#define FSMC_PATT4_ATTSET4_4 ((uint32_t)0x00000010) /*!< Bit 4 */ +#define FSMC_PATT4_ATTSET4_5 ((uint32_t)0x00000020) /*!< Bit 5 */ +#define FSMC_PATT4_ATTSET4_6 ((uint32_t)0x00000040) /*!< Bit 6 */ +#define FSMC_PATT4_ATTSET4_7 ((uint32_t)0x00000080) /*!< Bit 7 */ + +#define FSMC_PATT4_ATTWAIT4 ((uint32_t)0x0000FF00) /*!< ATTWAIT4[7:0] bits (Attribute memory 4 wait time) */ +#define FSMC_PATT4_ATTWAIT4_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define FSMC_PATT4_ATTWAIT4_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define FSMC_PATT4_ATTWAIT4_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define FSMC_PATT4_ATTWAIT4_3 ((uint32_t)0x00000800) /*!< Bit 3 */ +#define FSMC_PATT4_ATTWAIT4_4 ((uint32_t)0x00001000) /*!< Bit 4 */ +#define FSMC_PATT4_ATTWAIT4_5 ((uint32_t)0x00002000) /*!< Bit 5 */ +#define FSMC_PATT4_ATTWAIT4_6 ((uint32_t)0x00004000) /*!< Bit 6 */ +#define FSMC_PATT4_ATTWAIT4_7 ((uint32_t)0x00008000) /*!< Bit 7 */ + +#define FSMC_PATT4_ATTHOLD4 ((uint32_t)0x00FF0000) /*!< ATTHOLD4[7:0] bits (Attribute memory 4 hold time) */ +#define FSMC_PATT4_ATTHOLD4_0 ((uint32_t)0x00010000) /*!< Bit 0 */ +#define FSMC_PATT4_ATTHOLD4_1 ((uint32_t)0x00020000) /*!< Bit 1 */ +#define FSMC_PATT4_ATTHOLD4_2 ((uint32_t)0x00040000) /*!< Bit 2 */ +#define FSMC_PATT4_ATTHOLD4_3 ((uint32_t)0x00080000) /*!< Bit 3 */ +#define FSMC_PATT4_ATTHOLD4_4 ((uint32_t)0x00100000) /*!< Bit 4 */ +#define FSMC_PATT4_ATTHOLD4_5 ((uint32_t)0x00200000) /*!< Bit 5 */ +#define FSMC_PATT4_ATTHOLD4_6 ((uint32_t)0x00400000) /*!< Bit 6 */ +#define FSMC_PATT4_ATTHOLD4_7 ((uint32_t)0x00800000) /*!< Bit 7 */ + +#define FSMC_PATT4_ATTHIZ4 ((uint32_t)0xFF000000) /*!< ATTHIZ4[7:0] bits (Attribute memory 4 databus HiZ time) */ +#define FSMC_PATT4_ATTHIZ4_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define FSMC_PATT4_ATTHIZ4_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define FSMC_PATT4_ATTHIZ4_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define FSMC_PATT4_ATTHIZ4_3 ((uint32_t)0x08000000) /*!< Bit 3 */ +#define FSMC_PATT4_ATTHIZ4_4 ((uint32_t)0x10000000) /*!< Bit 4 */ +#define FSMC_PATT4_ATTHIZ4_5 ((uint32_t)0x20000000) /*!< Bit 5 */ +#define FSMC_PATT4_ATTHIZ4_6 ((uint32_t)0x40000000) /*!< Bit 6 */ +#define FSMC_PATT4_ATTHIZ4_7 ((uint32_t)0x80000000) /*!< Bit 7 */ + +/****************** Bit definition for FSMC_PIO4 register *******************/ +#define FSMC_PIO4_IOSET4 ((uint32_t)0x000000FF) /*!< IOSET4[7:0] bits (I/O 4 setup time) */ +#define FSMC_PIO4_IOSET4_0 ((uint32_t)0x00000001) /*!< Bit 0 */ +#define FSMC_PIO4_IOSET4_1 ((uint32_t)0x00000002) /*!< Bit 1 */ +#define FSMC_PIO4_IOSET4_2 ((uint32_t)0x00000004) /*!< Bit 2 */ +#define FSMC_PIO4_IOSET4_3 ((uint32_t)0x00000008) /*!< Bit 3 */ +#define FSMC_PIO4_IOSET4_4 ((uint32_t)0x00000010) /*!< Bit 4 */ +#define FSMC_PIO4_IOSET4_5 ((uint32_t)0x00000020) /*!< Bit 5 */ +#define FSMC_PIO4_IOSET4_6 ((uint32_t)0x00000040) /*!< Bit 6 */ +#define FSMC_PIO4_IOSET4_7 ((uint32_t)0x00000080) /*!< Bit 7 */ + +#define FSMC_PIO4_IOWAIT4 ((uint32_t)0x0000FF00) /*!< IOWAIT4[7:0] bits (I/O 4 wait time) */ +#define FSMC_PIO4_IOWAIT4_0 ((uint32_t)0x00000100) /*!< Bit 0 */ +#define FSMC_PIO4_IOWAIT4_1 ((uint32_t)0x00000200) /*!< Bit 1 */ +#define FSMC_PIO4_IOWAIT4_2 ((uint32_t)0x00000400) /*!< Bit 2 */ +#define FSMC_PIO4_IOWAIT4_3 ((uint32_t)0x00000800) /*!< Bit 3 */ +#define FSMC_PIO4_IOWAIT4_4 ((uint32_t)0x00001000) /*!< Bit 4 */ +#define FSMC_PIO4_IOWAIT4_5 ((uint32_t)0x00002000) /*!< Bit 5 */ +#define FSMC_PIO4_IOWAIT4_6 ((uint32_t)0x00004000) /*!< Bit 6 */ +#define FSMC_PIO4_IOWAIT4_7 ((uint32_t)0x00008000) /*!< Bit 7 */ + +#define FSMC_PIO4_IOHOLD4 ((uint32_t)0x00FF0000) /*!< IOHOLD4[7:0] bits (I/O 4 hold time) */ +#define FSMC_PIO4_IOHOLD4_0 ((uint32_t)0x00010000) /*!< Bit 0 */ +#define FSMC_PIO4_IOHOLD4_1 ((uint32_t)0x00020000) /*!< Bit 1 */ +#define FSMC_PIO4_IOHOLD4_2 ((uint32_t)0x00040000) /*!< Bit 2 */ +#define FSMC_PIO4_IOHOLD4_3 ((uint32_t)0x00080000) /*!< Bit 3 */ +#define FSMC_PIO4_IOHOLD4_4 ((uint32_t)0x00100000) /*!< Bit 4 */ +#define FSMC_PIO4_IOHOLD4_5 ((uint32_t)0x00200000) /*!< Bit 5 */ +#define FSMC_PIO4_IOHOLD4_6 ((uint32_t)0x00400000) /*!< Bit 6 */ +#define FSMC_PIO4_IOHOLD4_7 ((uint32_t)0x00800000) /*!< Bit 7 */ + +#define FSMC_PIO4_IOHIZ4 ((uint32_t)0xFF000000) /*!< IOHIZ4[7:0] bits (I/O 4 databus HiZ time) */ +#define FSMC_PIO4_IOHIZ4_0 ((uint32_t)0x01000000) /*!< Bit 0 */ +#define FSMC_PIO4_IOHIZ4_1 ((uint32_t)0x02000000) /*!< Bit 1 */ +#define FSMC_PIO4_IOHIZ4_2 ((uint32_t)0x04000000) /*!< Bit 2 */ +#define FSMC_PIO4_IOHIZ4_3 ((uint32_t)0x08000000) /*!< Bit 3 */ +#define FSMC_PIO4_IOHIZ4_4 ((uint32_t)0x10000000) /*!< Bit 4 */ +#define FSMC_PIO4_IOHIZ4_5 ((uint32_t)0x20000000) /*!< Bit 5 */ +#define FSMC_PIO4_IOHIZ4_6 ((uint32_t)0x40000000) /*!< Bit 6 */ +#define FSMC_PIO4_IOHIZ4_7 ((uint32_t)0x80000000) /*!< Bit 7 */ + +/****************** Bit definition for FSMC_ECCR2 register ******************/ +#define FSMC_ECCR2_ECC2 ((uint32_t)0xFFFFFFFF) /*!< ECC result */ + +/****************** Bit definition for FSMC_ECCR3 register ******************/ +#define FSMC_ECCR3_ECC3 ((uint32_t)0xFFFFFFFF) /*!< ECC result */ + +/******************************************************************************/ +/* */ +/* SD host Interface */ +/* */ +/******************************************************************************/ + +/****************** Bit definition for SDIO_POWER register ******************/ +#define SDIO_POWER_PWRCTRL ((uint8_t)0x03) /*!< PWRCTRL[1:0] bits (Power supply control bits) */ +#define SDIO_POWER_PWRCTRL_0 ((uint8_t)0x01) /*!< Bit 0 */ +#define SDIO_POWER_PWRCTRL_1 ((uint8_t)0x02) /*!< Bit 1 */ + +/****************** Bit definition for SDIO_CLKCR register ******************/ +#define SDIO_CLKCR_CLKDIV ((uint16_t)0x00FF) /*!< Clock divide factor */ +#define SDIO_CLKCR_CLKEN ((uint16_t)0x0100) /*!< Clock enable bit */ +#define SDIO_CLKCR_PWRSAV ((uint16_t)0x0200) /*!< Power saving configuration bit */ +#define SDIO_CLKCR_BYPASS ((uint16_t)0x0400) /*!< Clock divider bypass enable bit */ + +#define SDIO_CLKCR_WIDBUS ((uint16_t)0x1800) /*!< WIDBUS[1:0] bits (Wide bus mode enable bit) */ +#define SDIO_CLKCR_WIDBUS_0 ((uint16_t)0x0800) /*!< Bit 0 */ +#define SDIO_CLKCR_WIDBUS_1 ((uint16_t)0x1000) /*!< Bit 1 */ + +#define SDIO_CLKCR_NEGEDGE ((uint16_t)0x2000) /*!< SDIO_CK dephasing selection bit */ +#define SDIO_CLKCR_HWFC_EN ((uint16_t)0x4000) /*!< HW Flow Control enable */ + +/******************* Bit definition for SDIO_ARG register *******************/ +#define SDIO_ARG_CMDARG ((uint32_t)0xFFFFFFFF) /*!< Command argument */ + +/******************* Bit definition for SDIO_CMD register *******************/ +#define SDIO_CMD_CMDINDEX ((uint16_t)0x003F) /*!< Command Index */ + +#define SDIO_CMD_WAITRESP ((uint16_t)0x00C0) /*!< WAITRESP[1:0] bits (Wait for response bits) */ +#define SDIO_CMD_WAITRESP_0 ((uint16_t)0x0040) /*!< Bit 0 */ +#define SDIO_CMD_WAITRESP_1 ((uint16_t)0x0080) /*!< Bit 1 */ + +#define SDIO_CMD_WAITINT ((uint16_t)0x0100) /*!< CPSM Waits for Interrupt Request */ +#define SDIO_CMD_WAITPEND ((uint16_t)0x0200) /*!< CPSM Waits for ends of data transfer (CmdPend internal signal) */ +#define SDIO_CMD_CPSMEN ((uint16_t)0x0400) /*!< Command path state machine (CPSM) Enable bit */ +#define SDIO_CMD_SDIOSUSPEND ((uint16_t)0x0800) /*!< SD I/O suspend command */ +#define SDIO_CMD_ENCMDCOMPL ((uint16_t)0x1000) /*!< Enable CMD completion */ +#define SDIO_CMD_NIEN ((uint16_t)0x2000) /*!< Not Interrupt Enable */ +#define SDIO_CMD_CEATACMD ((uint16_t)0x4000) /*!< CE-ATA command */ + +/***************** Bit definition for SDIO_RESPCMD register *****************/ +#define SDIO_RESPCMD_RESPCMD ((uint8_t)0x3F) /*!< Response command index */ + +/****************** Bit definition for SDIO_RESP0 register ******************/ +#define SDIO_RESP0_CARDSTATUS0 ((uint32_t)0xFFFFFFFF) /*!< Card Status */ + +/****************** Bit definition for SDIO_RESP1 register ******************/ +#define SDIO_RESP1_CARDSTATUS1 ((uint32_t)0xFFFFFFFF) /*!< Card Status */ + +/****************** Bit definition for SDIO_RESP2 register ******************/ +#define SDIO_RESP2_CARDSTATUS2 ((uint32_t)0xFFFFFFFF) /*!< Card Status */ + +/****************** Bit definition for SDIO_RESP3 register ******************/ +#define SDIO_RESP3_CARDSTATUS3 ((uint32_t)0xFFFFFFFF) /*!< Card Status */ + +/****************** Bit definition for SDIO_RESP4 register ******************/ +#define SDIO_RESP4_CARDSTATUS4 ((uint32_t)0xFFFFFFFF) /*!< Card Status */ + +/****************** Bit definition for SDIO_DTIMER register *****************/ +#define SDIO_DTIMER_DATATIME ((uint32_t)0xFFFFFFFF) /*!< Data timeout period. */ + +/****************** Bit definition for SDIO_DLEN register *******************/ +#define SDIO_DLEN_DATALENGTH ((uint32_t)0x01FFFFFF) /*!< Data length value */ + +/****************** Bit definition for SDIO_DCTRL register ******************/ +#define SDIO_DCTRL_DTEN ((uint16_t)0x0001) /*!< Data transfer enabled bit */ +#define SDIO_DCTRL_DTDIR ((uint16_t)0x0002) /*!< Data transfer direction selection */ +#define SDIO_DCTRL_DTMODE ((uint16_t)0x0004) /*!< Data transfer mode selection */ +#define SDIO_DCTRL_DMAEN ((uint16_t)0x0008) /*!< DMA enabled bit */ + +#define SDIO_DCTRL_DBLOCKSIZE ((uint16_t)0x00F0) /*!< DBLOCKSIZE[3:0] bits (Data block size) */ +#define SDIO_DCTRL_DBLOCKSIZE_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define SDIO_DCTRL_DBLOCKSIZE_1 ((uint16_t)0x0020) /*!< Bit 1 */ +#define SDIO_DCTRL_DBLOCKSIZE_2 ((uint16_t)0x0040) /*!< Bit 2 */ +#define SDIO_DCTRL_DBLOCKSIZE_3 ((uint16_t)0x0080) /*!< Bit 3 */ + +#define SDIO_DCTRL_RWSTART ((uint16_t)0x0100) /*!< Read wait start */ +#define SDIO_DCTRL_RWSTOP ((uint16_t)0x0200) /*!< Read wait stop */ +#define SDIO_DCTRL_RWMOD ((uint16_t)0x0400) /*!< Read wait mode */ +#define SDIO_DCTRL_SDIOEN ((uint16_t)0x0800) /*!< SD I/O enable functions */ + +/****************** Bit definition for SDIO_DCOUNT register *****************/ +#define SDIO_DCOUNT_DATACOUNT ((uint32_t)0x01FFFFFF) /*!< Data count value */ + +/****************** Bit definition for SDIO_STA register ********************/ +#define SDIO_STA_CCRCFAIL ((uint32_t)0x00000001) /*!< Command response received (CRC check failed) */ +#define SDIO_STA_DCRCFAIL ((uint32_t)0x00000002) /*!< Data block sent/received (CRC check failed) */ +#define SDIO_STA_CTIMEOUT ((uint32_t)0x00000004) /*!< Command response timeout */ +#define SDIO_STA_DTIMEOUT ((uint32_t)0x00000008) /*!< Data timeout */ +#define SDIO_STA_TXUNDERR ((uint32_t)0x00000010) /*!< Transmit FIFO underrun error */ +#define SDIO_STA_RXOVERR ((uint32_t)0x00000020) /*!< Received FIFO overrun error */ +#define SDIO_STA_CMDREND ((uint32_t)0x00000040) /*!< Command response received (CRC check passed) */ +#define SDIO_STA_CMDSENT ((uint32_t)0x00000080) /*!< Command sent (no response required) */ +#define SDIO_STA_DATAEND ((uint32_t)0x00000100) /*!< Data end (data counter, SDIDCOUNT, is zero) */ +#define SDIO_STA_STBITERR ((uint32_t)0x00000200) /*!< Start bit not detected on all data signals in wide bus mode */ +#define SDIO_STA_DBCKEND ((uint32_t)0x00000400) /*!< Data block sent/received (CRC check passed) */ +#define SDIO_STA_CMDACT ((uint32_t)0x00000800) /*!< Command transfer in progress */ +#define SDIO_STA_TXACT ((uint32_t)0x00001000) /*!< Data transmit in progress */ +#define SDIO_STA_RXACT ((uint32_t)0x00002000) /*!< Data receive in progress */ +#define SDIO_STA_TXFIFOHE ((uint32_t)0x00004000) /*!< Transmit FIFO Half Empty: at least 8 words can be written into the FIFO */ +#define SDIO_STA_RXFIFOHF ((uint32_t)0x00008000) /*!< Receive FIFO Half Full: there are at least 8 words in the FIFO */ +#define SDIO_STA_TXFIFOF ((uint32_t)0x00010000) /*!< Transmit FIFO full */ +#define SDIO_STA_RXFIFOF ((uint32_t)0x00020000) /*!< Receive FIFO full */ +#define SDIO_STA_TXFIFOE ((uint32_t)0x00040000) /*!< Transmit FIFO empty */ +#define SDIO_STA_RXFIFOE ((uint32_t)0x00080000) /*!< Receive FIFO empty */ +#define SDIO_STA_TXDAVL ((uint32_t)0x00100000) /*!< Data available in transmit FIFO */ +#define SDIO_STA_RXDAVL ((uint32_t)0x00200000) /*!< Data available in receive FIFO */ +#define SDIO_STA_SDIOIT ((uint32_t)0x00400000) /*!< SDIO interrupt received */ +#define SDIO_STA_CEATAEND ((uint32_t)0x00800000) /*!< CE-ATA command completion signal received for CMD61 */ + +/******************* Bit definition for SDIO_ICR register *******************/ +#define SDIO_ICR_CCRCFAILC ((uint32_t)0x00000001) /*!< CCRCFAIL flag clear bit */ +#define SDIO_ICR_DCRCFAILC ((uint32_t)0x00000002) /*!< DCRCFAIL flag clear bit */ +#define SDIO_ICR_CTIMEOUTC ((uint32_t)0x00000004) /*!< CTIMEOUT flag clear bit */ +#define SDIO_ICR_DTIMEOUTC ((uint32_t)0x00000008) /*!< DTIMEOUT flag clear bit */ +#define SDIO_ICR_TXUNDERRC ((uint32_t)0x00000010) /*!< TXUNDERR flag clear bit */ +#define SDIO_ICR_RXOVERRC ((uint32_t)0x00000020) /*!< RXOVERR flag clear bit */ +#define SDIO_ICR_CMDRENDC ((uint32_t)0x00000040) /*!< CMDREND flag clear bit */ +#define SDIO_ICR_CMDSENTC ((uint32_t)0x00000080) /*!< CMDSENT flag clear bit */ +#define SDIO_ICR_DATAENDC ((uint32_t)0x00000100) /*!< DATAEND flag clear bit */ +#define SDIO_ICR_STBITERRC ((uint32_t)0x00000200) /*!< STBITERR flag clear bit */ +#define SDIO_ICR_DBCKENDC ((uint32_t)0x00000400) /*!< DBCKEND flag clear bit */ +#define SDIO_ICR_SDIOITC ((uint32_t)0x00400000) /*!< SDIOIT flag clear bit */ +#define SDIO_ICR_CEATAENDC ((uint32_t)0x00800000) /*!< CEATAEND flag clear bit */ + +/****************** Bit definition for SDIO_MASK register *******************/ +#define SDIO_MASK_CCRCFAILIE ((uint32_t)0x00000001) /*!< Command CRC Fail Interrupt Enable */ +#define SDIO_MASK_DCRCFAILIE ((uint32_t)0x00000002) /*!< Data CRC Fail Interrupt Enable */ +#define SDIO_MASK_CTIMEOUTIE ((uint32_t)0x00000004) /*!< Command TimeOut Interrupt Enable */ +#define SDIO_MASK_DTIMEOUTIE ((uint32_t)0x00000008) /*!< Data TimeOut Interrupt Enable */ +#define SDIO_MASK_TXUNDERRIE ((uint32_t)0x00000010) /*!< Tx FIFO UnderRun Error Interrupt Enable */ +#define SDIO_MASK_RXOVERRIE ((uint32_t)0x00000020) /*!< Rx FIFO OverRun Error Interrupt Enable */ +#define SDIO_MASK_CMDRENDIE ((uint32_t)0x00000040) /*!< Command Response Received Interrupt Enable */ +#define SDIO_MASK_CMDSENTIE ((uint32_t)0x00000080) /*!< Command Sent Interrupt Enable */ +#define SDIO_MASK_DATAENDIE ((uint32_t)0x00000100) /*!< Data End Interrupt Enable */ +#define SDIO_MASK_STBITERRIE ((uint32_t)0x00000200) /*!< Start Bit Error Interrupt Enable */ +#define SDIO_MASK_DBCKENDIE ((uint32_t)0x00000400) /*!< Data Block End Interrupt Enable */ +#define SDIO_MASK_CMDACTIE ((uint32_t)0x00000800) /*!< Command Acting Interrupt Enable */ +#define SDIO_MASK_TXACTIE ((uint32_t)0x00001000) /*!< Data Transmit Acting Interrupt Enable */ +#define SDIO_MASK_RXACTIE ((uint32_t)0x00002000) /*!< Data receive acting interrupt enabled */ +#define SDIO_MASK_TXFIFOHEIE ((uint32_t)0x00004000) /*!< Tx FIFO Half Empty interrupt Enable */ +#define SDIO_MASK_RXFIFOHFIE ((uint32_t)0x00008000) /*!< Rx FIFO Half Full interrupt Enable */ +#define SDIO_MASK_TXFIFOFIE ((uint32_t)0x00010000) /*!< Tx FIFO Full interrupt Enable */ +#define SDIO_MASK_RXFIFOFIE ((uint32_t)0x00020000) /*!< Rx FIFO Full interrupt Enable */ +#define SDIO_MASK_TXFIFOEIE ((uint32_t)0x00040000) /*!< Tx FIFO Empty interrupt Enable */ +#define SDIO_MASK_RXFIFOEIE ((uint32_t)0x00080000) /*!< Rx FIFO Empty interrupt Enable */ +#define SDIO_MASK_TXDAVLIE ((uint32_t)0x00100000) /*!< Data available in Tx FIFO interrupt Enable */ +#define SDIO_MASK_RXDAVLIE ((uint32_t)0x00200000) /*!< Data available in Rx FIFO interrupt Enable */ +#define SDIO_MASK_SDIOITIE ((uint32_t)0x00400000) /*!< SDIO Mode Interrupt Received interrupt Enable */ +#define SDIO_MASK_CEATAENDIE ((uint32_t)0x00800000) /*!< CE-ATA command completion signal received Interrupt Enable */ + +/***************** Bit definition for SDIO_FIFOCNT register *****************/ +#define SDIO_FIFOCNT_FIFOCOUNT ((uint32_t)0x00FFFFFF) /*!< Remaining number of words to be written to or read from the FIFO */ + +/****************** Bit definition for SDIO_FIFO register *******************/ +#define SDIO_FIFO_FIFODATA ((uint32_t)0xFFFFFFFF) /*!< Receive and transmit FIFO data */ + +/******************************************************************************/ +/* */ +/* USB Device FS */ +/* */ +/******************************************************************************/ + +/*!< Endpoint-specific registers */ +/******************* Bit definition for USB_EP0R register *******************/ +#define USB_EP0R_EA ((uint16_t)0x000F) /*!< Endpoint Address */ + +#define USB_EP0R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */ +#define USB_EP0R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define USB_EP0R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */ + +#define USB_EP0R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */ +#define USB_EP0R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */ +#define USB_EP0R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */ + +#define USB_EP0R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */ +#define USB_EP0R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */ +#define USB_EP0R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */ + +#define USB_EP0R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */ + +#define USB_EP0R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */ +#define USB_EP0R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define USB_EP0R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define USB_EP0R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */ +#define USB_EP0R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */ + +/******************* Bit definition for USB_EP1R register *******************/ +#define USB_EP1R_EA ((uint16_t)0x000F) /*!< Endpoint Address */ + +#define USB_EP1R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */ +#define USB_EP1R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define USB_EP1R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */ + +#define USB_EP1R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */ +#define USB_EP1R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */ +#define USB_EP1R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */ + +#define USB_EP1R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */ +#define USB_EP1R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */ +#define USB_EP1R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */ + +#define USB_EP1R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */ + +#define USB_EP1R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */ +#define USB_EP1R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define USB_EP1R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define USB_EP1R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */ +#define USB_EP1R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */ + +/******************* Bit definition for USB_EP2R register *******************/ +#define USB_EP2R_EA ((uint16_t)0x000F) /*!< Endpoint Address */ + +#define USB_EP2R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */ +#define USB_EP2R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define USB_EP2R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */ + +#define USB_EP2R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */ +#define USB_EP2R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */ +#define USB_EP2R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */ + +#define USB_EP2R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */ +#define USB_EP2R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */ +#define USB_EP2R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */ + +#define USB_EP2R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */ + +#define USB_EP2R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */ +#define USB_EP2R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define USB_EP2R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define USB_EP2R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */ +#define USB_EP2R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */ + +/******************* Bit definition for USB_EP3R register *******************/ +#define USB_EP3R_EA ((uint16_t)0x000F) /*!< Endpoint Address */ + +#define USB_EP3R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */ +#define USB_EP3R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define USB_EP3R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */ + +#define USB_EP3R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */ +#define USB_EP3R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */ +#define USB_EP3R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */ + +#define USB_EP3R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */ +#define USB_EP3R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */ +#define USB_EP3R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */ + +#define USB_EP3R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */ + +#define USB_EP3R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */ +#define USB_EP3R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define USB_EP3R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define USB_EP3R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */ +#define USB_EP3R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */ + +/******************* Bit definition for USB_EP4R register *******************/ +#define USB_EP4R_EA ((uint16_t)0x000F) /*!< Endpoint Address */ + +#define USB_EP4R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */ +#define USB_EP4R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define USB_EP4R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */ + +#define USB_EP4R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */ +#define USB_EP4R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */ +#define USB_EP4R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */ + +#define USB_EP4R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */ +#define USB_EP4R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */ +#define USB_EP4R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */ + +#define USB_EP4R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */ + +#define USB_EP4R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */ +#define USB_EP4R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define USB_EP4R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define USB_EP4R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */ +#define USB_EP4R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */ + +/******************* Bit definition for USB_EP5R register *******************/ +#define USB_EP5R_EA ((uint16_t)0x000F) /*!< Endpoint Address */ + +#define USB_EP5R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */ +#define USB_EP5R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define USB_EP5R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */ + +#define USB_EP5R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */ +#define USB_EP5R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */ +#define USB_EP5R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */ + +#define USB_EP5R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */ +#define USB_EP5R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */ +#define USB_EP5R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */ + +#define USB_EP5R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */ + +#define USB_EP5R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */ +#define USB_EP5R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define USB_EP5R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define USB_EP5R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */ +#define USB_EP5R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */ + +/******************* Bit definition for USB_EP6R register *******************/ +#define USB_EP6R_EA ((uint16_t)0x000F) /*!< Endpoint Address */ + +#define USB_EP6R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */ +#define USB_EP6R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define USB_EP6R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */ + +#define USB_EP6R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */ +#define USB_EP6R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */ +#define USB_EP6R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */ + +#define USB_EP6R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */ +#define USB_EP6R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */ +#define USB_EP6R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */ + +#define USB_EP6R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */ + +#define USB_EP6R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */ +#define USB_EP6R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define USB_EP6R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define USB_EP6R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */ +#define USB_EP6R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */ + +/******************* Bit definition for USB_EP7R register *******************/ +#define USB_EP7R_EA ((uint16_t)0x000F) /*!< Endpoint Address */ + +#define USB_EP7R_STAT_TX ((uint16_t)0x0030) /*!< STAT_TX[1:0] bits (Status bits, for transmission transfers) */ +#define USB_EP7R_STAT_TX_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define USB_EP7R_STAT_TX_1 ((uint16_t)0x0020) /*!< Bit 1 */ + +#define USB_EP7R_DTOG_TX ((uint16_t)0x0040) /*!< Data Toggle, for transmission transfers */ +#define USB_EP7R_CTR_TX ((uint16_t)0x0080) /*!< Correct Transfer for transmission */ +#define USB_EP7R_EP_KIND ((uint16_t)0x0100) /*!< Endpoint Kind */ + +#define USB_EP7R_EP_TYPE ((uint16_t)0x0600) /*!< EP_TYPE[1:0] bits (Endpoint type) */ +#define USB_EP7R_EP_TYPE_0 ((uint16_t)0x0200) /*!< Bit 0 */ +#define USB_EP7R_EP_TYPE_1 ((uint16_t)0x0400) /*!< Bit 1 */ + +#define USB_EP7R_SETUP ((uint16_t)0x0800) /*!< Setup transaction completed */ + +#define USB_EP7R_STAT_RX ((uint16_t)0x3000) /*!< STAT_RX[1:0] bits (Status bits, for reception transfers) */ +#define USB_EP7R_STAT_RX_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define USB_EP7R_STAT_RX_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define USB_EP7R_DTOG_RX ((uint16_t)0x4000) /*!< Data Toggle, for reception transfers */ +#define USB_EP7R_CTR_RX ((uint16_t)0x8000) /*!< Correct Transfer for reception */ + +/*!< Common registers */ +/******************* Bit definition for USB_CNTR register *******************/ +#define USB_CNTR_FRES ((uint16_t)0x0001) /*!< Force USB Reset */ +#define USB_CNTR_PDWN ((uint16_t)0x0002) /*!< Power down */ +#define USB_CNTR_LP_MODE ((uint16_t)0x0004) /*!< Low-power mode */ +#define USB_CNTR_FSUSP ((uint16_t)0x0008) /*!< Force suspend */ +#define USB_CNTR_RESUME ((uint16_t)0x0010) /*!< Resume request */ +#define USB_CNTR_ESOFM ((uint16_t)0x0100) /*!< Expected Start Of Frame Interrupt Mask */ +#define USB_CNTR_SOFM ((uint16_t)0x0200) /*!< Start Of Frame Interrupt Mask */ +#define USB_CNTR_RESETM ((uint16_t)0x0400) /*!< RESET Interrupt Mask */ +#define USB_CNTR_SUSPM ((uint16_t)0x0800) /*!< Suspend mode Interrupt Mask */ +#define USB_CNTR_WKUPM ((uint16_t)0x1000) /*!< Wakeup Interrupt Mask */ +#define USB_CNTR_ERRM ((uint16_t)0x2000) /*!< Error Interrupt Mask */ +#define USB_CNTR_PMAOVRM ((uint16_t)0x4000) /*!< Packet Memory Area Over / Underrun Interrupt Mask */ +#define USB_CNTR_CTRM ((uint16_t)0x8000) /*!< Correct Transfer Interrupt Mask */ + +/******************* Bit definition for USB_ISTR register *******************/ +#define USB_ISTR_EP_ID ((uint16_t)0x000F) /*!< Endpoint Identifier */ +#define USB_ISTR_DIR ((uint16_t)0x0010) /*!< Direction of transaction */ +#define USB_ISTR_ESOF ((uint16_t)0x0100) /*!< Expected Start Of Frame */ +#define USB_ISTR_SOF ((uint16_t)0x0200) /*!< Start Of Frame */ +#define USB_ISTR_RESET ((uint16_t)0x0400) /*!< USB RESET request */ +#define USB_ISTR_SUSP ((uint16_t)0x0800) /*!< Suspend mode request */ +#define USB_ISTR_WKUP ((uint16_t)0x1000) /*!< Wake up */ +#define USB_ISTR_ERR ((uint16_t)0x2000) /*!< Error */ +#define USB_ISTR_PMAOVR ((uint16_t)0x4000) /*!< Packet Memory Area Over / Underrun */ +#define USB_ISTR_CTR ((uint16_t)0x8000) /*!< Correct Transfer */ + +/******************* Bit definition for USB_FNR register ********************/ +#define USB_FNR_FN ((uint16_t)0x07FF) /*!< Frame Number */ +#define USB_FNR_LSOF ((uint16_t)0x1800) /*!< Lost SOF */ +#define USB_FNR_LCK ((uint16_t)0x2000) /*!< Locked */ +#define USB_FNR_RXDM ((uint16_t)0x4000) /*!< Receive Data - Line Status */ +#define USB_FNR_RXDP ((uint16_t)0x8000) /*!< Receive Data + Line Status */ + +/****************** Bit definition for USB_DADDR register *******************/ +#define USB_DADDR_ADD ((uint8_t)0x7F) /*!< ADD[6:0] bits (Device Address) */ +#define USB_DADDR_ADD0 ((uint8_t)0x01) /*!< Bit 0 */ +#define USB_DADDR_ADD1 ((uint8_t)0x02) /*!< Bit 1 */ +#define USB_DADDR_ADD2 ((uint8_t)0x04) /*!< Bit 2 */ +#define USB_DADDR_ADD3 ((uint8_t)0x08) /*!< Bit 3 */ +#define USB_DADDR_ADD4 ((uint8_t)0x10) /*!< Bit 4 */ +#define USB_DADDR_ADD5 ((uint8_t)0x20) /*!< Bit 5 */ +#define USB_DADDR_ADD6 ((uint8_t)0x40) /*!< Bit 6 */ + +#define USB_DADDR_EF ((uint8_t)0x80) /*!< Enable Function */ + +/****************** Bit definition for USB_BTABLE register ******************/ +#define USB_BTABLE_BTABLE ((uint16_t)0xFFF8) /*!< Buffer Table */ + +/*!< Buffer descriptor table */ +/***************** Bit definition for USB_ADDR0_TX register *****************/ +#define USB_ADDR0_TX_ADDR0_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 0 */ + +/***************** Bit definition for USB_ADDR1_TX register *****************/ +#define USB_ADDR1_TX_ADDR1_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 1 */ + +/***************** Bit definition for USB_ADDR2_TX register *****************/ +#define USB_ADDR2_TX_ADDR2_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 2 */ + +/***************** Bit definition for USB_ADDR3_TX register *****************/ +#define USB_ADDR3_TX_ADDR3_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 3 */ + +/***************** Bit definition for USB_ADDR4_TX register *****************/ +#define USB_ADDR4_TX_ADDR4_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 4 */ + +/***************** Bit definition for USB_ADDR5_TX register *****************/ +#define USB_ADDR5_TX_ADDR5_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 5 */ + +/***************** Bit definition for USB_ADDR6_TX register *****************/ +#define USB_ADDR6_TX_ADDR6_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 6 */ + +/***************** Bit definition for USB_ADDR7_TX register *****************/ +#define USB_ADDR7_TX_ADDR7_TX ((uint16_t)0xFFFE) /*!< Transmission Buffer Address 7 */ + +/*----------------------------------------------------------------------------*/ + +/***************** Bit definition for USB_COUNT0_TX register ****************/ +#define USB_COUNT0_TX_COUNT0_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 0 */ + +/***************** Bit definition for USB_COUNT1_TX register ****************/ +#define USB_COUNT1_TX_COUNT1_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 1 */ + +/***************** Bit definition for USB_COUNT2_TX register ****************/ +#define USB_COUNT2_TX_COUNT2_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 2 */ + +/***************** Bit definition for USB_COUNT3_TX register ****************/ +#define USB_COUNT3_TX_COUNT3_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 3 */ + +/***************** Bit definition for USB_COUNT4_TX register ****************/ +#define USB_COUNT4_TX_COUNT4_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 4 */ + +/***************** Bit definition for USB_COUNT5_TX register ****************/ +#define USB_COUNT5_TX_COUNT5_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 5 */ + +/***************** Bit definition for USB_COUNT6_TX register ****************/ +#define USB_COUNT6_TX_COUNT6_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 6 */ + +/***************** Bit definition for USB_COUNT7_TX register ****************/ +#define USB_COUNT7_TX_COUNT7_TX ((uint16_t)0x03FF) /*!< Transmission Byte Count 7 */ + +/*----------------------------------------------------------------------------*/ + +/**************** Bit definition for USB_COUNT0_TX_0 register ***************/ +#define USB_COUNT0_TX_0_COUNT0_TX_0 ((uint32_t)0x000003FF) /*!< Transmission Byte Count 0 (low) */ + +/**************** Bit definition for USB_COUNT0_TX_1 register ***************/ +#define USB_COUNT0_TX_1_COUNT0_TX_1 ((uint32_t)0x03FF0000) /*!< Transmission Byte Count 0 (high) */ + +/**************** Bit definition for USB_COUNT1_TX_0 register ***************/ +#define USB_COUNT1_TX_0_COUNT1_TX_0 ((uint32_t)0x000003FF) /*!< Transmission Byte Count 1 (low) */ + +/**************** Bit definition for USB_COUNT1_TX_1 register ***************/ +#define USB_COUNT1_TX_1_COUNT1_TX_1 ((uint32_t)0x03FF0000) /*!< Transmission Byte Count 1 (high) */ + +/**************** Bit definition for USB_COUNT2_TX_0 register ***************/ +#define USB_COUNT2_TX_0_COUNT2_TX_0 ((uint32_t)0x000003FF) /*!< Transmission Byte Count 2 (low) */ + +/**************** Bit definition for USB_COUNT2_TX_1 register ***************/ +#define USB_COUNT2_TX_1_COUNT2_TX_1 ((uint32_t)0x03FF0000) /*!< Transmission Byte Count 2 (high) */ + +/**************** Bit definition for USB_COUNT3_TX_0 register ***************/ +#define USB_COUNT3_TX_0_COUNT3_TX_0 ((uint16_t)0x000003FF) /*!< Transmission Byte Count 3 (low) */ + +/**************** Bit definition for USB_COUNT3_TX_1 register ***************/ +#define USB_COUNT3_TX_1_COUNT3_TX_1 ((uint16_t)0x03FF0000) /*!< Transmission Byte Count 3 (high) */ + +/**************** Bit definition for USB_COUNT4_TX_0 register ***************/ +#define USB_COUNT4_TX_0_COUNT4_TX_0 ((uint32_t)0x000003FF) /*!< Transmission Byte Count 4 (low) */ + +/**************** Bit definition for USB_COUNT4_TX_1 register ***************/ +#define USB_COUNT4_TX_1_COUNT4_TX_1 ((uint32_t)0x03FF0000) /*!< Transmission Byte Count 4 (high) */ + +/**************** Bit definition for USB_COUNT5_TX_0 register ***************/ +#define USB_COUNT5_TX_0_COUNT5_TX_0 ((uint32_t)0x000003FF) /*!< Transmission Byte Count 5 (low) */ + +/**************** Bit definition for USB_COUNT5_TX_1 register ***************/ +#define USB_COUNT5_TX_1_COUNT5_TX_1 ((uint32_t)0x03FF0000) /*!< Transmission Byte Count 5 (high) */ + +/**************** Bit definition for USB_COUNT6_TX_0 register ***************/ +#define USB_COUNT6_TX_0_COUNT6_TX_0 ((uint32_t)0x000003FF) /*!< Transmission Byte Count 6 (low) */ + +/**************** Bit definition for USB_COUNT6_TX_1 register ***************/ +#define USB_COUNT6_TX_1_COUNT6_TX_1 ((uint32_t)0x03FF0000) /*!< Transmission Byte Count 6 (high) */ + +/**************** Bit definition for USB_COUNT7_TX_0 register ***************/ +#define USB_COUNT7_TX_0_COUNT7_TX_0 ((uint32_t)0x000003FF) /*!< Transmission Byte Count 7 (low) */ + +/**************** Bit definition for USB_COUNT7_TX_1 register ***************/ +#define USB_COUNT7_TX_1_COUNT7_TX_1 ((uint32_t)0x03FF0000) /*!< Transmission Byte Count 7 (high) */ + +/*----------------------------------------------------------------------------*/ + +/***************** Bit definition for USB_ADDR0_RX register *****************/ +#define USB_ADDR0_RX_ADDR0_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 0 */ + +/***************** Bit definition for USB_ADDR1_RX register *****************/ +#define USB_ADDR1_RX_ADDR1_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 1 */ + +/***************** Bit definition for USB_ADDR2_RX register *****************/ +#define USB_ADDR2_RX_ADDR2_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 2 */ + +/***************** Bit definition for USB_ADDR3_RX register *****************/ +#define USB_ADDR3_RX_ADDR3_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 3 */ + +/***************** Bit definition for USB_ADDR4_RX register *****************/ +#define USB_ADDR4_RX_ADDR4_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 4 */ + +/***************** Bit definition for USB_ADDR5_RX register *****************/ +#define USB_ADDR5_RX_ADDR5_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 5 */ + +/***************** Bit definition for USB_ADDR6_RX register *****************/ +#define USB_ADDR6_RX_ADDR6_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 6 */ + +/***************** Bit definition for USB_ADDR7_RX register *****************/ +#define USB_ADDR7_RX_ADDR7_RX ((uint16_t)0xFFFE) /*!< Reception Buffer Address 7 */ + +/*----------------------------------------------------------------------------*/ + +/***************** Bit definition for USB_COUNT0_RX register ****************/ +#define USB_COUNT0_RX_COUNT0_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */ + +#define USB_COUNT0_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */ +#define USB_COUNT0_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define USB_COUNT0_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */ +#define USB_COUNT0_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */ +#define USB_COUNT0_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */ +#define USB_COUNT0_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */ + +#define USB_COUNT0_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */ + +/***************** Bit definition for USB_COUNT1_RX register ****************/ +#define USB_COUNT1_RX_COUNT1_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */ + +#define USB_COUNT1_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */ +#define USB_COUNT1_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define USB_COUNT1_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */ +#define USB_COUNT1_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */ +#define USB_COUNT1_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */ +#define USB_COUNT1_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */ + +#define USB_COUNT1_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */ + +/***************** Bit definition for USB_COUNT2_RX register ****************/ +#define USB_COUNT2_RX_COUNT2_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */ + +#define USB_COUNT2_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */ +#define USB_COUNT2_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define USB_COUNT2_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */ +#define USB_COUNT2_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */ +#define USB_COUNT2_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */ +#define USB_COUNT2_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */ + +#define USB_COUNT2_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */ + +/***************** Bit definition for USB_COUNT3_RX register ****************/ +#define USB_COUNT3_RX_COUNT3_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */ + +#define USB_COUNT3_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */ +#define USB_COUNT3_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define USB_COUNT3_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */ +#define USB_COUNT3_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */ +#define USB_COUNT3_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */ +#define USB_COUNT3_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */ + +#define USB_COUNT3_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */ + +/***************** Bit definition for USB_COUNT4_RX register ****************/ +#define USB_COUNT4_RX_COUNT4_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */ + +#define USB_COUNT4_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */ +#define USB_COUNT4_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define USB_COUNT4_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */ +#define USB_COUNT4_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */ +#define USB_COUNT4_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */ +#define USB_COUNT4_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */ + +#define USB_COUNT4_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */ + +/***************** Bit definition for USB_COUNT5_RX register ****************/ +#define USB_COUNT5_RX_COUNT5_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */ + +#define USB_COUNT5_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */ +#define USB_COUNT5_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define USB_COUNT5_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */ +#define USB_COUNT5_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */ +#define USB_COUNT5_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */ +#define USB_COUNT5_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */ + +#define USB_COUNT5_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */ + +/***************** Bit definition for USB_COUNT6_RX register ****************/ +#define USB_COUNT6_RX_COUNT6_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */ + +#define USB_COUNT6_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */ +#define USB_COUNT6_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define USB_COUNT6_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */ +#define USB_COUNT6_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */ +#define USB_COUNT6_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */ +#define USB_COUNT6_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */ + +#define USB_COUNT6_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */ + +/***************** Bit definition for USB_COUNT7_RX register ****************/ +#define USB_COUNT7_RX_COUNT7_RX ((uint16_t)0x03FF) /*!< Reception Byte Count */ + +#define USB_COUNT7_RX_NUM_BLOCK ((uint16_t)0x7C00) /*!< NUM_BLOCK[4:0] bits (Number of blocks) */ +#define USB_COUNT7_RX_NUM_BLOCK_0 ((uint16_t)0x0400) /*!< Bit 0 */ +#define USB_COUNT7_RX_NUM_BLOCK_1 ((uint16_t)0x0800) /*!< Bit 1 */ +#define USB_COUNT7_RX_NUM_BLOCK_2 ((uint16_t)0x1000) /*!< Bit 2 */ +#define USB_COUNT7_RX_NUM_BLOCK_3 ((uint16_t)0x2000) /*!< Bit 3 */ +#define USB_COUNT7_RX_NUM_BLOCK_4 ((uint16_t)0x4000) /*!< Bit 4 */ + +#define USB_COUNT7_RX_BLSIZE ((uint16_t)0x8000) /*!< BLock SIZE */ + +/*----------------------------------------------------------------------------*/ + +/**************** Bit definition for USB_COUNT0_RX_0 register ***************/ +#define USB_COUNT0_RX_0_COUNT0_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */ + +#define USB_COUNT0_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */ +#define USB_COUNT0_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */ +#define USB_COUNT0_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */ +#define USB_COUNT0_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */ +#define USB_COUNT0_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */ +#define USB_COUNT0_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */ + +#define USB_COUNT0_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */ + +/**************** Bit definition for USB_COUNT0_RX_1 register ***************/ +#define USB_COUNT0_RX_1_COUNT0_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */ + +#define USB_COUNT0_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */ +#define USB_COUNT0_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 1 */ +#define USB_COUNT0_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */ +#define USB_COUNT0_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */ +#define USB_COUNT0_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */ +#define USB_COUNT0_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */ + +#define USB_COUNT0_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */ + +/**************** Bit definition for USB_COUNT1_RX_0 register ***************/ +#define USB_COUNT1_RX_0_COUNT1_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */ + +#define USB_COUNT1_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */ +#define USB_COUNT1_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */ +#define USB_COUNT1_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */ +#define USB_COUNT1_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */ +#define USB_COUNT1_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */ +#define USB_COUNT1_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */ + +#define USB_COUNT1_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */ + +/**************** Bit definition for USB_COUNT1_RX_1 register ***************/ +#define USB_COUNT1_RX_1_COUNT1_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */ + +#define USB_COUNT1_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */ +#define USB_COUNT1_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 0 */ +#define USB_COUNT1_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */ +#define USB_COUNT1_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */ +#define USB_COUNT1_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */ +#define USB_COUNT1_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */ + +#define USB_COUNT1_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */ + +/**************** Bit definition for USB_COUNT2_RX_0 register ***************/ +#define USB_COUNT2_RX_0_COUNT2_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */ + +#define USB_COUNT2_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */ +#define USB_COUNT2_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */ +#define USB_COUNT2_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */ +#define USB_COUNT2_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */ +#define USB_COUNT2_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */ +#define USB_COUNT2_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */ + +#define USB_COUNT2_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */ + +/**************** Bit definition for USB_COUNT2_RX_1 register ***************/ +#define USB_COUNT2_RX_1_COUNT2_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */ + +#define USB_COUNT2_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */ +#define USB_COUNT2_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 0 */ +#define USB_COUNT2_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */ +#define USB_COUNT2_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */ +#define USB_COUNT2_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */ +#define USB_COUNT2_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */ + +#define USB_COUNT2_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */ + +/**************** Bit definition for USB_COUNT3_RX_0 register ***************/ +#define USB_COUNT3_RX_0_COUNT3_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */ + +#define USB_COUNT3_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */ +#define USB_COUNT3_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */ +#define USB_COUNT3_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */ +#define USB_COUNT3_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */ +#define USB_COUNT3_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */ +#define USB_COUNT3_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */ + +#define USB_COUNT3_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */ + +/**************** Bit definition for USB_COUNT3_RX_1 register ***************/ +#define USB_COUNT3_RX_1_COUNT3_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */ + +#define USB_COUNT3_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */ +#define USB_COUNT3_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 0 */ +#define USB_COUNT3_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */ +#define USB_COUNT3_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */ +#define USB_COUNT3_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */ +#define USB_COUNT3_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */ + +#define USB_COUNT3_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */ + +/**************** Bit definition for USB_COUNT4_RX_0 register ***************/ +#define USB_COUNT4_RX_0_COUNT4_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */ + +#define USB_COUNT4_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */ +#define USB_COUNT4_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */ +#define USB_COUNT4_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */ +#define USB_COUNT4_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */ +#define USB_COUNT4_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */ +#define USB_COUNT4_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */ + +#define USB_COUNT4_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */ + +/**************** Bit definition for USB_COUNT4_RX_1 register ***************/ +#define USB_COUNT4_RX_1_COUNT4_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */ + +#define USB_COUNT4_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */ +#define USB_COUNT4_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 0 */ +#define USB_COUNT4_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */ +#define USB_COUNT4_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */ +#define USB_COUNT4_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */ +#define USB_COUNT4_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */ + +#define USB_COUNT4_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */ + +/**************** Bit definition for USB_COUNT5_RX_0 register ***************/ +#define USB_COUNT5_RX_0_COUNT5_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */ + +#define USB_COUNT5_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */ +#define USB_COUNT5_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */ +#define USB_COUNT5_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */ +#define USB_COUNT5_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */ +#define USB_COUNT5_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */ +#define USB_COUNT5_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */ + +#define USB_COUNT5_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */ + +/**************** Bit definition for USB_COUNT5_RX_1 register ***************/ +#define USB_COUNT5_RX_1_COUNT5_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */ + +#define USB_COUNT5_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */ +#define USB_COUNT5_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 0 */ +#define USB_COUNT5_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */ +#define USB_COUNT5_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */ +#define USB_COUNT5_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */ +#define USB_COUNT5_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */ + +#define USB_COUNT5_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */ + +/*************** Bit definition for USB_COUNT6_RX_0 register ***************/ +#define USB_COUNT6_RX_0_COUNT6_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */ + +#define USB_COUNT6_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */ +#define USB_COUNT6_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */ +#define USB_COUNT6_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */ +#define USB_COUNT6_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */ +#define USB_COUNT6_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */ +#define USB_COUNT6_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */ + +#define USB_COUNT6_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */ + +/**************** Bit definition for USB_COUNT6_RX_1 register ***************/ +#define USB_COUNT6_RX_1_COUNT6_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */ + +#define USB_COUNT6_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */ +#define USB_COUNT6_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 0 */ +#define USB_COUNT6_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */ +#define USB_COUNT6_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */ +#define USB_COUNT6_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */ +#define USB_COUNT6_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */ + +#define USB_COUNT6_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */ + +/*************** Bit definition for USB_COUNT7_RX_0 register ****************/ +#define USB_COUNT7_RX_0_COUNT7_RX_0 ((uint32_t)0x000003FF) /*!< Reception Byte Count (low) */ + +#define USB_COUNT7_RX_0_NUM_BLOCK_0 ((uint32_t)0x00007C00) /*!< NUM_BLOCK_0[4:0] bits (Number of blocks) (low) */ +#define USB_COUNT7_RX_0_NUM_BLOCK_0_0 ((uint32_t)0x00000400) /*!< Bit 0 */ +#define USB_COUNT7_RX_0_NUM_BLOCK_0_1 ((uint32_t)0x00000800) /*!< Bit 1 */ +#define USB_COUNT7_RX_0_NUM_BLOCK_0_2 ((uint32_t)0x00001000) /*!< Bit 2 */ +#define USB_COUNT7_RX_0_NUM_BLOCK_0_3 ((uint32_t)0x00002000) /*!< Bit 3 */ +#define USB_COUNT7_RX_0_NUM_BLOCK_0_4 ((uint32_t)0x00004000) /*!< Bit 4 */ + +#define USB_COUNT7_RX_0_BLSIZE_0 ((uint32_t)0x00008000) /*!< BLock SIZE (low) */ + +/*************** Bit definition for USB_COUNT7_RX_1 register ****************/ +#define USB_COUNT7_RX_1_COUNT7_RX_1 ((uint32_t)0x03FF0000) /*!< Reception Byte Count (high) */ + +#define USB_COUNT7_RX_1_NUM_BLOCK_1 ((uint32_t)0x7C000000) /*!< NUM_BLOCK_1[4:0] bits (Number of blocks) (high) */ +#define USB_COUNT7_RX_1_NUM_BLOCK_1_0 ((uint32_t)0x04000000) /*!< Bit 0 */ +#define USB_COUNT7_RX_1_NUM_BLOCK_1_1 ((uint32_t)0x08000000) /*!< Bit 1 */ +#define USB_COUNT7_RX_1_NUM_BLOCK_1_2 ((uint32_t)0x10000000) /*!< Bit 2 */ +#define USB_COUNT7_RX_1_NUM_BLOCK_1_3 ((uint32_t)0x20000000) /*!< Bit 3 */ +#define USB_COUNT7_RX_1_NUM_BLOCK_1_4 ((uint32_t)0x40000000) /*!< Bit 4 */ + +#define USB_COUNT7_RX_1_BLSIZE_1 ((uint32_t)0x80000000) /*!< BLock SIZE (high) */ + +/******************************************************************************/ +/* */ +/* Controller Area Network */ +/* */ +/******************************************************************************/ + +/*!< CAN control and status registers */ +/******************* Bit definition for CAN_MCR register ********************/ +#define CAN_MCR_INRQ ((uint16_t)0x0001) /*!< Initialization Request */ +#define CAN_MCR_SLEEP ((uint16_t)0x0002) /*!< Sleep Mode Request */ +#define CAN_MCR_TXFP ((uint16_t)0x0004) /*!< Transmit FIFO Priority */ +#define CAN_MCR_RFLM ((uint16_t)0x0008) /*!< Receive FIFO Locked Mode */ +#define CAN_MCR_NART ((uint16_t)0x0010) /*!< No Automatic Retransmission */ +#define CAN_MCR_AWUM ((uint16_t)0x0020) /*!< Automatic Wakeup Mode */ +#define CAN_MCR_ABOM ((uint16_t)0x0040) /*!< Automatic Bus-Off Management */ +#define CAN_MCR_TTCM ((uint16_t)0x0080) /*!< Time Triggered Communication Mode */ +#define CAN_MCR_RESET ((uint16_t)0x8000) /*!< CAN software master reset */ + +/******************* Bit definition for CAN_MSR register ********************/ +#define CAN_MSR_INAK ((uint16_t)0x0001) /*!< Initialization Acknowledge */ +#define CAN_MSR_SLAK ((uint16_t)0x0002) /*!< Sleep Acknowledge */ +#define CAN_MSR_ERRI ((uint16_t)0x0004) /*!< Error Interrupt */ +#define CAN_MSR_WKUI ((uint16_t)0x0008) /*!< Wakeup Interrupt */ +#define CAN_MSR_SLAKI ((uint16_t)0x0010) /*!< Sleep Acknowledge Interrupt */ +#define CAN_MSR_TXM ((uint16_t)0x0100) /*!< Transmit Mode */ +#define CAN_MSR_RXM ((uint16_t)0x0200) /*!< Receive Mode */ +#define CAN_MSR_SAMP ((uint16_t)0x0400) /*!< Last Sample Point */ +#define CAN_MSR_RX ((uint16_t)0x0800) /*!< CAN Rx Signal */ + +/******************* Bit definition for CAN_TSR register ********************/ +#define CAN_TSR_RQCP0 ((uint32_t)0x00000001) /*!< Request Completed Mailbox0 */ +#define CAN_TSR_TXOK0 ((uint32_t)0x00000002) /*!< Transmission OK of Mailbox0 */ +#define CAN_TSR_ALST0 ((uint32_t)0x00000004) /*!< Arbitration Lost for Mailbox0 */ +#define CAN_TSR_TERR0 ((uint32_t)0x00000008) /*!< Transmission Error of Mailbox0 */ +#define CAN_TSR_ABRQ0 ((uint32_t)0x00000080) /*!< Abort Request for Mailbox0 */ +#define CAN_TSR_RQCP1 ((uint32_t)0x00000100) /*!< Request Completed Mailbox1 */ +#define CAN_TSR_TXOK1 ((uint32_t)0x00000200) /*!< Transmission OK of Mailbox1 */ +#define CAN_TSR_ALST1 ((uint32_t)0x00000400) /*!< Arbitration Lost for Mailbox1 */ +#define CAN_TSR_TERR1 ((uint32_t)0x00000800) /*!< Transmission Error of Mailbox1 */ +#define CAN_TSR_ABRQ1 ((uint32_t)0x00008000) /*!< Abort Request for Mailbox 1 */ +#define CAN_TSR_RQCP2 ((uint32_t)0x00010000) /*!< Request Completed Mailbox2 */ +#define CAN_TSR_TXOK2 ((uint32_t)0x00020000) /*!< Transmission OK of Mailbox 2 */ +#define CAN_TSR_ALST2 ((uint32_t)0x00040000) /*!< Arbitration Lost for mailbox 2 */ +#define CAN_TSR_TERR2 ((uint32_t)0x00080000) /*!< Transmission Error of Mailbox 2 */ +#define CAN_TSR_ABRQ2 ((uint32_t)0x00800000) /*!< Abort Request for Mailbox 2 */ +#define CAN_TSR_CODE ((uint32_t)0x03000000) /*!< Mailbox Code */ + +#define CAN_TSR_TME ((uint32_t)0x1C000000) /*!< TME[2:0] bits */ +#define CAN_TSR_TME0 ((uint32_t)0x04000000) /*!< Transmit Mailbox 0 Empty */ +#define CAN_TSR_TME1 ((uint32_t)0x08000000) /*!< Transmit Mailbox 1 Empty */ +#define CAN_TSR_TME2 ((uint32_t)0x10000000) /*!< Transmit Mailbox 2 Empty */ + +#define CAN_TSR_LOW ((uint32_t)0xE0000000) /*!< LOW[2:0] bits */ +#define CAN_TSR_LOW0 ((uint32_t)0x20000000) /*!< Lowest Priority Flag for Mailbox 0 */ +#define CAN_TSR_LOW1 ((uint32_t)0x40000000) /*!< Lowest Priority Flag for Mailbox 1 */ +#define CAN_TSR_LOW2 ((uint32_t)0x80000000) /*!< Lowest Priority Flag for Mailbox 2 */ + +/******************* Bit definition for CAN_RF0R register *******************/ +#define CAN_RF0R_FMP0 ((uint8_t)0x03) /*!< FIFO 0 Message Pending */ +#define CAN_RF0R_FULL0 ((uint8_t)0x08) /*!< FIFO 0 Full */ +#define CAN_RF0R_FOVR0 ((uint8_t)0x10) /*!< FIFO 0 Overrun */ +#define CAN_RF0R_RFOM0 ((uint8_t)0x20) /*!< Release FIFO 0 Output Mailbox */ + +/******************* Bit definition for CAN_RF1R register *******************/ +#define CAN_RF1R_FMP1 ((uint8_t)0x03) /*!< FIFO 1 Message Pending */ +#define CAN_RF1R_FULL1 ((uint8_t)0x08) /*!< FIFO 1 Full */ +#define CAN_RF1R_FOVR1 ((uint8_t)0x10) /*!< FIFO 1 Overrun */ +#define CAN_RF1R_RFOM1 ((uint8_t)0x20) /*!< Release FIFO 1 Output Mailbox */ + +/******************** Bit definition for CAN_IER register *******************/ +#define CAN_IER_TMEIE ((uint32_t)0x00000001) /*!< Transmit Mailbox Empty Interrupt Enable */ +#define CAN_IER_FMPIE0 ((uint32_t)0x00000002) /*!< FIFO Message Pending Interrupt Enable */ +#define CAN_IER_FFIE0 ((uint32_t)0x00000004) /*!< FIFO Full Interrupt Enable */ +#define CAN_IER_FOVIE0 ((uint32_t)0x00000008) /*!< FIFO Overrun Interrupt Enable */ +#define CAN_IER_FMPIE1 ((uint32_t)0x00000010) /*!< FIFO Message Pending Interrupt Enable */ +#define CAN_IER_FFIE1 ((uint32_t)0x00000020) /*!< FIFO Full Interrupt Enable */ +#define CAN_IER_FOVIE1 ((uint32_t)0x00000040) /*!< FIFO Overrun Interrupt Enable */ +#define CAN_IER_EWGIE ((uint32_t)0x00000100) /*!< Error Warning Interrupt Enable */ +#define CAN_IER_EPVIE ((uint32_t)0x00000200) /*!< Error Passive Interrupt Enable */ +#define CAN_IER_BOFIE ((uint32_t)0x00000400) /*!< Bus-Off Interrupt Enable */ +#define CAN_IER_LECIE ((uint32_t)0x00000800) /*!< Last Error Code Interrupt Enable */ +#define CAN_IER_ERRIE ((uint32_t)0x00008000) /*!< Error Interrupt Enable */ +#define CAN_IER_WKUIE ((uint32_t)0x00010000) /*!< Wakeup Interrupt Enable */ +#define CAN_IER_SLKIE ((uint32_t)0x00020000) /*!< Sleep Interrupt Enable */ + +/******************** Bit definition for CAN_ESR register *******************/ +#define CAN_ESR_EWGF ((uint32_t)0x00000001) /*!< Error Warning Flag */ +#define CAN_ESR_EPVF ((uint32_t)0x00000002) /*!< Error Passive Flag */ +#define CAN_ESR_BOFF ((uint32_t)0x00000004) /*!< Bus-Off Flag */ + +#define CAN_ESR_LEC ((uint32_t)0x00000070) /*!< LEC[2:0] bits (Last Error Code) */ +#define CAN_ESR_LEC_0 ((uint32_t)0x00000010) /*!< Bit 0 */ +#define CAN_ESR_LEC_1 ((uint32_t)0x00000020) /*!< Bit 1 */ +#define CAN_ESR_LEC_2 ((uint32_t)0x00000040) /*!< Bit 2 */ + +#define CAN_ESR_TEC ((uint32_t)0x00FF0000) /*!< Least significant byte of the 9-bit Transmit Error Counter */ +#define CAN_ESR_REC ((uint32_t)0xFF000000) /*!< Receive Error Counter */ + +/******************* Bit definition for CAN_BTR register ********************/ +#define CAN_BTR_BRP ((uint32_t)0x000003FF) /*!< Baud Rate Prescaler */ +#define CAN_BTR_TS1 ((uint32_t)0x000F0000) /*!< Time Segment 1 */ +#define CAN_BTR_TS2 ((uint32_t)0x00700000) /*!< Time Segment 2 */ +#define CAN_BTR_SJW ((uint32_t)0x03000000) /*!< Resynchronization Jump Width */ +#define CAN_BTR_LBKM ((uint32_t)0x40000000) /*!< Loop Back Mode (Debug) */ +#define CAN_BTR_SILM ((uint32_t)0x80000000) /*!< Silent Mode */ + +/*!< Mailbox registers */ +/****************** Bit definition for CAN_TI0R register ********************/ +#define CAN_TI0R_TXRQ ((uint32_t)0x00000001) /*!< Transmit Mailbox Request */ +#define CAN_TI0R_RTR ((uint32_t)0x00000002) /*!< Remote Transmission Request */ +#define CAN_TI0R_IDE ((uint32_t)0x00000004) /*!< Identifier Extension */ +#define CAN_TI0R_EXID ((uint32_t)0x001FFFF8) /*!< Extended Identifier */ +#define CAN_TI0R_STID ((uint32_t)0xFFE00000) /*!< Standard Identifier or Extended Identifier */ + +/****************** Bit definition for CAN_TDT0R register *******************/ +#define CAN_TDT0R_DLC ((uint32_t)0x0000000F) /*!< Data Length Code */ +#define CAN_TDT0R_TGT ((uint32_t)0x00000100) /*!< Transmit Global Time */ +#define CAN_TDT0R_TIME ((uint32_t)0xFFFF0000) /*!< Message Time Stamp */ + +/****************** Bit definition for CAN_TDL0R register *******************/ +#define CAN_TDL0R_DATA0 ((uint32_t)0x000000FF) /*!< Data byte 0 */ +#define CAN_TDL0R_DATA1 ((uint32_t)0x0000FF00) /*!< Data byte 1 */ +#define CAN_TDL0R_DATA2 ((uint32_t)0x00FF0000) /*!< Data byte 2 */ +#define CAN_TDL0R_DATA3 ((uint32_t)0xFF000000) /*!< Data byte 3 */ + +/****************** Bit definition for CAN_TDH0R register *******************/ +#define CAN_TDH0R_DATA4 ((uint32_t)0x000000FF) /*!< Data byte 4 */ +#define CAN_TDH0R_DATA5 ((uint32_t)0x0000FF00) /*!< Data byte 5 */ +#define CAN_TDH0R_DATA6 ((uint32_t)0x00FF0000) /*!< Data byte 6 */ +#define CAN_TDH0R_DATA7 ((uint32_t)0xFF000000) /*!< Data byte 7 */ + +/******************* Bit definition for CAN_TI1R register *******************/ +#define CAN_TI1R_TXRQ ((uint32_t)0x00000001) /*!< Transmit Mailbox Request */ +#define CAN_TI1R_RTR ((uint32_t)0x00000002) /*!< Remote Transmission Request */ +#define CAN_TI1R_IDE ((uint32_t)0x00000004) /*!< Identifier Extension */ +#define CAN_TI1R_EXID ((uint32_t)0x001FFFF8) /*!< Extended Identifier */ +#define CAN_TI1R_STID ((uint32_t)0xFFE00000) /*!< Standard Identifier or Extended Identifier */ + +/******************* Bit definition for CAN_TDT1R register ******************/ +#define CAN_TDT1R_DLC ((uint32_t)0x0000000F) /*!< Data Length Code */ +#define CAN_TDT1R_TGT ((uint32_t)0x00000100) /*!< Transmit Global Time */ +#define CAN_TDT1R_TIME ((uint32_t)0xFFFF0000) /*!< Message Time Stamp */ + +/******************* Bit definition for CAN_TDL1R register ******************/ +#define CAN_TDL1R_DATA0 ((uint32_t)0x000000FF) /*!< Data byte 0 */ +#define CAN_TDL1R_DATA1 ((uint32_t)0x0000FF00) /*!< Data byte 1 */ +#define CAN_TDL1R_DATA2 ((uint32_t)0x00FF0000) /*!< Data byte 2 */ +#define CAN_TDL1R_DATA3 ((uint32_t)0xFF000000) /*!< Data byte 3 */ + +/******************* Bit definition for CAN_TDH1R register ******************/ +#define CAN_TDH1R_DATA4 ((uint32_t)0x000000FF) /*!< Data byte 4 */ +#define CAN_TDH1R_DATA5 ((uint32_t)0x0000FF00) /*!< Data byte 5 */ +#define CAN_TDH1R_DATA6 ((uint32_t)0x00FF0000) /*!< Data byte 6 */ +#define CAN_TDH1R_DATA7 ((uint32_t)0xFF000000) /*!< Data byte 7 */ + +/******************* Bit definition for CAN_TI2R register *******************/ +#define CAN_TI2R_TXRQ ((uint32_t)0x00000001) /*!< Transmit Mailbox Request */ +#define CAN_TI2R_RTR ((uint32_t)0x00000002) /*!< Remote Transmission Request */ +#define CAN_TI2R_IDE ((uint32_t)0x00000004) /*!< Identifier Extension */ +#define CAN_TI2R_EXID ((uint32_t)0x001FFFF8) /*!< Extended identifier */ +#define CAN_TI2R_STID ((uint32_t)0xFFE00000) /*!< Standard Identifier or Extended Identifier */ + +/******************* Bit definition for CAN_TDT2R register ******************/ +#define CAN_TDT2R_DLC ((uint32_t)0x0000000F) /*!< Data Length Code */ +#define CAN_TDT2R_TGT ((uint32_t)0x00000100) /*!< Transmit Global Time */ +#define CAN_TDT2R_TIME ((uint32_t)0xFFFF0000) /*!< Message Time Stamp */ + +/******************* Bit definition for CAN_TDL2R register ******************/ +#define CAN_TDL2R_DATA0 ((uint32_t)0x000000FF) /*!< Data byte 0 */ +#define CAN_TDL2R_DATA1 ((uint32_t)0x0000FF00) /*!< Data byte 1 */ +#define CAN_TDL2R_DATA2 ((uint32_t)0x00FF0000) /*!< Data byte 2 */ +#define CAN_TDL2R_DATA3 ((uint32_t)0xFF000000) /*!< Data byte 3 */ + +/******************* Bit definition for CAN_TDH2R register ******************/ +#define CAN_TDH2R_DATA4 ((uint32_t)0x000000FF) /*!< Data byte 4 */ +#define CAN_TDH2R_DATA5 ((uint32_t)0x0000FF00) /*!< Data byte 5 */ +#define CAN_TDH2R_DATA6 ((uint32_t)0x00FF0000) /*!< Data byte 6 */ +#define CAN_TDH2R_DATA7 ((uint32_t)0xFF000000) /*!< Data byte 7 */ + +/******************* Bit definition for CAN_RI0R register *******************/ +#define CAN_RI0R_RTR ((uint32_t)0x00000002) /*!< Remote Transmission Request */ +#define CAN_RI0R_IDE ((uint32_t)0x00000004) /*!< Identifier Extension */ +#define CAN_RI0R_EXID ((uint32_t)0x001FFFF8) /*!< Extended Identifier */ +#define CAN_RI0R_STID ((uint32_t)0xFFE00000) /*!< Standard Identifier or Extended Identifier */ + +/******************* Bit definition for CAN_RDT0R register ******************/ +#define CAN_RDT0R_DLC ((uint32_t)0x0000000F) /*!< Data Length Code */ +#define CAN_RDT0R_FMI ((uint32_t)0x0000FF00) /*!< Filter Match Index */ +#define CAN_RDT0R_TIME ((uint32_t)0xFFFF0000) /*!< Message Time Stamp */ + +/******************* Bit definition for CAN_RDL0R register ******************/ +#define CAN_RDL0R_DATA0 ((uint32_t)0x000000FF) /*!< Data byte 0 */ +#define CAN_RDL0R_DATA1 ((uint32_t)0x0000FF00) /*!< Data byte 1 */ +#define CAN_RDL0R_DATA2 ((uint32_t)0x00FF0000) /*!< Data byte 2 */ +#define CAN_RDL0R_DATA3 ((uint32_t)0xFF000000) /*!< Data byte 3 */ + +/******************* Bit definition for CAN_RDH0R register ******************/ +#define CAN_RDH0R_DATA4 ((uint32_t)0x000000FF) /*!< Data byte 4 */ +#define CAN_RDH0R_DATA5 ((uint32_t)0x0000FF00) /*!< Data byte 5 */ +#define CAN_RDH0R_DATA6 ((uint32_t)0x00FF0000) /*!< Data byte 6 */ +#define CAN_RDH0R_DATA7 ((uint32_t)0xFF000000) /*!< Data byte 7 */ + +/******************* Bit definition for CAN_RI1R register *******************/ +#define CAN_RI1R_RTR ((uint32_t)0x00000002) /*!< Remote Transmission Request */ +#define CAN_RI1R_IDE ((uint32_t)0x00000004) /*!< Identifier Extension */ +#define CAN_RI1R_EXID ((uint32_t)0x001FFFF8) /*!< Extended identifier */ +#define CAN_RI1R_STID ((uint32_t)0xFFE00000) /*!< Standard Identifier or Extended Identifier */ + +/******************* Bit definition for CAN_RDT1R register ******************/ +#define CAN_RDT1R_DLC ((uint32_t)0x0000000F) /*!< Data Length Code */ +#define CAN_RDT1R_FMI ((uint32_t)0x0000FF00) /*!< Filter Match Index */ +#define CAN_RDT1R_TIME ((uint32_t)0xFFFF0000) /*!< Message Time Stamp */ + +/******************* Bit definition for CAN_RDL1R register ******************/ +#define CAN_RDL1R_DATA0 ((uint32_t)0x000000FF) /*!< Data byte 0 */ +#define CAN_RDL1R_DATA1 ((uint32_t)0x0000FF00) /*!< Data byte 1 */ +#define CAN_RDL1R_DATA2 ((uint32_t)0x00FF0000) /*!< Data byte 2 */ +#define CAN_RDL1R_DATA3 ((uint32_t)0xFF000000) /*!< Data byte 3 */ + +/******************* Bit definition for CAN_RDH1R register ******************/ +#define CAN_RDH1R_DATA4 ((uint32_t)0x000000FF) /*!< Data byte 4 */ +#define CAN_RDH1R_DATA5 ((uint32_t)0x0000FF00) /*!< Data byte 5 */ +#define CAN_RDH1R_DATA6 ((uint32_t)0x00FF0000) /*!< Data byte 6 */ +#define CAN_RDH1R_DATA7 ((uint32_t)0xFF000000) /*!< Data byte 7 */ + +/*!< CAN filter registers */ +/******************* Bit definition for CAN_FMR register ********************/ +#define CAN_FMR_FINIT ((uint8_t)0x01) /*!< Filter Init Mode */ + +/******************* Bit definition for CAN_FM1R register *******************/ +#define CAN_FM1R_FBM ((uint16_t)0x3FFF) /*!< Filter Mode */ +#define CAN_FM1R_FBM0 ((uint16_t)0x0001) /*!< Filter Init Mode bit 0 */ +#define CAN_FM1R_FBM1 ((uint16_t)0x0002) /*!< Filter Init Mode bit 1 */ +#define CAN_FM1R_FBM2 ((uint16_t)0x0004) /*!< Filter Init Mode bit 2 */ +#define CAN_FM1R_FBM3 ((uint16_t)0x0008) /*!< Filter Init Mode bit 3 */ +#define CAN_FM1R_FBM4 ((uint16_t)0x0010) /*!< Filter Init Mode bit 4 */ +#define CAN_FM1R_FBM5 ((uint16_t)0x0020) /*!< Filter Init Mode bit 5 */ +#define CAN_FM1R_FBM6 ((uint16_t)0x0040) /*!< Filter Init Mode bit 6 */ +#define CAN_FM1R_FBM7 ((uint16_t)0x0080) /*!< Filter Init Mode bit 7 */ +#define CAN_FM1R_FBM8 ((uint16_t)0x0100) /*!< Filter Init Mode bit 8 */ +#define CAN_FM1R_FBM9 ((uint16_t)0x0200) /*!< Filter Init Mode bit 9 */ +#define CAN_FM1R_FBM10 ((uint16_t)0x0400) /*!< Filter Init Mode bit 10 */ +#define CAN_FM1R_FBM11 ((uint16_t)0x0800) /*!< Filter Init Mode bit 11 */ +#define CAN_FM1R_FBM12 ((uint16_t)0x1000) /*!< Filter Init Mode bit 12 */ +#define CAN_FM1R_FBM13 ((uint16_t)0x2000) /*!< Filter Init Mode bit 13 */ + +/******************* Bit definition for CAN_FS1R register *******************/ +#define CAN_FS1R_FSC ((uint16_t)0x3FFF) /*!< Filter Scale Configuration */ +#define CAN_FS1R_FSC0 ((uint16_t)0x0001) /*!< Filter Scale Configuration bit 0 */ +#define CAN_FS1R_FSC1 ((uint16_t)0x0002) /*!< Filter Scale Configuration bit 1 */ +#define CAN_FS1R_FSC2 ((uint16_t)0x0004) /*!< Filter Scale Configuration bit 2 */ +#define CAN_FS1R_FSC3 ((uint16_t)0x0008) /*!< Filter Scale Configuration bit 3 */ +#define CAN_FS1R_FSC4 ((uint16_t)0x0010) /*!< Filter Scale Configuration bit 4 */ +#define CAN_FS1R_FSC5 ((uint16_t)0x0020) /*!< Filter Scale Configuration bit 5 */ +#define CAN_FS1R_FSC6 ((uint16_t)0x0040) /*!< Filter Scale Configuration bit 6 */ +#define CAN_FS1R_FSC7 ((uint16_t)0x0080) /*!< Filter Scale Configuration bit 7 */ +#define CAN_FS1R_FSC8 ((uint16_t)0x0100) /*!< Filter Scale Configuration bit 8 */ +#define CAN_FS1R_FSC9 ((uint16_t)0x0200) /*!< Filter Scale Configuration bit 9 */ +#define CAN_FS1R_FSC10 ((uint16_t)0x0400) /*!< Filter Scale Configuration bit 10 */ +#define CAN_FS1R_FSC11 ((uint16_t)0x0800) /*!< Filter Scale Configuration bit 11 */ +#define CAN_FS1R_FSC12 ((uint16_t)0x1000) /*!< Filter Scale Configuration bit 12 */ +#define CAN_FS1R_FSC13 ((uint16_t)0x2000) /*!< Filter Scale Configuration bit 13 */ + +/****************** Bit definition for CAN_FFA1R register *******************/ +#define CAN_FFA1R_FFA ((uint16_t)0x3FFF) /*!< Filter FIFO Assignment */ +#define CAN_FFA1R_FFA0 ((uint16_t)0x0001) /*!< Filter FIFO Assignment for Filter 0 */ +#define CAN_FFA1R_FFA1 ((uint16_t)0x0002) /*!< Filter FIFO Assignment for Filter 1 */ +#define CAN_FFA1R_FFA2 ((uint16_t)0x0004) /*!< Filter FIFO Assignment for Filter 2 */ +#define CAN_FFA1R_FFA3 ((uint16_t)0x0008) /*!< Filter FIFO Assignment for Filter 3 */ +#define CAN_FFA1R_FFA4 ((uint16_t)0x0010) /*!< Filter FIFO Assignment for Filter 4 */ +#define CAN_FFA1R_FFA5 ((uint16_t)0x0020) /*!< Filter FIFO Assignment for Filter 5 */ +#define CAN_FFA1R_FFA6 ((uint16_t)0x0040) /*!< Filter FIFO Assignment for Filter 6 */ +#define CAN_FFA1R_FFA7 ((uint16_t)0x0080) /*!< Filter FIFO Assignment for Filter 7 */ +#define CAN_FFA1R_FFA8 ((uint16_t)0x0100) /*!< Filter FIFO Assignment for Filter 8 */ +#define CAN_FFA1R_FFA9 ((uint16_t)0x0200) /*!< Filter FIFO Assignment for Filter 9 */ +#define CAN_FFA1R_FFA10 ((uint16_t)0x0400) /*!< Filter FIFO Assignment for Filter 10 */ +#define CAN_FFA1R_FFA11 ((uint16_t)0x0800) /*!< Filter FIFO Assignment for Filter 11 */ +#define CAN_FFA1R_FFA12 ((uint16_t)0x1000) /*!< Filter FIFO Assignment for Filter 12 */ +#define CAN_FFA1R_FFA13 ((uint16_t)0x2000) /*!< Filter FIFO Assignment for Filter 13 */ + +/******************* Bit definition for CAN_FA1R register *******************/ +#define CAN_FA1R_FACT ((uint16_t)0x3FFF) /*!< Filter Active */ +#define CAN_FA1R_FACT0 ((uint16_t)0x0001) /*!< Filter 0 Active */ +#define CAN_FA1R_FACT1 ((uint16_t)0x0002) /*!< Filter 1 Active */ +#define CAN_FA1R_FACT2 ((uint16_t)0x0004) /*!< Filter 2 Active */ +#define CAN_FA1R_FACT3 ((uint16_t)0x0008) /*!< Filter 3 Active */ +#define CAN_FA1R_FACT4 ((uint16_t)0x0010) /*!< Filter 4 Active */ +#define CAN_FA1R_FACT5 ((uint16_t)0x0020) /*!< Filter 5 Active */ +#define CAN_FA1R_FACT6 ((uint16_t)0x0040) /*!< Filter 6 Active */ +#define CAN_FA1R_FACT7 ((uint16_t)0x0080) /*!< Filter 7 Active */ +#define CAN_FA1R_FACT8 ((uint16_t)0x0100) /*!< Filter 8 Active */ +#define CAN_FA1R_FACT9 ((uint16_t)0x0200) /*!< Filter 9 Active */ +#define CAN_FA1R_FACT10 ((uint16_t)0x0400) /*!< Filter 10 Active */ +#define CAN_FA1R_FACT11 ((uint16_t)0x0800) /*!< Filter 11 Active */ +#define CAN_FA1R_FACT12 ((uint16_t)0x1000) /*!< Filter 12 Active */ +#define CAN_FA1R_FACT13 ((uint16_t)0x2000) /*!< Filter 13 Active */ + +/******************* Bit definition for CAN_F0R1 register *******************/ +#define CAN_F0R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F0R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F0R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F0R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F0R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F0R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F0R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F0R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F0R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F0R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F0R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F0R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F0R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F0R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F0R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F0R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F0R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F0R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F0R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F0R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F0R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F0R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F0R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F0R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F0R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F0R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F0R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F0R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F0R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F0R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F0R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F0R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F1R1 register *******************/ +#define CAN_F1R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F1R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F1R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F1R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F1R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F1R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F1R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F1R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F1R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F1R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F1R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F1R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F1R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F1R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F1R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F1R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F1R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F1R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F1R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F1R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F1R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F1R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F1R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F1R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F1R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F1R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F1R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F1R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F1R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F1R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F1R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F1R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F2R1 register *******************/ +#define CAN_F2R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F2R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F2R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F2R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F2R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F2R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F2R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F2R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F2R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F2R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F2R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F2R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F2R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F2R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F2R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F2R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F2R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F2R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F2R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F2R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F2R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F2R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F2R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F2R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F2R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F2R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F2R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F2R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F2R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F2R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F2R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F2R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F3R1 register *******************/ +#define CAN_F3R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F3R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F3R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F3R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F3R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F3R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F3R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F3R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F3R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F3R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F3R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F3R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F3R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F3R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F3R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F3R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F3R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F3R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F3R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F3R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F3R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F3R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F3R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F3R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F3R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F3R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F3R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F3R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F3R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F3R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F3R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F3R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F4R1 register *******************/ +#define CAN_F4R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F4R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F4R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F4R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F4R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F4R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F4R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F4R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F4R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F4R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F4R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F4R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F4R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F4R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F4R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F4R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F4R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F4R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F4R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F4R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F4R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F4R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F4R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F4R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F4R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F4R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F4R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F4R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F4R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F4R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F4R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F4R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F5R1 register *******************/ +#define CAN_F5R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F5R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F5R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F5R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F5R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F5R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F5R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F5R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F5R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F5R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F5R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F5R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F5R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F5R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F5R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F5R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F5R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F5R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F5R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F5R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F5R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F5R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F5R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F5R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F5R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F5R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F5R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F5R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F5R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F5R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F5R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F5R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F6R1 register *******************/ +#define CAN_F6R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F6R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F6R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F6R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F6R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F6R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F6R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F6R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F6R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F6R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F6R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F6R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F6R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F6R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F6R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F6R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F6R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F6R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F6R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F6R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F6R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F6R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F6R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F6R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F6R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F6R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F6R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F6R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F6R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F6R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F6R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F6R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F7R1 register *******************/ +#define CAN_F7R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F7R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F7R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F7R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F7R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F7R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F7R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F7R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F7R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F7R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F7R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F7R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F7R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F7R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F7R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F7R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F7R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F7R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F7R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F7R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F7R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F7R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F7R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F7R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F7R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F7R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F7R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F7R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F7R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F7R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F7R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F7R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F8R1 register *******************/ +#define CAN_F8R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F8R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F8R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F8R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F8R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F8R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F8R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F8R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F8R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F8R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F8R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F8R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F8R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F8R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F8R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F8R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F8R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F8R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F8R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F8R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F8R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F8R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F8R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F8R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F8R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F8R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F8R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F8R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F8R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F8R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F8R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F8R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F9R1 register *******************/ +#define CAN_F9R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F9R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F9R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F9R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F9R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F9R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F9R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F9R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F9R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F9R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F9R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F9R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F9R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F9R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F9R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F9R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F9R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F9R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F9R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F9R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F9R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F9R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F9R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F9R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F9R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F9R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F9R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F9R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F9R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F9R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F9R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F9R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F10R1 register ******************/ +#define CAN_F10R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F10R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F10R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F10R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F10R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F10R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F10R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F10R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F10R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F10R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F10R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F10R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F10R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F10R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F10R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F10R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F10R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F10R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F10R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F10R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F10R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F10R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F10R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F10R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F10R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F10R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F10R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F10R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F10R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F10R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F10R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F10R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F11R1 register ******************/ +#define CAN_F11R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F11R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F11R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F11R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F11R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F11R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F11R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F11R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F11R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F11R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F11R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F11R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F11R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F11R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F11R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F11R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F11R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F11R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F11R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F11R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F11R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F11R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F11R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F11R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F11R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F11R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F11R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F11R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F11R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F11R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F11R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F11R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F12R1 register ******************/ +#define CAN_F12R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F12R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F12R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F12R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F12R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F12R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F12R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F12R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F12R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F12R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F12R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F12R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F12R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F12R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F12R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F12R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F12R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F12R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F12R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F12R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F12R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F12R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F12R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F12R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F12R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F12R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F12R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F12R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F12R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F12R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F12R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F12R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F13R1 register ******************/ +#define CAN_F13R1_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F13R1_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F13R1_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F13R1_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F13R1_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F13R1_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F13R1_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F13R1_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F13R1_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F13R1_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F13R1_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F13R1_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F13R1_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F13R1_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F13R1_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F13R1_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F13R1_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F13R1_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F13R1_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F13R1_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F13R1_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F13R1_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F13R1_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F13R1_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F13R1_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F13R1_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F13R1_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F13R1_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F13R1_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F13R1_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F13R1_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F13R1_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F0R2 register *******************/ +#define CAN_F0R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F0R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F0R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F0R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F0R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F0R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F0R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F0R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F0R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F0R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F0R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F0R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F0R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F0R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F0R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F0R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F0R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F0R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F0R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F0R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F0R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F0R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F0R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F0R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F0R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F0R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F0R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F0R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F0R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F0R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F0R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F0R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F1R2 register *******************/ +#define CAN_F1R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F1R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F1R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F1R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F1R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F1R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F1R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F1R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F1R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F1R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F1R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F1R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F1R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F1R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F1R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F1R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F1R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F1R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F1R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F1R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F1R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F1R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F1R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F1R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F1R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F1R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F1R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F1R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F1R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F1R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F1R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F1R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F2R2 register *******************/ +#define CAN_F2R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F2R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F2R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F2R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F2R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F2R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F2R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F2R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F2R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F2R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F2R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F2R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F2R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F2R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F2R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F2R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F2R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F2R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F2R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F2R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F2R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F2R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F2R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F2R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F2R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F2R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F2R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F2R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F2R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F2R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F2R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F2R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F3R2 register *******************/ +#define CAN_F3R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F3R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F3R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F3R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F3R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F3R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F3R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F3R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F3R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F3R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F3R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F3R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F3R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F3R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F3R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F3R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F3R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F3R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F3R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F3R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F3R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F3R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F3R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F3R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F3R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F3R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F3R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F3R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F3R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F3R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F3R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F3R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F4R2 register *******************/ +#define CAN_F4R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F4R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F4R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F4R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F4R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F4R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F4R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F4R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F4R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F4R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F4R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F4R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F4R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F4R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F4R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F4R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F4R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F4R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F4R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F4R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F4R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F4R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F4R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F4R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F4R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F4R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F4R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F4R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F4R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F4R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F4R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F4R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F5R2 register *******************/ +#define CAN_F5R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F5R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F5R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F5R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F5R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F5R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F5R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F5R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F5R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F5R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F5R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F5R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F5R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F5R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F5R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F5R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F5R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F5R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F5R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F5R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F5R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F5R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F5R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F5R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F5R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F5R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F5R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F5R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F5R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F5R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F5R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F5R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F6R2 register *******************/ +#define CAN_F6R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F6R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F6R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F6R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F6R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F6R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F6R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F6R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F6R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F6R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F6R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F6R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F6R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F6R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F6R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F6R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F6R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F6R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F6R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F6R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F6R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F6R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F6R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F6R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F6R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F6R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F6R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F6R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F6R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F6R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F6R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F6R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F7R2 register *******************/ +#define CAN_F7R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F7R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F7R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F7R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F7R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F7R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F7R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F7R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F7R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F7R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F7R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F7R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F7R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F7R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F7R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F7R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F7R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F7R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F7R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F7R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F7R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F7R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F7R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F7R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F7R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F7R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F7R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F7R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F7R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F7R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F7R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F7R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F8R2 register *******************/ +#define CAN_F8R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F8R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F8R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F8R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F8R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F8R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F8R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F8R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F8R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F8R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F8R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F8R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F8R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F8R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F8R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F8R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F8R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F8R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F8R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F8R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F8R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F8R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F8R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F8R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F8R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F8R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F8R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F8R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F8R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F8R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F8R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F8R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F9R2 register *******************/ +#define CAN_F9R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F9R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F9R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F9R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F9R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F9R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F9R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F9R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F9R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F9R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F9R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F9R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F9R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F9R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F9R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F9R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F9R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F9R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F9R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F9R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F9R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F9R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F9R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F9R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F9R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F9R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F9R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F9R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F9R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F9R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F9R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F9R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F10R2 register ******************/ +#define CAN_F10R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F10R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F10R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F10R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F10R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F10R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F10R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F10R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F10R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F10R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F10R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F10R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F10R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F10R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F10R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F10R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F10R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F10R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F10R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F10R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F10R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F10R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F10R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F10R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F10R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F10R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F10R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F10R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F10R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F10R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F10R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F10R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F11R2 register ******************/ +#define CAN_F11R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F11R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F11R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F11R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F11R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F11R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F11R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F11R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F11R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F11R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F11R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F11R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F11R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F11R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F11R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F11R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F11R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F11R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F11R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F11R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F11R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F11R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F11R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F11R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F11R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F11R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F11R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F11R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F11R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F11R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F11R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F11R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F12R2 register ******************/ +#define CAN_F12R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F12R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F12R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F12R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F12R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F12R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F12R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F12R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F12R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F12R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F12R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F12R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F12R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F12R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F12R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F12R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F12R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F12R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F12R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F12R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F12R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F12R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F12R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F12R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F12R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F12R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F12R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F12R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F12R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F12R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F12R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F12R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************* Bit definition for CAN_F13R2 register ******************/ +#define CAN_F13R2_FB0 ((uint32_t)0x00000001) /*!< Filter bit 0 */ +#define CAN_F13R2_FB1 ((uint32_t)0x00000002) /*!< Filter bit 1 */ +#define CAN_F13R2_FB2 ((uint32_t)0x00000004) /*!< Filter bit 2 */ +#define CAN_F13R2_FB3 ((uint32_t)0x00000008) /*!< Filter bit 3 */ +#define CAN_F13R2_FB4 ((uint32_t)0x00000010) /*!< Filter bit 4 */ +#define CAN_F13R2_FB5 ((uint32_t)0x00000020) /*!< Filter bit 5 */ +#define CAN_F13R2_FB6 ((uint32_t)0x00000040) /*!< Filter bit 6 */ +#define CAN_F13R2_FB7 ((uint32_t)0x00000080) /*!< Filter bit 7 */ +#define CAN_F13R2_FB8 ((uint32_t)0x00000100) /*!< Filter bit 8 */ +#define CAN_F13R2_FB9 ((uint32_t)0x00000200) /*!< Filter bit 9 */ +#define CAN_F13R2_FB10 ((uint32_t)0x00000400) /*!< Filter bit 10 */ +#define CAN_F13R2_FB11 ((uint32_t)0x00000800) /*!< Filter bit 11 */ +#define CAN_F13R2_FB12 ((uint32_t)0x00001000) /*!< Filter bit 12 */ +#define CAN_F13R2_FB13 ((uint32_t)0x00002000) /*!< Filter bit 13 */ +#define CAN_F13R2_FB14 ((uint32_t)0x00004000) /*!< Filter bit 14 */ +#define CAN_F13R2_FB15 ((uint32_t)0x00008000) /*!< Filter bit 15 */ +#define CAN_F13R2_FB16 ((uint32_t)0x00010000) /*!< Filter bit 16 */ +#define CAN_F13R2_FB17 ((uint32_t)0x00020000) /*!< Filter bit 17 */ +#define CAN_F13R2_FB18 ((uint32_t)0x00040000) /*!< Filter bit 18 */ +#define CAN_F13R2_FB19 ((uint32_t)0x00080000) /*!< Filter bit 19 */ +#define CAN_F13R2_FB20 ((uint32_t)0x00100000) /*!< Filter bit 20 */ +#define CAN_F13R2_FB21 ((uint32_t)0x00200000) /*!< Filter bit 21 */ +#define CAN_F13R2_FB22 ((uint32_t)0x00400000) /*!< Filter bit 22 */ +#define CAN_F13R2_FB23 ((uint32_t)0x00800000) /*!< Filter bit 23 */ +#define CAN_F13R2_FB24 ((uint32_t)0x01000000) /*!< Filter bit 24 */ +#define CAN_F13R2_FB25 ((uint32_t)0x02000000) /*!< Filter bit 25 */ +#define CAN_F13R2_FB26 ((uint32_t)0x04000000) /*!< Filter bit 26 */ +#define CAN_F13R2_FB27 ((uint32_t)0x08000000) /*!< Filter bit 27 */ +#define CAN_F13R2_FB28 ((uint32_t)0x10000000) /*!< Filter bit 28 */ +#define CAN_F13R2_FB29 ((uint32_t)0x20000000) /*!< Filter bit 29 */ +#define CAN_F13R2_FB30 ((uint32_t)0x40000000) /*!< Filter bit 30 */ +#define CAN_F13R2_FB31 ((uint32_t)0x80000000) /*!< Filter bit 31 */ + +/******************************************************************************/ +/* */ +/* Serial Peripheral Interface */ +/* */ +/******************************************************************************/ + +/******************* Bit definition for SPI_CR1 register ********************/ +#define SPI_CR1_CPHA ((uint16_t)0x0001) /*!< Clock Phase */ +#define SPI_CR1_CPOL ((uint16_t)0x0002) /*!< Clock Polarity */ +#define SPI_CR1_MSTR ((uint16_t)0x0004) /*!< Master Selection */ + +#define SPI_CR1_BR ((uint16_t)0x0038) /*!< BR[2:0] bits (Baud Rate Control) */ +#define SPI_CR1_BR_0 ((uint16_t)0x0008) /*!< Bit 0 */ +#define SPI_CR1_BR_1 ((uint16_t)0x0010) /*!< Bit 1 */ +#define SPI_CR1_BR_2 ((uint16_t)0x0020) /*!< Bit 2 */ + +#define SPI_CR1_SPE ((uint16_t)0x0040) /*!< SPI Enable */ +#define SPI_CR1_LSBFIRST ((uint16_t)0x0080) /*!< Frame Format */ +#define SPI_CR1_SSI ((uint16_t)0x0100) /*!< Internal slave select */ +#define SPI_CR1_SSM ((uint16_t)0x0200) /*!< Software slave management */ +#define SPI_CR1_RXONLY ((uint16_t)0x0400) /*!< Receive only */ +#define SPI_CR1_DFF ((uint16_t)0x0800) /*!< Data Frame Format */ +#define SPI_CR1_CRCNEXT ((uint16_t)0x1000) /*!< Transmit CRC next */ +#define SPI_CR1_CRCEN ((uint16_t)0x2000) /*!< Hardware CRC calculation enable */ +#define SPI_CR1_BIDIOE ((uint16_t)0x4000) /*!< Output enable in bidirectional mode */ +#define SPI_CR1_BIDIMODE ((uint16_t)0x8000) /*!< Bidirectional data mode enable */ + +/******************* Bit definition for SPI_CR2 register ********************/ +#define SPI_CR2_RXDMAEN ((uint8_t)0x01) /*!< Rx Buffer DMA Enable */ +#define SPI_CR2_TXDMAEN ((uint8_t)0x02) /*!< Tx Buffer DMA Enable */ +#define SPI_CR2_SSOE ((uint8_t)0x04) /*!< SS Output Enable */ +#define SPI_CR2_ERRIE ((uint8_t)0x20) /*!< Error Interrupt Enable */ +#define SPI_CR2_RXNEIE ((uint8_t)0x40) /*!< RX buffer Not Empty Interrupt Enable */ +#define SPI_CR2_TXEIE ((uint8_t)0x80) /*!< Tx buffer Empty Interrupt Enable */ + +/******************** Bit definition for SPI_SR register ********************/ +#define SPI_SR_RXNE ((uint8_t)0x01) /*!< Receive buffer Not Empty */ +#define SPI_SR_TXE ((uint8_t)0x02) /*!< Transmit buffer Empty */ +#define SPI_SR_CHSIDE ((uint8_t)0x04) /*!< Channel side */ +#define SPI_SR_UDR ((uint8_t)0x08) /*!< Underrun flag */ +#define SPI_SR_CRCERR ((uint8_t)0x10) /*!< CRC Error flag */ +#define SPI_SR_MODF ((uint8_t)0x20) /*!< Mode fault */ +#define SPI_SR_OVR ((uint8_t)0x40) /*!< Overrun flag */ +#define SPI_SR_BSY ((uint8_t)0x80) /*!< Busy flag */ + +/******************** Bit definition for SPI_DR register ********************/ +#define SPI_DR_DR ((uint16_t)0xFFFF) /*!< Data Register */ + +/******************* Bit definition for SPI_CRCPR register ******************/ +#define SPI_CRCPR_CRCPOLY ((uint16_t)0xFFFF) /*!< CRC polynomial register */ + +/****************** Bit definition for SPI_RXCRCR register ******************/ +#define SPI_RXCRCR_RXCRC ((uint16_t)0xFFFF) /*!< Rx CRC Register */ + +/****************** Bit definition for SPI_TXCRCR register ******************/ +#define SPI_TXCRCR_TXCRC ((uint16_t)0xFFFF) /*!< Tx CRC Register */ + +/****************** Bit definition for SPI_I2SCFGR register *****************/ +#define SPI_I2SCFGR_CHLEN ((uint16_t)0x0001) /*!< Channel length (number of bits per audio channel) */ + +#define SPI_I2SCFGR_DATLEN ((uint16_t)0x0006) /*!< DATLEN[1:0] bits (Data length to be transferred) */ +#define SPI_I2SCFGR_DATLEN_0 ((uint16_t)0x0002) /*!< Bit 0 */ +#define SPI_I2SCFGR_DATLEN_1 ((uint16_t)0x0004) /*!< Bit 1 */ + +#define SPI_I2SCFGR_CKPOL ((uint16_t)0x0008) /*!< steady state clock polarity */ + +#define SPI_I2SCFGR_I2SSTD ((uint16_t)0x0030) /*!< I2SSTD[1:0] bits (I2S standard selection) */ +#define SPI_I2SCFGR_I2SSTD_0 ((uint16_t)0x0010) /*!< Bit 0 */ +#define SPI_I2SCFGR_I2SSTD_1 ((uint16_t)0x0020) /*!< Bit 1 */ + +#define SPI_I2SCFGR_PCMSYNC ((uint16_t)0x0080) /*!< PCM frame synchronization */ + +#define SPI_I2SCFGR_I2SCFG ((uint16_t)0x0300) /*!< I2SCFG[1:0] bits (I2S configuration mode) */ +#define SPI_I2SCFGR_I2SCFG_0 ((uint16_t)0x0100) /*!< Bit 0 */ +#define SPI_I2SCFGR_I2SCFG_1 ((uint16_t)0x0200) /*!< Bit 1 */ + +#define SPI_I2SCFGR_I2SE ((uint16_t)0x0400) /*!< I2S Enable */ +#define SPI_I2SCFGR_I2SMOD ((uint16_t)0x0800) /*!< I2S mode selection */ + +/****************** Bit definition for SPI_I2SPR register *******************/ +#define SPI_I2SPR_I2SDIV ((uint16_t)0x00FF) /*!< I2S Linear prescaler */ +#define SPI_I2SPR_ODD ((uint16_t)0x0100) /*!< Odd factor for the prescaler */ +#define SPI_I2SPR_MCKOE ((uint16_t)0x0200) /*!< Master Clock Output Enable */ + +/******************************************************************************/ +/* */ +/* Inter-integrated Circuit Interface */ +/* */ +/******************************************************************************/ + +/******************* Bit definition for I2C_CR1 register ********************/ +#define I2C_CR1_PE ((uint16_t)0x0001) /*!< Peripheral Enable */ +#define I2C_CR1_SMBUS ((uint16_t)0x0002) /*!< SMBus Mode */ +#define I2C_CR1_SMBTYPE ((uint16_t)0x0008) /*!< SMBus Type */ +#define I2C_CR1_ENARP ((uint16_t)0x0010) /*!< ARP Enable */ +#define I2C_CR1_ENPEC ((uint16_t)0x0020) /*!< PEC Enable */ +#define I2C_CR1_ENGC ((uint16_t)0x0040) /*!< General Call Enable */ +#define I2C_CR1_NOSTRETCH ((uint16_t)0x0080) /*!< Clock Stretching Disable (Slave mode) */ +#define I2C_CR1_START ((uint16_t)0x0100) /*!< Start Generation */ +#define I2C_CR1_STOP ((uint16_t)0x0200) /*!< Stop Generation */ +#define I2C_CR1_ACK ((uint16_t)0x0400) /*!< Acknowledge Enable */ +#define I2C_CR1_POS ((uint16_t)0x0800) /*!< Acknowledge/PEC Position (for data reception) */ +#define I2C_CR1_PEC ((uint16_t)0x1000) /*!< Packet Error Checking */ +#define I2C_CR1_ALERT ((uint16_t)0x2000) /*!< SMBus Alert */ +#define I2C_CR1_SWRST ((uint16_t)0x8000) /*!< Software Reset */ + +/******************* Bit definition for I2C_CR2 register ********************/ +#define I2C_CR2_FREQ ((uint16_t)0x003F) /*!< FREQ[5:0] bits (Peripheral Clock Frequency) */ +#define I2C_CR2_FREQ_0 ((uint16_t)0x0001) /*!< Bit 0 */ +#define I2C_CR2_FREQ_1 ((uint16_t)0x0002) /*!< Bit 1 */ +#define I2C_CR2_FREQ_2 ((uint16_t)0x0004) /*!< Bit 2 */ +#define I2C_CR2_FREQ_3 ((uint16_t)0x0008) /*!< Bit 3 */ +#define I2C_CR2_FREQ_4 ((uint16_t)0x0010) /*!< Bit 4 */ +#define I2C_CR2_FREQ_5 ((uint16_t)0x0020) /*!< Bit 5 */ + +#define I2C_CR2_ITERREN ((uint16_t)0x0100) /*!< Error Interrupt Enable */ +#define I2C_CR2_ITEVTEN ((uint16_t)0x0200) /*!< Event Interrupt Enable */ +#define I2C_CR2_ITBUFEN ((uint16_t)0x0400) /*!< Buffer Interrupt Enable */ +#define I2C_CR2_DMAEN ((uint16_t)0x0800) /*!< DMA Requests Enable */ +#define I2C_CR2_LAST ((uint16_t)0x1000) /*!< DMA Last Transfer */ + +/******************* Bit definition for I2C_OAR1 register *******************/ +#define I2C_OAR1_ADD1_7 ((uint16_t)0x00FE) /*!< Interface Address */ +#define I2C_OAR1_ADD8_9 ((uint16_t)0x0300) /*!< Interface Address */ + +#define I2C_OAR1_ADD0 ((uint16_t)0x0001) /*!< Bit 0 */ +#define I2C_OAR1_ADD1 ((uint16_t)0x0002) /*!< Bit 1 */ +#define I2C_OAR1_ADD2 ((uint16_t)0x0004) /*!< Bit 2 */ +#define I2C_OAR1_ADD3 ((uint16_t)0x0008) /*!< Bit 3 */ +#define I2C_OAR1_ADD4 ((uint16_t)0x0010) /*!< Bit 4 */ +#define I2C_OAR1_ADD5 ((uint16_t)0x0020) /*!< Bit 5 */ +#define I2C_OAR1_ADD6 ((uint16_t)0x0040) /*!< Bit 6 */ +#define I2C_OAR1_ADD7 ((uint16_t)0x0080) /*!< Bit 7 */ +#define I2C_OAR1_ADD8 ((uint16_t)0x0100) /*!< Bit 8 */ +#define I2C_OAR1_ADD9 ((uint16_t)0x0200) /*!< Bit 9 */ + +#define I2C_OAR1_ADDMODE ((uint16_t)0x8000) /*!< Addressing Mode (Slave mode) */ + +/******************* Bit definition for I2C_OAR2 register *******************/ +#define I2C_OAR2_ENDUAL ((uint8_t)0x01) /*!< Dual addressing mode enable */ +#define I2C_OAR2_ADD2 ((uint8_t)0xFE) /*!< Interface address */ + +/******************** Bit definition for I2C_DR register ********************/ +#define I2C_DR_DR ((uint8_t)0xFF) /*!< 8-bit Data Register */ + +/******************* Bit definition for I2C_SR1 register ********************/ +#define I2C_SR1_SB ((uint16_t)0x0001) /*!< Start Bit (Master mode) */ +#define I2C_SR1_ADDR ((uint16_t)0x0002) /*!< Address sent (master mode)/matched (slave mode) */ +#define I2C_SR1_BTF ((uint16_t)0x0004) /*!< Byte Transfer Finished */ +#define I2C_SR1_ADD10 ((uint16_t)0x0008) /*!< 10-bit header sent (Master mode) */ +#define I2C_SR1_STOPF ((uint16_t)0x0010) /*!< Stop detection (Slave mode) */ +#define I2C_SR1_RXNE ((uint16_t)0x0040) /*!< Data Register not Empty (receivers) */ +#define I2C_SR1_TXE ((uint16_t)0x0080) /*!< Data Register Empty (transmitters) */ +#define I2C_SR1_BERR ((uint16_t)0x0100) /*!< Bus Error */ +#define I2C_SR1_ARLO ((uint16_t)0x0200) /*!< Arbitration Lost (master mode) */ +#define I2C_SR1_AF ((uint16_t)0x0400) /*!< Acknowledge Failure */ +#define I2C_SR1_OVR ((uint16_t)0x0800) /*!< Overrun/Underrun */ +#define I2C_SR1_PECERR ((uint16_t)0x1000) /*!< PEC Error in reception */ +#define I2C_SR1_TIMEOUT ((uint16_t)0x4000) /*!< Timeout or Tlow Error */ +#define I2C_SR1_SMBALERT ((uint16_t)0x8000) /*!< SMBus Alert */ + +/******************* Bit definition for I2C_SR2 register ********************/ +#define I2C_SR2_MSL ((uint16_t)0x0001) /*!< Master/Slave */ +#define I2C_SR2_BUSY ((uint16_t)0x0002) /*!< Bus Busy */ +#define I2C_SR2_TRA ((uint16_t)0x0004) /*!< Transmitter/Receiver */ +#define I2C_SR2_GENCALL ((uint16_t)0x0010) /*!< General Call Address (Slave mode) */ +#define I2C_SR2_SMBDEFAULT ((uint16_t)0x0020) /*!< SMBus Device Default Address (Slave mode) */ +#define I2C_SR2_SMBHOST ((uint16_t)0x0040) /*!< SMBus Host Header (Slave mode) */ +#define I2C_SR2_DUALF ((uint16_t)0x0080) /*!< Dual Flag (Slave mode) */ +#define I2C_SR2_PEC ((uint16_t)0xFF00) /*!< Packet Error Checking Register */ + +/******************* Bit definition for I2C_CCR register ********************/ +#define I2C_CCR_CCR ((uint16_t)0x0FFF) /*!< Clock Control Register in Fast/Standard mode (Master mode) */ +#define I2C_CCR_DUTY ((uint16_t)0x4000) /*!< Fast Mode Duty Cycle */ +#define I2C_CCR_FS ((uint16_t)0x8000) /*!< I2C Master Mode Selection */ + +/****************** Bit definition for I2C_TRISE register *******************/ +#define I2C_TRISE_TRISE ((uint8_t)0x3F) /*!< Maximum Rise Time in Fast/Standard mode (Master mode) */ + +/******************************************************************************/ +/* */ +/* Universal Synchronous Asynchronous Receiver Transmitter */ +/* */ +/******************************************************************************/ + +/******************* Bit definition for USART_SR register *******************/ +#define USART_SR_PE ((uint16_t)0x0001) /*!< Parity Error */ +#define USART_SR_FE ((uint16_t)0x0002) /*!< Framing Error */ +#define USART_SR_NE ((uint16_t)0x0004) /*!< Noise Error Flag */ +#define USART_SR_ORE ((uint16_t)0x0008) /*!< OverRun Error */ +#define USART_SR_IDLE ((uint16_t)0x0010) /*!< IDLE line detected */ +#define USART_SR_RXNE ((uint16_t)0x0020) /*!< Read Data Register Not Empty */ +#define USART_SR_TC ((uint16_t)0x0040) /*!< Transmission Complete */ +#define USART_SR_TXE ((uint16_t)0x0080) /*!< Transmit Data Register Empty */ +#define USART_SR_LBD ((uint16_t)0x0100) /*!< LIN Break Detection Flag */ +#define USART_SR_CTS ((uint16_t)0x0200) /*!< CTS Flag */ + +/******************* Bit definition for USART_DR register *******************/ +#define USART_DR_DR ((uint16_t)0x01FF) /*!< Data value */ + +/****************** Bit definition for USART_BRR register *******************/ +#define USART_BRR_DIV_Fraction ((uint16_t)0x000F) /*!< Fraction of USARTDIV */ +#define USART_BRR_DIV_Mantissa ((uint16_t)0xFFF0) /*!< Mantissa of USARTDIV */ + +/****************** Bit definition for USART_CR1 register *******************/ +#define USART_CR1_SBK ((uint16_t)0x0001) /*!< Send Break */ +#define USART_CR1_RWU ((uint16_t)0x0002) /*!< Receiver wakeup */ +#define USART_CR1_RE ((uint16_t)0x0004) /*!< Receiver Enable */ +#define USART_CR1_TE ((uint16_t)0x0008) /*!< Transmitter Enable */ +#define USART_CR1_IDLEIE ((uint16_t)0x0010) /*!< IDLE Interrupt Enable */ +#define USART_CR1_RXNEIE ((uint16_t)0x0020) /*!< RXNE Interrupt Enable */ +#define USART_CR1_TCIE ((uint16_t)0x0040) /*!< Transmission Complete Interrupt Enable */ +#define USART_CR1_TXEIE ((uint16_t)0x0080) /*!< PE Interrupt Enable */ +#define USART_CR1_PEIE ((uint16_t)0x0100) /*!< PE Interrupt Enable */ +#define USART_CR1_PS ((uint16_t)0x0200) /*!< Parity Selection */ +#define USART_CR1_PCE ((uint16_t)0x0400) /*!< Parity Control Enable */ +#define USART_CR1_WAKE ((uint16_t)0x0800) /*!< Wakeup method */ +#define USART_CR1_M ((uint16_t)0x1000) /*!< Word length */ +#define USART_CR1_UE ((uint16_t)0x2000) /*!< USART Enable */ +#define USART_CR1_OVER8 ((uint16_t)0x8000) /*!< USART Oversmapling 8-bits */ + +/****************** Bit definition for USART_CR2 register *******************/ +#define USART_CR2_ADD ((uint16_t)0x000F) /*!< Address of the USART node */ +#define USART_CR2_LBDL ((uint16_t)0x0020) /*!< LIN Break Detection Length */ +#define USART_CR2_LBDIE ((uint16_t)0x0040) /*!< LIN Break Detection Interrupt Enable */ +#define USART_CR2_LBCL ((uint16_t)0x0100) /*!< Last Bit Clock pulse */ +#define USART_CR2_CPHA ((uint16_t)0x0200) /*!< Clock Phase */ +#define USART_CR2_CPOL ((uint16_t)0x0400) /*!< Clock Polarity */ +#define USART_CR2_CLKEN ((uint16_t)0x0800) /*!< Clock Enable */ + +#define USART_CR2_STOP ((uint16_t)0x3000) /*!< STOP[1:0] bits (STOP bits) */ +#define USART_CR2_STOP_0 ((uint16_t)0x1000) /*!< Bit 0 */ +#define USART_CR2_STOP_1 ((uint16_t)0x2000) /*!< Bit 1 */ + +#define USART_CR2_LINEN ((uint16_t)0x4000) /*!< LIN mode enable */ + +/****************** Bit definition for USART_CR3 register *******************/ +#define USART_CR3_EIE ((uint16_t)0x0001) /*!< Error Interrupt Enable */ +#define USART_CR3_IREN ((uint16_t)0x0002) /*!< IrDA mode Enable */ +#define USART_CR3_IRLP ((uint16_t)0x0004) /*!< IrDA Low-Power */ +#define USART_CR3_HDSEL ((uint16_t)0x0008) /*!< Half-Duplex Selection */ +#define USART_CR3_NACK ((uint16_t)0x0010) /*!< Smartcard NACK enable */ +#define USART_CR3_SCEN ((uint16_t)0x0020) /*!< Smartcard mode enable */ +#define USART_CR3_DMAR ((uint16_t)0x0040) /*!< DMA Enable Receiver */ +#define USART_CR3_DMAT ((uint16_t)0x0080) /*!< DMA Enable Transmitter */ +#define USART_CR3_RTSE ((uint16_t)0x0100) /*!< RTS Enable */ +#define USART_CR3_CTSE ((uint16_t)0x0200) /*!< CTS Enable */ +#define USART_CR3_CTSIE ((uint16_t)0x0400) /*!< CTS Interrupt Enable */ +#define USART_CR3_ONEBIT ((uint16_t)0x0800) /*!< One Bit method */ + +/****************** Bit definition for USART_GTPR register ******************/ +#define USART_GTPR_PSC ((uint16_t)0x00FF) /*!< PSC[7:0] bits (Prescaler value) */ +#define USART_GTPR_PSC_0 ((uint16_t)0x0001) /*!< Bit 0 */ +#define USART_GTPR_PSC_1 ((uint16_t)0x0002) /*!< Bit 1 */ +#define USART_GTPR_PSC_2 ((uint16_t)0x0004) /*!< Bit 2 */ +#define USART_GTPR_PSC_3 ((uint16_t)0x0008) /*!< Bit 3 */ +#define USART_GTPR_PSC_4 ((uint16_t)0x0010) /*!< Bit 4 */ +#define USART_GTPR_PSC_5 ((uint16_t)0x0020) /*!< Bit 5 */ +#define USART_GTPR_PSC_6 ((uint16_t)0x0040) /*!< Bit 6 */ +#define USART_GTPR_PSC_7 ((uint16_t)0x0080) /*!< Bit 7 */ + +#define USART_GTPR_GT ((uint16_t)0xFF00) /*!< Guard time value */ + +/******************************************************************************/ +/* */ +/* Debug MCU */ +/* */ +/******************************************************************************/ + +/**************** Bit definition for DBGMCU_IDCODE register *****************/ +#define DBGMCU_IDCODE_DEV_ID ((uint32_t)0x00000FFF) /*!< Device Identifier */ + +#define DBGMCU_IDCODE_REV_ID ((uint32_t)0xFFFF0000) /*!< REV_ID[15:0] bits (Revision Identifier) */ +#define DBGMCU_IDCODE_REV_ID_0 ((uint32_t)0x00010000) /*!< Bit 0 */ +#define DBGMCU_IDCODE_REV_ID_1 ((uint32_t)0x00020000) /*!< Bit 1 */ +#define DBGMCU_IDCODE_REV_ID_2 ((uint32_t)0x00040000) /*!< Bit 2 */ +#define DBGMCU_IDCODE_REV_ID_3 ((uint32_t)0x00080000) /*!< Bit 3 */ +#define DBGMCU_IDCODE_REV_ID_4 ((uint32_t)0x00100000) /*!< Bit 4 */ +#define DBGMCU_IDCODE_REV_ID_5 ((uint32_t)0x00200000) /*!< Bit 5 */ +#define DBGMCU_IDCODE_REV_ID_6 ((uint32_t)0x00400000) /*!< Bit 6 */ +#define DBGMCU_IDCODE_REV_ID_7 ((uint32_t)0x00800000) /*!< Bit 7 */ +#define DBGMCU_IDCODE_REV_ID_8 ((uint32_t)0x01000000) /*!< Bit 8 */ +#define DBGMCU_IDCODE_REV_ID_9 ((uint32_t)0x02000000) /*!< Bit 9 */ +#define DBGMCU_IDCODE_REV_ID_10 ((uint32_t)0x04000000) /*!< Bit 10 */ +#define DBGMCU_IDCODE_REV_ID_11 ((uint32_t)0x08000000) /*!< Bit 11 */ +#define DBGMCU_IDCODE_REV_ID_12 ((uint32_t)0x10000000) /*!< Bit 12 */ +#define DBGMCU_IDCODE_REV_ID_13 ((uint32_t)0x20000000) /*!< Bit 13 */ +#define DBGMCU_IDCODE_REV_ID_14 ((uint32_t)0x40000000) /*!< Bit 14 */ +#define DBGMCU_IDCODE_REV_ID_15 ((uint32_t)0x80000000) /*!< Bit 15 */ + +/****************** Bit definition for DBGMCU_CR register *******************/ +#define DBGMCU_CR_DBG_SLEEP ((uint32_t)0x00000001) /*!< Debug Sleep Mode */ +#define DBGMCU_CR_DBG_STOP ((uint32_t)0x00000002) /*!< Debug Stop Mode */ +#define DBGMCU_CR_DBG_STANDBY ((uint32_t)0x00000004) /*!< Debug Standby mode */ +#define DBGMCU_CR_TRACE_IOEN ((uint32_t)0x00000020) /*!< Trace Pin Assignment Control */ + +#define DBGMCU_CR_TRACE_MODE ((uint32_t)0x000000C0) /*!< TRACE_MODE[1:0] bits (Trace Pin Assignment Control) */ +#define DBGMCU_CR_TRACE_MODE_0 ((uint32_t)0x00000040) /*!< Bit 0 */ +#define DBGMCU_CR_TRACE_MODE_1 ((uint32_t)0x00000080) /*!< Bit 1 */ + +#define DBGMCU_CR_DBG_IWDG_STOP ((uint32_t)0x00000100) /*!< Debug Independent Watchdog stopped when Core is halted */ +#define DBGMCU_CR_DBG_WWDG_STOP ((uint32_t)0x00000200) /*!< Debug Window Watchdog stopped when Core is halted */ +#define DBGMCU_CR_DBG_TIM1_STOP ((uint32_t)0x00000400) /*!< TIM1 counter stopped when core is halted */ +#define DBGMCU_CR_DBG_TIM2_STOP ((uint32_t)0x00000800) /*!< TIM2 counter stopped when core is halted */ +#define DBGMCU_CR_DBG_TIM3_STOP ((uint32_t)0x00001000) /*!< TIM3 counter stopped when core is halted */ +#define DBGMCU_CR_DBG_TIM4_STOP ((uint32_t)0x00002000) /*!< TIM4 counter stopped when core is halted */ +#define DBGMCU_CR_DBG_CAN1_STOP ((uint32_t)0x00004000) /*!< Debug CAN1 stopped when Core is halted */ +#define DBGMCU_CR_DBG_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00008000) /*!< SMBUS timeout mode stopped when Core is halted */ +#define DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00010000) /*!< SMBUS timeout mode stopped when Core is halted */ +#define DBGMCU_CR_DBG_TIM8_STOP ((uint32_t)0x00020000) /*!< TIM8 counter stopped when core is halted */ +#define DBGMCU_CR_DBG_TIM5_STOP ((uint32_t)0x00040000) /*!< TIM5 counter stopped when core is halted */ +#define DBGMCU_CR_DBG_TIM6_STOP ((uint32_t)0x00080000) /*!< TIM6 counter stopped when core is halted */ +#define DBGMCU_CR_DBG_TIM7_STOP ((uint32_t)0x00100000) /*!< TIM7 counter stopped when core is halted */ +#define DBGMCU_CR_DBG_CAN2_STOP ((uint32_t)0x00200000) /*!< Debug CAN2 stopped when Core is halted */ +#define DBGMCU_CR_DBG_TIM15_STOP ((uint32_t)0x00400000) /*!< Debug TIM15 stopped when Core is halted */ +#define DBGMCU_CR_DBG_TIM16_STOP ((uint32_t)0x00800000) /*!< Debug TIM16 stopped when Core is halted */ +#define DBGMCU_CR_DBG_TIM17_STOP ((uint32_t)0x01000000) /*!< Debug TIM17 stopped when Core is halted */ +#define DBGMCU_CR_DBG_TIM12_STOP ((uint32_t)0x02000000) /*!< Debug TIM12 stopped when Core is halted */ +#define DBGMCU_CR_DBG_TIM13_STOP ((uint32_t)0x04000000) /*!< Debug TIM13 stopped when Core is halted */ +#define DBGMCU_CR_DBG_TIM14_STOP ((uint32_t)0x08000000) /*!< Debug TIM14 stopped when Core is halted */ +#define DBGMCU_CR_DBG_TIM9_STOP ((uint32_t)0x10000000) /*!< Debug TIM9 stopped when Core is halted */ +#define DBGMCU_CR_DBG_TIM10_STOP ((uint32_t)0x20000000) /*!< Debug TIM10 stopped when Core is halted */ +#define DBGMCU_CR_DBG_TIM11_STOP ((uint32_t)0x40000000) /*!< Debug TIM11 stopped when Core is halted */ + +/******************************************************************************/ +/* */ +/* FLASH and Option Bytes Registers */ +/* */ +/******************************************************************************/ + +/******************* Bit definition for FLASH_ACR register ******************/ +#define FLASH_ACR_LATENCY ((uint8_t)0x03) /*!< LATENCY[2:0] bits (Latency) */ +#define FLASH_ACR_LATENCY_0 ((uint8_t)0x00) /*!< Bit 0 */ +#define FLASH_ACR_LATENCY_1 ((uint8_t)0x01) /*!< Bit 0 */ +#define FLASH_ACR_LATENCY_2 ((uint8_t)0x02) /*!< Bit 1 */ + +#define FLASH_ACR_HLFCYA ((uint8_t)0x08) /*!< Flash Half Cycle Access Enable */ +#define FLASH_ACR_PRFTBE ((uint8_t)0x10) /*!< Prefetch Buffer Enable */ +#define FLASH_ACR_PRFTBS ((uint8_t)0x20) /*!< Prefetch Buffer Status */ + +/****************** Bit definition for FLASH_KEYR register ******************/ +#define FLASH_KEYR_FKEYR ((uint32_t)0xFFFFFFFF) /*!< FPEC Key */ + +/***************** Bit definition for FLASH_OPTKEYR register ****************/ +#define FLASH_OPTKEYR_OPTKEYR ((uint32_t)0xFFFFFFFF) /*!< Option Byte Key */ + +/****************** Bit definition for FLASH_SR register *******************/ +#define FLASH_SR_BSY ((uint8_t)0x01) /*!< Busy */ +#define FLASH_SR_PGERR ((uint8_t)0x04) /*!< Programming Error */ +#define FLASH_SR_WRPRTERR ((uint8_t)0x10) /*!< Write Protection Error */ +#define FLASH_SR_EOP ((uint8_t)0x20) /*!< End of operation */ + +/******************* Bit definition for FLASH_CR register *******************/ +#define FLASH_CR_PG ((uint16_t)0x0001) /*!< Programming */ +#define FLASH_CR_PER ((uint16_t)0x0002) /*!< Page Erase */ +#define FLASH_CR_MER ((uint16_t)0x0004) /*!< Mass Erase */ +#define FLASH_CR_OPTPG ((uint16_t)0x0010) /*!< Option Byte Programming */ +#define FLASH_CR_OPTER ((uint16_t)0x0020) /*!< Option Byte Erase */ +#define FLASH_CR_STRT ((uint16_t)0x0040) /*!< Start */ +#define FLASH_CR_LOCK ((uint16_t)0x0080) /*!< Lock */ +#define FLASH_CR_OPTWRE ((uint16_t)0x0200) /*!< Option Bytes Write Enable */ +#define FLASH_CR_ERRIE ((uint16_t)0x0400) /*!< Error Interrupt Enable */ +#define FLASH_CR_EOPIE ((uint16_t)0x1000) /*!< End of operation interrupt enable */ + +/******************* Bit definition for FLASH_AR register *******************/ +#define FLASH_AR_FAR ((uint32_t)0xFFFFFFFF) /*!< Flash Address */ + +/****************** Bit definition for FLASH_OBR register *******************/ +#define FLASH_OBR_OPTERR ((uint16_t)0x0001) /*!< Option Byte Error */ +#define FLASH_OBR_RDPRT ((uint16_t)0x0002) /*!< Read protection */ + +#define FLASH_OBR_USER ((uint16_t)0x03FC) /*!< User Option Bytes */ +#define FLASH_OBR_WDG_SW ((uint16_t)0x0004) /*!< WDG_SW */ +#define FLASH_OBR_nRST_STOP ((uint16_t)0x0008) /*!< nRST_STOP */ +#define FLASH_OBR_nRST_STDBY ((uint16_t)0x0010) /*!< nRST_STDBY */ +#define FLASH_OBR_BFB2 ((uint16_t)0x0020) /*!< BFB2 */ + +/****************** Bit definition for FLASH_WRPR register ******************/ +#define FLASH_WRPR_WRP ((uint32_t)0xFFFFFFFF) /*!< Write Protect */ + +/*----------------------------------------------------------------------------*/ + +/****************** Bit definition for FLASH_RDP register *******************/ +#define FLASH_RDP_RDP ((uint32_t)0x000000FF) /*!< Read protection option byte */ +#define FLASH_RDP_nRDP ((uint32_t)0x0000FF00) /*!< Read protection complemented option byte */ + +/****************** Bit definition for FLASH_USER register ******************/ +#define FLASH_USER_USER ((uint32_t)0x00FF0000) /*!< User option byte */ +#define FLASH_USER_nUSER ((uint32_t)0xFF000000) /*!< User complemented option byte */ + +/****************** Bit definition for FLASH_Data0 register *****************/ +#define FLASH_Data0_Data0 ((uint32_t)0x000000FF) /*!< User data storage option byte */ +#define FLASH_Data0_nData0 ((uint32_t)0x0000FF00) /*!< User data storage complemented option byte */ + +/****************** Bit definition for FLASH_Data1 register *****************/ +#define FLASH_Data1_Data1 ((uint32_t)0x00FF0000) /*!< User data storage option byte */ +#define FLASH_Data1_nData1 ((uint32_t)0xFF000000) /*!< User data storage complemented option byte */ + +/****************** Bit definition for FLASH_WRP0 register ******************/ +#define FLASH_WRP0_WRP0 ((uint32_t)0x000000FF) /*!< Flash memory write protection option bytes */ +#define FLASH_WRP0_nWRP0 ((uint32_t)0x0000FF00) /*!< Flash memory write protection complemented option bytes */ + +/****************** Bit definition for FLASH_WRP1 register ******************/ +#define FLASH_WRP1_WRP1 ((uint32_t)0x00FF0000) /*!< Flash memory write protection option bytes */ +#define FLASH_WRP1_nWRP1 ((uint32_t)0xFF000000) /*!< Flash memory write protection complemented option bytes */ + +/****************** Bit definition for FLASH_WRP2 register ******************/ +#define FLASH_WRP2_WRP2 ((uint32_t)0x000000FF) /*!< Flash memory write protection option bytes */ +#define FLASH_WRP2_nWRP2 ((uint32_t)0x0000FF00) /*!< Flash memory write protection complemented option bytes */ + +/****************** Bit definition for FLASH_WRP3 register ******************/ +#define FLASH_WRP3_WRP3 ((uint32_t)0x00FF0000) /*!< Flash memory write protection option bytes */ +#define FLASH_WRP3_nWRP3 ((uint32_t)0xFF000000) /*!< Flash memory write protection complemented option bytes */ + +#ifdef STM32F10X_CL +/******************************************************************************/ +/* Ethernet MAC Registers bits definitions */ +/******************************************************************************/ +/* Bit definition for Ethernet MAC Control Register register */ +#define ETH_MACCR_WD ((uint32_t)0x00800000) /* Watchdog disable */ +#define ETH_MACCR_JD ((uint32_t)0x00400000) /* Jabber disable */ +#define ETH_MACCR_IFG ((uint32_t)0x000E0000) /* Inter-frame gap */ + #define ETH_MACCR_IFG_96Bit ((uint32_t)0x00000000) /* Minimum IFG between frames during transmission is 96Bit */ + #define ETH_MACCR_IFG_88Bit ((uint32_t)0x00020000) /* Minimum IFG between frames during transmission is 88Bit */ + #define ETH_MACCR_IFG_80Bit ((uint32_t)0x00040000) /* Minimum IFG between frames during transmission is 80Bit */ + #define ETH_MACCR_IFG_72Bit ((uint32_t)0x00060000) /* Minimum IFG between frames during transmission is 72Bit */ + #define ETH_MACCR_IFG_64Bit ((uint32_t)0x00080000) /* Minimum IFG between frames during transmission is 64Bit */ + #define ETH_MACCR_IFG_56Bit ((uint32_t)0x000A0000) /* Minimum IFG between frames during transmission is 56Bit */ + #define ETH_MACCR_IFG_48Bit ((uint32_t)0x000C0000) /* Minimum IFG between frames during transmission is 48Bit */ + #define ETH_MACCR_IFG_40Bit ((uint32_t)0x000E0000) /* Minimum IFG between frames during transmission is 40Bit */ +#define ETH_MACCR_CSD ((uint32_t)0x00010000) /* Carrier sense disable (during transmission) */ +#define ETH_MACCR_FES ((uint32_t)0x00004000) /* Fast ethernet speed */ +#define ETH_MACCR_ROD ((uint32_t)0x00002000) /* Receive own disable */ +#define ETH_MACCR_LM ((uint32_t)0x00001000) /* loopback mode */ +#define ETH_MACCR_DM ((uint32_t)0x00000800) /* Duplex mode */ +#define ETH_MACCR_IPCO ((uint32_t)0x00000400) /* IP Checksum offload */ +#define ETH_MACCR_RD ((uint32_t)0x00000200) /* Retry disable */ +#define ETH_MACCR_APCS ((uint32_t)0x00000080) /* Automatic Pad/CRC stripping */ +#define ETH_MACCR_BL ((uint32_t)0x00000060) /* Back-off limit: random integer number (r) of slot time delays before rescheduling + a transmission attempt during retries after a collision: 0 =< r <2^k */ + #define ETH_MACCR_BL_10 ((uint32_t)0x00000000) /* k = min (n, 10) */ + #define ETH_MACCR_BL_8 ((uint32_t)0x00000020) /* k = min (n, 8) */ + #define ETH_MACCR_BL_4 ((uint32_t)0x00000040) /* k = min (n, 4) */ + #define ETH_MACCR_BL_1 ((uint32_t)0x00000060) /* k = min (n, 1) */ +#define ETH_MACCR_DC ((uint32_t)0x00000010) /* Defferal check */ +#define ETH_MACCR_TE ((uint32_t)0x00000008) /* Transmitter enable */ +#define ETH_MACCR_RE ((uint32_t)0x00000004) /* Receiver enable */ + +/* Bit definition for Ethernet MAC Frame Filter Register */ +#define ETH_MACFFR_RA ((uint32_t)0x80000000) /* Receive all */ +#define ETH_MACFFR_HPF ((uint32_t)0x00000400) /* Hash or perfect filter */ +#define ETH_MACFFR_SAF ((uint32_t)0x00000200) /* Source address filter enable */ +#define ETH_MACFFR_SAIF ((uint32_t)0x00000100) /* SA inverse filtering */ +#define ETH_MACFFR_PCF ((uint32_t)0x000000C0) /* Pass control frames: 3 cases */ + #define ETH_MACFFR_PCF_BlockAll ((uint32_t)0x00000040) /* MAC filters all control frames from reaching the application */ + #define ETH_MACFFR_PCF_ForwardAll ((uint32_t)0x00000080) /* MAC forwards all control frames to application even if they fail the Address Filter */ + #define ETH_MACFFR_PCF_ForwardPassedAddrFilter ((uint32_t)0x000000C0) /* MAC forwards control frames that pass the Address Filter. */ +#define ETH_MACFFR_BFD ((uint32_t)0x00000020) /* Broadcast frame disable */ +#define ETH_MACFFR_PAM ((uint32_t)0x00000010) /* Pass all mutlicast */ +#define ETH_MACFFR_DAIF ((uint32_t)0x00000008) /* DA Inverse filtering */ +#define ETH_MACFFR_HM ((uint32_t)0x00000004) /* Hash multicast */ +#define ETH_MACFFR_HU ((uint32_t)0x00000002) /* Hash unicast */ +#define ETH_MACFFR_PM ((uint32_t)0x00000001) /* Promiscuous mode */ + +/* Bit definition for Ethernet MAC Hash Table High Register */ +#define ETH_MACHTHR_HTH ((uint32_t)0xFFFFFFFF) /* Hash table high */ + +/* Bit definition for Ethernet MAC Hash Table Low Register */ +#define ETH_MACHTLR_HTL ((uint32_t)0xFFFFFFFF) /* Hash table low */ + +/* Bit definition for Ethernet MAC MII Address Register */ +#define ETH_MACMIIAR_PA ((uint32_t)0x0000F800) /* Physical layer address */ +#define ETH_MACMIIAR_MR ((uint32_t)0x000007C0) /* MII register in the selected PHY */ +#define ETH_MACMIIAR_CR ((uint32_t)0x0000001C) /* CR clock range: 6 cases */ + #define ETH_MACMIIAR_CR_Div42 ((uint32_t)0x00000000) /* HCLK:60-72 MHz; MDC clock= HCLK/42 */ + #define ETH_MACMIIAR_CR_Div16 ((uint32_t)0x00000008) /* HCLK:20-35 MHz; MDC clock= HCLK/16 */ + #define ETH_MACMIIAR_CR_Div26 ((uint32_t)0x0000000C) /* HCLK:35-60 MHz; MDC clock= HCLK/26 */ +#define ETH_MACMIIAR_MW ((uint32_t)0x00000002) /* MII write */ +#define ETH_MACMIIAR_MB ((uint32_t)0x00000001) /* MII busy */ + +/* Bit definition for Ethernet MAC MII Data Register */ +#define ETH_MACMIIDR_MD ((uint32_t)0x0000FFFF) /* MII data: read/write data from/to PHY */ + +/* Bit definition for Ethernet MAC Flow Control Register */ +#define ETH_MACFCR_PT ((uint32_t)0xFFFF0000) /* Pause time */ +#define ETH_MACFCR_ZQPD ((uint32_t)0x00000080) /* Zero-quanta pause disable */ +#define ETH_MACFCR_PLT ((uint32_t)0x00000030) /* Pause low threshold: 4 cases */ + #define ETH_MACFCR_PLT_Minus4 ((uint32_t)0x00000000) /* Pause time minus 4 slot times */ + #define ETH_MACFCR_PLT_Minus28 ((uint32_t)0x00000010) /* Pause time minus 28 slot times */ + #define ETH_MACFCR_PLT_Minus144 ((uint32_t)0x00000020) /* Pause time minus 144 slot times */ + #define ETH_MACFCR_PLT_Minus256 ((uint32_t)0x00000030) /* Pause time minus 256 slot times */ +#define ETH_MACFCR_UPFD ((uint32_t)0x00000008) /* Unicast pause frame detect */ +#define ETH_MACFCR_RFCE ((uint32_t)0x00000004) /* Receive flow control enable */ +#define ETH_MACFCR_TFCE ((uint32_t)0x00000002) /* Transmit flow control enable */ +#define ETH_MACFCR_FCBBPA ((uint32_t)0x00000001) /* Flow control busy/backpressure activate */ + +/* Bit definition for Ethernet MAC VLAN Tag Register */ +#define ETH_MACVLANTR_VLANTC ((uint32_t)0x00010000) /* 12-bit VLAN tag comparison */ +#define ETH_MACVLANTR_VLANTI ((uint32_t)0x0000FFFF) /* VLAN tag identifier (for receive frames) */ + +/* Bit definition for Ethernet MAC Remote Wake-UpFrame Filter Register */ +#define ETH_MACRWUFFR_D ((uint32_t)0xFFFFFFFF) /* Wake-up frame filter register data */ +/* Eight sequential Writes to this address (offset 0x28) will write all Wake-UpFrame Filter Registers. + Eight sequential Reads from this address (offset 0x28) will read all Wake-UpFrame Filter Registers. */ +/* Wake-UpFrame Filter Reg0 : Filter 0 Byte Mask + Wake-UpFrame Filter Reg1 : Filter 1 Byte Mask + Wake-UpFrame Filter Reg2 : Filter 2 Byte Mask + Wake-UpFrame Filter Reg3 : Filter 3 Byte Mask + Wake-UpFrame Filter Reg4 : RSVD - Filter3 Command - RSVD - Filter2 Command - + RSVD - Filter1 Command - RSVD - Filter0 Command + Wake-UpFrame Filter Re5 : Filter3 Offset - Filter2 Offset - Filter1 Offset - Filter0 Offset + Wake-UpFrame Filter Re6 : Filter1 CRC16 - Filter0 CRC16 + Wake-UpFrame Filter Re7 : Filter3 CRC16 - Filter2 CRC16 */ + +/* Bit definition for Ethernet MAC PMT Control and Status Register */ +#define ETH_MACPMTCSR_WFFRPR ((uint32_t)0x80000000) /* Wake-Up Frame Filter Register Pointer Reset */ +#define ETH_MACPMTCSR_GU ((uint32_t)0x00000200) /* Global Unicast */ +#define ETH_MACPMTCSR_WFR ((uint32_t)0x00000040) /* Wake-Up Frame Received */ +#define ETH_MACPMTCSR_MPR ((uint32_t)0x00000020) /* Magic Packet Received */ +#define ETH_MACPMTCSR_WFE ((uint32_t)0x00000004) /* Wake-Up Frame Enable */ +#define ETH_MACPMTCSR_MPE ((uint32_t)0x00000002) /* Magic Packet Enable */ +#define ETH_MACPMTCSR_PD ((uint32_t)0x00000001) /* Power Down */ + +/* Bit definition for Ethernet MAC Status Register */ +#define ETH_MACSR_TSTS ((uint32_t)0x00000200) /* Time stamp trigger status */ +#define ETH_MACSR_MMCTS ((uint32_t)0x00000040) /* MMC transmit status */ +#define ETH_MACSR_MMMCRS ((uint32_t)0x00000020) /* MMC receive status */ +#define ETH_MACSR_MMCS ((uint32_t)0x00000010) /* MMC status */ +#define ETH_MACSR_PMTS ((uint32_t)0x00000008) /* PMT status */ + +/* Bit definition for Ethernet MAC Interrupt Mask Register */ +#define ETH_MACIMR_TSTIM ((uint32_t)0x00000200) /* Time stamp trigger interrupt mask */ +#define ETH_MACIMR_PMTIM ((uint32_t)0x00000008) /* PMT interrupt mask */ + +/* Bit definition for Ethernet MAC Address0 High Register */ +#define ETH_MACA0HR_MACA0H ((uint32_t)0x0000FFFF) /* MAC address0 high */ + +/* Bit definition for Ethernet MAC Address0 Low Register */ +#define ETH_MACA0LR_MACA0L ((uint32_t)0xFFFFFFFF) /* MAC address0 low */ + +/* Bit definition for Ethernet MAC Address1 High Register */ +#define ETH_MACA1HR_AE ((uint32_t)0x80000000) /* Address enable */ +#define ETH_MACA1HR_SA ((uint32_t)0x40000000) /* Source address */ +#define ETH_MACA1HR_MBC ((uint32_t)0x3F000000) /* Mask byte control: bits to mask for comparison of the MAC Address bytes */ + #define ETH_MACA1HR_MBC_HBits15_8 ((uint32_t)0x20000000) /* Mask MAC Address high reg bits [15:8] */ + #define ETH_MACA1HR_MBC_HBits7_0 ((uint32_t)0x10000000) /* Mask MAC Address high reg bits [7:0] */ + #define ETH_MACA1HR_MBC_LBits31_24 ((uint32_t)0x08000000) /* Mask MAC Address low reg bits [31:24] */ + #define ETH_MACA1HR_MBC_LBits23_16 ((uint32_t)0x04000000) /* Mask MAC Address low reg bits [23:16] */ + #define ETH_MACA1HR_MBC_LBits15_8 ((uint32_t)0x02000000) /* Mask MAC Address low reg bits [15:8] */ + #define ETH_MACA1HR_MBC_LBits7_0 ((uint32_t)0x01000000) /* Mask MAC Address low reg bits [7:0] */ +#define ETH_MACA1HR_MACA1H ((uint32_t)0x0000FFFF) /* MAC address1 high */ + +/* Bit definition for Ethernet MAC Address1 Low Register */ +#define ETH_MACA1LR_MACA1L ((uint32_t)0xFFFFFFFF) /* MAC address1 low */ + +/* Bit definition for Ethernet MAC Address2 High Register */ +#define ETH_MACA2HR_AE ((uint32_t)0x80000000) /* Address enable */ +#define ETH_MACA2HR_SA ((uint32_t)0x40000000) /* Source address */ +#define ETH_MACA2HR_MBC ((uint32_t)0x3F000000) /* Mask byte control */ + #define ETH_MACA2HR_MBC_HBits15_8 ((uint32_t)0x20000000) /* Mask MAC Address high reg bits [15:8] */ + #define ETH_MACA2HR_MBC_HBits7_0 ((uint32_t)0x10000000) /* Mask MAC Address high reg bits [7:0] */ + #define ETH_MACA2HR_MBC_LBits31_24 ((uint32_t)0x08000000) /* Mask MAC Address low reg bits [31:24] */ + #define ETH_MACA2HR_MBC_LBits23_16 ((uint32_t)0x04000000) /* Mask MAC Address low reg bits [23:16] */ + #define ETH_MACA2HR_MBC_LBits15_8 ((uint32_t)0x02000000) /* Mask MAC Address low reg bits [15:8] */ + #define ETH_MACA2HR_MBC_LBits7_0 ((uint32_t)0x01000000) /* Mask MAC Address low reg bits [70] */ +#define ETH_MACA2HR_MACA2H ((uint32_t)0x0000FFFF) /* MAC address1 high */ + +/* Bit definition for Ethernet MAC Address2 Low Register */ +#define ETH_MACA2LR_MACA2L ((uint32_t)0xFFFFFFFF) /* MAC address2 low */ + +/* Bit definition for Ethernet MAC Address3 High Register */ +#define ETH_MACA3HR_AE ((uint32_t)0x80000000) /* Address enable */ +#define ETH_MACA3HR_SA ((uint32_t)0x40000000) /* Source address */ +#define ETH_MACA3HR_MBC ((uint32_t)0x3F000000) /* Mask byte control */ + #define ETH_MACA3HR_MBC_HBits15_8 ((uint32_t)0x20000000) /* Mask MAC Address high reg bits [15:8] */ + #define ETH_MACA3HR_MBC_HBits7_0 ((uint32_t)0x10000000) /* Mask MAC Address high reg bits [7:0] */ + #define ETH_MACA3HR_MBC_LBits31_24 ((uint32_t)0x08000000) /* Mask MAC Address low reg bits [31:24] */ + #define ETH_MACA3HR_MBC_LBits23_16 ((uint32_t)0x04000000) /* Mask MAC Address low reg bits [23:16] */ + #define ETH_MACA3HR_MBC_LBits15_8 ((uint32_t)0x02000000) /* Mask MAC Address low reg bits [15:8] */ + #define ETH_MACA3HR_MBC_LBits7_0 ((uint32_t)0x01000000) /* Mask MAC Address low reg bits [70] */ +#define ETH_MACA3HR_MACA3H ((uint32_t)0x0000FFFF) /* MAC address3 high */ + +/* Bit definition for Ethernet MAC Address3 Low Register */ +#define ETH_MACA3LR_MACA3L ((uint32_t)0xFFFFFFFF) /* MAC address3 low */ + +/******************************************************************************/ +/* Ethernet MMC Registers bits definition */ +/******************************************************************************/ + +/* Bit definition for Ethernet MMC Contol Register */ +#define ETH_MMCCR_MCF ((uint32_t)0x00000008) /* MMC Counter Freeze */ +#define ETH_MMCCR_ROR ((uint32_t)0x00000004) /* Reset on Read */ +#define ETH_MMCCR_CSR ((uint32_t)0x00000002) /* Counter Stop Rollover */ +#define ETH_MMCCR_CR ((uint32_t)0x00000001) /* Counters Reset */ + +/* Bit definition for Ethernet MMC Receive Interrupt Register */ +#define ETH_MMCRIR_RGUFS ((uint32_t)0x00020000) /* Set when Rx good unicast frames counter reaches half the maximum value */ +#define ETH_MMCRIR_RFAES ((uint32_t)0x00000040) /* Set when Rx alignment error counter reaches half the maximum value */ +#define ETH_MMCRIR_RFCES ((uint32_t)0x00000020) /* Set when Rx crc error counter reaches half the maximum value */ + +/* Bit definition for Ethernet MMC Transmit Interrupt Register */ +#define ETH_MMCTIR_TGFS ((uint32_t)0x00200000) /* Set when Tx good frame count counter reaches half the maximum value */ +#define ETH_MMCTIR_TGFMSCS ((uint32_t)0x00008000) /* Set when Tx good multi col counter reaches half the maximum value */ +#define ETH_MMCTIR_TGFSCS ((uint32_t)0x00004000) /* Set when Tx good single col counter reaches half the maximum value */ + +/* Bit definition for Ethernet MMC Receive Interrupt Mask Register */ +#define ETH_MMCRIMR_RGUFM ((uint32_t)0x00020000) /* Mask the interrupt when Rx good unicast frames counter reaches half the maximum value */ +#define ETH_MMCRIMR_RFAEM ((uint32_t)0x00000040) /* Mask the interrupt when when Rx alignment error counter reaches half the maximum value */ +#define ETH_MMCRIMR_RFCEM ((uint32_t)0x00000020) /* Mask the interrupt when Rx crc error counter reaches half the maximum value */ + +/* Bit definition for Ethernet MMC Transmit Interrupt Mask Register */ +#define ETH_MMCTIMR_TGFM ((uint32_t)0x00200000) /* Mask the interrupt when Tx good frame count counter reaches half the maximum value */ +#define ETH_MMCTIMR_TGFMSCM ((uint32_t)0x00008000) /* Mask the interrupt when Tx good multi col counter reaches half the maximum value */ +#define ETH_MMCTIMR_TGFSCM ((uint32_t)0x00004000) /* Mask the interrupt when Tx good single col counter reaches half the maximum value */ + +/* Bit definition for Ethernet MMC Transmitted Good Frames after Single Collision Counter Register */ +#define ETH_MMCTGFSCCR_TGFSCC ((uint32_t)0xFFFFFFFF) /* Number of successfully transmitted frames after a single collision in Half-duplex mode. */ + +/* Bit definition for Ethernet MMC Transmitted Good Frames after More than a Single Collision Counter Register */ +#define ETH_MMCTGFMSCCR_TGFMSCC ((uint32_t)0xFFFFFFFF) /* Number of successfully transmitted frames after more than a single collision in Half-duplex mode. */ + +/* Bit definition for Ethernet MMC Transmitted Good Frames Counter Register */ +#define ETH_MMCTGFCR_TGFC ((uint32_t)0xFFFFFFFF) /* Number of good frames transmitted. */ + +/* Bit definition for Ethernet MMC Received Frames with CRC Error Counter Register */ +#define ETH_MMCRFCECR_RFCEC ((uint32_t)0xFFFFFFFF) /* Number of frames received with CRC error. */ + +/* Bit definition for Ethernet MMC Received Frames with Alignement Error Counter Register */ +#define ETH_MMCRFAECR_RFAEC ((uint32_t)0xFFFFFFFF) /* Number of frames received with alignment (dribble) error */ + +/* Bit definition for Ethernet MMC Received Good Unicast Frames Counter Register */ +#define ETH_MMCRGUFCR_RGUFC ((uint32_t)0xFFFFFFFF) /* Number of good unicast frames received. */ + +/******************************************************************************/ +/* Ethernet PTP Registers bits definition */ +/******************************************************************************/ + +/* Bit definition for Ethernet PTP Time Stamp Contol Register */ +#define ETH_PTPTSCR_TSARU ((uint32_t)0x00000020) /* Addend register update */ +#define ETH_PTPTSCR_TSITE ((uint32_t)0x00000010) /* Time stamp interrupt trigger enable */ +#define ETH_PTPTSCR_TSSTU ((uint32_t)0x00000008) /* Time stamp update */ +#define ETH_PTPTSCR_TSSTI ((uint32_t)0x00000004) /* Time stamp initialize */ +#define ETH_PTPTSCR_TSFCU ((uint32_t)0x00000002) /* Time stamp fine or coarse update */ +#define ETH_PTPTSCR_TSE ((uint32_t)0x00000001) /* Time stamp enable */ + +/* Bit definition for Ethernet PTP Sub-Second Increment Register */ +#define ETH_PTPSSIR_STSSI ((uint32_t)0x000000FF) /* System time Sub-second increment value */ + +/* Bit definition for Ethernet PTP Time Stamp High Register */ +#define ETH_PTPTSHR_STS ((uint32_t)0xFFFFFFFF) /* System Time second */ + +/* Bit definition for Ethernet PTP Time Stamp Low Register */ +#define ETH_PTPTSLR_STPNS ((uint32_t)0x80000000) /* System Time Positive or negative time */ +#define ETH_PTPTSLR_STSS ((uint32_t)0x7FFFFFFF) /* System Time sub-seconds */ + +/* Bit definition for Ethernet PTP Time Stamp High Update Register */ +#define ETH_PTPTSHUR_TSUS ((uint32_t)0xFFFFFFFF) /* Time stamp update seconds */ + +/* Bit definition for Ethernet PTP Time Stamp Low Update Register */ +#define ETH_PTPTSLUR_TSUPNS ((uint32_t)0x80000000) /* Time stamp update Positive or negative time */ +#define ETH_PTPTSLUR_TSUSS ((uint32_t)0x7FFFFFFF) /* Time stamp update sub-seconds */ + +/* Bit definition for Ethernet PTP Time Stamp Addend Register */ +#define ETH_PTPTSAR_TSA ((uint32_t)0xFFFFFFFF) /* Time stamp addend */ + +/* Bit definition for Ethernet PTP Target Time High Register */ +#define ETH_PTPTTHR_TTSH ((uint32_t)0xFFFFFFFF) /* Target time stamp high */ + +/* Bit definition for Ethernet PTP Target Time Low Register */ +#define ETH_PTPTTLR_TTSL ((uint32_t)0xFFFFFFFF) /* Target time stamp low */ + +/******************************************************************************/ +/* Ethernet DMA Registers bits definition */ +/******************************************************************************/ + +/* Bit definition for Ethernet DMA Bus Mode Register */ +#define ETH_DMABMR_AAB ((uint32_t)0x02000000) /* Address-Aligned beats */ +#define ETH_DMABMR_FPM ((uint32_t)0x01000000) /* 4xPBL mode */ +#define ETH_DMABMR_USP ((uint32_t)0x00800000) /* Use separate PBL */ +#define ETH_DMABMR_RDP ((uint32_t)0x007E0000) /* RxDMA PBL */ + #define ETH_DMABMR_RDP_1Beat ((uint32_t)0x00020000) /* maximum number of beats to be transferred in one RxDMA transaction is 1 */ + #define ETH_DMABMR_RDP_2Beat ((uint32_t)0x00040000) /* maximum number of beats to be transferred in one RxDMA transaction is 2 */ + #define ETH_DMABMR_RDP_4Beat ((uint32_t)0x00080000) /* maximum number of beats to be transferred in one RxDMA transaction is 4 */ + #define ETH_DMABMR_RDP_8Beat ((uint32_t)0x00100000) /* maximum number of beats to be transferred in one RxDMA transaction is 8 */ + #define ETH_DMABMR_RDP_16Beat ((uint32_t)0x00200000) /* maximum number of beats to be transferred in one RxDMA transaction is 16 */ + #define ETH_DMABMR_RDP_32Beat ((uint32_t)0x00400000) /* maximum number of beats to be transferred in one RxDMA transaction is 32 */ + #define ETH_DMABMR_RDP_4xPBL_4Beat ((uint32_t)0x01020000) /* maximum number of beats to be transferred in one RxDMA transaction is 4 */ + #define ETH_DMABMR_RDP_4xPBL_8Beat ((uint32_t)0x01040000) /* maximum number of beats to be transferred in one RxDMA transaction is 8 */ + #define ETH_DMABMR_RDP_4xPBL_16Beat ((uint32_t)0x01080000) /* maximum number of beats to be transferred in one RxDMA transaction is 16 */ + #define ETH_DMABMR_RDP_4xPBL_32Beat ((uint32_t)0x01100000) /* maximum number of beats to be transferred in one RxDMA transaction is 32 */ + #define ETH_DMABMR_RDP_4xPBL_64Beat ((uint32_t)0x01200000) /* maximum number of beats to be transferred in one RxDMA transaction is 64 */ + #define ETH_DMABMR_RDP_4xPBL_128Beat ((uint32_t)0x01400000) /* maximum number of beats to be transferred in one RxDMA transaction is 128 */ +#define ETH_DMABMR_FB ((uint32_t)0x00010000) /* Fixed Burst */ +#define ETH_DMABMR_RTPR ((uint32_t)0x0000C000) /* Rx Tx priority ratio */ + #define ETH_DMABMR_RTPR_1_1 ((uint32_t)0x00000000) /* Rx Tx priority ratio */ + #define ETH_DMABMR_RTPR_2_1 ((uint32_t)0x00004000) /* Rx Tx priority ratio */ + #define ETH_DMABMR_RTPR_3_1 ((uint32_t)0x00008000) /* Rx Tx priority ratio */ + #define ETH_DMABMR_RTPR_4_1 ((uint32_t)0x0000C000) /* Rx Tx priority ratio */ +#define ETH_DMABMR_PBL ((uint32_t)0x00003F00) /* Programmable burst length */ + #define ETH_DMABMR_PBL_1Beat ((uint32_t)0x00000100) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 1 */ + #define ETH_DMABMR_PBL_2Beat ((uint32_t)0x00000200) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 2 */ + #define ETH_DMABMR_PBL_4Beat ((uint32_t)0x00000400) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 4 */ + #define ETH_DMABMR_PBL_8Beat ((uint32_t)0x00000800) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 8 */ + #define ETH_DMABMR_PBL_16Beat ((uint32_t)0x00001000) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 16 */ + #define ETH_DMABMR_PBL_32Beat ((uint32_t)0x00002000) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 32 */ + #define ETH_DMABMR_PBL_4xPBL_4Beat ((uint32_t)0x01000100) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 4 */ + #define ETH_DMABMR_PBL_4xPBL_8Beat ((uint32_t)0x01000200) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 8 */ + #define ETH_DMABMR_PBL_4xPBL_16Beat ((uint32_t)0x01000400) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 16 */ + #define ETH_DMABMR_PBL_4xPBL_32Beat ((uint32_t)0x01000800) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 32 */ + #define ETH_DMABMR_PBL_4xPBL_64Beat ((uint32_t)0x01001000) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 64 */ + #define ETH_DMABMR_PBL_4xPBL_128Beat ((uint32_t)0x01002000) /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 128 */ +#define ETH_DMABMR_DSL ((uint32_t)0x0000007C) /* Descriptor Skip Length */ +#define ETH_DMABMR_DA ((uint32_t)0x00000002) /* DMA arbitration scheme */ +#define ETH_DMABMR_SR ((uint32_t)0x00000001) /* Software reset */ + +/* Bit definition for Ethernet DMA Transmit Poll Demand Register */ +#define ETH_DMATPDR_TPD ((uint32_t)0xFFFFFFFF) /* Transmit poll demand */ + +/* Bit definition for Ethernet DMA Receive Poll Demand Register */ +#define ETH_DMARPDR_RPD ((uint32_t)0xFFFFFFFF) /* Receive poll demand */ + +/* Bit definition for Ethernet DMA Receive Descriptor List Address Register */ +#define ETH_DMARDLAR_SRL ((uint32_t)0xFFFFFFFF) /* Start of receive list */ + +/* Bit definition for Ethernet DMA Transmit Descriptor List Address Register */ +#define ETH_DMATDLAR_STL ((uint32_t)0xFFFFFFFF) /* Start of transmit list */ + +/* Bit definition for Ethernet DMA Status Register */ +#define ETH_DMASR_TSTS ((uint32_t)0x20000000) /* Time-stamp trigger status */ +#define ETH_DMASR_PMTS ((uint32_t)0x10000000) /* PMT status */ +#define ETH_DMASR_MMCS ((uint32_t)0x08000000) /* MMC status */ +#define ETH_DMASR_EBS ((uint32_t)0x03800000) /* Error bits status */ + /* combination with EBS[2:0] for GetFlagStatus function */ + #define ETH_DMASR_EBS_DescAccess ((uint32_t)0x02000000) /* Error bits 0-data buffer, 1-desc. access */ + #define ETH_DMASR_EBS_ReadTransf ((uint32_t)0x01000000) /* Error bits 0-write trnsf, 1-read transfr */ + #define ETH_DMASR_EBS_DataTransfTx ((uint32_t)0x00800000) /* Error bits 0-Rx DMA, 1-Tx DMA */ +#define ETH_DMASR_TPS ((uint32_t)0x00700000) /* Transmit process state */ + #define ETH_DMASR_TPS_Stopped ((uint32_t)0x00000000) /* Stopped - Reset or Stop Tx Command issued */ + #define ETH_DMASR_TPS_Fetching ((uint32_t)0x00100000) /* Running - fetching the Tx descriptor */ + #define ETH_DMASR_TPS_Waiting ((uint32_t)0x00200000) /* Running - waiting for status */ + #define ETH_DMASR_TPS_Reading ((uint32_t)0x00300000) /* Running - reading the data from host memory */ + #define ETH_DMASR_TPS_Suspended ((uint32_t)0x00600000) /* Suspended - Tx Descriptor unavailabe */ + #define ETH_DMASR_TPS_Closing ((uint32_t)0x00700000) /* Running - closing Rx descriptor */ +#define ETH_DMASR_RPS ((uint32_t)0x000E0000) /* Receive process state */ + #define ETH_DMASR_RPS_Stopped ((uint32_t)0x00000000) /* Stopped - Reset or Stop Rx Command issued */ + #define ETH_DMASR_RPS_Fetching ((uint32_t)0x00020000) /* Running - fetching the Rx descriptor */ + #define ETH_DMASR_RPS_Waiting ((uint32_t)0x00060000) /* Running - waiting for packet */ + #define ETH_DMASR_RPS_Suspended ((uint32_t)0x00080000) /* Suspended - Rx Descriptor unavailable */ + #define ETH_DMASR_RPS_Closing ((uint32_t)0x000A0000) /* Running - closing descriptor */ + #define ETH_DMASR_RPS_Queuing ((uint32_t)0x000E0000) /* Running - queuing the recieve frame into host memory */ +#define ETH_DMASR_NIS ((uint32_t)0x00010000) /* Normal interrupt summary */ +#define ETH_DMASR_AIS ((uint32_t)0x00008000) /* Abnormal interrupt summary */ +#define ETH_DMASR_ERS ((uint32_t)0x00004000) /* Early receive status */ +#define ETH_DMASR_FBES ((uint32_t)0x00002000) /* Fatal bus error status */ +#define ETH_DMASR_ETS ((uint32_t)0x00000400) /* Early transmit status */ +#define ETH_DMASR_RWTS ((uint32_t)0x00000200) /* Receive watchdog timeout status */ +#define ETH_DMASR_RPSS ((uint32_t)0x00000100) /* Receive process stopped status */ +#define ETH_DMASR_RBUS ((uint32_t)0x00000080) /* Receive buffer unavailable status */ +#define ETH_DMASR_RS ((uint32_t)0x00000040) /* Receive status */ +#define ETH_DMASR_TUS ((uint32_t)0x00000020) /* Transmit underflow status */ +#define ETH_DMASR_ROS ((uint32_t)0x00000010) /* Receive overflow status */ +#define ETH_DMASR_TJTS ((uint32_t)0x00000008) /* Transmit jabber timeout status */ +#define ETH_DMASR_TBUS ((uint32_t)0x00000004) /* Transmit buffer unavailable status */ +#define ETH_DMASR_TPSS ((uint32_t)0x00000002) /* Transmit process stopped status */ +#define ETH_DMASR_TS ((uint32_t)0x00000001) /* Transmit status */ + +/* Bit definition for Ethernet DMA Operation Mode Register */ +#define ETH_DMAOMR_DTCEFD ((uint32_t)0x04000000) /* Disable Dropping of TCP/IP checksum error frames */ +#define ETH_DMAOMR_RSF ((uint32_t)0x02000000) /* Receive store and forward */ +#define ETH_DMAOMR_DFRF ((uint32_t)0x01000000) /* Disable flushing of received frames */ +#define ETH_DMAOMR_TSF ((uint32_t)0x00200000) /* Transmit store and forward */ +#define ETH_DMAOMR_FTF ((uint32_t)0x00100000) /* Flush transmit FIFO */ +#define ETH_DMAOMR_TTC ((uint32_t)0x0001C000) /* Transmit threshold control */ + #define ETH_DMAOMR_TTC_64Bytes ((uint32_t)0x00000000) /* threshold level of the MTL Transmit FIFO is 64 Bytes */ + #define ETH_DMAOMR_TTC_128Bytes ((uint32_t)0x00004000) /* threshold level of the MTL Transmit FIFO is 128 Bytes */ + #define ETH_DMAOMR_TTC_192Bytes ((uint32_t)0x00008000) /* threshold level of the MTL Transmit FIFO is 192 Bytes */ + #define ETH_DMAOMR_TTC_256Bytes ((uint32_t)0x0000C000) /* threshold level of the MTL Transmit FIFO is 256 Bytes */ + #define ETH_DMAOMR_TTC_40Bytes ((uint32_t)0x00010000) /* threshold level of the MTL Transmit FIFO is 40 Bytes */ + #define ETH_DMAOMR_TTC_32Bytes ((uint32_t)0x00014000) /* threshold level of the MTL Transmit FIFO is 32 Bytes */ + #define ETH_DMAOMR_TTC_24Bytes ((uint32_t)0x00018000) /* threshold level of the MTL Transmit FIFO is 24 Bytes */ + #define ETH_DMAOMR_TTC_16Bytes ((uint32_t)0x0001C000) /* threshold level of the MTL Transmit FIFO is 16 Bytes */ +#define ETH_DMAOMR_ST ((uint32_t)0x00002000) /* Start/stop transmission command */ +#define ETH_DMAOMR_FEF ((uint32_t)0x00000080) /* Forward error frames */ +#define ETH_DMAOMR_FUGF ((uint32_t)0x00000040) /* Forward undersized good frames */ +#define ETH_DMAOMR_RTC ((uint32_t)0x00000018) /* receive threshold control */ + #define ETH_DMAOMR_RTC_64Bytes ((uint32_t)0x00000000) /* threshold level of the MTL Receive FIFO is 64 Bytes */ + #define ETH_DMAOMR_RTC_32Bytes ((uint32_t)0x00000008) /* threshold level of the MTL Receive FIFO is 32 Bytes */ + #define ETH_DMAOMR_RTC_96Bytes ((uint32_t)0x00000010) /* threshold level of the MTL Receive FIFO is 96 Bytes */ + #define ETH_DMAOMR_RTC_128Bytes ((uint32_t)0x00000018) /* threshold level of the MTL Receive FIFO is 128 Bytes */ +#define ETH_DMAOMR_OSF ((uint32_t)0x00000004) /* operate on second frame */ +#define ETH_DMAOMR_SR ((uint32_t)0x00000002) /* Start/stop receive */ + +/* Bit definition for Ethernet DMA Interrupt Enable Register */ +#define ETH_DMAIER_NISE ((uint32_t)0x00010000) /* Normal interrupt summary enable */ +#define ETH_DMAIER_AISE ((uint32_t)0x00008000) /* Abnormal interrupt summary enable */ +#define ETH_DMAIER_ERIE ((uint32_t)0x00004000) /* Early receive interrupt enable */ +#define ETH_DMAIER_FBEIE ((uint32_t)0x00002000) /* Fatal bus error interrupt enable */ +#define ETH_DMAIER_ETIE ((uint32_t)0x00000400) /* Early transmit interrupt enable */ +#define ETH_DMAIER_RWTIE ((uint32_t)0x00000200) /* Receive watchdog timeout interrupt enable */ +#define ETH_DMAIER_RPSIE ((uint32_t)0x00000100) /* Receive process stopped interrupt enable */ +#define ETH_DMAIER_RBUIE ((uint32_t)0x00000080) /* Receive buffer unavailable interrupt enable */ +#define ETH_DMAIER_RIE ((uint32_t)0x00000040) /* Receive interrupt enable */ +#define ETH_DMAIER_TUIE ((uint32_t)0x00000020) /* Transmit Underflow interrupt enable */ +#define ETH_DMAIER_ROIE ((uint32_t)0x00000010) /* Receive Overflow interrupt enable */ +#define ETH_DMAIER_TJTIE ((uint32_t)0x00000008) /* Transmit jabber timeout interrupt enable */ +#define ETH_DMAIER_TBUIE ((uint32_t)0x00000004) /* Transmit buffer unavailable interrupt enable */ +#define ETH_DMAIER_TPSIE ((uint32_t)0x00000002) /* Transmit process stopped interrupt enable */ +#define ETH_DMAIER_TIE ((uint32_t)0x00000001) /* Transmit interrupt enable */ + +/* Bit definition for Ethernet DMA Missed Frame and Buffer Overflow Counter Register */ +#define ETH_DMAMFBOCR_OFOC ((uint32_t)0x10000000) /* Overflow bit for FIFO overflow counter */ +#define ETH_DMAMFBOCR_MFA ((uint32_t)0x0FFE0000) /* Number of frames missed by the application */ +#define ETH_DMAMFBOCR_OMFC ((uint32_t)0x00010000) /* Overflow bit for missed frame counter */ +#define ETH_DMAMFBOCR_MFC ((uint32_t)0x0000FFFF) /* Number of frames missed by the controller */ + +/* Bit definition for Ethernet DMA Current Host Transmit Descriptor Register */ +#define ETH_DMACHTDR_HTDAP ((uint32_t)0xFFFFFFFF) /* Host transmit descriptor address pointer */ + +/* Bit definition for Ethernet DMA Current Host Receive Descriptor Register */ +#define ETH_DMACHRDR_HRDAP ((uint32_t)0xFFFFFFFF) /* Host receive descriptor address pointer */ + +/* Bit definition for Ethernet DMA Current Host Transmit Buffer Address Register */ +#define ETH_DMACHTBAR_HTBAP ((uint32_t)0xFFFFFFFF) /* Host transmit buffer address pointer */ + +/* Bit definition for Ethernet DMA Current Host Receive Buffer Address Register */ +#define ETH_DMACHRBAR_HRBAP ((uint32_t)0xFFFFFFFF) /* Host receive buffer address pointer */ +#endif /* STM32F10X_CL */ + +/** + * @} + */ + + /** + * @} + */ + +#ifdef USE_STDPERIPH_DRIVER + #include "stm32f10x_conf.h" +#endif + +/** @addtogroup Exported_macro + * @{ + */ + +#define SET_BIT(REG, BIT) ((REG) |= (BIT)) + +#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) + +#define READ_BIT(REG, BIT) ((REG) & (BIT)) + +#define CLEAR_REG(REG) ((REG) = (0x0)) + +#define WRITE_REG(REG, VAL) ((REG) = (VAL)) + +#define READ_REG(REG) ((REG)) + +#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_H */ + +/** + * @} + */ + + /** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/CMSIS/system_stm32f10x.c b/STM32_4路称重_Git提交精简工程/src/CMSIS/system_stm32f10x.c new file mode 100755 index 0000000..c131ee8 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/CMSIS/system_stm32f10x.c @@ -0,0 +1,1094 @@ +/** + ****************************************************************************** + * @file GPIO/IOToggle/system_stm32f10x.c + * @author MCD Application Team + * @version V3.5.0 + * @date 08-April-2011 + * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. + * + * 1. This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier + * factors, AHB/APBx prescalers and Flash settings). + * This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32f10x_xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * 2. After each device reset the HSI (8 MHz) is used as system clock source. + * Then SystemInit() function is called, in "startup_stm32f10x_xx.s" file, to + * configure the system clock before to branch to main program. + * + * 3. If the system clock source selected by user fails to startup, the SystemInit() + * function will do nothing and HSI still used as system clock source. User can + * add some code to deal with this issue inside the SetSysClock() function. + * + * 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depedning on + * the product used), refer to "HSE_VALUE" define in "stm32f10x.h" file. + * When HSE is used as system clock source, directly or through PLL, and you + * are using different crystal you have to adapt the HSE value to your own + * configuration. + * + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32f10x_system + * @{ + */ + +/** @addtogroup STM32F10x_System_Private_Includes + * @{ + */ + +#include "stm32f10x.h" + +/** + * @} + */ + +/** @addtogroup STM32F10x_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F10x_System_Private_Defines + * @{ + */ + +/*!< Uncomment the line corresponding to the desired System clock (SYSCLK) + frequency (after reset the HSI is used as SYSCLK source) + + IMPORTANT NOTE: + ============== + 1. After each device reset the HSI is used as System clock source. + + 2. Please make sure that the selected System clock doesn't exceed your device's + maximum frequency. + + 3. If none of the define below is enabled, the HSI is used as System clock + source. + + 4. The System clock configuration functions provided within this file assume that: + - For Low, Medium and High density Value line devices an external 8MHz + crystal is used to drive the System clock. + - For Low, Medium and High density devices an external 8MHz crystal is + used to drive the System clock. + - For Connectivity line devices an external 25MHz crystal is used to drive + the System clock. + If you are using different crystal you have to adapt those functions accordingly. + */ + +#if defined (STM32F10X_LD_VL) || (defined STM32F10X_MD_VL) || (defined STM32F10X_HD_VL) +/* #define SYSCLK_FREQ_HSE HSE_VALUE */ + #define SYSCLK_FREQ_24MHz 24000000 +#else +/* #define SYSCLK_FREQ_HSE HSE_VALUE */ +/* #define SYSCLK_FREQ_24MHz 24000000 */ +/* #define SYSCLK_FREQ_36MHz 36000000 */ +/* #define SYSCLK_FREQ_48MHz 48000000 */ +/* #define SYSCLK_FREQ_56MHz 56000000 */ +#define SYSCLK_FREQ_72MHz 72000000 +#endif + +/*!< Uncomment the following line if you need to use external SRAM mounted + on STM3210E-EVAL board (STM32 High density and XL-density devices) or on + STM32100E-EVAL board (STM32 High-density value line devices) as data memory */ +#if defined (STM32F10X_HD) || (defined STM32F10X_XL) || (defined STM32F10X_HD_VL) +/* #define DATA_IN_ExtSRAM */ +#endif + +/*!< Uncomment the following line if you need to relocate your vector Table in + Internal SRAM. */ +/* #define VECT_TAB_SRAM */ +#define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ + + +/** + * @} + */ + +/** @addtogroup STM32F10x_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F10x_System_Private_Variables + * @{ + */ + +/******************************************************************************* +* Clock Definitions +*******************************************************************************/ +#ifdef SYSCLK_FREQ_HSE + uint32_t SystemCoreClock = SYSCLK_FREQ_HSE; /*!< System Clock Frequency (Core Clock) */ +#elif defined SYSCLK_FREQ_24MHz + uint32_t SystemCoreClock = SYSCLK_FREQ_24MHz; /*!< System Clock Frequency (Core Clock) */ +#elif defined SYSCLK_FREQ_36MHz + uint32_t SystemCoreClock = SYSCLK_FREQ_36MHz; /*!< System Clock Frequency (Core Clock) */ +#elif defined SYSCLK_FREQ_48MHz + uint32_t SystemCoreClock = SYSCLK_FREQ_48MHz; /*!< System Clock Frequency (Core Clock) */ +#elif defined SYSCLK_FREQ_56MHz + uint32_t SystemCoreClock = SYSCLK_FREQ_56MHz; /*!< System Clock Frequency (Core Clock) */ +#elif defined SYSCLK_FREQ_72MHz + uint32_t SystemCoreClock = SYSCLK_FREQ_72MHz; /*!< System Clock Frequency (Core Clock) */ +#else /*!< HSI Selected as System Clock source */ + uint32_t SystemCoreClock = HSI_VALUE; /*!< System Clock Frequency (Core Clock) */ +#endif + +__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; +/** + * @} + */ + +/** @addtogroup STM32F10x_System_Private_FunctionPrototypes + * @{ + */ + +static void SetSysClock(void); + +#ifdef SYSCLK_FREQ_HSE + static void SetSysClockToHSE(void); +#elif defined SYSCLK_FREQ_24MHz + static void SetSysClockTo24(void); +#elif defined SYSCLK_FREQ_36MHz + static void SetSysClockTo36(void); +#elif defined SYSCLK_FREQ_48MHz + static void SetSysClockTo48(void); +#elif defined SYSCLK_FREQ_56MHz + static void SetSysClockTo56(void); +#elif defined SYSCLK_FREQ_72MHz + static void SetSysClockTo72(void); +#endif + +#ifdef DATA_IN_ExtSRAM + static void SystemInit_ExtMemCtl(void); +#endif /* DATA_IN_ExtSRAM */ + +/** + * @} + */ + +/** @addtogroup STM32F10x_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system + * Initialize the Embedded Flash Interface, the PLL and update the + * SystemCoreClock variable. + * @note This function should be used only after reset. + * @param None + * @retval None + */ +void SystemInit (void) +{ + /* Reset the RCC clock configuration to the default reset state(for debug purpose) */ + /* Set HSION bit */ + RCC->CR |= (uint32_t)0x00000001; + + /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ +#ifndef STM32F10X_CL + RCC->CFGR &= (uint32_t)0xF8FF0000; +#else + RCC->CFGR &= (uint32_t)0xF0FF0000; +#endif /* STM32F10X_CL */ + + /* Reset HSEON, CSSON and PLLON bits */ + RCC->CR &= (uint32_t)0xFEF6FFFF; + + /* Reset HSEBYP bit */ + RCC->CR &= (uint32_t)0xFFFBFFFF; + + /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ + RCC->CFGR &= (uint32_t)0xFF80FFFF; + +#ifdef STM32F10X_CL + /* Reset PLL2ON and PLL3ON bits */ + RCC->CR &= (uint32_t)0xEBFFFFFF; + + /* Disable all interrupts and clear pending bits */ + RCC->CIR = 0x00FF0000; + + /* Reset CFGR2 register */ + RCC->CFGR2 = 0x00000000; +#elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || (defined STM32F10X_HD_VL) + /* Disable all interrupts and clear pending bits */ + RCC->CIR = 0x009F0000; + + /* Reset CFGR2 register */ + RCC->CFGR2 = 0x00000000; +#else + /* Disable all interrupts and clear pending bits */ + RCC->CIR = 0x009F0000; +#endif /* STM32F10X_CL */ + +#if defined (STM32F10X_HD) || (defined STM32F10X_XL) || (defined STM32F10X_HD_VL) + #ifdef DATA_IN_ExtSRAM + SystemInit_ExtMemCtl(); + #endif /* DATA_IN_ExtSRAM */ +#endif + + /* Configure the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers */ + /* Configure the Flash Latency cycles and enable prefetch buffer */ + SetSysClock(); + +#ifdef VECT_TAB_SRAM + SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ +#else + SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ +#endif +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) + * or HSI_VALUE(*) multiplied by the PLL factors. + * + * (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value + * 8 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value + * 8 MHz or 25 MHz, depedning on the product used), user has to ensure + * that HSE_VALUE is same as the real frequency of the crystal used. + * Otherwise, this function may have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * @param None + * @retval None + */ +void SystemCoreClockUpdate (void) +{ + uint32_t tmp = 0, pllmull = 0, pllsource = 0; + +#ifdef STM32F10X_CL + uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0; +#endif /* STM32F10X_CL */ + +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || (defined STM32F10X_HD_VL) + uint32_t prediv1factor = 0; +#endif /* STM32F10X_LD_VL or STM32F10X_MD_VL or STM32F10X_HD_VL */ + + /* Get SYSCLK source -------------------------------------------------------*/ + tmp = RCC->CFGR & RCC_CFGR_SWS; + + switch (tmp) + { + case 0x00: /* HSI used as system clock */ + SystemCoreClock = HSI_VALUE; + break; + case 0x04: /* HSE used as system clock */ + SystemCoreClock = HSE_VALUE; + break; + case 0x08: /* PLL used as system clock */ + + /* Get PLL clock source and multiplication factor ----------------------*/ + pllmull = RCC->CFGR & RCC_CFGR_PLLMULL; + pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; + +#ifndef STM32F10X_CL + pllmull = ( pllmull >> 18) + 2; + + if (pllsource == 0x00) + { + /* HSI oscillator clock divided by 2 selected as PLL clock entry */ + SystemCoreClock = (HSI_VALUE >> 1) * pllmull; + } + else + { + #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || (defined STM32F10X_HD_VL) + prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; + /* HSE oscillator clock selected as PREDIV1 clock entry */ + SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; + #else + /* HSE selected as PLL clock entry */ + if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET) + {/* HSE oscillator clock divided by 2 */ + SystemCoreClock = (HSE_VALUE >> 1) * pllmull; + } + else + { + SystemCoreClock = HSE_VALUE * pllmull; + } + #endif + } +#else + pllmull = pllmull >> 18; + + if (pllmull != 0x0D) + { + pllmull += 2; + } + else + { /* PLL multiplication factor = PLL input clock * 6.5 */ + pllmull = 13 / 2; + } + + if (pllsource == 0x00) + { + /* HSI oscillator clock divided by 2 selected as PLL clock entry */ + SystemCoreClock = (HSI_VALUE >> 1) * pllmull; + } + else + {/* PREDIV1 selected as PLL clock entry */ + + /* Get PREDIV1 clock source and division factor */ + prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC; + prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; + + if (prediv1source == 0) + { + /* HSE oscillator clock selected as PREDIV1 clock entry */ + SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; + } + else + {/* PLL2 clock selected as PREDIV1 clock entry */ + + /* Get PREDIV2 division factor and PLL2 multiplication factor */ + prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4) + 1; + pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8 ) + 2; + SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull; + } + } +#endif /* STM32F10X_CL */ + break; + + default: + SystemCoreClock = HSI_VALUE; + break; + } + + /* Compute HCLK clock frequency ----------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; + /* HCLK clock frequency */ + SystemCoreClock >>= tmp; +} + +/** + * @brief Configures the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers. + * @param None + * @retval None + */ +static void SetSysClock(void) +{ +#ifdef SYSCLK_FREQ_HSE + SetSysClockToHSE(); +#elif defined SYSCLK_FREQ_24MHz + SetSysClockTo24(); +#elif defined SYSCLK_FREQ_36MHz + SetSysClockTo36(); +#elif defined SYSCLK_FREQ_48MHz + SetSysClockTo48(); +#elif defined SYSCLK_FREQ_56MHz + SetSysClockTo56(); +#elif defined SYSCLK_FREQ_72MHz + SetSysClockTo72(); +#endif + + /* If none of the define above is enabled, the HSI is used as System clock + source (default after reset) */ +} + +/** + * @brief Setup the external memory controller. Called in startup_stm32f10x.s + * before jump to __main + * @param None + * @retval None + */ +#ifdef DATA_IN_ExtSRAM +/** + * @brief Setup the external memory controller. + * Called in startup_stm32f10x_xx.s/.c before jump to main. + * This function configures the external SRAM mounted on STM3210E-EVAL + * board (STM32 High density devices). This SRAM will be used as program + * data memory (including heap and stack). + * @param None + * @retval None + */ +void SystemInit_ExtMemCtl(void) +{ +/*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is + required, then adjust the Register Addresses */ + + /* Enable FSMC clock */ + RCC->AHBENR = 0x00000114; + + /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */ + RCC->APB2ENR = 0x000001E0; + +/* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/ +/*---------------- SRAM Address lines configuration -------------------------*/ +/*---------------- NOE and NWE configuration --------------------------------*/ +/*---------------- NE3 configuration ----------------------------------------*/ +/*---------------- NBL0, NBL1 configuration ---------------------------------*/ + + GPIOD->CRL = 0x44BB44BB; + GPIOD->CRH = 0xBBBBBBBB; + + GPIOE->CRL = 0xB44444BB; + GPIOE->CRH = 0xBBBBBBBB; + + GPIOF->CRL = 0x44BBBBBB; + GPIOF->CRH = 0xBBBB4444; + + GPIOG->CRL = 0x44BBBBBB; + GPIOG->CRH = 0x44444B44; + +/*---------------- FSMC Configuration ---------------------------------------*/ +/*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/ + + FSMC_Bank1->BTCR[4] = 0x00001011; + FSMC_Bank1->BTCR[5] = 0x00000200; +} +#endif /* DATA_IN_ExtSRAM */ + +#ifdef SYSCLK_FREQ_HSE +/** + * @brief Selects HSE as System clock source and configure HCLK, PCLK2 + * and PCLK1 prescalers. + * @note This function should be used only after reset. + * @param None + * @retval None + */ +static void SetSysClockToHSE(void) +{ + __IO uint32_t StartUpCounter = 0, HSEStatus = 0; + + /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration ---------------------------*/ + /* Enable HSE */ + RCC->CR |= ((uint32_t)RCC_CR_HSEON); + + /* Wait till HSE is ready and if Time out is reached exit */ + do + { + HSEStatus = RCC->CR & RCC_CR_HSERDY; + StartUpCounter++; + } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT)); + + if ((RCC->CR & RCC_CR_HSERDY) != RESET) + { + HSEStatus = (uint32_t)0x01; + } + else + { + HSEStatus = (uint32_t)0x00; + } + + if (HSEStatus == (uint32_t)0x01) + { + +#if !defined STM32F10X_LD_VL && !defined STM32F10X_MD_VL && !defined STM32F10X_HD_VL + /* Enable Prefetch Buffer */ + FLASH->ACR |= FLASH_ACR_PRFTBE; + + /* Flash 0 wait state */ + FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY); + +#ifndef STM32F10X_CL + FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_0; +#else + if (HSE_VALUE <= 24000000) + { + FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_0; + } + else + { + FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_1; + } +#endif /* STM32F10X_CL */ +#endif + + /* HCLK = SYSCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1; + + /* PCLK2 = HCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1; + + /* PCLK1 = HCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV1; + + /* Select HSE as system clock source */ + RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); + RCC->CFGR |= (uint32_t)RCC_CFGR_SW_HSE; + + /* Wait till HSE is used as system clock source */ + while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x04) + { + } + } + else + { /* If HSE fails to start-up, the application will have wrong clock + configuration. User can add here some code to deal with this error */ + } +} +#elif defined SYSCLK_FREQ_24MHz +/** + * @brief Sets System clock frequency to 24MHz and configure HCLK, PCLK2 + * and PCLK1 prescalers. + * @note This function should be used only after reset. + * @param None + * @retval None + */ +static void SetSysClockTo24(void) +{ + __IO uint32_t StartUpCounter = 0, HSEStatus = 0; + + /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration ---------------------------*/ + /* Enable HSE */ + RCC->CR |= ((uint32_t)RCC_CR_HSEON); + + /* Wait till HSE is ready and if Time out is reached exit */ + do + { + HSEStatus = RCC->CR & RCC_CR_HSERDY; + StartUpCounter++; + } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT)); + + if ((RCC->CR & RCC_CR_HSERDY) != RESET) + { + HSEStatus = (uint32_t)0x01; + } + else + { + HSEStatus = (uint32_t)0x00; + } + + if (HSEStatus == (uint32_t)0x01) + { +#if !defined STM32F10X_LD_VL && !defined STM32F10X_MD_VL && !defined STM32F10X_HD_VL + /* Enable Prefetch Buffer */ + FLASH->ACR |= FLASH_ACR_PRFTBE; + + /* Flash 0 wait state */ + FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY); + FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_0; +#endif + + /* HCLK = SYSCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1; + + /* PCLK2 = HCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1; + + /* PCLK1 = HCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV1; + +#ifdef STM32F10X_CL + /* Configure PLLs ------------------------------------------------------*/ + /* PLL configuration: PLLCLK = PREDIV1 * 6 = 24 MHz */ + RCC->CFGR &= (uint32_t)~(RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL); + RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLSRC_PREDIV1 | + RCC_CFGR_PLLMULL6); + + /* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */ + /* PREDIV1 configuration: PREDIV1CLK = PLL2 / 10 = 4 MHz */ + RCC->CFGR2 &= (uint32_t)~(RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL | + RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC); + RCC->CFGR2 |= (uint32_t)(RCC_CFGR2_PREDIV2_DIV5 | RCC_CFGR2_PLL2MUL8 | + RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV10); + + /* Enable PLL2 */ + RCC->CR |= RCC_CR_PLL2ON; + /* Wait till PLL2 is ready */ + while((RCC->CR & RCC_CR_PLL2RDY) == 0) + { + } +#elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) + /* PLL configuration: = (HSE / 2) * 6 = 24 MHz */ + RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL)); + RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_PREDIV1 | RCC_CFGR_PLLXTPRE_PREDIV1_Div2 | RCC_CFGR_PLLMULL6); +#else + /* PLL configuration: = (HSE / 2) * 6 = 24 MHz */ + RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL)); + RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLXTPRE_HSE_Div2 | RCC_CFGR_PLLMULL6); +#endif /* STM32F10X_CL */ + + /* Enable PLL */ + RCC->CR |= RCC_CR_PLLON; + + /* Wait till PLL is ready */ + while((RCC->CR & RCC_CR_PLLRDY) == 0) + { + } + + /* Select PLL as system clock source */ + RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); + RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL; + + /* Wait till PLL is used as system clock source */ + while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08) + { + } + } + else + { /* If HSE fails to start-up, the application will have wrong clock + configuration. User can add here some code to deal with this error */ + } +} +#elif defined SYSCLK_FREQ_36MHz +/** + * @brief Sets System clock frequency to 36MHz and configure HCLK, PCLK2 + * and PCLK1 prescalers. + * @note This function should be used only after reset. + * @param None + * @retval None + */ +static void SetSysClockTo36(void) +{ + __IO uint32_t StartUpCounter = 0, HSEStatus = 0; + + /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration ---------------------------*/ + /* Enable HSE */ + RCC->CR |= ((uint32_t)RCC_CR_HSEON); + + /* Wait till HSE is ready and if Time out is reached exit */ + do + { + HSEStatus = RCC->CR & RCC_CR_HSERDY; + StartUpCounter++; + } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT)); + + if ((RCC->CR & RCC_CR_HSERDY) != RESET) + { + HSEStatus = (uint32_t)0x01; + } + else + { + HSEStatus = (uint32_t)0x00; + } + + if (HSEStatus == (uint32_t)0x01) + { + /* Enable Prefetch Buffer */ + FLASH->ACR |= FLASH_ACR_PRFTBE; + + /* Flash 1 wait state */ + FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY); + FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_1; + + /* HCLK = SYSCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1; + + /* PCLK2 = HCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1; + + /* PCLK1 = HCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV1; + +#ifdef STM32F10X_CL + /* Configure PLLs ------------------------------------------------------*/ + + /* PLL configuration: PLLCLK = PREDIV1 * 9 = 36 MHz */ + RCC->CFGR &= (uint32_t)~(RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL); + RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLSRC_PREDIV1 | + RCC_CFGR_PLLMULL9); + + /*!< PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */ + /* PREDIV1 configuration: PREDIV1CLK = PLL2 / 10 = 4 MHz */ + + RCC->CFGR2 &= (uint32_t)~(RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL | + RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC); + RCC->CFGR2 |= (uint32_t)(RCC_CFGR2_PREDIV2_DIV5 | RCC_CFGR2_PLL2MUL8 | + RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV10); + + /* Enable PLL2 */ + RCC->CR |= RCC_CR_PLL2ON; + /* Wait till PLL2 is ready */ + while((RCC->CR & RCC_CR_PLL2RDY) == 0) + { + } + +#else + /* PLL configuration: PLLCLK = (HSE / 2) * 9 = 36 MHz */ + RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL)); + RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLXTPRE_HSE_Div2 | RCC_CFGR_PLLMULL9); +#endif /* STM32F10X_CL */ + + /* Enable PLL */ + RCC->CR |= RCC_CR_PLLON; + + /* Wait till PLL is ready */ + while((RCC->CR & RCC_CR_PLLRDY) == 0) + { + } + + /* Select PLL as system clock source */ + RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); + RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL; + + /* Wait till PLL is used as system clock source */ + while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08) + { + } + } + else + { /* If HSE fails to start-up, the application will have wrong clock + configuration. User can add here some code to deal with this error */ + } +} +#elif defined SYSCLK_FREQ_48MHz +/** + * @brief Sets System clock frequency to 48MHz and configure HCLK, PCLK2 + * and PCLK1 prescalers. + * @note This function should be used only after reset. + * @param None + * @retval None + */ +static void SetSysClockTo48(void) +{ + __IO uint32_t StartUpCounter = 0, HSEStatus = 0; + + /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration ---------------------------*/ + /* Enable HSE */ + RCC->CR |= ((uint32_t)RCC_CR_HSEON); + + /* Wait till HSE is ready and if Time out is reached exit */ + do + { + HSEStatus = RCC->CR & RCC_CR_HSERDY; + StartUpCounter++; + } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT)); + + if ((RCC->CR & RCC_CR_HSERDY) != RESET) + { + HSEStatus = (uint32_t)0x01; + } + else + { + HSEStatus = (uint32_t)0x00; + } + + if (HSEStatus == (uint32_t)0x01) + { + /* Enable Prefetch Buffer */ + FLASH->ACR |= FLASH_ACR_PRFTBE; + + /* Flash 1 wait state */ + FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY); + FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_1; + + /* HCLK = SYSCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1; + + /* PCLK2 = HCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1; + + /* PCLK1 = HCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV2; + +#ifdef STM32F10X_CL + /* Configure PLLs ------------------------------------------------------*/ + /* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */ + /* PREDIV1 configuration: PREDIV1CLK = PLL2 / 5 = 8 MHz */ + + RCC->CFGR2 &= (uint32_t)~(RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL | + RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC); + RCC->CFGR2 |= (uint32_t)(RCC_CFGR2_PREDIV2_DIV5 | RCC_CFGR2_PLL2MUL8 | + RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV5); + + /* Enable PLL2 */ + RCC->CR |= RCC_CR_PLL2ON; + /* Wait till PLL2 is ready */ + while((RCC->CR & RCC_CR_PLL2RDY) == 0) + { + } + + + /* PLL configuration: PLLCLK = PREDIV1 * 6 = 48 MHz */ + RCC->CFGR &= (uint32_t)~(RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL); + RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLSRC_PREDIV1 | + RCC_CFGR_PLLMULL6); +#else + /* PLL configuration: PLLCLK = HSE * 6 = 48 MHz */ + RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL)); + RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLMULL6); +#endif /* STM32F10X_CL */ + + /* Enable PLL */ + RCC->CR |= RCC_CR_PLLON; + + /* Wait till PLL is ready */ + while((RCC->CR & RCC_CR_PLLRDY) == 0) + { + } + + /* Select PLL as system clock source */ + RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); + RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL; + + /* Wait till PLL is used as system clock source */ + while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08) + { + } + } + else + { /* If HSE fails to start-up, the application will have wrong clock + configuration. User can add here some code to deal with this error */ + } +} + +#elif defined SYSCLK_FREQ_56MHz +/** + * @brief Sets System clock frequency to 56MHz and configure HCLK, PCLK2 + * and PCLK1 prescalers. + * @note This function should be used only after reset. + * @param None + * @retval None + */ +static void SetSysClockTo56(void) +{ + __IO uint32_t StartUpCounter = 0, HSEStatus = 0; + + /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration ---------------------------*/ + /* Enable HSE */ + RCC->CR |= ((uint32_t)RCC_CR_HSEON); + + /* Wait till HSE is ready and if Time out is reached exit */ + do + { + HSEStatus = RCC->CR & RCC_CR_HSERDY; + StartUpCounter++; + } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT)); + + if ((RCC->CR & RCC_CR_HSERDY) != RESET) + { + HSEStatus = (uint32_t)0x01; + } + else + { + HSEStatus = (uint32_t)0x00; + } + + if (HSEStatus == (uint32_t)0x01) + { + /* Enable Prefetch Buffer */ + FLASH->ACR |= FLASH_ACR_PRFTBE; + + /* Flash 2 wait state */ + FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY); + FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_2; + + /* HCLK = SYSCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1; + + /* PCLK2 = HCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1; + + /* PCLK1 = HCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV2; + +#ifdef STM32F10X_CL + /* Configure PLLs ------------------------------------------------------*/ + /* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */ + /* PREDIV1 configuration: PREDIV1CLK = PLL2 / 5 = 8 MHz */ + + RCC->CFGR2 &= (uint32_t)~(RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL | + RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC); + RCC->CFGR2 |= (uint32_t)(RCC_CFGR2_PREDIV2_DIV5 | RCC_CFGR2_PLL2MUL8 | + RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV5); + + /* Enable PLL2 */ + RCC->CR |= RCC_CR_PLL2ON; + /* Wait till PLL2 is ready */ + while((RCC->CR & RCC_CR_PLL2RDY) == 0) + { + } + + + /* PLL configuration: PLLCLK = PREDIV1 * 7 = 56 MHz */ + RCC->CFGR &= (uint32_t)~(RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL); + RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLSRC_PREDIV1 | + RCC_CFGR_PLLMULL7); +#else + /* PLL configuration: PLLCLK = HSE * 7 = 56 MHz */ + RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL)); + RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLMULL7); + +#endif /* STM32F10X_CL */ + + /* Enable PLL */ + RCC->CR |= RCC_CR_PLLON; + + /* Wait till PLL is ready */ + while((RCC->CR & RCC_CR_PLLRDY) == 0) + { + } + + /* Select PLL as system clock source */ + RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); + RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL; + + /* Wait till PLL is used as system clock source */ + while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08) + { + } + } + else + { /* If HSE fails to start-up, the application will have wrong clock + configuration. User can add here some code to deal with this error */ + } +} + +#elif defined SYSCLK_FREQ_72MHz +/** + * @brief Sets System clock frequency to 72MHz and configure HCLK, PCLK2 + * and PCLK1 prescalers. + * @note This function should be used only after reset. + * @param None + * @retval None + */ +static void SetSysClockTo72(void) +{ + __IO uint32_t StartUpCounter = 0, HSEStatus = 0; + + /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration ---------------------------*/ + /* Enable HSE */ + RCC->CR |= ((uint32_t)RCC_CR_HSEON); + + /* Wait till HSE is ready and if Time out is reached exit */ + do + { + HSEStatus = RCC->CR & RCC_CR_HSERDY; + StartUpCounter++; + } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT)); + + if ((RCC->CR & RCC_CR_HSERDY) != RESET) + { + HSEStatus = (uint32_t)0x01; + } + else + { + HSEStatus = (uint32_t)0x00; + } + + if (HSEStatus == (uint32_t)0x01) + { + /* Enable Prefetch Buffer */ + FLASH->ACR |= FLASH_ACR_PRFTBE; + + /* Flash 2 wait state */ + FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY); + FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_2; + + + /* HCLK = SYSCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1; + + /* PCLK2 = HCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1; + + /* PCLK1 = HCLK */ + RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV2; + +#ifdef STM32F10X_CL + /* Configure PLLs ------------------------------------------------------*/ + /* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */ + /* PREDIV1 configuration: PREDIV1CLK = PLL2 / 5 = 8 MHz */ + + RCC->CFGR2 &= (uint32_t)~(RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL | + RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC); + RCC->CFGR2 |= (uint32_t)(RCC_CFGR2_PREDIV2_DIV5 | RCC_CFGR2_PLL2MUL8 | + RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV5); + + /* Enable PLL2 */ + RCC->CR |= RCC_CR_PLL2ON; + /* Wait till PLL2 is ready */ + while((RCC->CR & RCC_CR_PLL2RDY) == 0) + { + } + + + /* PLL configuration: PLLCLK = PREDIV1 * 9 = 72 MHz */ + RCC->CFGR &= (uint32_t)~(RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL); + RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLSRC_PREDIV1 | + RCC_CFGR_PLLMULL9); +#else + /* PLL configuration: PLLCLK = HSE * 9 = 72 MHz */ + RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | + RCC_CFGR_PLLMULL)); + RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLMULL9); +#endif /* STM32F10X_CL */ + + /* Enable PLL */ + RCC->CR |= RCC_CR_PLLON; + + /* Wait till PLL is ready */ + while((RCC->CR & RCC_CR_PLLRDY) == 0) + { + } + + /* Select PLL as system clock source */ + RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); + RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL; + + /* Wait till PLL is used as system clock source */ + while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08) + { + } + } + else + { /* If HSE fails to start-up, the application will have wrong clock + configuration. User can add here some code to deal with this error */ + } +} +#endif + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/CMSIS/system_stm32f10x.h b/STM32_4路称重_Git提交精简工程/src/CMSIS/system_stm32f10x.h new file mode 100755 index 0000000..739f332 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/CMSIS/system_stm32f10x.h @@ -0,0 +1,98 @@ +/** + ****************************************************************************** + * @file system_stm32f10x.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32f10x_system + * @{ + */ + +/** + * @brief Define to prevent recursive inclusion + */ +#ifndef __SYSTEM_STM32F10X_H +#define __SYSTEM_STM32F10X_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** @addtogroup STM32F10x_System_Includes + * @{ + */ + +/** + * @} + */ + + +/** @addtogroup STM32F10x_System_Exported_types + * @{ + */ + +extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ + +/** + * @} + */ + +/** @addtogroup STM32F10x_System_Exported_Constants + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F10x_System_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F10x_System_Exported_Functions + * @{ + */ + +extern void SystemInit(void); +extern void SystemCoreClockUpdate(void); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /*__SYSTEM_STM32F10X_H */ + +/** + * @} + */ + +/** + * @} + */ +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_WM8978.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_WM8978.h new file mode 100755 index 0000000..a036748 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_WM8978.h @@ -0,0 +1,79 @@ +/* +********************************************************************************************************* +* +* ģ : WM8978ƵоƬģ +* ļ : bsp_WM8978.h +* : V1.0 +* ˵ : ͷļ +* ޸ļ¼ : +* 汾 ˵ +* v0.1 2009-12-27 armfly ļST̼汾ΪV3.1.2 +* v1.0 2011-09-04 armfly ST̼V3.5.0汾 +* +* Copyright (C), 2010-2011, www.armfly.com +* +********************************************************************************************************* +*/ + +#ifndef _BSP_WM8978_H +#define _BSP_WM8978_H + +#include + +#define WM8978_SLAVE_ADDRESS 0x34 /* WM8978 I2Cӻַ */ + +/* WM8978 Ƶͨѡ, ѡ· MIC_LEFT_ON | LINE_ON */ +typedef enum +{ + IN_PATH_OFF = 0x00, /* */ + MIC_LEFT_ON = 0x01, /* LIN,LIPţMICӰͷ */ + MIC_RIGHT_ON = 0x02, /* RIN,RIPţMICGPRSģƵ */ + LINE_ON = 0x04, /* L2,R2 */ + AUX_ON = 0x08, /* AUXL,AUXR */ + DAC_ON = 0x10, /* I2SDAC (CPUƵź) */ + ADC_ON = 0x20 /* ƵWM8978ڲADC I2S¼) */ +}IN_PATH_E; + +/* WM8978 Ƶͨѡ, ѡ· */ +typedef enum +{ + OUT_PATH_OFF = 0x00, /* */ + EAR_LEFT_ON = 0x01, /* LOUT1 */ + EAR_RIGHT_ON = 0x02, /* ROUT1 */ + SPK_ON = 0x04, /* LOUT2ROUT2, */ + OUT3_4_ON = 0x08, /* OUT3 OUT4 Ƶ GSMģƵ */ +}OUT_PATH_E; + +/* */ +#define VOLUME_MAX 63 /* */ +#define VOLUME_STEP 1 /* ڲ */ + +/* MIC */ +#define GAIN_MAX 63 /* */ +#define GAIN_STEP 1 /* 沽 */ + + +/* ⲿõĺ */ +uint8_t wm8978_Init(void); +void wm8978_CfgAudioIF(uint16_t _usStandard, uint8_t _ucWordLen); +void wm8978_OutMute(uint8_t _ucMute); +void wm8978_PowerDown(void); + +void wm8978_CfgAudioPath(uint16_t _InPath, uint16_t _OutPath); + +void wm8978_SetMicGain(uint8_t _ucGain); +void wm8978_SetLineGain(uint8_t _ucGain); +void wm8978_SetSpkVolume(uint8_t _ucVolume); +void wm8978_SetEarVolume(uint8_t _ucVolume); +uint8_t wm8978_ReadEarVolume(void); +uint8_t wm8978_ReadSpkVolume(void); + +void wm8978_NotchFilter(uint16_t _NFA0, uint16_t _NFA1); + +void I2S_CODEC_Init(void); +void I2S_StartPlay(uint16_t _usStandard, uint16_t _usWordLen, uint16_t _usAudioFreq); +void I2S_StartRecord(uint16_t _usStandard, uint16_t _usWordLen, uint16_t _usAudioFreq); +void I2S_Stop(void); + +void wm8978_RegCash_Output(void); +#endif diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_i2c_gpio.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_i2c_gpio.c new file mode 100755 index 0000000..7a4adae --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_i2c_gpio.c @@ -0,0 +1,232 @@ +/*************************** (C) COPYRIGHT 2018 PING **************************** + * ļ bsp_i2c_gpio.h + * IOģI2C + * V1.0 + * 2018-01-11 + * XuZhongPing + * ¼¼ +*********************************************************************************/ + +#include "stm32f10x.h" +#include "bsp_i2c_gpio.h" +#include "delay.h" + +/* I2CӵGPIO˿, ûֻҪ޸4д뼴ıSCLSDA */ +#define GPIO_PORT_I2C GPIOD /* GPIO˿ */ +#define RCC_I2C_PORT RCC_APB2Periph_GPIOD /* GPIO˿ʱ */ +#define I2C_SCL_PIN GPIO_Pin_10 /* ӵSCLʱߵGPIO */ +#define I2C_SDA_PIN GPIO_Pin_9 /* ӵSDAߵGPIO */ + + +static void i2c_CfgGpio(void); + +/* +********************************************************************************************************* +* : i2c_Start +* ˵: CPUI2Cź +* Σ +* ֵ: +********************************************************************************************************* +*/ +void i2c_Start(void) +{ + SDA_OUT(); //sda + IIC_SDA=1; + IIC_SCL=1; + delay_us(4); + IIC_SDA=0; //START:when CLK is high,DATA change form high to low + delay_us(4); + IIC_SCL=0; //ǯסI2Cߣ׼ͻ +} + +/* +********************************************************************************************************* +* : i2c_Start +* ˵: CPUI2Cֹͣź +* Σ +* ֵ: +********************************************************************************************************* +*/ +void i2c_Stop(void) +{ + SDA_OUT();//sda + IIC_SCL=0; + IIC_SDA=0;//STOP:when CLK is high DATA change form low to high + delay_us(4); + IIC_SCL=1; + IIC_SDA=1;//I2C߽ź + delay_us(4); +} + +/* +********************************************************************************************************* +* : i2c_SendByte +* ˵: CPUI2C豸8bit +* Σ_ucByte ȴ͵ֽ +* ֵ: +********************************************************************************************************* +*/ +void i2c_SendByte(uint8_t _ucByte) +{ + uint8_t t; + + SDA_OUT(); + IIC_SCL = 0; //ʱӿʼݴ + for(t=0; t<8; t++) + { + //IIC_SDA=(txd&0x80)>>7; + if((_ucByte&0x80)>>7) + IIC_SDA=1; + else + IIC_SDA=0; + _ucByte<<=1; + delay_us(2); //TEA5767ʱDZ + IIC_SCL=1; + delay_us(2); + IIC_SCL=0; + delay_us(2); + } +} + +/* +********************************************************************************************************* +* : i2c_ReadByte +* ˵: CPUI2C豸ȡ8bit +* Σ +* ֵ: +********************************************************************************************************* +*/ +uint8_t i2c_ReadByte(void) +{ +// unsigned char i,receive=0; +// SDA_IN();//SDAΪ +// for(i=0;i<8;i++ ) +// { +// IIC_SCL=0; +// delay_us(2); +// IIC_SCL=1; +// receive<<=1; +// if(READ_SDA)receive++; +// delay_us(1); +// } +// if (!ack) +// IIC_NAck();//nACK +// else +// IIC_Ack(); //ACK +// return receive; +} + +/* +********************************************************************************************************* +* : i2c_WaitAck +* ˵: CPUһʱӣȡACKӦź +* Σ +* ֵ: 0ʾȷӦ1ʾӦ +********************************************************************************************************* +*/ +uint8_t i2c_WaitAck(void) +{ + uint8_t ucErrTime=0; + SDA_IN(); //SDAΪ + IIC_SDA=1;delay_us(1); + IIC_SCL=1;delay_us(1); + while(READ_SDA) + { + ucErrTime++; + if(ucErrTime>250) + { + i2c_Stop(); + return 1; + } + } + IIC_SCL=0;//ʱ0 + return 0; +} + +/* +********************************************************************************************************* +* : i2c_Ack +* ˵: CPUһACKź +* Σ +* ֵ: +********************************************************************************************************* +*/ +void i2c_Ack(void) +{ + IIC_SCL=0; + SDA_OUT(); + IIC_SDA=0; + delay_us(2); + IIC_SCL=1; + delay_us(2); + IIC_SCL=0; +} + +/* +********************************************************************************************************* +* : i2c_NAck +* ˵: CPU1NACKź +* Σ +* ֵ: +********************************************************************************************************* +*/ +void i2c_NAck(void) +{ + IIC_SCL=0; + SDA_OUT(); + IIC_SDA=1; + delay_us(2); + IIC_SCL=1; + delay_us(2); + IIC_SCL=0; +} + +/* +********************************************************************************************************* +* : i2c_CfgGpio +* ˵: I2CߵGPIOģIOķʽʵ +* Σ +* ֵ: +********************************************************************************************************* +*/ +static void i2c_CfgGpio(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + RCC_APB2PeriphClockCmd(RCC_I2C_PORT, ENABLE); /* GPIOʱ */ + + GPIO_InitStructure.GPIO_Pin = I2C_SCL_PIN | I2C_SDA_PIN; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; /* © GPIO_Mode_Out_PP GPIO_Mode_Out_OD*/ + GPIO_Init(GPIO_PORT_I2C, &GPIO_InitStructure); + + GPIO_SetBits(GPIO_PORT_I2C, I2C_SCL_PIN | I2C_SDA_PIN); + + /* һֹͣź, λI2Cϵ豸ģʽ */ + i2c_Stop(); +} + +/* +********************************************************************************************************* +* : i2c_CheckDevice +* ˵: I2C豸CPU豸ַȻȡ豸Ӧжϸ豸Ƿ +* Σ_Address豸I2Cߵַ +* ֵ: ֵ 0 ʾȷ 1ʾδ̽⵽ +********************************************************************************************************* +*/ +uint8_t i2c_CheckDevice(uint8_t _Address) +{ + uint8_t ucAck; + + i2c_CfgGpio(); /* GPIO */ + + i2c_Start(); /* ź */ + + /* 豸ַ+дbit0 = w 1 = r) bit7 ȴ */ + i2c_SendByte(_Address | I2C_WR); + ucAck = i2c_WaitAck(); /* 豸ACKӦ */ + + i2c_Stop(); /* ֹͣź */ + + return ucAck; +} diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_i2c_gpio.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_i2c_gpio.h new file mode 100755 index 0000000..ab9beeb --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_i2c_gpio.h @@ -0,0 +1,44 @@ +/* +********************************************************************************************************* +* +* ģ : I2Cģ +* ļ : bsp_i2c_gpio.h +* : V1.0 +* ˵ : ͷļ +* ޸ļ¼ : +* 汾 ˵ +* v1.0 2011-08-21 armfly ST̼V3.5.0汾 +* +* Copyright (C), 2010-2011, www.armfly.com +* +********************************************************************************************************* +*/ + +#ifndef _BSP_I2C_GPIO_H +#define _BSP_I2C_GPIO_H + +#include +#include "stm32f10x.h" + +#define I2C_WR 0 /* дbit */ +#define I2C_RD 1 /* bit */ + +//IO +#define SDA_IN() {GPIOD->CRH&=0XFFFFFF0F;GPIOD->CRH|=8<<4;} +#define SDA_OUT() {GPIOD->CRH&=0XFFFFFF0F;GPIOD->CRH|=3<<4;} + +//IO +#define IIC_SCL PDout(10) //SCL +#define IIC_SDA PDout(9) //SDA +#define READ_SDA PDin(9) //SDA + +void i2c_Start(void); +void i2c_Stop(void); +void i2c_SendByte(uint8_t _ucByte); +uint8_t i2c_ReadByte(void); +uint8_t i2c_WaitAck(void); +void i2c_Ack(void); +void i2c_NAck(void); +uint8_t i2c_CheckDevice(uint8_t _Address); + +#endif diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_wm8978.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_wm8978.c new file mode 100755 index 0000000..ed3db52 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/bsp_wm8978.c @@ -0,0 +1,1103 @@ +/* +********************************************************************************************************* +* +* ģ : WM8978ƵоƬģ +* ļ : bsp_WM8978.c +* : V1.0 +* ˵ : WM8978ƵоƬSTM32 I2SײڰSTM32ϵͨ +* ޸ļ¼ : +* 汾 ˵ +* v0.1 2009-12-27 armfly ļST̼汾ΪV3.1.2 +* v1.0 2011-09-11 armfly ʵI2S¼ãST̼V3.5.0汾 +* +* Copyright (C), 2010-2011, www.armfly.com +* +********************************************************************************************************* +*/ + +#include "stm32f10x.h" +#include "bsp_WM8978.h" +#include "bsp_i2c_gpio.h" +#include "usart.h" + +/* +********************************************************************************************************* +* +* Ҫʾ: +* 1wm8978_ ͷĺDzWM8978ĴWM8978ĴͨI2Cģ߽е +* 2I2S_ ͷĺDzSTM32 I2SؼĴ +* 3ʵ¼ӦãҪͬʱWM8978STM32I2S +* 4ֺõβεĶST̼У磺I2S_Standard_PhillipsI2S_Standard_MSBI2S_Standard_LSB +* I2S_MCLKOutput_EnableI2S_MCLKOutput_Disable +* I2S_AudioFreq_8KI2S_AudioFreq_16KI2S_AudioFreq_22KI2S_AudioFreq_44KI2S_AudioFreq_48 +* I2S_Mode_MasterTxI2S_Mode_MasterRx +* 5ע pdf ָ wm8978.pdf ֲᣬwm8978deĴܶ࣬õļĴעpdfļҳ룬ڲѯ +* +********************************************************************************************************* +*/ + +/* ڱģڲʹõľֲ */ +static uint16_t wm8978_ReadReg(uint8_t _ucRegAddr); +static uint8_t wm8978_WriteReg(uint8_t _ucRegAddr, uint16_t _usValue); +static void I2S_GPIO_Config(void); +static void I2S_Mode_Config(uint16_t _usStandard, uint16_t _usWordLen, uint16_t _usAudioFreq, uint16_t _usMode); +static void I2S_NVIC_Config(void); +static void wm8978_CfgInOut(uint8_t _ucDacEn, uint8_t _ucAuxEn, uint8_t _ucLineEn, uint8_t _ucSpkEn, uint8_t _ucEarEn); +static void wm8978_CtrlGPIO1(uint8_t _ucValue); +static void wm8978_Reset(void); +static void wm8978_CfgAdc(uint8_t _ucMicEn, uint8_t _ucAuxEn, uint8_t _ucLineEn); + +/* + wm8978Ĵ + WM8978I2C߽ӿڲֶ֧ȡ˼ĴֵڴУдĴʱͬ»棬Ĵʱ + ֱӷػеֵ + ĴMAP WM8978.pdf ĵ67ҳĴַ7bit Ĵ9bit +*/ +static uint16_t wm8978_RegCash[] = { + 0x000, 0x000, 0x000, 0x000, 0x050, 0x000, 0x140, 0x000, + 0x000, 0x000, 0x000, 0x0FF, 0x0FF, 0x000, 0x100, 0x0FF, + 0x0FF, 0x000, 0x12C, 0x02C, 0x02C, 0x02C, 0x02C, 0x000, + 0x032, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x038, 0x00B, 0x032, 0x000, 0x008, 0x00C, 0x093, 0x0E9, + 0x000, 0x000, 0x000, 0x000, 0x003, 0x010, 0x010, 0x100, + 0x100, 0x002, 0x001, 0x001, 0x039, 0x039, 0x039, 0x039, + 0x001, 0x001 +}; + +/* +********************************************************************************************************* +* : wm8978_Init +* ˵: I2C GPIOI2CϵWM8978Ƿ +* Σ +* ֵ: 1 ʾʼ0ʾʼ +********************************************************************************************************* +*/ +uint8_t wm8978_Init(void) +{ + uint8_t re; + + if (i2c_CheckDevice(WM8978_SLAVE_ADDRESS) == 0) /* STM32GPIOģI2Cʱ */ + { + re = 1; + } + else + { + re = 0; + } + wm8978_Reset(); /* ӲλWM8978мĴȱʡ״̬ */ + return re; +} + +/* +********************************************************************************************************* +* : wm8978_SetEarVolume +* ˵: ޸Ķ +* : _ucLeftVolume ֵ, 0-63 +* _ucLRightVolume : ֵ,0-63 +* ֵ: +********************************************************************************************************* +*/ +void wm8978_SetEarVolume(uint8_t _ucVolume) +{ + uint16_t regL; + uint16_t regR; + + if (_ucVolume > 0x3F) + { + _ucVolume = 0x3F; + } + + regL = _ucVolume; + regR = _ucVolume; + + /* + R52 LOUT1 Volume control + R53 ROUT1 Volume control + */ + /* ȸֵ */ + wm8978_WriteReg(52, regL | 0x00); + + /* ͬ */ + wm8978_WriteReg(53, regR | 0x100); /* 0x180ʾ Ϊ0ʱٸ£ֵġա */ +} + +/* +********************************************************************************************************* +* : wm8978_SetSpkVolume +* ˵: ޸ +* : _ucLeftVolume ֵ, 0-63 +* _ucLRightVolume : ֵ,0-63 +* ֵ: +********************************************************************************************************* +*/ +void wm8978_SetSpkVolume(uint8_t _ucVolume) +{ + uint16_t regL; + uint16_t regR; + + if (_ucVolume > 0x3F) + { + _ucVolume = 0x3F; + } + + regL = _ucVolume; + regR = _ucVolume; + + /* + R54 LOUT2 (SPK) Volume control + R55 ROUT2 (SPK) Volume control + */ + /* ȸֵ */ + wm8978_WriteReg(54, regL | 0x00); + + /* ͬ */ + wm8978_WriteReg(55, regR | 0x100); /* Ϊ0ʱٸ£ֵġա */ +} + +/* +********************************************************************************************************* +* : wm8978_ReadEarVolume +* ˵: ضͨ. +* : +* ֵ: ǰֵ +********************************************************************************************************* +*/ +uint8_t wm8978_ReadEarVolume(void) +{ + return (uint8_t)(wm8978_ReadReg(52) & 0x3F ); +} + +/* +********************************************************************************************************* +* : wm8978_ReadSpkVolume +* ˵: ͨ. +* : +* ֵ: ǰֵ +********************************************************************************************************* +*/ +uint8_t wm8978_ReadSpkVolume(void) +{ + return (uint8_t)(wm8978_ReadReg(54) & 0x3F ); +} + +/* +********************************************************************************************************* +* : wm8978_OutMute +* ˵: . +* : _ucMute 1Ǿ0Dz. +* ֵ: ǰֵ +********************************************************************************************************* +*/ +void wm8978_OutMute(uint8_t _ucMute) +{ + uint16_t usRegValue; + + if (_ucMute == 1) /* */ + { + usRegValue = wm8978_ReadReg(52); /* Left Mixer Control */ + usRegValue |= (1u << 6); + wm8978_WriteReg(52, usRegValue); + + usRegValue = wm8978_ReadReg(53); /* Left Mixer Control */ + usRegValue |= (1u << 6); + wm8978_WriteReg(53, usRegValue); + + usRegValue = wm8978_ReadReg(54); /* Right Mixer Control */ + usRegValue |= (1u << 6); + wm8978_WriteReg(54, usRegValue); + + usRegValue = wm8978_ReadReg(55); /* Right Mixer Control */ + usRegValue |= (1u << 6); + wm8978_WriteReg(55, usRegValue); + } + else /* ȡ */ + { + usRegValue = wm8978_ReadReg(52); + usRegValue &= ~(1u << 6); + wm8978_WriteReg(52, usRegValue); + + usRegValue = wm8978_ReadReg(53); /* Left Mixer Control */ + usRegValue &= ~(1u << 6); + wm8978_WriteReg(53, usRegValue); + + usRegValue = wm8978_ReadReg(54); + usRegValue &= ~(1u << 6); + wm8978_WriteReg(54, usRegValue); + + usRegValue = wm8978_ReadReg(55); /* Left Mixer Control */ + usRegValue &= ~(1u << 6); + wm8978_WriteReg(55, usRegValue); + } +} + +/* +********************************************************************************************************* +* : wm8978_SetMicGain +* ˵: MIC +* : _ucGain ֵ, 0-63 +* ֵ: +********************************************************************************************************* +*/ +void wm8978_SetMicGain(uint8_t _ucGain) +{ + if (_ucGain > GAIN_MAX) + { + _ucGain = GAIN_MAX; + } + + /* PGA R45 R46 pdf 19ҳ + Bit8 INPPGAUPDATE + Bit7 INPPGAZCL ٸ + Bit6 INPPGAMUTEL PGA + Bit5:0 ֵ0100000dB + */ + wm8978_WriteReg(45, _ucGain); + wm8978_WriteReg(46, _ucGain | (1 << 8)); +} + +/* +********************************************************************************************************* +* : wm8978_SetLineGain +* ˵: Lineͨ +* : _ucGain ֵ, 0-7. 70С ˥ɷŴ +* ֵ: +********************************************************************************************************* +*/ +void wm8978_SetLineGain(uint8_t _ucGain) +{ + uint16_t usRegValue; + + if (_ucGain > 7) + { + _ucGain = 7; + } + + /* + Mic ŵ PGABOOSTL PGABOOSTR + Aux ŵ AUXL2BOOSTVO[2:0] AUXR2BOOSTVO[2:0] + Line ŵ LIP2BOOSTVOL[2:0] RIP2BOOSTVOL[2:0] + */ + /* pdf 21ҳR47R48, MIC ƼĴ + R47 (R48ͬ) + B8 PGABOOSTL = 1, 0ʾMICźֱͨ棬1ʾMICź+20dB棨ͨԾٵ· + B7 = 0 + B6:4 L2_2BOOSTVOL = x 0ʾֹ1-7ʾ-12dB ~ +6dB ˥ҲԷŴ + B3 = 0 + B2:0` AUXL2BOOSTVOL = x0ʾֹ1-7ʾ-12dB ~ +6dB ˥ҲԷŴ + */ + + usRegValue = wm8978_ReadReg(47); + usRegValue &= 0x8F;/* Bit6:40 1000 1111*/ + usRegValue |= (_ucGain << 4); + wm8978_WriteReg(47, usRegValue); /* дƼĴ */ + + usRegValue = wm8978_ReadReg(48); + usRegValue &= 0x8F;/* Bit6:40 1000 1111*/ + usRegValue |= (_ucGain << 4); + wm8978_WriteReg(48, usRegValue); /* дƼĴ */ +} + +/* +********************************************************************************************************* +* : wm8978_PowerDown +* ˵: رwm8978͹ģʽ +* : +* ֵ: +********************************************************************************************************* +*/ +void wm8978_PowerDown(void) +{ + wm8978_Reset(); /* ӲλWM8978мĴȱʡ״̬ */ +} + +/* +********************************************************************************************************* +* : wm8978_CfgAudioIF +* ˵: WM8978Ƶӿ(I2S) +* : +* _usStandard : ӿڱ׼I2S_Standard_Phillips, I2S_Standard_MSB I2S_Standard_LSB +* _ucWordLen : ֳ162432 õ20bitʽ +* _usMode : CPU I2SĹģʽI2S_Mode_MasterTxI2S_Mode_MasterRx +* Ӳ֧ I2S_Mode_SlaveTxI2S_Mode_SlaveRx ģʽҪWM8978 +* ⲿ +* ֵ: +********************************************************************************************************* +*/ +void wm8978_CfgAudioIF(uint16_t _usStandard, uint8_t _ucWordLen) +{ + uint16_t usReg; + + /* pdf 67ҳĴб */ + + /* REG R4, ƵӿڿƼĴ + B8 BCP = X, BCLKԣ0ʾ1ʾ + B7 LRCP = x, LRCʱӼԣ0ʾ1ʾ + B6:5 WL = x ֳ00=16bit01=20bit10=24bit11=32bit Ҷģʽֻܲ24bit) + B4:3 FMT = xƵݸʽ00=Ҷ룬01=룬10=I2Sʽ11=PCM + B2 DACLRSWAP = x, DACݳLRCʱӵ߻ұ + B1 ADCLRSWAP = xADCݳLRCʱӵ߻ұ + B0 MONO = 00ʾ1ʾЧ + */ + usReg = 0; + if (_usStandard == I2S_Standard_Phillips) /* I2Sֱ׼ */ + { + usReg |= (2 << 3); + } + else if (_usStandard == I2S_Standard_MSB) /* MSB׼() */ + { + usReg |= (1 << 3); + } + else if (_usStandard == I2S_Standard_LSB) /* LSB׼(Ҷ) */ + { + usReg |= (0 << 3); + } + else /* PCM׼(16λͨ֡ϴ֡ͬ16λ֡չΪ32λͨ֡) */ + { + usReg |= (3 << 3);; + } + + if (_ucWordLen == 24) + { + usReg |= (2 << 5); + } + else if (_ucWordLen == 32) + { + usReg |= (3 << 5); + } + else + { + usReg |= (0 << 5); /* 16bit */ + } + wm8978_WriteReg(4, usReg); + + /* R5 pdf 57ҳ */ + + + /* + R6ʱӲƼĴ + MS = 0, WM8978ʱӣMCUṩMCLKʱ + */ + wm8978_WriteReg(6, 0x000); +} + +/* +********************************************************************************************************* +* : wm8978_ReadReg +* ˵: cashжضwm8978Ĵ +* Σ_ucRegAddr Ĵַ +* ֵ: +********************************************************************************************************* +*/ +static uint16_t wm8978_ReadReg(uint8_t _ucRegAddr) +{ + return wm8978_RegCash[_ucRegAddr]; +} + +/* +********************************************************************************************************* +* : wm8978_WriteReg +* ˵: дwm8978Ĵ +* Σ_ucRegAddr Ĵַ +* _usValue Ĵֵ +* ֵ: +********************************************************************************************************* +*/ +static uint8_t wm8978_WriteReg(uint8_t _ucRegAddr, uint16_t _usValue) +{ + uint8_t ucAck; + + /* ʼλ */ + i2c_Start(); + + /* 豸ַ+дbit0 = w 1 = r) bit7 ȴ */ + i2c_SendByte(WM8978_SLAVE_ADDRESS | I2C_WR); + + /* ACK */ + ucAck = i2c_WaitAck(); + if (ucAck == 1) + { + return 0; + } + + /* Ϳֽ1 */ + i2c_SendByte(((_ucRegAddr << 1) & 0xFE) | ((_usValue >> 8) & 0x1)); + + /* ACK */ + ucAck = i2c_WaitAck(); + if (ucAck == 1) + { + return 0; + } + + /* Ϳֽ2 */ + i2c_SendByte(_usValue & 0xFF); + + /* ACK */ + ucAck = i2c_WaitAck(); + if (ucAck == 1) + { + return 0; + } + + /* STOP */ + i2c_Stop(); + + wm8978_RegCash[_ucRegAddr] = _usValue; + return 1; +} + +/* +********************************************************************************************************* +* : wm8978_CfgInOut +* ˵: wm8978Ƶͨ +* : +* _InPath : Ƶͨ +* _OutPath : Ƶͨ +* ֵ: +********************************************************************************************************* +*/ +void wm8978_CfgAudioPath(uint16_t _InPath, uint16_t _OutPath) +{ + uint16_t usReg; + + /* 鿴WM8978ֲ REGISTER MAP ½ڣ 67ҳ */ + + if ((_InPath == IN_PATH_OFF) && (_OutPath == OUT_PATH_OFF)) + { + wm8978_PowerDown(); + return; + } + + /* --------------------------- 1ͨüĴ -----------------------*/ + /* + R1 Ĵ Power manage 1 + Bit8 BUFDCOPEN, Output stage 1.5xAVDD/2 driver enable + Bit7 OUT4MIXEN, OUT4 mixer enable + Bit6 OUT3MIXEN, OUT3 mixer enable + Bit5 PLLEN . + Bit4 MICBEN ,Microphone Bias Enable (MICƫõ·ʹ) + Bit3 BIASEN ,Analogue amplifier bias control Ϊ1ģŴŹ + Bit2 BUFIOEN , Unused input/output tie off buffer enable + Bit1:0 VMIDSEL, Ϊ00ֵģŴŹ + */ + usReg = (1 << 3) | (3 << 0); + if (_OutPath & OUT3_4_ON) /* OUT3OUT4ʹGSMģ */ + { + usReg |= ((1 << 7) | (1 << 6)); + } + if ((_InPath & MIC_LEFT_ON) || (_InPath & MIC_RIGHT_ON)) + { + usReg |= (1 << 4); + } + wm8978_WriteReg(1, usReg); /* дĴ */ + + /* + R2 Ĵ Power manage 2 + Bit8 ROUT1EN, ROUT1 output enable ʹ + Bit7 LOUT1EN, LOUT1 output enable ʹ + Bit6 SLEEP, 0 = Normal device operation 1 = Residual current reduced in device standby mode + Bit5 BOOSTENR, Right channel Input BOOST enable ͨԾٵ·ʹ. õPGAŴʱʹ + Bit4 BOOSTENL, Left channel Input BOOST enable + Bit3 INPGAENR, Right channel input PGA enable PGAʹ + Bit2 INPGAENL, Left channel input PGA enable + Bit1 ADCENR, Enable ADC right channel + Bit0 ADCENL, Enable ADC left channel + */ + usReg = 0; + if (_OutPath & EAR_LEFT_ON) + { + usReg |= (1 << 7); + } + if (_OutPath & EAR_RIGHT_ON) + { + usReg |= (1 << 8); + } + if (_InPath & MIC_LEFT_ON) + { + usReg |= ((1 << 4) | (1 << 2)); + } + if (_InPath & MIC_RIGHT_ON) + { + usReg |= ((1 << 5) | (1 << 3)); + } + if (_InPath & LINE_ON) + { + usReg |= ((1 << 4) | (1 << 5)); + } + if (_InPath & MIC_RIGHT_ON) + { + usReg |= ((1 << 5) | (1 << 3)); + } + if (_InPath & ADC_ON) + { + usReg |= ((1 << 1) | (1 << 0)); + } + wm8978_WriteReg(2, usReg); /* дĴ */ + + /* + R3 Ĵ Power manage 3 + Bit8 OUT4EN, OUT4 enable + Bit7 OUT3EN, OUT3 enable + Bit6 LOUT2EN, LOUT2 output enable + Bit5 ROUT2EN, ROUT2 output enable + Bit4 0, + Bit3 RMIXEN, Right mixer enable + Bit2 LMIXEN, Left mixer enable + Bit1 DACENR, Right channel DAC enable + Bit0 DACENL, Left channel DAC enable + */ + usReg = 0; + if (_OutPath & OUT3_4_ON) + { + usReg |= ((1 << 8) | (1 << 7)); + } + if (_OutPath & SPK_ON) + { + usReg |= ((1 << 6) | (1 << 5)); + } + if (_OutPath != OUT_PATH_OFF) + { + usReg |= ((1 << 3) | (1 << 2)); + } + if (_InPath & DAC_ON) + { + usReg |= ((1 << 1) | (1 << 0)); + } + wm8978_WriteReg(3, usReg); /* дĴ */ + + /* + R44 Ĵ Input ctrl + + Bit8 MBVSEL, Microphone Bias Voltage Control 0 = 0.9 * AVDD 1 = 0.6 * AVDD + Bit7 0 + Bit6 R2_2INPPGA, Connect R2 pin to right channel input PGA positive terminal + Bit5 RIN2INPPGA, Connect RIN pin to right channel input PGA negative terminal + Bit4 RIP2INPPGA, Connect RIP pin to right channel input PGA amplifier positive terminal + Bit3 0 + Bit2 L2_2INPPGA, Connect L2 pin to left channel input PGA positive terminal + Bit1 LIN2INPPGA, Connect LIN pin to left channel input PGA negative terminal + Bit0 LIP2INPPGA, Connect LIP pin to left channel input PGA amplifier positive terminal + */ + usReg = 0 << 8; + if (_InPath & LINE_ON) + { + usReg |= ((1 << 6) | (1 << 2)); + } + if (_InPath & MIC_RIGHT_ON) + { + usReg |= ((1 << 5) | (1 << 4)); + } + if (_InPath & MIC_LEFT_ON) + { + usReg |= ((1 << 1) | (1 << 0)); + } + wm8978_WriteReg(44, usReg); /* дĴ */ + + + /* + R14 Ĵ ADC Control + øͨ˲ѡģ pdf 2425ҳ, + Bit8 HPFEN, High Pass Filter Enableͨ˲ʹܣ0ʾֹ1ʾʹ + BIt7 HPFAPP, Select audio mode or application mode ѡƵģʽӦģʽ0ʾƵģʽ + Bit6:4 HPFCUTApplication mode cut-off frequency 000-111ѡӦģʽĽֹƵ + Bit3 ADCOSR, ADC oversample rate select: 0=64x (lower power) 1=128x (best performance) + Bit2 0 + Bit1 ADC right channel polarity adjust: 0=normal 1=inverted + Bit0 ADC left channel polarity adjust: 0=normal 1=inverted + */ + if (_InPath & ADC_ON) + { + usReg = (1 << 3) | (0 << 8) | (4 << 0); /* ֹADCͨ˲, ýƵ */ + } + else + { + usReg = 0; + } + wm8978_WriteReg(14, usReg); /* дĴ */ + + /* ݲ˲notch filterҪƻͲХ. ʱر + R27R28R29R30 ڿ޲˲pdf 26ҳ + R7 Bit7 NFEN = 0 ʾֹ1ʾʹ + */ + if (_InPath & ADC_ON) + { + usReg = (0 << 7); + wm8978_WriteReg(27, usReg); /* дĴ */ + usReg = 0; + wm8978_WriteReg(28, usReg); /* дĴ,0ΪѾֹҲɲ */ + wm8978_WriteReg(29, usReg); /* дĴ,0ΪѾֹҲɲ */ + wm8978_WriteReg(30, usReg); /* дĴ,0ΪѾֹҲɲ */ + } + + /* Զ ALC, R32 - 34 pdf 19ҳ */ + { + usReg = 0; /* ֹԶ */ + wm8978_WriteReg(32, usReg); + wm8978_WriteReg(33, usReg); + wm8978_WriteReg(34, usReg); + } + + /* R35 ALC Noise Gate Control + Bit3 NGATEN, Noise gate function enable + Bit2:0 Noise gate threshold: + */ + usReg = (3 << 1) | (7 << 0); /* ֹԶ */ + wm8978_WriteReg(35, usReg); + + /* + Mic ŵ PGABOOSTL PGABOOSTR + Aux ŵ AUXL2BOOSTVO[2:0] AUXR2BOOSTVO[2:0] + Line ŵ LIP2BOOSTVOL[2:0] RIP2BOOSTVOL[2:0] + */ + /* pdf 21ҳR47R48, MIC ƼĴ + R47 (R48ͬ) + B8 PGABOOSTL = 1, 0ʾMICźֱͨ棬1ʾMICź+20dB棨ͨԾٵ· + B7 = 0 + B6:4 L2_2BOOSTVOL = x 0ʾֹ1-7ʾ-12dB ~ +6dB ˥ҲԷŴ + B3 = 0 + B2:0` AUXL2BOOSTVOL = x0ʾֹ1-7ʾ-12dB ~ +6dB ˥ҲԷŴ + */ + usReg = 0; + if ((_InPath & MIC_LEFT_ON) || (_InPath & MIC_RIGHT_ON)) + { + usReg |= (1 << 8); /* MICȡ+20dB */ + } + if (_InPath & AUX_ON) + { + usReg |= (3 << 0); /* Aux̶ȡ3ûе */ + } + if (_InPath & LINE_ON) + { + usReg |= (3 << 4); /* Line̶ȡ3ûе */ + } + wm8978_WriteReg(47, usReg); /* дƼĴ */ + wm8978_WriteReg(48, usReg); /* дƼĴ */ + + /* ADCƣpdf 27ҳ + R15 ADCR16ADC + Bit8 ADCVU = 1 ʱŸ£ͬADC + Bit7:0 ѡ 0000 0000 = + 0000 0001 = -127dB + 0000 0010 = -12.5dB 0.5dB + 1111 1111 = 0dB ˥ + */ + usReg = 0xFF; + wm8978_WriteReg(15, usReg); /* ѡ0dBȻ */ + usReg = 0x1FF; + wm8978_WriteReg(16, usReg); /* ͬ */ + + /* ͨ wm8978_SetMicGain mic PGA */ + + /* R43 Ĵ AUXR C ROUT2 BEEP Mixer Function + B8:6 = 0 + + B5 MUTERPGA2INV, Mute input to INVROUT2 mixer + B4 INVROUT2, Invert ROUT2 output + B3:1 BEEPVOL = 7; AUXR input to ROUT2 inverter gain + B0 BEEPEN = 1; Enable AUXR beep input + + */ + usReg = 0; + if (_OutPath & SPK_ON) + { + usReg |= (1 << 4); /* ROUT2 , */ + } + if (_InPath & AUX_ON) + { + usReg |= ((7 << 1) | (1 << 0)); + } + wm8978_WriteReg(43, usReg); + + /* R49 Output ctrl + B8:7 0 + B6 DACL2RMIX, Left DAC output to right output mixer + B5 DACR2LMIX, Right DAC output to left output + B4 OUT4BOOST, 0 = OUT4 output gain = -1; DC = AVDD / 21 = OUT4 output gain = +1.5DC = 1.5 x AVDD / 2 + B3 OUT3BOOST, 0 = OUT3 output gain = -1; DC = AVDD / 21 = OUT3 output gain = +1.5DC = 1.5 x AVDD / 2 + B2 SPKBOOST, 0 = Speaker gain = -1; DC = AVDD / 2 ; 1 = Speaker gain = +1.5; DC = 1.5 x AVDD / 2 + B1 TSDEN, Thermal Shutdown Enable ȱʹܣȱʡ1 + B0 VROI, Disabled Outputs to VREF Resistance + */ + usReg = 0; + if (_InPath & DAC_ON) + { + usReg |= ((1 << 6) | (1 << 5)); + } + if (_OutPath & SPK_ON) + { + usReg |= ((1 << 2) | (1 << 1)); /* SPK 1.5x, ȱʹ */ + } + if (_OutPath & OUT3_4_ON) + { + usReg |= ((1 << 4) | (1 << 3)); /* BOOT3 BOOT4 1.5x */ + } + wm8978_WriteReg(49, usReg); + + /* REG 50 (5051üĴһ) pdf 40ҳ + B8:6 AUXLMIXVOL = 111 AUXFMź + B5 AUXL2LMIX = 1 Left Auxilliary input to left channel + B4:2 BYPLMIXVOL + B1 BYPL2LMIX = 0; Left bypass path (from the left channel input boost output) to left output mixer + B0 DACL2LMIX = 1; Left DAC output to left output mixer + */ + usReg = 0; + if (_InPath & AUX_ON) + { + usReg |= ((7 << 6) | (1 << 5)); + } + if ((_InPath & LINE_ON) || (_InPath & MIC_LEFT_ON) || (_InPath & MIC_RIGHT_ON)) + { + usReg |= ((7 << 2) | (1 << 1)); + } + if (_InPath & DAC_ON) + { + usReg |= (1 << 0); + } + wm8978_WriteReg(50, usReg); + wm8978_WriteReg(51, usReg); + + /* R56 Ĵ OUT3 mixer ctrl + B8:7 0 + B6 OUT3MUTE, 0 = Output stage outputs OUT3 mixer; 1 = Output stage muted C drives out VMID. + B5:4 0 + B3 BYPL2OUT3, OUT4 mixer output to OUT3 () + B4 0 + B2 LMIX2OUT3, Left ADC input to OUT3 + B1 LDAC2OUT3, Left DAC mixer to OUT3 + B0 LDAC2OUT3, Left DAC output to OUT3 + */ + usReg = 0; + if (_OutPath & OUT3_4_ON) + { + usReg |= (1 << 3); + } + wm8978_WriteReg(56, usReg); + + /* R57 Ĵ OUT4 (MONO) mixer ctrl + B8:7 0 + B6 OUT4MUTE, 0 = Output stage outputs OUT4 mixer 1 = Output stage muted C drives outVMID. + B5 HALFSIG, 0 = OUT4 normal output 1 = OUT4 attenuated by 6dB + B4 LMIX2OUT4, Left DAC mixer to OUT4 + B3 LDAC2UT4, Left DAC to OUT4 + B2 BYPR2OUT4, Right ADC input to OUT4 + B1 RMIX2OUT4, Right DAC mixer to OUT4 + B0 RDAC2OUT4, Right DAC output to OUT4 + */ + usReg = 0; + if (_OutPath & OUT3_4_ON) + { + usReg |= ((1 << 4) | (1 << 1)); + } + wm8978_WriteReg(57, usReg); + + + /* R11, 12 Ĵ DAC + R11 Left DAC Digital Volume + R12 Right DAC Digital Volume + */ + if (_InPath & DAC_ON) + { + wm8978_WriteReg(11, 255); + wm8978_WriteReg(12, 255 | 0x100); + } + else + { + wm8978_WriteReg(11, 0); + wm8978_WriteReg(12, 0 | 0x100); + } + + /* R10 Ĵ DAC Control + B8 0 + B7 0 + B6 SOFTMUTE, Softmute enable: + B5 0 + B4 0 + B3 DACOSR128, DAC oversampling rate: 0=64x (lowest power) 1=128x (best performance) + B2 AMUTE, Automute enable + B1 DACPOLR, Right DAC output polarity + B0 DACPOLL, Left DAC output polarity: + */ + if (_InPath & DAC_ON) + { + wm8978_WriteReg(10, 0); + } + ; +} + +/* +********************************************************************************************************* +* : wm8978_NotchFilter +* ˵: ݲ˲notch filterҪƻͲХ +* : NFA0[13:0] and NFA1[13:0] +* ֵ: +********************************************************************************************************* +*/ +void wm8978_NotchFilter(uint16_t _NFA0, uint16_t _NFA1) +{ + uint16_t usReg; + + /* page 26 + A programmable notch filter is provided. This filter has a variable centre frequency and bandwidth, + programmable via two coefficients, a0 and a1. a0 and a1 are represented by the register bits + NFA0[13:0] and NFA1[13:0]. Because these coefficient values require four register writes to setup + there is an NFU (Notch Filter Update) flag which should be set only when all four registers are setup. + */ + usReg = (1 << 7) | (_NFA0 & 0x3F); + wm8978_WriteReg(27, usReg); /* дĴ */ + + usReg = ((_NFA0 >> 7) & 0x3F); + wm8978_WriteReg(28, usReg); /* дĴ */ + + usReg = (_NFA1 & 0x3F); + wm8978_WriteReg(29, usReg); /* дĴ */ + + usReg = (1 << 8) | ((_NFA1 >> 7) & 0x3F); + wm8978_WriteReg(30, usReg); /* дĴ */ +} + +/* +********************************************************************************************************* +* : wm8978_CtrlGPIO1 +* ˵: WM8978GPIO101 +* Σ_ucValue GPIO1ֵ01 +* ֵ: ǰֵ +********************************************************************************************************* +*/ +static void wm8978_CtrlGPIO1(uint8_t _ucValue) +{ + uint16_t usRegValue; + + /* R8 pdf 62ҳ */ + if (_ucValue == 0) /* 0 */ + { + usRegValue = 6; /* B2:0 = 110 */ + } + else + { + usRegValue = 7; /* B2:0 = 111 */ + } + wm8978_WriteReg(8, usRegValue); +} + +/* +********************************************************************************************************* +* : wm8978_Reset +* ˵: λwm8978еļĴֵָȱʡֵ +* Σ +* ֵ: +********************************************************************************************************* +*/ +static void wm8978_Reset(void) +{ + /* wm8978Ĵȱʡֵ */ + const uint16_t reg_default[] = { + 0x000, 0x000, 0x000, 0x000, 0x050, 0x000, 0x140, 0x000, + 0x000, 0x000, 0x000, 0x0FF, 0x0FF, 0x000, 0x100, 0x0FF, + 0x0FF, 0x000, 0x12C, 0x02C, 0x02C, 0x02C, 0x02C, 0x000, + 0x032, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, + 0x038, 0x00B, 0x032, 0x000, 0x008, 0x00C, 0x093, 0x0E9, + 0x000, 0x000, 0x000, 0x000, 0x003, 0x010, 0x010, 0x100, + 0x100, 0x002, 0x001, 0x001, 0x039, 0x039, 0x039, 0x039, + 0x001, 0x001 + }; + uint8_t i; + + wm8978_WriteReg(0x00, 0); + + for (i = 0; i < sizeof(reg_default) / 2; i++) + { + wm8978_RegCash[i] = reg_default[i]; + } +} + +/* +********************************************************************************************************* +* ĴǺSTM32 I2SӲص +********************************************************************************************************* +*/ + +/* +********************************************************************************************************* +* : I2S_CODEC_Init +* ˵: GPIOźжͨcodecӦ +* Σ +* ֵ: +********************************************************************************************************* +*/ +void I2S_CODEC_Init(void) +{ + /* I2Sжͨ */ + I2S_NVIC_Config(); + + /* I2S2 GPIO */ + I2S_GPIO_Config(); + + /* ֹI2S2 TXEж(ͻ)Ҫʱٴ */ + SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_TXE, DISABLE); + + /* ֹI2S2 RXNEж(ղ)Ҫʱٴ */ + SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_RXNE, DISABLE); +} + +/* +********************************************************************************************************* +* : I2S_StartPlay +* ˵: I2SģʽI2Sͻжϣʼ +* Σ_usStandard : ӿڱ׼I2S_Standard_Phillips, I2S_Standard_MSB I2S_Standard_LSB +* _usMCLKOutput : ʱI2S_MCLKOutput_Enable or I2S_MCLKOutput_Disable +* _usAudioFreq : ƵʣI2S_AudioFreq_8KI2S_AudioFreq_16KI2S_AudioFreq_22K +* I2S_AudioFreq_44KI2S_AudioFreq_48 +* ֵ: +********************************************************************************************************* +*/ +void I2S_StartPlay(uint16_t _usStandard, uint16_t _usWordLen, uint16_t _usAudioFreq) +{ + /* I2SΪģʽSTM32ṩʱӣI2SݿǷͷ() */ + I2S_Mode_Config(_usStandard, _usWordLen, _usAudioFreq, I2S_Mode_MasterTx); + + SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_TXE, ENABLE); /* ʹܷж */ +} + +/* +********************************************************************************************************* +* : I2S_Stop +* ˵: ֹͣI2S +* Σ +* ֵ: +********************************************************************************************************* +*/ +void I2S_Stop(void) +{ + /* ֹI2S2 TXEж(ͻ)Ҫʱٴ */ + SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_TXE, DISABLE); + + /* ֹI2S2 RXNEж(ղ)Ҫʱٴ */ + SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_RXNE, DISABLE); + + /* SPI2/I2S2 */ + I2S_Cmd(SPI2, DISABLE); + + /* ر I2S2 APB1 ʱ */ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); +} + + +/* +********************************************************************************************************* +* : I2S_GPIO_Config +* ˵: GPIOcodecӦ +* Σ +* ֵ: +********************************************************************************************************* +*/ +static void I2S_GPIO_Config(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + /* Enable GPIOB, GPIOC and AFIO clock */ + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOG | + RCC_APB2Periph_GPIOF | RCC_APB2Periph_AFIO, ENABLE); + + /* I2S2 SD, CK and WS pins configuration */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_15; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + GPIO_Init(GPIOB, &GPIO_InitStructure); + + /* I2S2 MCK pin configuration */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; + GPIO_Init(GPIOC, &GPIO_InitStructure); +} + +/* +********************************************************************************************************* +* : I2S_Config +* ˵: STM32I2S蹤ģʽ +* Σ_usStandard : ӿڱ׼I2S_Standard_Phillips, I2S_Standard_MSB I2S_Standard_LSB +* _usMCLKOutput : ʱI2S_MCLKOutput_Enable or I2S_MCLKOutput_Disable +* _usAudioFreq : ƵʣI2S_AudioFreq_8KI2S_AudioFreq_16KI2S_AudioFreq_22K +* I2S_AudioFreq_44KI2S_AudioFreq_48 +* _usMode : CPU I2SĹģʽI2S_Mode_MasterTxI2S_Mode_MasterRx +* Ӳ֧ I2S_Mode_SlaveTxI2S_Mode_SlaveRx ģʽҪWM8978 +* ⲿ +* ֵ: +********************************************************************************************************* +*/ +static void I2S_Mode_Config(uint16_t _usStandard, uint16_t _usWordLen, uint16_t _usAudioFreq, uint16_t _usMode) +{ + I2S_InitTypeDef I2S_InitStructure; + + if ((_usMode == I2S_Mode_SlaveTx) && (_usMode == I2S_Mode_SlaveRx)) + { + /* 岻֧2ģʽ */ + return; + } + + /* I2S2 APB1 ʱ */ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); + + /* λ SPI2 赽ȱʡ״̬ */ + SPI_I2S_DeInit(SPI2); + + /* I2S2 */ + if (_usMode == I2S_Mode_MasterTx) + { + I2S_InitStructure.I2S_Mode = I2S_Mode_MasterTx; /* I2Sģʽ */ + I2S_InitStructure.I2S_Standard = _usStandard; /* ӿڱ׼ */ + I2S_InitStructure.I2S_DataFormat = _usWordLen; /* ݸʽ16bit */ + I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Enable; /* ʱģʽ */ + I2S_InitStructure.I2S_AudioFreq = _usAudioFreq; /* ƵƵ */ + I2S_InitStructure.I2S_CPOL = I2S_CPOL_Low; + I2S_Init(SPI2, &I2S_InitStructure); + } + else if (_usMode == I2S_Mode_MasterRx) + { + I2S_InitStructure.I2S_Mode = I2S_Mode_MasterRx; /* I2Sģʽ */ + I2S_InitStructure.I2S_Standard = _usStandard; /* ӿڱ׼ */ + I2S_InitStructure.I2S_DataFormat = _usWordLen; /* ݸʽ16bit */ + I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Enable; /* ʱģʽ */ + I2S_InitStructure.I2S_AudioFreq = _usAudioFreq; /* ƵƵ */ + I2S_InitStructure.I2S_CPOL = I2S_CPOL_Low; + I2S_Init(SPI2, &I2S_InitStructure); + } + + /* ֹI2S2 TXEж(ͻ)Ҫʱٴ */ + SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_TXE, DISABLE); + + /* ֹI2S2 RXNEж(ղ)Ҫʱٴ */ + SPI_I2S_ITConfig(SPI2, SPI_I2S_IT_RXNE, DISABLE); + + /* ʹ SPI2/I2S2 */ + I2S_Cmd(SPI2, ENABLE); +} + +/* +********************************************************************************************************* +* : I2S_NVIC_Config +* ˵: I2S NVICͨ(жģʽ)жϷvoid SPI2_IRQHandler(void) stm32f10x_it.c +* Σ +* ֵ: +********************************************************************************************************* +*/ +static void I2S_NVIC_Config(void) +{ + NVIC_InitTypeDef NVIC_InitStructure; + + /* SPI2 IRQ ͨ */ + NVIC_InitStructure.NVIC_IRQChannel = SPI2_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); +} + +void wm8978_RegCash_Output(void) +{ + uint8_t i; + for(i = 0; i < 58; i++) + { + printf("0x%04X, ", wm8978_RegCash[i]); + } +} + +/***************************** (END OF FILE) *********************************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/sound.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/sound.c new file mode 100755 index 0000000..534b615 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/sound.c @@ -0,0 +1,198 @@ +/*************************** (C) COPYRIGHT 2018 PING **************************** + * ļ sound.h + * Ƴ + * V1.0 + * 2016-01-11 + * XuZhongPing + * ¼¼ +*********************************************************************************/ +#include "sound.h" +#include "delay.h" +#include "timer.h" +#include "usart1.h" +#include "stdio.h" +#include "string.h" + +#define SPEAKER_PORT_PeriphClock RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO +#define SPEAKER_PORT GPIOB +#define SPEAKER_CTRL_PIN GPIO_Pin_3 + +uint8_t audioOutputMark = 0; //־Ƿ +uint8_t audioNum = 0; // +uint8_t audioOutputStatus = 0; //Ƶ״̬ + +/* +*********************************************************************** +* : SpeakerInit +* ˵: ƽӿڳʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void SpeakerInit(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(SPEAKER_PORT_PeriphClock, ENABLE); //ʹʱ + + GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE); //رJTAGPB3,PB4ù + + GPIO_InitStructure.GPIO_Pin = SPEAKER_CTRL_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(SPEAKER_PORT, &GPIO_InitStructure); + + GPIO_ResetBits(SPEAKER_PORT, SPEAKER_CTRL_PIN); +} + +/* +*********************************************************************** +* : AudioInit +* ˵: Ƶسʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void Audio_Init(void) +{ + SpeakerInit(); + Audio_SetVolume(20); +} + +/* +*********************************************************************** +* : Audio_OutputEnable +* ˵: Ƶʹ +* Σ +* ֵ: +*********************************************************************** +*/ +static void Audio_OutputEnable(void) +{ + GPIO_SetBits(SPEAKER_PORT, SPEAKER_CTRL_PIN); + audioOutputStatus = 1; +} + +/* +*********************************************************************** +* : Audio_OutputDisable +* ˵: Ƶʧ +* Σ +* ֵ: +*********************************************************************** +*/ +static void Audio_OutputDisable(void) +{ + GPIO_ResetBits(SPEAKER_PORT, SPEAKER_CTRL_PIN); + audioOutputStatus = 0; +} + +/* +*********************************************************************** +* : Audio_SetVolume +* ˵: Ƶ +* Σval -> ֵ +* ֵ: +*********************************************************************** +*/ +void Audio_SetVolume(uint8_t volume) +{ + char str[32]; + + if (volume<=30 && volume>=1) + { + sprintf(str, "AF:%d", volume); + USART1_SendFrameData((uint8_t*)str, strlen(str)); + } +} + +/* +*********************************************************************** +* : Audio_Play +* ˵: ָƵ +* Σnum -> +* ֵ: +*********************************************************************** +*/ +void Audio_PlayOutput(uint8_t num) +{ + char str[32]; + + sprintf(str, "A7:%05d", num); + Audio_OutputEnable(); //ʹ + USART1_SendFrameData((uint8_t*)str, strlen(str)); +} + +/* +*********************************************************************** +* : Audio_Play +* ˵: ָƵ +* Σnum -> +* ֵ: +*********************************************************************** +*/ +void Audio_Play(uint8_t num) +{ + audioOutputMark = 1; + audioNum = num; +} + +/* +*********************************************************************** +* : Audio_Play +* ˵: ָƵ +* Σnum -> +* ֵ: +*********************************************************************** +*/ +void Audio_PlayTask(void) +{ + static uint8_t RunningStatus = 0x00; + + static timer waitingTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&waitingTimer, CLOCK_SECOND*5); + } + + switch(RunningStatus) + { + case 0x00: + if(audioOutputMark == 1) + { + audioOutputMark = 0; + Audio_PlayOutput(audioNum); + timer_restart(&waitingTimer); + RunningStatus = 0x01; + break; + } + break; + + case 0x01: + if(audioOutputMark == 1) + { + RunningStatus = 0x00; + break; + } + + if(timer_expired(&waitingTimer)) + { + printf("\r\nֹͣţ\r\n"); + Audio_OutputDisable(); //ر + RunningStatus = 0x00; + break; + } + break; + + case 0x02: + break; + + default: + RunningStatus = 0x00; + break; + } +} + +/******************** (C) COPYRIGHT 2014 GLHF *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/sound.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/sound.h new file mode 100755 index 0000000..98a91a8 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/sound.h @@ -0,0 +1,28 @@ +/*************************** (C) COPYRIGHT 2014 GLHF **************************** + * ļ sound.h + * ͷļ + * V1.0 + * 2016-01-11 + * XuZhongPing + * ¼¼ +*********************************************************************************/ +#ifndef __SOUND_H +#define __SOUND_H +#include "stm32f10x.h" +#include "stdio.h" + +extern uint8_t audioOutputMark; //־Ƿ +extern uint8_t audioNum; // +extern uint8_t audioOutputStatus; //Ƶ״̬ + +void AudioInit(void); +void VoiceBroadcast (uint8_t number); + +void Audio_Init(void); +void Audio_SetVolume(uint8_t volume); +void Audio_Play(uint8_t num); +void Audio_PlayTask(void); + +#endif + +/******************** (C) COPYRIGHT 2014 GLHF *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/soundfilelists.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/soundfilelists.h new file mode 100755 index 0000000..4d04992 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/AUDIO/soundfilelists.h @@ -0,0 +1,15 @@ +#ifndef __SOUNDFILELIST_H +#define __SOUNDFILELIST_H +#include "stm32f10x.h" + +const uint32_t SOUND_FILE_LIST[5][2] = { + /*ַ */ + {0x00002C, 0x0088BC}, //00Ϣ + {0x0088E8, 0x00F898}, //01Ϣ + {0x018180, 0x0151F8}, //02Ϣ + {0x02D378, 0x01701A}, //03Ϣ + {0x044392, 0x032E5C} //04Ϣ +}; + +#endif + diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/BUZZER/buzzer.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/BUZZER/buzzer.c new file mode 100755 index 0000000..17cdc17 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/BUZZER/buzzer.c @@ -0,0 +1,669 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ buzzer.c + * + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#include "buzzer.h" +#include "timer.h" + +#define BEEP_PeriphClock RCC_APB2Periph_GPIOB +#define BEEP_PORT GPIOB +#define BEEP_PIN GPIO_Pin_2 + +uint8_t beep_startUpMark = 0; //ʾ־ +uint8_t beep_shortBeepMark = 0; //־ +uint8_t beep_longBeepMark = 0; //־ +uint8_t beep_closeDoorBeepMark = 0; //־ +uint8_t beep_warningBeepMark = 0; //󾯸ʾ־ +uint8_t beep_contSlowBeepMark = 0; //־ +uint8_t beep_contFastBeepMark = 0; //־ + +/* +*********************************************************************** +* : KeyInit +* ˵: IOڳʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void BeepInit(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(BEEP_PeriphClock, ENABLE); + + + GPIO_InitStructure.GPIO_Pin = BEEP_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(BEEP_PORT, &GPIO_InitStructure); + + GPIO_ResetBits(BEEP_PORT, BEEP_PIN); + + beep_startUpMark = 1; //־ڿʾ +} + +/* +*********************************************************************** +* : SetBuzzerStatus +* ˵: ÷״̬ +* Σparam -> õ״̬0أ1 +* ֵ: +*********************************************************************** +*/ +void SetBuzzerStatus(uint8_t param) +{ + if(param) + { + GPIO_SetBits(BEEP_PORT, BEEP_PIN); +// printf("\r\n\r\n"); + }else{ + GPIO_ResetBits(BEEP_PORT, BEEP_PIN); +// printf("\r\nط\r\n"); + } +} + + +/* +*********************************************************************** +* : BEEP_ShortBeep +* ˵: +* Σ +* ֵ: +*********************************************************************** +*/ +static void BEEP_ShortBeep(void) +{ + static uint8_t beepStatus = 0x00; + + static timer beepOnTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&beepOnTimer, 2); + } + + switch(beepStatus) + { + case 0x00: + if(beep_shortBeepMark == 1) + { + beep_shortBeepMark = 0; + SetBuzzerStatus(1); //򿪷 + + timer_restart(&beepOnTimer); + beepStatus = 0x01; + break; + } + break; + + case 0x01: + if(timer_expired(&beepOnTimer)) + { + SetBuzzerStatus(0); //رշ + beepStatus = 0x00; + break; + } + break; + + default: + SetBuzzerStatus(0); //رշ + beepStatus = 0x00; + break; + } +} + +/* +*********************************************************************** +* : BEEP_LongBeep +* ˵: +* Σ +* ֵ: +*********************************************************************** +*/ +static void BEEP_LongBeep(void) +{ + static uint8_t beepStatus = 0x00; + + static timer beepOnTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&beepOnTimer, 20); + } + + switch(beepStatus) + { + case 0x00: + if(beep_longBeepMark == 1) + { + beep_longBeepMark = 0; + SetBuzzerStatus(1); //򿪷 + + timer_restart(&beepOnTimer); + beepStatus = 0x01; + break; + } + break; + + case 0x01: + if(timer_expired(&beepOnTimer)) + { + SetBuzzerStatus(0); //رշ + beepStatus = 0x00; + break; + } + SetBuzzerStatus(1); //򿪷 + break; + + default: + SetBuzzerStatus(0); //رշ + beepStatus = 0x00; + break; + } +} + +/* +*********************************************************************** +* : BEEP_StartUpBeep +* ˵: ʾ +* Σ +* ֵ: +*********************************************************************** +*/ +static void BEEP_StartUpBeep(void) +{ + static uint8_t beepStatus = 0x00; + + static timer beepOnTimer1; + static timer beepOnTimer2; + static timer beepOffTimer1; + static timer beepOffTimer2; + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&beepOnTimer1, 1); + timer_set(&beepOnTimer2, 2); + timer_set(&beepOffTimer1, 1); + timer_set(&beepOffTimer2, 2); + } + + switch(beepStatus) + { + case 0x00: + if(beep_startUpMark == 1) + { + beep_startUpMark = 0; + SetBuzzerStatus(1); //򿪷 + timer_restart(&beepOnTimer1); + beepStatus = 0x01; + break; + } + break; + + case 0x01: + if(timer_expired(&beepOnTimer1)) + { + SetBuzzerStatus(0); //رշ + timer_restart(&beepOffTimer1); + beepStatus = 0x02; + break; + } + break; + + case 0x02: + if(timer_expired(&beepOffTimer1)) + { + SetBuzzerStatus(1); //򿪷 + timer_restart(&beepOnTimer2); + beepStatus = 0x03; + break; + } + break; + + case 0x03: + if(timer_expired(&beepOnTimer2)) + { + SetBuzzerStatus(0); //رշ + timer_restart(&beepOffTimer2); + beepStatus = 0x04; + break; + } + break; + + case 0x04: + if(timer_expired(&beepOffTimer2)) + { + SetBuzzerStatus(1); + timer_restart(&beepOnTimer2); + beepStatus = 0x05; + break; + } + break; + + case 0x05: + if(timer_expired(&beepOnTimer2)) + { + SetBuzzerStatus(0); //رշ + beep_startUpMark = 0; + beepStatus = 0x00; + break; + } + break; + + default: + SetBuzzerStatus(0); //رշ + beepStatus = 0x00; + break; + } +} + +/* +*********************************************************************** +* : BEEP_CloseDoorBeep +* ˵: ʾ +* Σ +* ֵ: +*********************************************************************** +*/ +static void BEEP_CloseDoorBeep(void) +{ + static uint8_t beepStatus = 0x00; + + static timer closeDoorBeepOnTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&closeDoorBeepOnTimer, 5); + } + + switch(beepStatus) + { + case 0x00: + if(beep_closeDoorBeepMark == 1) + { + beep_closeDoorBeepMark = 0; + SetBuzzerStatus(1); //򿪷 + timer_restart(&closeDoorBeepOnTimer); + beepStatus = 0x01; + break; + } + break; + + case 0x01: + if(timer_expired(&closeDoorBeepOnTimer)) + { + SetBuzzerStatus(0); //رշ + timer_restart(&closeDoorBeepOnTimer); + beepStatus = 0x02; + break; + } + break; + + case 0x02: + if(timer_expired(&closeDoorBeepOnTimer)) + { + SetBuzzerStatus(1); //򿪷 + timer_restart(&closeDoorBeepOnTimer); + beepStatus = 0x03; + break; + } + break; + + case 0x03: + if(timer_expired(&closeDoorBeepOnTimer)) + { + SetBuzzerStatus(0); //رշ + timer_restart(&closeDoorBeepOnTimer); + beepStatus = 0x04; + break; + } + break; + + case 0x04: + if(timer_expired(&closeDoorBeepOnTimer)) + { + SetBuzzerStatus(1); //򿪷 + timer_restart(&closeDoorBeepOnTimer); + beepStatus = 0x05; + break; + } + break; + + case 0x05: + if(timer_expired(&closeDoorBeepOnTimer)) + { + SetBuzzerStatus(0); //رշ + beep_closeDoorBeepMark = 0; + beepStatus = 0x00; + break; + } + break; + + default: + SetBuzzerStatus(0); //رշ + beepStatus = 0x00; + break; + } +} + +/* +*********************************************************************** +* : BEEP_WarningBeep +* ˵: ʾ +* Σ +* ֵ: +*********************************************************************** +*/ +static void BEEP_WarningBeep(void) +{ + static uint8_t beepStatus = 0x00; + + static timer warningBeepOnTimer; + static timer warningBeepOffTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&warningBeepOnTimer, 2); + timer_set(&warningBeepOffTimer, 2); + } + + switch(beepStatus) + { + case 0x00: + if(beep_warningBeepMark == 1) + { + beep_warningBeepMark = 0; + SetBuzzerStatus(1); //򿪷 + timer_restart(&warningBeepOnTimer); + beepStatus = 0x01; + break; + } + break; + + case 0x01: + if(timer_expired(&warningBeepOnTimer)) + { + SetBuzzerStatus(0); //رշ + timer_restart(&warningBeepOnTimer); + beepStatus = 0x02; + break; + } + break; + + case 0x02: + if(timer_expired(&warningBeepOnTimer)) + { + SetBuzzerStatus(1); //򿪷 + timer_restart(&warningBeepOnTimer); + beepStatus = 0x03; + break; + } + break; + + case 0x03: + if(timer_expired(&warningBeepOnTimer)) + { + SetBuzzerStatus(0); //رշ + timer_restart(&warningBeepOnTimer); + beepStatus = 0x04; + break; + } + break; + + case 0x04: + if(timer_expired(&warningBeepOnTimer)) + { + SetBuzzerStatus(1); //򿪷 + timer_restart(&warningBeepOnTimer); + beepStatus = 0x05; + break; + } + break; + + case 0x05: + if(timer_expired(&warningBeepOnTimer)) + { + SetBuzzerStatus(0); //رշ + timer_restart(&warningBeepOnTimer); + beepStatus = 0x06; + break; + } + break; + + case 0x06: + if(timer_expired(&warningBeepOnTimer)) + { + SetBuzzerStatus(1); //򿪷 + timer_restart(&warningBeepOnTimer); + beepStatus = 0x07; + break; + } + break; + + case 0x07: + if(timer_expired(&warningBeepOnTimer)) + { + SetBuzzerStatus(0); //رշ + timer_restart(&warningBeepOnTimer); + beepStatus = 0x08; + break; + } + break; + + case 0x08: + if(timer_expired(&warningBeepOnTimer)) + { + SetBuzzerStatus(1); //򿪷 + timer_restart(&warningBeepOnTimer); + beepStatus = 0x09; + break; + } + break; + + case 0x09: + if(timer_expired(&warningBeepOnTimer)) + { + SetBuzzerStatus(0); //رշ + beep_warningBeepMark = 0; + beepStatus = 0x00; + } + break; + + default: + SetBuzzerStatus(0); //رշ + beep_warningBeepMark = 0; + beepStatus = 0x00; + break; + } +} + +/* +*********************************************************************** +* : BEEP_ContSlowBeep +* ˵: +* Σ +* ֵ: +*********************************************************************** +*/ +static void BEEP_ContSlowBeep(void) +{ + static uint8_t beepStatus = 0x00; + + static timer beepOnTimer; + static timer beepOffTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&beepOnTimer, 2); + timer_set(&beepOffTimer, 8); + } + + switch(beepStatus) + { + case 0x00: + if(beep_contSlowBeepMark == 1) + { + SetBuzzerStatus(1); //򿪷 + + timer_restart(&beepOnTimer); + beepStatus = 0x01; + break; + } + break; + + case 0x01: + if(timer_expired(&beepOnTimer)) + { + SetBuzzerStatus(0); //رշ + timer_restart(&beepOffTimer); + beepStatus = 0x02; + break; + } + + if(beep_contSlowBeepMark == 0) + { + SetBuzzerStatus(0); + beepStatus = 0x00; + break; + } + break; + + case 0x02: + if(timer_expired(&beepOffTimer)) + { + beepStatus = 0x00; + break; + } + + if(beep_contSlowBeepMark == 0) + { + SetBuzzerStatus(0); + beepStatus = 0x00; + break; + } + break; + + default: + SetBuzzerStatus(0); //رշ + beepStatus = 0x00; + break; + } +} + +/* +*********************************************************************** +* : BEEP_ContFastBeep +* ˵: +* Σ +* ֵ: +*********************************************************************** +*/ +static void BEEP_ContFastBeep(void) +{ + static uint8_t beepStatus = 0x00; + + static timer beepOnTimer; + static timer beepOffTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&beepOnTimer, 1); + timer_set(&beepOffTimer, 2); + } + + switch(beepStatus) + { + case 0x00: + if(beep_contFastBeepMark == 1) + { + SetBuzzerStatus(1); //򿪷 + + timer_restart(&beepOnTimer); + beepStatus = 0x01; + break; + } + break; + + case 0x01: + if(timer_expired(&beepOnTimer)) + { + SetBuzzerStatus(0); //رշ + timer_restart(&beepOffTimer); + beepStatus = 0x02; + break; + } + + if(beep_contFastBeepMark == 0) + { + SetBuzzerStatus(0); + beepStatus = 0x00; + break; + } + break; + + case 0x02: + if(timer_expired(&beepOffTimer)) + { + beepStatus = 0x00; + break; + } + + if(beep_contFastBeepMark == 0) + { + SetBuzzerStatus(0); + beepStatus = 0x00; + break; + } + break; + + default: + SetBuzzerStatus(0); //رշ + beepStatus = 0x00; + break; + } +} + +/* +*********************************************************************** +* : BeepTask +* ˵: +* Σ +* ֵ: ضӦصļֵ +*********************************************************************** +*/ +void BeepTask(void) +{ + BEEP_ContSlowBeep(); + BEEP_ContFastBeep(); + BEEP_ShortBeep(); + BEEP_LongBeep(); + BEEP_StartUpBeep(); + BEEP_CloseDoorBeep(); + BEEP_WarningBeep(); +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/BUZZER/buzzer.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/BUZZER/buzzer.h new file mode 100755 index 0000000..17c5651 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/BUZZER/buzzer.h @@ -0,0 +1,26 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ buzzer.h + * + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#ifndef __BUZZER_H +#define __BUZZER_H + +#include "stm32f10x.h" + +extern uint8_t beep_startUpMark; //ʾ־ +extern uint8_t beep_shortBeepMark; //־ +extern uint8_t beep_longBeepMark; //־ +extern uint8_t beep_closeDoorBeepMark; //־ +extern uint8_t beep_warningBeepMark; //󾯸ʾ־ +extern uint8_t beep_contSlowBeepMark; //־ +extern uint8_t beep_contFastBeepMark; //־ + +void BeepInit(void); +void BeepTask(void); + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/device.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/device.c new file mode 100755 index 0000000..4502f57 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/device.c @@ -0,0 +1,1387 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ device.c + * ⲿ豸Ƽ + * V1.0 + * XuZhongPing + * 2017/09/04 +*********************************************************************************/ +#include "device.h" +#include "deviceSet.h" +#include "usart2.h" +#include "delay.h" +#include "timer.h" +#include "data_typedef.h" +#include "tcp_protocol.h" +#include "lcd.h" +#include "display.h" +#include "ec200x.h" +#include "door_ctrl.h" +#include "pc_protocol.h" +#include "disinfection.h" + +/* +*********************************************************************** +* : show +* ˵: ʮʾ +* : +* ֵ: +*********************************************************************** +*/ +void show(uint8_t num[], uint8_t n) +{ + uint8_t i; + printf("\r\n"); + for(i=0; i п豸 <----\r\n"); + isOpenDoor = 0; + +// swipingCardStatus = 1; //ʾ + +// keyValue = 0; + exitMark = 0; + isOpenDoorRequest_1 = 0; + isOpenDoorRequest_2 = 0; + isOpenDoorRequest_3 = 0; + isOpenDoorRequest_4 = 0; + putInEndMark = 0; + + printf("\r\nȴûͶ\r\n"); + + timer_restart(&waitingPutInTimer); + controlSteps = 0x01; //пתͶŲ + } + break; + + case 0x01: //ȴûͶ + if(timer_expired(&waitingPutInTimer)) //Ͷųʱ + { + putInOKMark = 1; + + printf("\r\nͶʱ䵽˳\r\n"); + controlSteps = 0x03; + break; + } + + //ǷӳͶ + if(delayCloseDoorStatus2 == 1) + { + delayCloseDoorStatus2 = 0; + timer_restart(&waitingPutInTimer); + printf("\r\nOpenDoorRequestTaskӳ!\r\n"); + } + + if(openDoorNumber == 255) + { + openDoorNumber = 0; + + beep_shortBeepMark = 1; + + if(fullMark1 == 0) isOpenDoorRequest_1 = 1; + if(fullMark2 == 0) isOpenDoorRequest_2 = 1; + if(fullMark3 == 0) isOpenDoorRequest_3 = 1; + if(fullMark4 == 0) isOpenDoorRequest_4 = 1; + } + + if(openDoorNumber != 0) //ûѡͶ + { + beep_shortBeepMark = 1; + switch(openDoorNumber) + { + case 1: + if(fullMark1 == 0) + { + isOpenDoorRequest_1 = 1; //־1豸ʼ + printf("\r\n1Ű\r\n"); + }else{ + printf("\r\n1\r\n"); + } + break; + + case 2: + if(fullMark2 == 0) + { + isOpenDoorRequest_2 = 1; //־1豸ʼ + printf("\r\n2Ű\r\n"); + }else{ + printf("\r\n2\r\n"); + } + break; + + case 3: + if(fullMark3 == 0) + { + isOpenDoorRequest_3 = 1; + printf("\r\n3Ű\r\n"); + }else{ + printf("\r\n3\r\n"); + } + break; + + case 4: + if(fullMark4 == 0) + { + isOpenDoorRequest_4 = 1; + printf("\r\n4Ű\r\n"); + }else{ + printf("\r\n4\r\n"); + } + break; + + default: + break; + } + openDoorNumber = 0; + } + + //жûͶŵǷѾͶ + if(putInEndMark == 1) + { + putInEndMark = 0; + putInOKMark = 1; + printf("\r\nûѾͶ\r\n"); + + controlSteps = 0x03; + break; + } + break; + + case 0x03: +// SetKeyLedOFF(1); +// SetKeyLedOFF(2); + + //ʹõıΪһ׼ + isOpenDoor = 0; + keyValue = 0; + isOpenDoorRequest_1 = 0; + isOpenDoorRequest_2 = 0; + isOpenDoorRequest_3 = 0; + isOpenDoorRequest_4 = 0; + + controlSteps = 0x00; + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : ClearDevCtrlVar +* ˵: 豸ƹʹõıΪһ׼ +* Σ +* ֵ: +*********************************************************************** +*/ +void ClearDevCtrlVar(void) +{ + keyValue = 0; //ť±־ + + isOpenDoor = 0; //־ + isOpenDoorRequest_1 = 0; + isOpenDoorRequest_2 = 0; + isOpenDoorRequest_3 = 0; + isOpenDoorRequest_4 = 0; +} + +/* +*********************************************************************** +* : DeviceControl +* ˵: 豸 +* Σ +* ֵ: ޣȫֱputInOK_StateɲΪ1ⲿ +*********************************************************************** +*/ +void DeviceControlTask(void) +{ + static uint8_t controlSteps = 0; + uint16_t tempWeight = 0; + + static uint8_t currentOpenDoorStatus_1 = 0; + static uint8_t currentOpenDoorStatus_2 = 0; + static uint8_t currentOpenDoorStatus_3 = 0; + static uint8_t currentOpenDoorStatus_4 = 0; + + static uint8_t doorCloseOK_1 = 0; + static uint8_t doorCloseOK_2 = 0; + static uint8_t doorCloseOK_3 = 0; + static uint8_t doorCloseOK_4 = 0; + + static uint16_t preChangeWeight1 = 0; + static uint16_t preChangeWeight2 = 0; + static uint16_t preChangeWeight3 = 0; + static uint16_t preChangeWeight4 = 0; + + uint16_t tempData1 = 0; + uint16_t tempData2 = 0; + + static uint32_t startTimer = 0; //ſʼʱ + static uint32_t endTimer = 0; //Žʱ + + static uint32_t preRemainingTimer = 0; //һλʣʱ + + static timer waitingTimer_100ms; //ȴ100msʱ + static timer waitingTimer_300ms; //ȴ300msʱ + static timer waitingTimer_500ms; //ȴ500msʱ + static timer waitingTimer_1S; //ȴ1Sʱ + static timer openDoorTimer; //ڿʱ + static timer closeDoorTimer; //ڹʱ + static timer waitingLeaveTimer; //ȴ뿪ʱ + static timer waitingTimer_300S; //5ӺԶ + static timer waitingGetWeight; + static timer waitingGetDis; + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&waitingTimer_100ms, 1); + timer_set(&waitingTimer_300ms, 15); + timer_set(&waitingTimer_500ms, 5); + timer_set(&waitingTimer_1S, CLOCK_SECOND*1); + timer_set(&openDoorTimer, 16); //1ʱڿʱ + timer_set(&closeDoorTimer, 60); //1ʱڹʱ + timer_set(&waitingLeaveTimer, CLOCK_SECOND*180); //1ʱڼ뿪 + timer_set(&waitingTimer_300S, CLOCK_SECOND*300); //1ʱ5ӺԶ + timer_set(&waitingGetWeight, CLOCK_SECOND*2); + timer_set(&waitingGetDis, CLOCK_SECOND*1); + } + + switch(controlSteps) + { + case 0x00: //ʼ״̬ + if((isOpenDoorRequest_1 == 1) || (isOpenDoorRequest_2 == 1) || (isOpenDoorRequest_3 == 1) || (isOpenDoorRequest_4 == 1)) //п + { + printf("\r\n----> п\r\n"); + +// disinfectingMark = 2; //ǰж +// sprayDisinfectingMark = 2; + + updateDistanceMark = 1; //־ǰͶŲȡ + + pcRequestClooseDoorMark = 0; + + isOpenDoor_1 = 0; + isOpenDoor_2 = 0; + isOpenDoor_3 = 0; + isOpenDoor_4 = 0; + + currentOpenDoorStatus_1 = 0; + currentOpenDoorStatus_2 = 0; + currentOpenDoorStatus_3 = 0; + currentOpenDoorStatus_4 = 0; + + doorCloseOK_1 = 0; + doorCloseOK_2 = 0; + doorCloseOK_3 = 0; + doorCloseOK_4 = 0; + + isCloseDoorMark_1 = 0; + isCloseDoorMark_2 = 0; + isCloseDoorMark_3 = 0; + isCloseDoorMark_4 = 0; + + smallBottleCount = 0; //Ͷǰƿӵ + bigBottleCount = 0; + cansCount = 0; + + getWeightBefore1 = weight1; //ȡǰϴ + getWeightBefore2 = weight2; + getWeightBefore3 = weight3; + getWeightBefore4 = weight4; + + preChangeWeight1 = weight1; //ȡǰжϳûб仯 + preChangeWeight2 = weight2; + preChangeWeight3 = weight3; + preChangeWeight4 = weight4; + + remainingTimer = 0; + + printf("\r\nȡǰ"); + printf("W1 = %2.2f Kg, W2 = %2.2f Kg, W3 = %2.2f Kg, W4 = %2.2f Kg\r\n", + (float)getWeightBefore1/100, + (float)getWeightBefore2/100, + (float)getWeightBefore3/100, + (float)getWeightBefore4/100); + + timer_restart(&waitingTimer_100ms); + controlSteps = 0x01; //пתͶŲ + break; + } + break; + + case 0x01: + if(timer_expired(&waitingTimer_100ms)) + { + if(isOpenDoorRequest_1 == 1) + { + isOpenDoorRequest_1 = 0; + isOpenDoor_1 = 1; + currentOpenDoorStatus_1 = 1; //־1д + } + + if(isOpenDoorRequest_2 == 1) + { + isOpenDoorRequest_2 = 0; + isOpenDoor_2 = 1; + currentOpenDoorStatus_2 = 1; //־2д + } + + if(isOpenDoorRequest_3 == 1) + { + isOpenDoorRequest_3 = 0; + isOpenDoor_3 = 1; + currentOpenDoorStatus_3 = 1; //־3д + } + + if(isOpenDoorRequest_4 == 1) + { + isOpenDoorRequest_4 = 0; + isOpenDoor_4 = 1; + currentOpenDoorStatus_4 = 1; //־4д + } + + timer_restart(&waitingTimer_300S); + controlSteps = 0x02; + break; + } + break; + + case 0x02: //ǷѾ뿪 + if(timer_expired(&waitingTimer_300S)) + { + printf("\r\n5ӳʱԶ\r\n"); + controlSteps = 0x04; //ת + break; + } + + timer_restart(&waitingLeaveTimer); + timer_restart(&waitingTimer_300S); + controlSteps = 0x03; + break; + + case 0x03: //ȷ뿪 + if(timer_expired(&waitingTimer_300S)) //5Ӷʱʱ䵽ˣֹͣ + { + controlSteps = 0x04; //ת + printf("\r\n5ӳʱԶ\r\n"); + break; + } + + //жϵȴǷм + if(isOpenDoorRequest_1 == 1) + { + isOpenDoorRequest_1 = 0; + isOpenDoor_1 = 1; + currentOpenDoorStatus_1 = 1; //־1д + timer_restart(&waitingLeaveTimer); + delayCloseDoorStatus = 1; + delayCloseDoorStatus2 = 1; + } + + if(isOpenDoorRequest_2 == 1) + { + isOpenDoorRequest_2 = 0; + isOpenDoor_2 = 1; + currentOpenDoorStatus_2 = 1; //־2д + timer_restart(&waitingLeaveTimer); + delayCloseDoorStatus = 1; + delayCloseDoorStatus2 = 1; + } + + if(isOpenDoorRequest_3 == 1) + { + isOpenDoorRequest_3 = 0; + isOpenDoor_3 = 1; + currentOpenDoorStatus_3 = 1; //־3д + timer_restart(&waitingLeaveTimer); + delayCloseDoorStatus = 1; + delayCloseDoorStatus2 = 1; + } + + if(isOpenDoorRequest_4 == 1) + { + isOpenDoorRequest_4 = 0; + isOpenDoor_4 = 1; + currentOpenDoorStatus_4 = 1; //־4д + timer_restart(&waitingLeaveTimer); + delayCloseDoorStatus = 1; + delayCloseDoorStatus2 = 1; + } + + //жǷͶţͶӳٹʱ + if(weight1 > preChangeWeight1) + { + if((weight1 - preChangeWeight1) >= 5) //ͶŴ50g + { + preChangeWeight1 = weight1; + timer_restart(&waitingLeaveTimer); //趨ȴʱڼ⵽Ͷţһֱֿ + delayCloseDoorStatus = 1; //־ӳٹţÿͶӳͬ + delayCloseDoorStatus2 = 1; + printf("\r\nӳٹ1\r\n"); + } + } + if(weight2 > preChangeWeight2) + { + if((weight2 - preChangeWeight2) >= 5) + { + preChangeWeight2 = weight2; + timer_restart(&waitingLeaveTimer); //趨ȴʱڼ⵽Ͷţһֱֿ + delayCloseDoorStatus = 1; //־ӳٹţÿͶӳͬ + delayCloseDoorStatus2 = 1; + printf("\r\nӳٹ2\r\n"); + } + } + if(weight3 > preChangeWeight3) + { + if((weight3 - preChangeWeight3) >= 5) + { + preChangeWeight3 = weight3; + timer_restart(&waitingLeaveTimer); + delayCloseDoorStatus = 1; + delayCloseDoorStatus2 = 1; + printf("\r\nӳٹ3\r\n"); + } + } + if(weight4 > preChangeWeight4) + { + if((weight4 - preChangeWeight4) >= 5) + { + preChangeWeight4 = weight4; + timer_restart(&waitingLeaveTimer); + delayCloseDoorStatus = 1; + delayCloseDoorStatus2 = 1; + printf("\r\nӳٹ4\r\n"); + } + } + + //ȡʣʱ + remainingTimer = timer_remaining(&waitingLeaveTimer)/10; + if(remainingTimer != preRemainingTimer) + { + preRemainingTimer = remainingTimer; + getRemainingTimerStatus = 1; + + if(remainingTimer == 3) + { + beep_closeDoorBeepMark = 1; + } +// printf("\r\nʣʱ = %d\r\n", remainingTimer); + } + + if(timer_expired(&waitingLeaveTimer)) //ʱʱ䵽ˣֹͣ + { + printf("\r\nѾ뿪\r\n"); + printf("\r\n\r\n"); + controlSteps = 0x04; + break; + } + + if(pcRequestClooseDoorMark == 1) + { + pcRequestClooseDoorMark = 0; + + printf("\r\nλرͶ\r\n"); + printf("\r\n\r\n"); + controlSteps = 0x04; + break; + } + + break; + + case 0x04: // + printf("\r\nͶţڹ\r\n"); + isCloseDoorMark_1 = 1; // + isCloseDoorMark_2 = 1; + isCloseDoorMark_3 = 1; + isCloseDoorMark_4 = 1; + + controlSteps = 0x05; + timer_restart(&closeDoorTimer); //ӵǰʱ¿ʼn붨ʱ + break; + + case 0x05: //ż + if(timer_expired(&closeDoorTimer)) //ʱʱ䵽ˣֹͣ + { + controlSteps = 0x06; + printf("\r\nȴʱ䵽\r\n"); + timer_restart(&waitingGetWeight); + break; + } + + //ж϶ӦǷѾر + if(currentOpenDoorStatus_1 == 1) + { + if(openDoorCtrlEndMark_1 == 1) + { + doorCloseOK_1 = 1; + } + }else{ + doorCloseOK_1 = 1; + } + + if(currentOpenDoorStatus_2 == 1) + { + if(openDoorCtrlEndMark_2 == 1) + { + doorCloseOK_2 = 1; + } + }else{ + doorCloseOK_2 = 1; + } + + if(currentOpenDoorStatus_3 == 1) + { + if(openDoorCtrlEndMark_3 == 1) + { + doorCloseOK_3 = 1; + } + }else{ + doorCloseOK_3 = 1; + } + + if(currentOpenDoorStatus_4 == 1) + { + if(openDoorCtrlEndMark_4 == 1) + { + doorCloseOK_4 = 1; + } + }else{ + doorCloseOK_4 = 1; + } + + if((doorCloseOK_1 == 1) && (doorCloseOK_2 == 1) && + (doorCloseOK_3 == 1) && (doorCloseOK_4 == 1)) + { + doorCloseOK_1 = 0; + doorCloseOK_2 = 0; + doorCloseOK_3 = 0; + doorCloseOK_4 = 0; + + timer_restart(&waitingGetWeight); + controlSteps = 0x06; + break; + } + break; + + case 0x06: //ȴȶȡ + if(timer_expired(&waitingGetWeight)) + { + getWeightAfter1 = weight1; //ȡͶź + getWeightAfter2 = weight2; + getWeightAfter3 = weight3; + getWeightAfter4 = weight4; + + updateDistanceMark = 0; //־Իȡ + restartGetDisDataMark = 1; //²ɼ + + timer_restart(&waitingGetDis); + controlSteps = 0x50; + break; + } + break; + + case 0x50: + if(timer_expired(&waitingGetDis)) + { + controlSteps = 0x07; + break; + } + break; + + case 0x07: //㱾Ͷ + printf("\r\n㱾Ͷ\r\n"); + printf("\r\n1: %2.2f Kg -> %2.2f Kg\r\n", (float)getWeightBefore1/100, (float)getWeightAfter1/100); + printf("\r\n2: %2.2f Kg -> %2.2f Kg\r\n", (float)getWeightBefore2/100, (float)getWeightAfter2/100); + printf("\r\n3: %2.2f Kg -> %2.2f Kg\r\n", (float)getWeightBefore3/100, (float)getWeightAfter3/100); + printf("\r\n4: %2.2f Kg -> %2.2f Kg\r\n", (float)getWeightBefore4/100, (float)getWeightAfter4/100); + + //һ + if(getWeightAfter1 < getWeightBefore1) + { + getWeight1 = 0; + }else{ + tempWeight = getWeightAfter1 - getWeightBefore1; //ǰ - ǰ = һͶŵ + if(tempWeight >= 10) //100gʱֵ + { + getWeight1 = tempWeight; + }else{ + getWeight1 = 0; + } + } + + //ڶ + if(getWeightAfter2 < getWeightBefore2) + { + getWeight2 = 0; + }else{ + tempWeight = getWeightAfter2 - getWeightBefore2; //ǰ - ǰ = һͶŵ + if(tempWeight >= 10) //100gʱֵ + { + getWeight2 = tempWeight; + }else{ + getWeight2 = 0; + } + } + + // + if(getWeightAfter3 < getWeightBefore3) + { + getWeight3 = 0; + }else{ + tempWeight = getWeightAfter3 - getWeightBefore3; + getWeight3 = (tempWeight >= 10) ? tempWeight : 0; + } + + // + if(getWeightAfter4 < getWeightBefore4) + { + getWeight4 = 0; + }else{ + tempWeight = getWeightAfter4 - getWeightBefore4; + getWeight4 = (tempWeight >= 10) ? tempWeight : 0; + } + + printf("\r\nڻȡ\r\n"); + controlSteps = 0x11; //תȡ + break; + + case 0x11: //ȡ + printf("\r\nݽл\r\n"); + controlSteps = 0x12; + break; + + case 0x12: //ԱͶݻ +// printf("\r\n---------> Ͷ£\r\n"); + + controlSteps = 0x13; + break; + + case 0x13: + printf("\r\n־Ͷɣ\r\n"); + putInEndMark = 1; //־ͶŲɣϴͶ + +// disinfectingMark = 1; //ͶŽ +// sprayDisinfectingMark = 1; + + //ӿ쳣 +// controlSteps = 0x40; + controlSteps = 0x14; +// timer_restart(&waitingTimer_100ms); + break; + + case 0x40: + + break; + + case 0x14: + ClearDevCtrlVar(); //ͶŹʹõıϢΪһͶ׼ + + printf("\r\n---> Ͷſɣ\r\n"); + controlSteps = 0x00; + + break; + + case 0x15: //ͰѾװ˳ + printf("\r\nMCU1Ͱָֹ\r\n"); + ClearPutInInfo(); //ͶŹʹõıϢΪһͶ׼ + +// SetKeyLedOFF(1); +// SetKeyLedOFF(2); + + printf("\r\n---------> Ͷţ\r\n"); + controlSteps = 0x00; + break; + + + + case 0x20: //豸˳λûбպϣ + printf("\r\nMCU1豸ָ\r\n"); +// SendEquipmentFailureCMD(); //豸ָ + ClearPutInInfo(); //ͶŹʹõıϢΪһͶ׼ + + SetKeyLedOFF(1); + SetKeyLedOFF(2); + + faultLedFlashMark = 1; //־豸ϣʾ + deviceFault = 1; //־豸ϣ쳣ϵͳ + + printf("\r\n---------> ͶŽ\r\n"); + controlSteps = 0x21; + break; + + case 0x21: + //λ쳣ͻе˴ֱ޸ + break; + + default: + controlSteps = 0x00; + break; + } +} + +/* +*********************************************************************** +* : CleanHolding +* ˵: Чִ +* Σ +* ֵ: +*********************************************************************** +*/ +void CleanHolding(void) +{ + static uint8_t currentStatus = 0x00; + static uint8_t nextStatus = 0x00; + + static timer cleanHoldingTimer; //˹Чʱ䣨ڿˢ˿ЧʱDzִģ + + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&cleanHoldingTimer, CLOCK_SECOND*60*3); + } + + currentStatus = nextStatus; + switch(currentStatus) + { + case 0x00: + if((disinfectingMark == 2) || (sprayDisinfectingMark == 2)) + { + printf("\r\nǰˣһʱ䲻\r\n"); + timer_restart(&cleanHoldingTimer); + nextStatus = 0x01; + break; + } + break; + + case 0x01: + if(timer_expired(&cleanHoldingTimer)) + { + printf("\r\n˱ʱ䵽\r\n"); + disinfectingMark = 0; + sprayDisinfectingMark = 0; + nextStatus = 0x00; + break; + } + break; + + default: break; + } +} + +/* +*********************************************************************** +* : CollectorLockCtrlTask +* ˵: +* Σ +* ֵ: +*********************************************************************** +*/ +void CollectorLockCtrlTask(void) +{ + static uint8_t runningSteps = 0; + + static timer eleLockUnlockingTimer; //ʱ + static timer waitingTimer; + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&eleLockUnlockingTimer, 2); + timer_set(&waitingTimer, 2); + } + + switch(runningSteps) + { + case 0x00: //ʼ״̬ + //ˢ˿ + if(boxOpenMark == 1) + { + boxOpenMark = 0; + + disinfectingMark = 2; //ʱͣ + sprayDisinfectingMark = 2; + + runningSteps = 0x01; + break; + } + break; + + case 0x01: //ϴԱϢ + printf("\r\nţ\r\n"); +// Unlock(5); + Unlock(6); + timer_restart(&eleLockUnlockingTimer); + runningSteps = 0x02; + break; + + case 0x02: //ȴ + if(timer_expired(&eleLockUnlockingTimer)) + { +// Locked(5); + Locked(6); + timer_restart(&waitingTimer); + runningSteps = 0x03; + break; + } + break; + + case 0x03: //˳ + if(timer_expired(&waitingTimer)) + { + boxOpenMark = 0; + runningSteps = 0x00; + break; + } + break; + + default: + break; + } + + CleanHolding(); //Чִڿˢ˿ЧʱDzִ +} + +/* +*********************************************************************** +* : FillLightTask +* ˵: ղƴ +* : +* ֵ: +*********************************************************************** +*/ +void FillLightTask(void) +{ + static uint8_t ledStatus = 0; + + static timer ledOnTimer; + static timer ledOffTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&ledOnTimer, 150); + } + + switch(ledStatus) + { + case 0x00: + if(fillLightMask == 1) + { + Unlock(1); + Unlock(2); + printf("\r\n򿪲ƣ\r\n"); + + timer_restart(&ledOnTimer); + ledStatus = 0x01; + break; + } + break; + + case 0x01: + if(timer_expired(&ledOnTimer)) + { + Locked(1); + Locked(2); + + printf("\r\nرղƣ\r\n"); + + fillLightMask = 0; + ledStatus = 0x00; + } + break; + + default: + ledStatus = 0x00; + break; + } +} + +/* +*********************************************************************** +* : CoolingFanCtrlTask +* ˵: ɢȷȿ +* Σ +* ֵ: +*********************************************************************** +*/ +void CoolingFanCtrlTask(void) +{ + static uint8_t currentStatus = 0x00; + static uint8_t nextStatus = 0x00; + + static timer responseTimeout; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&responseTimeout, CLOCK_SECOND*10); + } + + currentStatus = nextStatus; + switch(currentStatus) + { + case 0x00: + if(temperature >= 40) + { + printf("\r\n¶ȹȣɢȷȣ\r\n"); + Unlock(3); + Unlock(4); + nextStatus = 0x01; + break; + } + break; + + case 0x01: + if(temperature <= 38) + { + printf("\r\n¶Ȼָ\r\n"); + Locked(3); + Locked(4); + nextStatus = 0x00; + break; + } + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : SprayCtrlTask +* ˵: ܿ +* Σ +* ֵ: +*********************************************************************** +*/ +void SprayCtrlTask(void) +{ + static uint8_t currentStatus = 0x00; + static uint8_t nextStatus = 0x00; + + static timer responseTimeout; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&responseTimeout, CLOCK_SECOND*10); + } + + currentStatus = nextStatus; + switch(currentStatus) + { + case 0x00: + if(LIMI_KEY3 == 0) + { + printf("\r\n⵽쳣ܣ\r\n"); + DoorClose(4); + beep_warningBeepMark = 1; + + smokeAlarmStatus = 1; + PC_ProCommandSend(0x65); + nextStatus = 0x02; + break; + } + + if(temperature >= 80) + { + printf("\r\n¶ȹ(>80)ܣ\r\n"); +// DoorClose(4); + beep_warningBeepMark = 1; + nextStatus = 0x01; + break; + } + break; + + case 0x01: //¶ȹȴ + if(temperature <= 75) + { + printf("\r\n¶(<75)ָ\r\n"); +// DoorStop(4); + nextStatus = 0x00; + break; + } + beep_warningBeepMark = 1; + break; + + case 0x02: //⵽쳣 + if(LIMI_KEY3 == 1) + { + printf("\r\nָ\r\n"); + DoorStop(4); + + smokeAlarmStatus = 0; + PC_ProCommandSend(0x65); + nextStatus = 0x00; + } + beep_warningBeepMark = 1; + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : SystemExceptionTask +* ˵: ϵͳ쳣 +* Σ +* ֵ: λɺ󷵻1 +*********************************************************************** +*/ +void SystemExceptionTask(void) +{ + static uint8_t restartSteps = 0x00; + static uint8_t ledFlashStatus = 0; + + static timer restartTimer; + static timer ledFlashTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&restartTimer, CLOCK_SECOND*20); + timer_set(&ledFlashTimer, 5); //LED˸ʱ + } + + switch(restartSteps) + { + case 0x00: + if(deviceFault == 1) //豸⵽ϵͳ쳣쳣 + { + restartSteps = 0x01; + timer_restart(&restartTimer); + break; + } + break; + + case 0x01: + if(timer_expired(&restartTimer)) //ѭÿŹλϵͳ + { + while(1); + } + break; + + default: + break; + } + + //쳣ʱָʾ˸ + switch(ledFlashStatus) + { + case 0x00: + if(faultLedFlashMark == 1) + { + SetKeyLedON(3); + SetKeyLedON(4); + if(timer_expired(&ledFlashTimer)) + { + ledFlashStatus = 0x01; + timer_restart(&ledFlashTimer); + } + } + break; + + case 0x01: + SetKeyLedOFF(3); + SetKeyLedOFF(4); + if(timer_expired(&ledFlashTimer)) + { + ledFlashStatus = 0x00; + timer_restart(&ledFlashTimer); + } + break; + + default: + ledFlashStatus = 0x00; + break; + } +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/device.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/device.h new file mode 100755 index 0000000..7f10d44 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/device.h @@ -0,0 +1,72 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ device.h + * 豸Ƴ + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#ifndef __DEVICE_H +#define __DEVICE_H + +//ķ+кͶ壨ķһҪ˶ע͵ +#define FOUR_CHANNEL_AND_HARMFUL +#define FOUR_DROP_PORTS + +#include "stm32f10x.h" +#include "usart1.h" +#include "usart2.h" +#include "usart3.h" +#include "usart4.h" +#include "usart5.h" + +#include "string.h" +#include "stdlib.h" + +#include "led.h" +#include "key.h" +#include "opto_sw_key.h" +#include "sw_key.h" +#include "buzzer.h" +#include "scale.h" +#include "ElectronicLock.h" +#include "motor.h" +#include "RFID_IC.h" +#include "qr_code.h" +#include "ntc.h" +#include "sound.h" +#include "spi.h" +#include "flash.h" +#include "stmflash.h" +#include "distancer.h" + +#include "ec200x.h" +#include "disinfection.h" +#include "door_ctrl.h" +#include "m_s_comm.h" + +#define VersionNumber "V2.1_260709_4CH" + +void show(uint8_t num[], uint8_t n); +void CalcOverflowStartPointParam(void); +void DeviceInit(void); //豸ʼ +void DeviceTest(void); //Ӳ +void UserIdentificationTask(void); +uint8_t GetPutInType(void); //ȡÿͶ +void ShowPutInTyep(uint8_t uType); +void GetUserInfo(uint8_t inputType); //ݿʽȡûϢ +void ClearPutInInfo(void); // + + +void DeviceScanning(void); +void PutInOpenDoorTask(void); +void OpenDoorRequestTask(void); +void DeviceControlTask(void); +void CollectorLockCtrlTask(void); +void FillLightTask(void); +void CoolingFanCtrlTask(void); +void SprayCtrlTask(void); +void SystemExceptionTask(void); + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/deviceSet.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/deviceSet.c new file mode 100755 index 0000000..180fda8 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/deviceSet.c @@ -0,0 +1,1694 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ device.c + * ⲿ豸Ƽ + * V1.0 + * XuZhongPing + * 2017/09/04 +*********************************************************************************/ +#include "deviceSet.h" +#include "device.h" +#include "usart1.h" +#include "usart2.h" +#include "delay.h" +#include "timer.h" +#include "data_typedef.h" +#include "tcp_protocol.h" +#include "lcd.h" +#include "display.h" +#include "stmflash.h" +#include "qr_code.h" +#include "scale.h" + + +/* +*********************************************************************** +* : ShowRecyclingType +* ˵: ʾ +* Σtype -> ɻ +* ֵ: +*********************************************************************** +*/ +void ShowRecyclingType(uint8_t type) +{ + switch(type) + { + case PAPER: + printf("ֽ"); + break; + + case PLASTIC: + printf(""); + break; + + case GLASS: + printf(""); + break; + + case METAL: + printf(""); + break; + + case RECYCLED: + printf("ɻ"); + break; + + case KITCHEN: + printf(""); + break; + + case SMALL_BOTTLE: + printf("Сƿ"); + break; + + case BIG_BOTTLE: + printf("ƿ"); + break; + + case CANS: + printf(""); + break; + + case BATTERY: + printf(""); + break; + + case FABRIC: + printf("֯"); + break; + + case BOOK: + printf("鱾"); + break; + + case NEWSPAPER: + printf("ֽ"); + break; + + case KITCHEN_1: + printf("1"); + break; + + case KITCHEN_2: + printf("2"); + break; + + case PLASTIC_2: + printf("2"); + break; + + case OTHER: + printf(""); + break; + + case HARMFUL: + printf("к"); + break; + + case DRY_WASTES: + printf(""); + break; + + case WET_WASTES: + printf("ʪ"); + break; + + default: + printf("δ֪(%d)", type); + break; + } +} + +/* +*********************************************************************** +* : DeviceInfoShow +* ˵: 豸Ϣʾ +* Σ +* ֵ: +*********************************************************************** +*/ +void DeviceInfoShow(void) +{ + printf("\r\n豸Ϣ\r\n"); + printf("------------\r\n"); + + printf("%s\r\n", VersionStr); + + switch(deviceType) + { + case SINGLE_CLASSIFICATION: + printf("豸: һ豸 ("); + ShowRecyclingType(devChannel1Type); + printf(")\r\n"); + break; + + case DOUBLE_CLASSIFICATION: + printf("豸: 豸 ("); + ShowRecyclingType(devChannel1Type); + printf(""); + ShowRecyclingType(devChannel2Type); + printf(")\r\n"); + break; + + case DOUBLE_CLASSIFICATION_BOTTLE: + printf("豸: 豸_ƿࡱ ("); + ShowRecyclingType(devChannel1Type); + printf(""); + ShowRecyclingType(devChannel2Type); + printf(")\r\n"); + break; + + case THREE_CLASSIFICATION: + printf("豸: 豸 ("); + ShowRecyclingType(devChannel1Type); + printf(""); + ShowRecyclingType(devChannel2Type); + printf(""); + ShowRecyclingType(devChannel3Type); + printf(")\r\n"); + break; + + case FOUR_CLASSIFICATION: + printf("豸: ķ豸 ("); + ShowRecyclingType(devChannel1Type); + printf(""); + ShowRecyclingType(devChannel2Type); + printf(""); + ShowRecyclingType(devChannel3Type); + printf(""); + ShowRecyclingType(devChannel4Type); + printf(")\r\n"); + break; + } + + Screen_ShowDeviceInfo(VersionStr, devChannel1Type, devChannel2Type, devChannel3Type, devChannel4Type); + + printf("---------------------------\r\n"); +} + +/* +*********************************************************************** +* : SetDefaultOverflowAlarmParam +* ˵: 籨Ĭϲ +* Σ +* ֵ: +*********************************************************************** +*/ +void SetDefaultOverflowAlarmParam(void) +{ + switch(deviceType) + { + case SINGLE_CLASSIFICATION: // + break; + + case DOUBLE_CLASSIFICATION: // + break; + + case DOUBLE_CLASSIFICATION_BOTTLE: //ຬƿ + break; + + default: + break; + } + +// printf("\r\nĬ: h1 = %d; H1 = %d; A1 = %d; h2 = %d; H2 = %d; A2 = %d;\r\n", +// setDistance_L_DepthVal, setDistance_L_MaxVal, setDistance_L_AlarmPercent, +// setDistance_R_DepthVal, setDistance_R_MaxVal, setDistance_R_AlarmPercent); +} + +/* +*********************************************************************** +* : DeviceSetParamInit +* ˵: 豸òʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void DeviceSetParamInit(void) +{ + setDeviceType = deviceType; + setDevChannelNumbers = devChannelNumbers; + setDevChannel1Type = devChannel1Type; + setDevChannel2Type = devChannel2Type; + setDevChannel3Type = devChannel3Type; + setDevChannel4Type = devChannel4Type; + + setPassword = password; //Ҫõ豸 + setCustomerID = customerID; //ͻţڿ˭Դţ + + setDevChannel1DisDepthVal = devChannel1DisDepthVal; + setDevChannel1DisMaxVal = devChannel1DisMaxVal; + setDevChannel1DisAlarmPercent = devChannel1DisAlarmPercent; + + setDevChannel2DisDepthVal = devChannel2DisDepthVal; + setDevChannel2DisMaxVal = devChannel2DisMaxVal; + setDevChannel2DisAlarmPercent = devChannel2DisAlarmPercent; + + setDevChannel3DisDepthVal = devChannel3DisDepthVal; + setDevChannel3DisMaxVal = devChannel3DisMaxVal; + setDevChannel3DisAlarmPercent = devChannel3DisAlarmPercent; + + setDevChannel4DisDepthVal = devChannel4DisDepthVal; + setDevChannel4DisMaxVal = devChannel4DisMaxVal; + setDevChannel4DisAlarmPercent = devChannel4DisAlarmPercent; + + setDisableICCardFunStatus = disableICCardFunStatus; //áICûܱ־λ + setEnableCleanQRCodeStatus = enableCleanQRCodeStatus; //á˿ά뿪š־ + + printf("\r\n豸òʼɣ\r\n"); + printf("\r\nSetParam:\r\n"); + printf("P=%d; ID=%d; DevType=%d; Cnt=%d\r\n", + setPassword, + setCustomerID, + setDeviceType, + setDevChannelNumbers); + + printf("T1=%d, h1=%d, H1=%d, A1=%d\r\n", + setDevChannel1Type, setDevChannel1DisDepthVal, setDevChannel1DisMaxVal, setDevChannel1DisAlarmPercent); + + printf("T2=%d, h2=%d, H2=%d, A2=%d\r\n", + setDevChannel2Type, setDevChannel2DisDepthVal, setDevChannel2DisMaxVal, setDevChannel2DisAlarmPercent); + + printf("T3=%d, h3=%d, H3=%d, A3=%d\r\n", + setDevChannel3Type, setDevChannel3DisDepthVal, setDevChannel3DisMaxVal, setDevChannel3DisAlarmPercent); + + printf("T4=%d, h4=%d, H4=%d, A4=%d\r\n", + setDevChannel4Type, setDevChannel4DisDepthVal, setDevChannel4DisMaxVal, setDevChannel4DisAlarmPercent); + + printf("ICE=%d, ICQR=%d\r\n", setDisableICCardFunStatus, setEnableCleanQRCodeStatus); +} + +/* +*********************************************************************** +* : DeviceParamInit +* ˵: 豸ʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void DeviceParamInit(void) +{ + password = setPassword; + customerID = setCustomerID; + + deviceType = setDeviceType; + devChannelNumbers = setDevChannelNumbers; + devChannel1Type = setDevChannel1Type; + devChannel2Type = setDevChannel2Type; + devChannel3Type = setDevChannel3Type; + devChannel4Type = setDevChannel4Type; + +#ifdef FOUR_DROP_PORTS + deviceType = FOUR_CLASSIFICATION; + devChannelNumbers = 4; + setDeviceType = deviceType; + setDevChannelNumbers = devChannelNumbers; +#endif + + devChannel1DisDepthVal = setDevChannel1DisDepthVal; + devChannel1DisMaxVal = setDevChannel1DisMaxVal; + devChannel1DisAlarmPercent = setDevChannel1DisAlarmPercent; + + devChannel2DisDepthVal = setDevChannel2DisDepthVal; + devChannel2DisMaxVal = setDevChannel2DisMaxVal; + devChannel2DisAlarmPercent = setDevChannel2DisAlarmPercent; + + devChannel3DisDepthVal = setDevChannel3DisDepthVal; + devChannel3DisMaxVal = setDevChannel3DisMaxVal; + devChannel3DisAlarmPercent = setDevChannel3DisAlarmPercent; + + devChannel4DisDepthVal = setDevChannel4DisDepthVal; + devChannel4DisMaxVal = setDevChannel4DisMaxVal; + devChannel4DisAlarmPercent = setDevChannel4DisAlarmPercent; + + disableICCardFunStatus = setDisableICCardFunStatus; + enableCleanQRCodeStatus = setEnableCleanQRCodeStatus; + + printf("\r\nDevice Param Init OK\r\n"); + printf("\r\nCurParam:\r\n"); + printf("P=%d; ID=%d; DevType=%d; Cnt=%d\r\n", + password, + customerID, + deviceType, + devChannelNumbers); + + printf("T1=%d, h1=%d, H1=%d, A1=%d\r\n", + devChannel1Type, devChannel1DisDepthVal, devChannel1DisMaxVal, devChannel1DisAlarmPercent); + + printf("T2=%d, h2=%d, H2=%d, A2=%d\r\n", + devChannel2Type, devChannel2DisDepthVal, devChannel2DisMaxVal, devChannel2DisAlarmPercent); + + printf("T3=%d, h3=%d, H3=%d, A3=%d\r\n", + devChannel3Type, devChannel3DisDepthVal, devChannel3DisMaxVal, devChannel3DisAlarmPercent); + + printf("T4=%d, h4=%d, H4=%d, A4=%d\r\n", + devChannel4Type, devChannel4DisDepthVal, devChannel4DisMaxVal, devChannel4DisAlarmPercent); + + printf("ICE=%d, ICQR=%d\r\n", disableICCardFunStatus, enableCleanQRCodeStatus); +} + + +//----------------------------------------------------------------------------------- +//ͨά豸 + +/* +*********************************************************************** +* : StrToInt +* ˵: ַתݣʽУ飩 +* Σstr -> תַ +* ֵ: תݣʽȷʱ0xFFFFFFFF +*********************************************************************** +*/ +uint32_t StrToInt(char *str) +{ + uint32_t res = 0xFFFFFFFF; + + if(strlen(str) < 10) //ҪתݳС10λ + { + if(strspn(str, "0123456789") == strlen(str)) //УDzǶ + { + res = atoi(str); + }else{ + res = 0xFFFFFFFF; + printf("\r\nݸʽ\r\n"); + } + } + return res; +} + +/* +*********************************************************************** +* : StrArrToIntArr +* ˵: ַת +* ΣstrArr -> תַ + intArr -> ת + len -> Ҫת鳤 +* ֵ: תɹ1ʧܷ0 +*********************************************************************** +*/ +uint8_t StrArrToIntArr(char strArr[][16], uint32_t intArr[], uint8_t len) +{ + uint8_t i = 0; + uint32_t temp; + +// printf("\r\nstrArr[i] = {", strArr[i]); + for(i = 0; i < len; i++) + { +// printf("%s, ", strArr[i]); + temp = StrToInt(strArr[i]); //ַת + if(temp != 0xFFFFFFFF) + { + intArr[i] = temp; + }else{ + printf("\r\nwrong format\r\n"); + return 0; + } + } +// printf("}\r\n"); + + return 1; +} + +/* +*********************************************************************** +* : StringSplit +* ˵: ַ +* Σstr -> ַ +* ֵ: 뷵1󷵻0 +*********************************************************************** +*/ +uint8_t StringSplit(char *str) +{ + uint8_t res = 0; + uint8_t i = 0; + uint32_t temp = 0xFFFFFFFF; + static uint8_t preSetParamCmd = 0; //һε + char *token; + + memset(setParamList, 0x00, 16*16); + + //ֽ + printf("\r\n\r\n"); + + setParamCount = 0; + token = strtok(str, ","); + while (token != NULL) + { +// printf("\r\nparam%d %s\r\n", setParamCount, token); + if(strlen(token) < 16) + { + strcpy(setParamList[setParamCount], token); + token = strtok(NULL, ","); + setParamCount++; + }else{ + printf("\r\nȹ\r\n"); + return 0; + } + } + + printf("\r\nlen = %d, dataList: {", setParamCount); + for(i = 0; i < setParamCount; i++) + { + printf("%s, ", setParamList[i]); + } + printf("}\r\n"); + + //ֽ + temp = StrToInt(setParamList[0]); //ַת + if(temp != 0xFFFFFFFF) + { + setParamCmd = temp; //ָ + res = 1; + printf("\r\ncmd = %d\r\n", setParamCmd); + + if((preSetParamCmd != setParamCmd) && (setParamCmd != 1)) + { + if(setParamCmd != 1) + { + setParamChangeMark = 1; + printf("\r\nָб仯\r\n"); + } + preSetParamCmd = setParamCmd; + } + }else{ + res = 0; + printf("\r\n\r\n"); + } + + return res; +} + +/* +*********************************************************************** +* : SetParamDecode +* ˵: ò +* Σ +* ֵ: +*********************************************************************** +*/ +void SetParamDecode(uint8_t *pSetParamStr) +{ + uint32_t temp = 0xFFFFFFFF; + char paramBuf[128]; + uint32_t intDataArr[16]; + uint8_t i = 0; + uint8_t len = 0; + uint8_t decodeOkMark = 0; + + char *p; + char *pParam; + char *token; + + p = (char*)strstr((const char*)pSetParamStr, ":"); + pParam = p+1; + memset(paramBuf, 0x00, 128); + strcpy(paramBuf, pParam); //ȱõIJ + + decodeOkMark = StringSplit(paramBuf); //ֳ + + //жǷΪ + if(decodeOkMark == 1) + { + printf("\r\nsetCmd = %d\r\n", setParamCmd); + switch(setParamCmd) + { + case 1: //ȷ + printf("\r\nSET --> ȷϣ\r\n"); + printf("\r\nlist[1]%s\r\n", setParamList[1]); + + temp = StrToInt(setParamList[1]); //ַת + if(temp != 0xFFFFFFFF) + { + getConfirmPassword = temp; + getConfirmPasswordMark = 1; //־Ѿȡôȷϵ + printf("\r\nΪ%d\r\n", getConfirmPassword); + }else{ + getConfirmPasswordMark = 0; + printf("\r\nȷݸʽ\r\n"); + break; + } + break; + + case 2: //޸ + printf("\r\nSET --> ޸ģ\r\n"); + printf("\r\nlist[1]%s\r\n", setParamList[1]); + + temp = StrToInt(setParamList[1]); //ַת + if(temp != 0xFFFFFFFF) + { + getPassword = temp; + getPasswordMark = 1; //־Ѿȡôȷϵ + printf("\r\nΪ%d\r\n", getPassword); + }else{ + getPasswordMark = 0; + printf("\r\nݸʽ\r\n"); + break; + } + break; + + case 3: //豸 + printf("\r\nSET --> 豸ã\r\n"); + + //豸 + printf("\r\nlist[1]%s\r\n", setParamList[1]); + temp = StrToInt(setParamList[1]); //ַת + if(temp != 0xFFFFFFFF) + { + getDeviceType = temp; + printf("\r\n豸Ϊ%d\r\n", getDeviceType); + }else{ + getDeviceTypeMark = 0; + printf("\r\nݸʽ\r\n"); + break; + } + + //Ͷͨ + printf("\r\nlist[2]%s\r\n", setParamList[2]); + temp = StrToInt(setParamList[2]); //ַת + if(temp != 0xFFFFFFFF) + { + getDevChannelNumbers = temp; + printf("\r\n豸ͶͨΪ%d\r\n", getDevChannelNumbers); + }else{ + getDeviceTypeMark = 0; + printf("\r\n豸Ͷͨݸʽ\r\n"); + break; + } + + temp = StrArrToIntArr(&setParamList[3], intDataArr, getDevChannelNumbers); + if(temp == 1) + { + if(getDevChannelNumbers == 1) //1 + { + getDevChannel1Type = intDataArr[0]; + getDeviceTypeMark = 1; //Ͷ豸־ɹ + printf("\r\n1%d\r\n", getDevChannel1Type); + }else if(getDevChannelNumbers == 2){ //2 + getDevChannel1Type = intDataArr[0]; + getDevChannel2Type = intDataArr[1]; + getDeviceTypeMark = 1; //־ɹ + printf("\r\n2%d, %d\r\n", getDevChannel1Type, getDevChannel2Type); + }else if(getDevChannelNumbers == 3){ //3 + getDevChannel1Type = intDataArr[0]; + getDevChannel2Type = intDataArr[1]; + getDevChannel3Type = intDataArr[2]; + getDeviceTypeMark = 1; //־ɹ + printf("\r\n3%d, %d, %d\r\n", getDevChannel1Type, getDevChannel2Type, getDevChannel3Type); + }else if(getDevChannelNumbers == 4){ //4 + getDevChannel1Type = intDataArr[0]; + getDevChannel2Type = intDataArr[1]; + getDevChannel3Type = intDataArr[2]; + getDevChannel4Type = intDataArr[3]; + getDeviceTypeMark = 1; //־ɹ + printf("\r\n4%d, %d, %d, %d\r\n", getDevChannel1Type, getDevChannel2Type, getDevChannel3Type, getDevChannel4Type); + }else{} + }else{ + getDeviceTypeMark = 0; + printf("\r\nûݸʽ\r\n"); + break; + } + break; + + case 4: //豸ͻ + printf("\r\nSET --> 豸ͻã\r\n"); + printf("\r\nlist[1]%s\r\n", setParamList[1]); + + temp = StrToInt(setParamList[1]); //ַת + if(temp != 0xFFFFFFFF) + { + getCustomerID = temp; + getCustomerIDMark = 1; //־Ѿȡôȷϵ + printf("\r\nͻΪ%d\r\n", getCustomerID); + }else{ + getCustomerIDMark = 0; + printf("\r\nÿͻݸʽ\r\n"); + } + break; + + case 5: + break; + + case 6: ///ͣáõICܿš + printf("\r\nSET -->õICܿţã\r\n"); + printf("\r\nlist[1]%s\r\n", setParamList[1]); + + temp = StrToInt(setParamList[1]); //ַת + if(temp != 0xFFFFFFFF) + { + getDisableICCardFunStatus = temp; + getDisableICCardFunMark = 1; //־Ѿȡôȷϵ + printf("\r\n״̬Ϊ%d\r\n", getDisableICCardFunStatus); + break; + }else{ + getDisableICCardFunMark = 0; + printf("\r\nãõICܿţݸʽ\r\n"); + break; + } + break; + + case 7: ///ͣá˶ά뿪š + printf("\r\nSET -->˶ά뿪ţã\r\n"); + printf("\r\nlist[1]%s\r\n", setParamList[1]); + + temp = StrToInt(setParamList[1]); //ַת + if(temp != 0xFFFFFFFF) + { + getEnableCleanQRCodeStatus = temp; + getEnableCleanQRCodeMark = 1; //־Ѿȡôȷϵ + printf("\r\n״̬Ϊ%d\r\n", getEnableCleanQRCodeStatus); + break; + }else{ + getEnableCleanQRCodeMark = 0; + printf("\r\nã˶ά뿪ţݸʽ\r\n"); + break; + } + break; + + case 13: //籨 + printf("\r\nSET -->ã\r\n"); + + //Ͷͨ + printf("\r\nlist[1]%s\r\n", setParamList[1]); + temp = StrToInt(setParamList[1]); //ַת + if(temp != 0xFFFFFFFF) + { + getDevChannelNumbers = temp; + printf("\r\n豸ͶͨΪ%d\r\n", getDevChannelNumbers); + }else{ + getDeviceTypeMark = 0; + printf("\r\n豸Ͷͨݸʽ\r\n"); + break; + } + + temp = StrArrToIntArr(&setParamList[2], intDataArr, getDevChannelNumbers*3); + if(temp == 1) + { + if(getDevChannelNumbers == 1) //1 + { + getDevChannel1DisDepthVal = intDataArr[0]; + getDevChannel1DisMaxVal = intDataArr[1]; + getDevChannel1DisAlarmPercent = intDataArr[2]; + getOverflowSetMark = 1; //Ͷ豸־ɹ + printf("\r\nOF1: %d, %d, %d\r\n", getDevChannel1DisDepthVal, getDevChannel1DisMaxVal, getDevChannel1DisAlarmPercent); + }else if(getDevChannelNumbers == 2){ //2 + getDevChannel1DisDepthVal = intDataArr[0]; + getDevChannel1DisMaxVal = intDataArr[1]; + getDevChannel1DisAlarmPercent = intDataArr[2]; + + getDevChannel2DisDepthVal = intDataArr[3]; + getDevChannel2DisMaxVal = intDataArr[4]; + getDevChannel2DisAlarmPercent = intDataArr[5]; + + getOverflowSetMark = 1; //־ɹ + printf("\r\nOF1: %d, %d, %d; OF2: %d, %d, %d\r\n", getDevChannel1DisDepthVal, getDevChannel1DisMaxVal, getDevChannel1DisAlarmPercent, + getDevChannel2DisDepthVal, getDevChannel2DisMaxVal, getDevChannel2DisAlarmPercent); + }else if(getDevChannelNumbers == 3){ //3 + getDevChannel1DisDepthVal = intDataArr[0]; + getDevChannel1DisMaxVal = intDataArr[1]; + getDevChannel1DisAlarmPercent = intDataArr[2]; + + getDevChannel2DisDepthVal = intDataArr[3]; + getDevChannel2DisMaxVal = intDataArr[4]; + getDevChannel2DisAlarmPercent = intDataArr[5]; + + getDevChannel3DisDepthVal = intDataArr[6]; + getDevChannel3DisMaxVal = intDataArr[7]; + getDevChannel3DisAlarmPercent = intDataArr[8]; + + getOverflowSetMark = 1; //־ɹ + printf("\r\nOF1: %d, %d, %d; OF2: %d, %d, %d; OF3: %d, %d, %d\r\n", + getDevChannel1DisDepthVal, getDevChannel1DisMaxVal, getDevChannel1DisAlarmPercent, + getDevChannel2DisDepthVal, getDevChannel2DisMaxVal, getDevChannel2DisAlarmPercent, + getDevChannel3DisDepthVal, getDevChannel3DisMaxVal, getDevChannel3DisAlarmPercent); + }else if(getDevChannelNumbers == 4){ //4 + getDevChannel1DisDepthVal = intDataArr[0]; + getDevChannel1DisMaxVal = intDataArr[1]; + getDevChannel1DisAlarmPercent = intDataArr[2]; + + getDevChannel2DisDepthVal = intDataArr[3]; + getDevChannel2DisMaxVal = intDataArr[4]; + getDevChannel2DisAlarmPercent = intDataArr[5]; + + getDevChannel3DisDepthVal = intDataArr[6]; + getDevChannel3DisMaxVal = intDataArr[7]; + getDevChannel3DisAlarmPercent = intDataArr[8]; + + getDevChannel4DisDepthVal = intDataArr[9]; + getDevChannel4DisMaxVal = intDataArr[10]; + getDevChannel4DisAlarmPercent = intDataArr[11]; + + getOverflowSetMark = 1; //־ɹ + printf("\r\nOF1: %d, %d, %d; OF2: %d, %d, %d; OF3: %d, %d, %d; OF4: %d, %d, %d\r\n", + getDevChannel1DisDepthVal, getDevChannel1DisMaxVal, getDevChannel1DisAlarmPercent, + getDevChannel2DisDepthVal, getDevChannel2DisMaxVal, getDevChannel2DisAlarmPercent, + getDevChannel3DisDepthVal, getDevChannel3DisMaxVal, getDevChannel3DisAlarmPercent, + getDevChannel4DisDepthVal, getDevChannel4DisMaxVal, getDevChannel4DisAlarmPercent); + }else{} + }else{ + getDeviceTypeMark = 0; + printf("\r\nݸʽ\r\n"); + break; + } + break; + + case 30: //У׼ + printf("\r\nSET --> У׼\r\n"); + printf("\r\nlist[1]%s\r\n", setParamList[1]); + + temp = StrToInt(setParamList[1]); //ַת + if(temp != 0xFFFFFFFF) + { + getScaleNum = temp; + getScaleCalibrationMark = 1; //־Ѿȡôȷϵ + printf("\r\ṉΪ%d\r\n", getScaleNum); + }else{ + getConfirmPasswordMark = 0; + printf("\r\nУ׼̲ݸʽ\r\n"); + break; + } + break; + + case 31: //ʱŶά + printf("\r\nSET --> ʱţ\r\n"); + printf("\r\nlist[1]%s\r\n", setParamList[1]); + + temp = StrToInt(setParamList[1]); //ַת + if(temp != 0xFFFFFFFF) + { + getBoxOpenMark = 1; //־Ѿȡôȷϵ + printf("\r\nűΪ%d\r\n", getScaleNum); + }else{ + getBoxOpenMark = 0; + printf("\r\nʱŲݸʽ\r\n"); + break; + } + break; + + case 56: //ǿ޸ + printf("\r\nSET --> ǿ޸ģ\r\n"); + printf("\r\nlist[1]%s\r\n", setParamList[1]); + + temp = StrToInt(setParamList[1]); //ַת + if(temp != 0xFFFFFFFF) + { + getPassword = temp; + getForceChangeMark = 1; //־Ѿȡôȷϵ + printf("\r\nΪ%d\r\n", getPassword); + }else{ + getForceChangeMark = 0; + printf("\r\nǿݸʽ\r\n"); + break; + } + break; + + case 100: //豸ָ + printf("\r\nSET --> 豸ָã\r\n"); + getDeviceParamResetMark = 1; + break; + + default: + break; + } + } +} + +/* +*********************************************************************** +* : PasswordCheck +* ˵: У +* Σ +* ֵ: 1ȷϳɹ0δȷ +*********************************************************************** +*/ +uint8_t PasswordCheck(void) +{ + uint8_t res = 0; + + if(getConfirmPasswordMark == 1) + { + getConfirmPasswordMark = 0; + if(password == getConfirmPassword) + { + printf("\r\nУȷ\r\n"); + res = 1; + }else{ + printf("\r\nУ\r\n"); + res = 0; + } + } + return res; +} + +/* +*********************************************************************** +* : PasswordSetTask +* ˵: ޸ +* Σ +* ֵ: +*********************************************************************** +*/ +void PasswordSetTask(void) +{ + static uint8_t setStep = 0x00; + + switch(setStep) + { + case 0x00: + if(getPasswordMark == 1) + { + getPasswordMark = 0; + getConfirmPasswordMark = 0; + setParamChangeMark = 0; + setStep = 0x01; + } + break; + + case 0x01: + if(getConfirmPasswordMark == 1) + { + getConfirmPasswordMark = 0; + if(password == getConfirmPassword) + { + printf("\r\nУȷ\r\n"); + setPassword = getPassword; + printf("\r\n޸ijɹ\r\n"); + setParamSaveMark = 1; //־в޸ģҪб + setStep = 0x00; + break; + }else{ + printf("\r\nУ\r\n"); + break; + } + } + + if(setParamChangeMark == 1) + { + setParamChangeMark = 0; + setStep = 0x00; + printf("\r\nл\r\n"); + break; + } + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : PasswordCastSetTask +* ˵: ǿ޸ +* Σ +* ֵ: +*********************************************************************** +*/ +void PasswordCastSetTask(void) +{ + static uint8_t setStep = 0x00; + + switch(setStep) + { + case 0x00: + if(getForceChangeMark == 1) + { + getForceChangeMark = 0; + setPassword = getPassword; + setParamSaveMark = 1; //־в޸ģҪб + printf("\r\nǿ޸ijɹ\r\n"); + setStep = 0x00; + } + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : DeviceTypeSetTask +* ˵: 豸 +* Σ +* ֵ: +*********************************************************************** +*/ +void DeviceTypeSetTask(void) +{ + static uint8_t setStep = 0x00; + + switch(setStep) + { + case 0x00: + if(getDeviceTypeMark == 1) + { + getDeviceTypeMark = 0; + getConfirmPasswordMark = 0; + setParamChangeMark = 0; + printf("\r\nȡͣȴȷ룡\r\n"); + setStep = 0x01; + } + break; + + case 0x01: + if(getConfirmPasswordMark == 1) + { + getConfirmPasswordMark = 0; + if(password == getConfirmPassword) + { + printf("\r\nУȷ\r\n"); + setDeviceType = getDeviceType; + setDevChannelNumbers = getDevChannelNumbers; + setDevChannel1Type = getDevChannel1Type; + setDevChannel2Type = getDevChannel2Type; + setDevChannel3Type = getDevChannel3Type; + setDevChannel4Type = getDevChannel4Type; +// SetDefaultOverflowAlarmParam(); //豸б仯ʱҪ籨 + setParamSaveMark = 1; //־в޸ģҪб + setStep = 0x00; + break; + }else{ + printf("\r\nУ\r\n"); + break; + } + } + + if(setParamChangeMark == 1) + { + setParamChangeMark = 0; + setStep = 0x00; + printf("\r\nл\r\n"); + break; + } + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : CustomerIdSetTask +* ˵: 豸ͻ +* Σ +* ֵ: +*********************************************************************** +*/ +void CustomerIdSetTask(void) +{ + static uint8_t setStep = 0x00; + + switch(setStep) + { + case 0x00: + if(getCustomerIDMark == 1) + { + getCustomerIDMark = 0; + getConfirmPasswordMark = 0; + setParamChangeMark = 0; + setStep = 0x01; + } + break; + + case 0x01: + if(getConfirmPasswordMark == 1) + { + getConfirmPasswordMark = 0; + if(password == getConfirmPassword) + { + printf("\r\nУȷ\r\n"); + setCustomerID = getCustomerID; + printf("\r\nͻ޸ijɹ\r\n"); + setParamSaveMark = 1; //־в޸ģҪб + setStep = 0x00; + break; + }else{ + printf("\r\nУ\r\n"); + break; + } + } + + if(setParamChangeMark == 1) + { + setParamChangeMark = 0; + setStep = 0x00; + printf("\r\nл\r\n"); + break; + } + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : DisableICCardFunSetTask +* ˵: /ͣáõICܿš +* Σ +* ֵ: +*********************************************************************** +*/ +void DisableICCardFunSetTask(void) +{ + static uint8_t setStep = 0x00; + + switch(setStep) + { + case 0x00: + if(getDisableICCardFunMark == 1) + { + getDisableICCardFunMark = 0; + getConfirmPasswordMark = 0; + setParamChangeMark = 0; + setStep = 0x01; + } + break; + + case 0x01: + if(getConfirmPasswordMark == 1) + { + getConfirmPasswordMark = 0; + if(password == getConfirmPassword) + { + printf("\r\nУȷ\r\n"); + setDisableICCardFunStatus = getDisableICCardFunStatus; + printf("\r\nõICܿš޸ijɹ\r\n"); + if(setDisableICCardFunStatus == 1) + { + printf("\r\nͣã\r\n"); + }else{ + printf("\r\nã\r\n"); + } + setParamSaveMark = 1; //־в޸ģҪб + setStep = 0x00; + break; + }else{ + printf("\r\nУ\r\n"); + break; + } + } + + if(setParamChangeMark == 1) + { + setParamChangeMark = 0; + setStep = 0x00; + printf("\r\nл\r\n"); + break; + } + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : DisableICCardFunSetTask +* ˵: /ͣá˶ά뿪š +* Σ +* ֵ: +*********************************************************************** +*/ +void EnableCleanQRCodeSetTask(void) +{ + static uint8_t setStep = 0x00; + + switch(setStep) + { + case 0x00: + if(getEnableCleanQRCodeMark == 1) + { + getEnableCleanQRCodeMark = 0; + getConfirmPasswordMark = 0; + setParamChangeMark = 0; + setStep = 0x01; + } + break; + + case 0x01: + if(getConfirmPasswordMark == 1) + { + getConfirmPasswordMark = 0; + if(password == getConfirmPassword) + { + printf("\r\nУȷ\r\n"); + setEnableCleanQRCodeStatus = getEnableCleanQRCodeStatus; + printf("\r\n˶ά뿪š޸ijɹ\r\n"); + if(setEnableCleanQRCodeStatus == 1) + { + printf("\r\nã\r\n"); + }else{ + printf("\r\nͣã\r\n"); + } + setParamSaveMark = 1; //־в޸ģҪб + setStep = 0x00; + break; + }else{ + printf("\r\nУ\r\n"); + break; + } + } + + if(setParamChangeMark == 1) + { + setParamChangeMark = 0; + setStep = 0x00; + printf("\r\nл\r\n"); + break; + } + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : OverflowSetTask +* ˵: +* Σ +* ֵ: +*********************************************************************** +*/ +void OverflowSetTask(void) +{ + static uint8_t setStep = 0x00; + + switch(setStep) + { + case 0x00: + if(getOverflowSetMark == 1) + { + getOverflowSetMark = 0; + getConfirmPasswordMark = 0; + setParamChangeMark = 0; + printf("\r\nȡͣȴȷ룡\r\n"); + setStep = 0x01; + } + break; + + case 0x01: + if(getConfirmPasswordMark == 1) + { + getConfirmPasswordMark = 0; + if(password == getConfirmPassword) + { + printf("\r\nУȷ\r\n"); + setDevChannel1DisDepthVal = getDevChannel1DisDepthVal; + setDevChannel1DisMaxVal = getDevChannel1DisMaxVal; + setDevChannel1DisAlarmPercent = getDevChannel1DisAlarmPercent; + + setDevChannel2DisDepthVal = getDevChannel2DisDepthVal; + setDevChannel2DisMaxVal = getDevChannel2DisMaxVal; + setDevChannel2DisAlarmPercent = getDevChannel2DisAlarmPercent; + + setDevChannel3DisDepthVal = getDevChannel3DisDepthVal; + setDevChannel3DisMaxVal = getDevChannel3DisMaxVal; + setDevChannel3DisAlarmPercent = getDevChannel3DisAlarmPercent; + + setDevChannel4DisDepthVal = getDevChannel4DisDepthVal; + setDevChannel4DisMaxVal = getDevChannel4DisMaxVal; + setDevChannel4DisAlarmPercent = getDevChannel4DisAlarmPercent; + +// SetDefaultOverflowAlarmParam(); //豸б仯ʱҪ籨 + setParamSaveMark = 1; //־в޸ģҪб + setStep = 0x00; + break; + }else{ + printf("\r\nУ\r\n"); + break; + } + } + + if(setParamChangeMark == 1) + { + setParamChangeMark = 0; + setStep = 0x00; + printf("\r\nл\r\n"); + break; + } + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : ScaleCalibrationTask +* ˵: У׼ +* Σ +* ֵ: +*********************************************************************** +*/ +void ScaleCalibrationTask(void) +{ + static uint8_t setStep = 0x00; + static timer waitingTimer; + static timer waitingTimer1S; + static timer waitingExitTimer; + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&waitingTimer, CLOCK_SECOND*3); + timer_set(&waitingTimer1S, CLOCK_SECOND*1); + timer_set(&waitingExitTimer, CLOCK_SECOND*20); + } + + switch(setStep) + { + case 0x00: //ʼ״̬ + if(getScaleCalibrationMark == 1) + { + getScaleCalibrationMark = 0; + getConfirmPasswordMark = 0; //ȷ־ + setParamChangeMark = 0; //ָл־ + setStep = 0x01; + } + break; + + case 0x01: //У + if(getConfirmPasswordMark == 1) + { + getConfirmPasswordMark = 0; + if(password == getConfirmPassword) + { + printf("\r\nУȷ\r\n"); + + printf("\r\nУ׼\r\n"); + setStep = 0x02; + break; + }else{ + printf("\r\nУ\r\n"); + break; + } + } + + if(setParamChangeMark == 1) + { + setParamChangeMark = 0; + setStep = 0x00; + printf("\r\nл\r\n"); + break; + } + break; + + case 0x02: //У׼ + Screen_ScaleCalibraEnter(getScaleNum); //ʾУ׼ + + if(getScaleNum == 0) + { + if(deviceWorkStatus == 1) + { + Screen_Default(); + }else{ + Screen_DeviceDisable(); + } + + setStep = 0x00; + break; + } + + scaleNum = getScaleNum; + getCalibraZeroMark1 = 0; + getCalibraZeroMark2 = 0; + + beep_contSlowBeepMark = 1; + M_S_CommandSend(0xA1); + timer_restart(&waitingExitTimer); + setStep = 0x03; + break; + + case 0x3: //ȴģӦȡ + if(timer_expired(&waitingExitTimer)) + { + printf("\r\nȡУ׼㳬ʱ˳\r\n"); + + beep_contSlowBeepMark = 0; + setStep = 0x10; + } + + switch(getScaleNum) + { + case 1: //1 + if(getCalibraZeroMark1 == 1) + { + printf("\r\nյ1У׼㣡\r\n"); + Screen_ScaleCalibraStart(getScaleNum); + getCalibraParamOkMark1 = 0; + + beep_contSlowBeepMark = 0; + beep_contFastBeepMark = 1; + + timer_restart(&waitingExitTimer); + setStep = 0x04; + break; + } + break; + + case 2: //2 + if(getCalibraZeroMark2 == 1) + { + printf("\r\nյ2У׼㣡\r\n"); + Screen_ScaleCalibraStart(getScaleNum); + getCalibraParamOkMark2 = 0; + + beep_contSlowBeepMark = 0; + beep_contFastBeepMark = 1; + + timer_restart(&waitingExitTimer); + setStep = 0x04; + break; + } + break; + + default: + setStep = 0x00; + break; + } + break; + + case 0x04: //ȴУ׼ + if(timer_expired(&waitingExitTimer)) + { + printf("\r\nȡУ׼㳬ʱ˳\r\n"); + + beep_contFastBeepMark = 0; + setStep = 0x10; + break; + } + + switch(getScaleNum) + { + case 1: //1 + if(getCalibraParamOkMark1 == 1) + { + printf("\r\nյ1У׼ɣ\r\n"); + Screen_ScaleCalibraFinish(getScaleNum); + + beep_contFastBeepMark = 0; + beep_longBeepMark = 1; + timer_restart(&waitingTimer); + setStep = 0x05; + break; + } + break; + + case 2: //2 + if(getCalibraParamOkMark2 == 1) + { + printf("\r\nյ2У׼ɣ\r\n"); + Screen_ScaleCalibraFinish(getScaleNum); + + beep_contFastBeepMark = 0; + beep_longBeepMark = 1; + timer_restart(&waitingTimer); + setStep = 0x05; + break; + } + break; + + default: + setStep = 0x00; + break; + } + break; + + case 0x05: //˳ + if(timer_expired(&waitingTimer)) + { + beep_contSlowBeepMark = 0; + beep_contFastBeepMark = 0; + + if(deviceWorkStatus == 1) + { + Screen_Default(); + }else{ + Screen_DeviceDisable(); + } + setStep = 0x00; + } + break; + + case 0x10: //У׼ʧģԴ +// ScalePowerOFF(1); +// ScalePowerOFF(2); + M_S_CommandSend(0xA5); + timer_restart(&waitingTimer1S); + setStep = 0x11; + break; + + case 0x11: //У׼ʧģԴ + if(timer_expired(&waitingTimer1S)) + { +// ScalePowerON(1); +// ScalePowerON(2); + setStep = 0x05; + } + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : BoxOpenSetTask +* ˵: ʱŲ +* Σ +* ֵ: +*********************************************************************** +*/ + +void BoxOpenSetTask(void) +{ + static uint8_t setStep = 0x00; + + switch(setStep) + { + case 0x00: + if(getBoxOpenMark == 1) + { + getBoxOpenMark = 0; + boxOpenMark = 1; + printf("\r\n׼ţ\r\n"); + setStep = 0x00; + } + break; + + default: + break; + } +} + +// void BoxOpenSetTask(void) +// { +// static uint8_t setStep = 0x00; +// +// switch(setStep) +// { +// case 0x00: +// if(getBoxOpenMark == 1) +// { +// getBoxOpenMark = 0; +// getConfirmPasswordMark = 0; +// setParamChangeMark = 0; +// setStep = 0x01; +// } +// break; +// +// case 0x01: +// if(getConfirmPasswordMark == 1) +// { +// getConfirmPasswordMark = 0; +// if(password == getConfirmPassword) +// { +// printf("\r\nУȷ\r\n"); +// boxOpenMark = 1; +// printf("\r\n׼ţ\r\n"); +// setStep = 0x00; +// break; +// }else{ +// printf("\r\nУ\r\n"); +// break; +// } +// } +// +// if(setParamChangeMark == 1) +// { +// setParamChangeMark = 0; +// setStep = 0x00; +// printf("\r\nл\r\n"); +// break; +// } +// break; +// +// default: +// break; +// } +// } + +/* +*********************************************************************** +* : DeviceParamResetTask +* ˵: 豸ָ +* Σ +* ֵ: +*********************************************************************** +*/ +void DeviceParamResetTask(void) +{ + static uint8_t setStep = 0x00; + + switch(setStep) + { + case 0x00: + if(getDeviceParamResetMark == 1) + { + getDeviceParamResetMark = 0; + getConfirmPasswordMark = 0; + setParamChangeMark = 0; + setStep = 0x01; + } + break; + + case 0x01: + if(PasswordCheck() == 1) + { + printf("\r\nʼָ豸\r\n"); + ResetDeviceConfig(); + beep_shortBeepMark = 1; +// DeviceConfigParamInit(); //豸òʼ + + + getDeviceParamResetMark = 0; + setStep = 0x10; + break; + } + + if(setParamChangeMark == 1) + { + setParamChangeMark = 0; + + getDeviceParamResetMark = 0; + setStep = 0x00; + printf("\r\nл\r\n"); + break; + } + break; + + case 0x10: + while(1); //ָɺϵͳ + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : ParamSaveTask +* ˵: 豸в޸ȷϣҪб棩 +* Σ +* ֵ: +*********************************************************************** +*/ +void ParamSaveTask(void) +{ + static uint8_t setStep = 0x00; + + static timer waitingTimer; + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&waitingTimer, CLOCK_SECOND*2); //1ʱڵʱ + } + + switch(setStep) + { + case 0x00: + if(setParamSaveMark == 1) + { + setParamSaveMark = 0; + + SaveDeviceConfig(); + DeviceParamInit(); //б䶯³ʼ豸 + CalcOverflowStartPointParam(); + + DeviceInfoShow(); + setStep = 0x01; + timer_restart(&waitingTimer); + } + break; + + case 0x01: + if(timer_expired(&waitingTimer)) + { + if(deviceWorkStatus == 1) + { + Screen_Default(); + }else{ + Screen_DeviceDisable(); + } + setStep = 0x00; + } + break; + + case 0x02: + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : ParamSetTask +* ˵: +* Σ +* ֵ: +*********************************************************************** +*/ +void ParamSetTask(void) +{ + if(devSetQrCodeState == 1) + { + printf("\r\nò---->\r\n"); + devSetQrCodeState = 0; + SetParamDecode(codeBuf); //öά + } + + PasswordSetTask(); //޸ + PasswordCastSetTask(); //ǿ޸ + DeviceTypeSetTask(); //豸 + CustomerIdSetTask(); //ͻ + + DisableICCardFunSetTask(); ///ͣáõICܿš + EnableCleanQRCodeSetTask(); ///ͣá˶ά뿪š + + OverflowSetTask(); // + + ScaleCalibrationTask(); //У׼ + BoxOpenSetTask(); //ʱŲ + + DeviceParamResetTask(); //豸ָ + + ParamSaveTask(); //豸 +} + + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/deviceSet.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/deviceSet.h new file mode 100755 index 0000000..083e05d --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/deviceSet.h @@ -0,0 +1,36 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ deviceSet.h + * 豸ó + * V1.0 + * XuZhongPing + * 2019/03/06 +*********************************************************************************/ +#ifndef __DEVICE_SET_H +#define __DEVICE_SET_H + +#include "stm32f10x.h" +#include "string.h" +#include "stdlib.h" + +#include "led.h" +#include "key.h" +#include "opto_sw_key.h" +#include "sw_key.h" +#include "usart5.h" + +#include "sound.h" +#include "spi.h" +#include "flash.h" + +void DeviceInfoShow(void); +void ShowRecyclingBinsType(uint8_t type); +void DeviceTypeSet(uint8_t setkeyVal); +void DeviceSetParamInit(void); +void DeviceParamInit(void); +void SetDefaultOverflowAlarmParam(void); + +void ParamSetTask(void); + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/distancer.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/distancer.c new file mode 100755 index 0000000..ce1cc4e --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/distancer.c @@ -0,0 +1,387 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ distancer.c + * + * V1.0 + * XuZhongPing + * 2017/08/04 +*********************************************************************************/ +#include "distancer.h" +#include "timer.h" +#include "delay.h" +#include "my_math.h" +#include "data_typedef.h" +#include "key.h" +#include "pc_protocol.h" + +uint16_t distanceCnt1 = 0; +uint16_t distanceCnt2 = 0; + +uint8_t distanceBuf1[DISTANCE_CNT_MAX] = {0}; //ݻ +uint8_t distanceBuf2[DISTANCE_CNT_MAX] = {0}; + +uint8_t outputDistance1 = 255; //βIJ +uint8_t outputDistance2 = 255; +uint8_t outputDistance3 = 255; +uint8_t outputDistance4 = 255; + +uint8_t restartGetDisDataMark = 0; //¿ʼ־ + + + +void showData(uint8_t num[], uint8_t n) +{ + uint8_t i; + printf("\r\n"); + for(i=0; i x[k]) k = j; + } + if(k != i) + { + t = x[i]; + x[i] = x[k]; + x[k] = t; + } + } +} + +/* +*********************************************************************** +* : uint average(uint *p,uchar n) +* ˵: ȥСֵƽ +* Σ +* x[]:Ҫ +* n:ij +* discardVal:ֵͷ +* ֵ: Ľ +*********************************************************************** +*/ +uint8_t Average(uint8_t x[], uint8_t n, uint8_t discardVal) +{ + uint8_t i = 0; + uint8_t aver = 0; + uint32_t sum = 0; + + for(i = discardVal; i < n-discardVal; i++) + { + sum = sum+x[i]; + } + aver = sum/(n - discardVal*2); + return aver; +} + +/* +*********************************************************************** +* : DistanceDataUpdata +* ˵: βݴ +* Σ +* ֵ: +*********************************************************************** +*/ +void DistanceDataUpdata(void) +{ + static uint8_t currentStatus = 0x00; + static uint8_t nextStatus = 0x00; + + static timer waitingTimer; + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&waitingTimer, CLOCK_SECOND*15); + } + + if(restartGetDisDataMark == 1) + { + restartGetDisDataMark = 0; + + distanceCnt1 = 0; + distanceCnt2 = 0; + + printf("\r\n²ɼݣ\r\n"); + timer_restart(&waitingTimer); + } + + if(putInProgress == 0) + { + if(timer_expired(&waitingTimer)) + { + timer_restart(&waitingTimer); + + printf("\r\nݴ\r\n"); + + printf("\r\ndistanceCnt1 = %d\r\n", distanceCnt1); + showData(distanceBuf1, distanceCnt1); + DataSort(distanceBuf1, distanceCnt1); + showData(distanceBuf1, distanceCnt1); + outputDistance1 = Average(distanceBuf1, distanceCnt1, 10); + if((outputDistance1 > distanceParamAtStart) && (outputDistance1 != 255)) + { + outputDistance1 = devChannel1DisMaxVal; + } + printf("\r\noutputDistance1 = %d\r\n", outputDistance1); + + printf("\r\ndistanceCnt2 = %d\r\n", distanceCnt2); + showData(distanceBuf2, distanceCnt2); + DataSort(distanceBuf2, distanceCnt2); + showData(distanceBuf2, distanceCnt2); + outputDistance2 = Average(distanceBuf2, distanceCnt2, 10); + if((outputDistance2 > distanceParamAtStart) && (outputDistance2 != 255)) + { + outputDistance2 = devChannel2DisMaxVal; + } + printf("\r\noutputDistance2 = %d\r\n", outputDistance2); + + //¿ʼ + distanceCnt1 = 0; + distanceCnt2 = 0; + + PC_ProCommandSend(0x62); + } + } +} + +/* +*********************************************************************** +* : OverflowDetectionTask +* ˵: Ͱװ +* Σ +* ֵ: +*********************************************************************** +*/ +void OverflowDetectionTask(void) +{ + uint8_t a1 = 0, a2 = 0, a3 = 0, a4 = 0; + uint8_t A1 = 0, A2 = 0, A3 = 0, A4 = 0; + + static uint8_t fullMarkPre1 = 0; + static uint8_t fullMarkPre2 = 0; + static uint8_t fullMarkPre3 = 0; + static uint8_t fullMarkPre4 = 0; + + static timer timer_60s; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&timer_60s, CLOCK_SECOND*10); + } + + //趨IJжǷװ + //1ͨж + if((devChannel1DisDepthVal > 0) && (outputDistance1 <= devChannel1DisMaxVal)) + { + a1 = devChannel1DisMaxVal - outputDistance1; + A1 = ((uint16_t)a1*100)/devChannel1DisDepthVal; + +// printf("\r\nd1 = %d, a1 = %d, A1 = %d\r\n", getDistance1, a1, A1); + + if(A1 >= devChannel1DisAlarmPercent) + { + fullMark1 = 1; + }else{ + fullMark1 = 0; + } + }else{ //ǰõľ趨İװ߶˵Ϊ + fullMark1 = 0; + } + + //2ͨж + if((devChannel2DisDepthVal > 0) && (outputDistance2 <= devChannel2DisMaxVal)) + { + a2 = devChannel2DisMaxVal - outputDistance2; + A2 = ((uint16_t)a2*100)/devChannel2DisDepthVal; + +// printf("\r\nd2 = %d, a2 = %d, A2 = %d\r\n", getDistance2, a2, A2); + + if(A2 >= devChannel2DisAlarmPercent) + { + fullMark2 = 1; + }else{ + fullMark2 = 0; + } + }else{ //ǰõľ趨İװ߶˵Ϊ + fullMark2 = 0; + } + + //3ͨж + if((devChannel3DisDepthVal > 0) && (outputDistance3 <= devChannel3DisMaxVal)) + { + a3 = devChannel3DisMaxVal - outputDistance3; + A3 = ((uint16_t)a3*100)/devChannel3DisDepthVal; + fullMark3 = (A3 >= devChannel3DisAlarmPercent) ? 1 : 0; + }else{ + fullMark3 = 0; + } + + //4ͨж + if((devChannel4DisDepthVal > 0) && (outputDistance4 <= devChannel4DisMaxVal)) + { + a4 = devChannel4DisMaxVal - outputDistance4; + A4 = ((uint16_t)a4*100)/devChannel4DisDepthVal; + fullMark4 = (A4 >= devChannel4DisAlarmPercent) ? 1 : 0; + }else{ + fullMark4 = 0; + } + + //缰ָʾ + if((netStatus == 2) || (devRunnigStatus == 2)) + { + //йʱĵƹɫ + SetKeyLedOFF(1); + SetKeyLedON(2); + SetKeyLedOFF(3); + SetKeyLedON(4); + }else{ +#ifdef FOUR_DROP_PORTS + //ͶſÿͶſʹһָʾơ + if(fullMark1) SetKeyLedON(1); else SetKeyLedOFF(1); + if(fullMark2) SetKeyLedON(2); else SetKeyLedOFF(2); + if(fullMark3) SetKeyLedON(3); else SetKeyLedOFF(3); + if(fullMark4) SetKeyLedON(4); else SetKeyLedOFF(4); +#else + //ͨ1 + if(fullMark1 == 1) + { + SetKeyLedOFF(1); + SetKeyLedON(2); + }else{ + SetKeyLedON(1); + SetKeyLedOFF(2); + } + + //ͨ2 + if(fullMark2 == 1) + { + SetKeyLedOFF(3); + SetKeyLedON(4); + }else{ + SetKeyLedON(3); + SetKeyLedOFF(4); + } +#endif + } + + + //ӡϢ + if((fullMarkPre1 != fullMark1) || (fullMarkPre2 != fullMark2) || + (fullMarkPre3 != fullMark3) || (fullMarkPre4 != fullMark4)) + { + if(fullMark1 == 1) + { + printf("\r\nCH1װ\r\n"); + }else{ + printf("\r\nCH1\r\n"); + } + fullMarkPre1 = fullMark1; + printf("\r\nd1 = %d, a1 = %d, A1 = %d%%\r\n", outputDistance1, a1, A1); + + if(fullMark2 == 1) + { + printf("\r\nCH2װ\r\n"); + }else{ + printf("\r\nCH2\r\n"); + } + fullMarkPre2 = fullMark2; + + printf("\r\nd2 = %d, a2 = %d, A2 = %d%%\r\n", outputDistance2, a2, A2); + + fullMarkPre3 = fullMark3; + fullMarkPre4 = fullMark4; + printf("\r\nd3 = %d, a3 = %d, A3 = %d%%\r\n", outputDistance3, a3, A3); + printf("\r\nd4 = %d, a4 = %d, A4 = %d%%\r\n", outputDistance4, a4, A4); + + PC_ProCommandSend(0x62); + } + +// //ӡϢ +// if(fullMarkPre1 != fullMark1) +// { +// if(fullMark1 == 1) +// { +// printf("\r\nCH1װ\r\n"); +// }else{ +// printf("\r\nCH1\r\n"); +// } +// fullMarkPre1 = fullMark1; +// printf("\r\nd1 = %d, a1 = %d, A1 = %d%%\r\n", getDistance1, a1, A1); +// } +// +// if(fullMarkPre2 != fullMark2) +// { +// if(fullMark2 == 1) +// { +// printf("\r\nCH2װ\r\n"); +// }else{ +// printf("\r\nCH2\r\n"); +// } +// fullMarkPre2 = fullMark2; +// +// printf("\r\nd2 = %d, a2 = %d, A2 = %d%%\r\n", getDistance2, a2, A2); +// } +// +// if(fullMarkPre3 != fullMark3) +// { +// if(fullMark3 == 1) +// { +// printf("\r\nCH3װ\r\n"); +// }else{ +// printf("\r\nCH3\r\n"); +// } +// fullMarkPre3 = fullMark3; +// printf("\r\nd3 = %d, a3 = %d, A3 = %d%%\r\n", getDistance3, a3, A3); +// } +// +// if(fullMarkPre4 != fullMark4) +// { +// if(fullMark4 == 1) +// { +// printf("\r\nCH4װ\r\n"); +// }else{ +// printf("\r\nCH4\r\n"); +// } +// fullMarkPre4 = fullMark4; +// printf("\r\nd4 = %d, a4 = %d, A4 = %d%%\r\n", getDistance4, a4, A4); +// } + + //װ1Ӵӡһװʾ + if(timer_expired(&timer_60s)) + { + timer_restart(&timer_60s); + + printf("\r\nͨ1d1 = %d, a1 = %d, A1 = %d%%\r\n", outputDistance1, a1, A1); + printf("\r\nͨ2d2 = %d, a2 = %d, A2 = %d%%\r\n", outputDistance2, a2, A2); + printf("\r\nͨ3d3 = %d, a3 = %d, A3 = %d%%\r\n", outputDistance3, a3, A3); + printf("\r\nͨ4d4 = %d, a4 = %d, A4 = %d%%\r\n", outputDistance4, a4, A4); + } +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/distancer.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/distancer.h new file mode 100755 index 0000000..05e6323 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/distancer.h @@ -0,0 +1,47 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ distancer.h + * + * V1.0 + * XuZhongPing + * 2017/08/04 +*********************************************************************************/ +#ifndef __DISTANCER_H +#define __DISTANCER_H +#include "stm32f10x.h" +#include "IR_Distancer.h" +#include "UltrasonicWave.h" + + +// 豸 +typedef enum +{ + ULTRASONIC_DISTANCER = 1, // + IR_DISTANCER // +}DistanceSensorDefine; + +extern uint8_t distancerTpye; //ഫ + +#define DISTANCE_CNT_MAX 120 + +extern uint16_t distanceCnt1; +extern uint16_t distanceCnt2; + +extern uint8_t distanceBuf1[DISTANCE_CNT_MAX]; +extern uint8_t distanceBuf2[DISTANCE_CNT_MAX]; + +extern uint8_t restartGetDisDataMark; + +extern uint8_t outputDistance1; +extern uint8_t outputDistance2; +extern uint8_t outputDistance3; +extern uint8_t outputDistance4; + + +void GetDistanceTask(void); +void OverflowDetectionTask(void); + +void DistanceDataUpdata(void); + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/m_s_comm.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/m_s_comm.c new file mode 100755 index 0000000..a796bf7 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/m_s_comm.c @@ -0,0 +1,492 @@ +/*************************** (C) COPYRIGHT 2020 Ping **************************** + * ļ m_s_comm.c + * MCUͨѶ + * V1.0 + * XuZhongPing + * 2020/03/31 +*********************************************************************************/ +#include "m_s_comm.h" +#include "device.h" +#include "data_typedef.h" +//#include "distancer.h" + +uint8_t M_S_RX_BUF[M_S_RECV_LEN]; //ջ +uint8_t M_S_TX_BUF[M_S_SEND_LEN]; //ͻ + +static void M_S_DataDecode(uint8_t *pRxBuf, uint8_t *pTxBuf); + +static uint8_t CorrectOverflowDistance(uint8_t rawDistance, uint16_t channelWeight, + uint8_t maxVal, uint8_t depthVal) +{ + uint16_t correctedDistance; + uint16_t measureStart; + + if(rawDistance == 255) + { + return 255; + } + + correctedDistance = (uint16_t)rawDistance + 15; + measureStart = maxVal - (((uint16_t)depthVal * PerCentSetVal) / 100); + + if(correctedDistance > measureStart) + { + correctedDistance = maxVal; + } + + if((channelWeight < 1700) && (correctedDistance < 75)) + { + correctedDistance = maxVal; + } + + return (uint8_t)correctedDistance; +} + +/* +*********************************************************************** +* : M_S_DataPackingAndSend +* ˵: ӻͨѶݴ +* : *pdata -> ҪݵַdataLen -> ݳ +* ֵ: +*********************************************************************** +*/ +void M_S_DataPackingAndSend(uint8_t *pdata, uint16_t dataLen) +{ + uint8_t i; + uint8_t CS = 0x68; + uint8_t TX_Size = 0; + + uint8_t sendDataBuf[128]; + uint8_t dataAddrIndex = 0; + uint8_t sendDataLen = 0; + + sendDataBuf[dataAddrIndex++] = 0xfe; //ǰֽ + sendDataBuf[dataAddrIndex++] = 0xfe; + sendDataBuf[dataAddrIndex++] = 0xfe; + sendDataBuf[dataAddrIndex++] = 0x68; //֡ͷ + + sendDataBuf[dataAddrIndex++] = *pdata; //͵ַ + CS += *pdata; + sendDataBuf[dataAddrIndex++] = 0x68; //֡ͷ + CS += 0x68; + sendDataBuf[dataAddrIndex++] = *(pdata+1); //֡ + CS += *(pdata+1); + TX_Size = *(pdata+2); //ȡͨѶݳ + sendDataBuf[dataAddrIndex++] = TX_Size; //ݳ + CS += *(pdata+2); + for(i=0; i ָ +* ֵ: +*********************************************************************** +*/ +void M_S_CommandSend(uint8_t comNum) +{ + uint8_t dataLen = 0; //Эܳ + uint8_t dataIndex = 0; //͵± + + M_S_TX_BUF[0] = 0x00; //ͨѶַ + M_S_TX_BUF[1] = comNum; // + + dataIndex += 3; //ӵַȺʼ + + printf("\r\nM->S --> 0x%02X\r\n", comNum); + + switch(comNum) + { + case 0x01: + + break; + + case 0xA1: //У׼ + M_S_TX_BUF[dataIndex++] = scaleNum; + break; + + case 0xA5: //ͳУ׼ʧ + break; + + default: + break; + } + + //ͨݳ + M_S_TX_BUF[2] = dataIndex - 3; //ͨѶݳֽ + dataLen = dataIndex; + +// printf("\r\nlen = %d\r\n", dataLen); + M_S_DataPackingAndSend(M_S_TX_BUF, dataLen); //ָȻ +} + +/* +*********************************************************************** +* : OverflowDataCorrection1 +* ˵: +* : +* ֵ: +*********************************************************************** +*/ +static void OverflowDataCorrection1(void) +{ + static uint8_t currentStatus = 0x00; + static uint8_t nextStatus = 0x00; + + static uint16_t preweight = 0; + uint16_t tempDate = 0; + + currentStatus = nextStatus; + switch(currentStatus) + { + case 0x00: + if((weight1 > 2000) && (getDistance1) < 65) //糬90%ﵽ10kg,ǿоݽֱΪ5kg + { + printf("\r\nNo.1ʼ\r\n"); + + preweight = weight1; + getDistance1 = 55; + nextStatus = 0x01; + break; + } + break; + + case 0x01: + if(weight1 < preweight) + { + tempDate = preweight - weight1; + }else{ + tempDate = 0; + } + + if(tempDate > 500) //ᣨͰ + { + + printf("\r\nNo.1ȡ\r\n"); + nextStatus = 0x00; + break; + }else{ + getDistance1 = 55; + } + break; + + default: + nextStatus = 0x00; + break; + } +} + +/* +*********************************************************************** +* : OverflowDataCorrection1 +* ˵: +* : +* ֵ: +*********************************************************************** +*/ +static void OverflowDataCorrection2(void) +{ + static uint8_t currentStatus = 0x00; + static uint8_t nextStatus = 0x00; + + static uint16_t preweight = 0; + uint16_t tempDate = 0; + + currentStatus = nextStatus; + switch(currentStatus) + { + case 0x00: + if((weight2 > 2000) && (getDistance2) < 65) //糬90%ﵽ10kg,ǿоݽֱΪ5kg + { + printf("\r\nNo.2ʼ\r\n"); + + preweight = weight2; + getDistance2 = 55; + nextStatus = 0x01; + break; + } + break; + + case 0x01: + if(weight2 < preweight) + { + tempDate = preweight - weight2; + }else{ + tempDate = 0; + } + + if(tempDate > 500) //ᣨͰ + { + printf("\r\nNo.2ȡ\r\n"); + nextStatus = 0x00; + break; + }else{ + getDistance2 = 55; + } + break; + + default: + nextStatus = 0x00; + break; + } +} + + +/* +*********************************************************************** +* : M_S_DataDecode +* ˵: ӻͨѶݽ +* : *pRxBuf -> ջĵַ*pTxBuf -> ݻַ +* ֵ: +*********************************************************************** +*/ +static void M_S_DataDecode(uint8_t *pRxBuf, uint8_t *pTxBuf) +{ + uint8_t comNum = 0; //ӻָ + + comNum = *(pRxBuf+1); + +// printf("\r\nS->M <-- 0x%02X\r\n", comNum); + switch(comNum) //ͨѶ + { + case 0x01: //յӻMCU2͹ijءࡢ翪״̬ + weight1 = *(pRxBuf+3) << 8; + weight1 |= *(pRxBuf+4); + + weight2 = *(pRxBuf+5) << 8; + weight2 |= *(pRxBuf+6); + + weight3 = *(pRxBuf+7) << 8; + weight3 |= *(pRxBuf+8); + + weight4 = *(pRxBuf+9) << 8; + weight4 |= *(pRxBuf+10); + + // + //Ӳӿ˳ת +#ifdef FOUR_CHANNEL_AND_HARMFUL +//-------------------------------------------------------------------> + + if(updateDistanceMark == 0) //ͶŹ̲²ֵ + { + getDistance1 = CorrectOverflowDistance(*(pRxBuf+11), weight1, + devChannel1DisMaxVal, devChannel1DisDepthVal); + getDistance2 = CorrectOverflowDistance(*(pRxBuf+12), weight2, + devChannel2DisMaxVal, devChannel2DisDepthVal); + getDistance3 = CorrectOverflowDistance(*(pRxBuf+13), weight3, + devChannel3DisMaxVal, devChannel3DisDepthVal); + getDistance4 = CorrectOverflowDistance(*(pRxBuf+14), weight4, + devChannel4DisMaxVal, devChannel4DisDepthVal); + + outputDistance1 = getDistance1; + outputDistance2 = getDistance2; + outputDistance3 = getDistance3; + outputDistance4 = getDistance4; + + printf("\r\nGet D1=%d, D2=%d, D3=%d, D4=%d\r\n", + getDistance1, getDistance2, getDistance3, getDistance4); + } +//<------------------------------------------------------------------- + + //ݾ +// if(updateDistanceMark == 0) //ͶŹ̲²ֵ +// { +// tempData1 = *(pRxBuf+11); +// tempData2 = *(pRxBuf+12); +// +// //ȡ1· +// if(tempData1 == 255) +// { +// getDistance1 = 255; +// }else{ +// tempData1 += 35; //ݰװ߶Ȳֵ +// +// if(tempData1 > distanceParamAtStart) +// { +// getDistance1 = devChannel1DisMaxVal; +// }else{ +// getDistance1 = tempData1; +// } +// } +// +// //20230727޸ģ +// OverflowDataCorrection1(); +// +// if((weight1 < 1500) && (getDistance1) > 80) +// { +// getDistance1 = devChannel1DisMaxVal; +// } +// +// //20230524޸ģ⴫װ߶Ȳβɼ +// outputDistance1 = getDistance1; +// +//// distanceBuf1[distanceCnt1++] = getDistance1; +//// if(distanceCnt1 >= DISTANCE_CNT_MAX) +//// { +//// distanceCnt1 = DISTANCE_CNT_MAX - 1; +//// printf("\r\nCnt1 >= MAX\r\n"); +//// } +// +// //ȡ2· +// if(tempData2 == 255) +// { +// getDistance2 = 255; +// }else{ +// tempData2 += 35; //ݰװ߶Ȳֵ +// +// if(tempData2 > distanceParamAtStart) +// { +// getDistance2 = devChannel1DisMaxVal; +// }else{ +// getDistance2 = tempData2; +// } +// } +// +// //20230727޸ģ +// OverflowDataCorrection2(); +// +// if((weight2 < 1500) && (getDistance2) > 80) +// { +// getDistance2 = devChannel2DisMaxVal; +// } +// +// //20230524޸ģ⴫װ߶Ȳβɼ +// outputDistance2 = getDistance2; +// +//// distanceBuf2[distanceCnt2++] = getDistance2; +//// if(distanceCnt2 >= DISTANCE_CNT_MAX) +//// { +//// distanceCnt2 = DISTANCE_CNT_MAX - 1; +//// printf("\r\nCnt2 >= MAX\r\n"); +//// } +// +// +// getDistance3 = *(pRxBuf+13); +// getDistance4 = *(pRxBuf+14); +// +// printf("\r\nGet D1=%d, D2=%d\r\n", getDistance1, getDistance2); +// } + +// getDistance1 = *(pRxBuf+11); +// getDistance2 = *(pRxBuf+12); +// getDistance3 = *(pRxBuf+13); +// getDistance4 = *(pRxBuf+14); +#else + getDistance1 = *(pRxBuf+11); + getDistance4 = *(pRxBuf+12); + getDistance2 = *(pRxBuf+13); + getDistance3 = *(pRxBuf+14); +#endif + + //¶ + temperature_C = *(pRxBuf+15); + + //״̬ + getRecycleClearDoorMark = *(pRxBuf+16); + + //ⲿ¶ + temperature_A = *(pRxBuf+17); + + //ӽ״̬ + switchKey1Status = *(pRxBuf+18); + switchKey2Status = *(pRxBuf+19); + + getMcu2SensorDataMark = 1; //־յݣⲿȡ + break; + + case 0x02: //MCU2⵽Ĺ翪״̬ݣڵʹã + optoKeyStatus = *(pRxBuf+3); + break; + + case 0x03: //GPSλϢ + gpsConnectSta = *(pRxBuf+3); //GPSģӲ״̬ + gpsStatus = *(pRxBuf+4); //GPSλ״̬ + gpsEW = *(pRxBuf+5); //ȷ0->E-,W- + gpsLon = *(pRxBuf+6) << 24; //ȣѷŴ1000000 + gpsLon |= *(pRxBuf+7) << 16; + gpsLon |= *(pRxBuf+8) << 8; + gpsLon |= *(pRxBuf+9); + gpsNS = *(pRxBuf+10); //γȷ0->N-,1->S-ϣ + gpsLat = *(pRxBuf+11) << 24; //γȣѷŴ1000000 + gpsLat |= *(pRxBuf+12) << 16; + gpsLat |= *(pRxBuf+13) << 8; + gpsLat |= *(pRxBuf+14); + + getGpsStatus = 1; + break; + + case 0xA2: //ȡУ׼ + receiveScaleNum = *(pRxBuf+3); + switch(receiveScaleNum) + { + case 1: + getCalibraZeroMark1 = 1; + break; + + case 2: + getCalibraZeroMark2 = 1; + break; + + default: + break; + } + + break; + + case 0xA3: //У׼ + receiveScaleNum = *(pRxBuf+3); + switch(receiveScaleNum) + { + case 1: + getCalibraParamOkMark1 = 1; + break; + + case 2: + getCalibraParamOkMark2 = 1; + break; + + default: + break; + } + + break; + + default: // + break; + } +} + +/* +*********************************************************************** +* : M_S_DataDecodeTask +* ˵: ӻͨѶ +* : +* ֵ: +*********************************************************************** +*/ +void M_S_DataDecodeTask(void) +{ + if(USART2_RX_STA == 0xfd) //нյ͵ + { + M_S_DataDecode(USART2_RX_BUF, USART2_TX_BUF); //ͷص + + memset(USART2_RX_BUF, 0x00, USART2_RECV_LEN); // + USART2_RX_STA = 0; + } +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/m_s_comm.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/m_s_comm.h new file mode 100755 index 0000000..9f718d3 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/DEVICE/m_s_comm.h @@ -0,0 +1,16 @@ +#ifndef __M_S_COMM_H +#define __M_S_COMM_H +#include "stm32f10x.h" + +#define M_S_RECV_LEN 128 //ջֽ +#define M_S_SEND_LEN 128 //ͻֽ + +extern uint8_t M_S_RX_BUF[M_S_RECV_LEN]; //ջ +extern uint8_t M_S_TX_BUF[M_S_SEND_LEN]; //ͻ + +void M_S_CommandSend(uint8_t comNum); //ӻݷ +void M_S_DataDecodeTask(void); //ӻݽ + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/Disinfection/disinfection.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/Disinfection/disinfection.c new file mode 100755 index 0000000..9df7896 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/Disinfection/disinfection.c @@ -0,0 +1,308 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ disinfection.c + * Ƴ + * V1.0 + * XuZhongPing + * 2020/04/17 +*********************************************************************************/ +#include "disinfection.h" +#include "timer.h" +#include "ElectronicLock.h" +#include "motor.h" + +uint8_t disinfectionStatus = 0; +uint8_t disinfectingMark = 0; //״̬ +uint8_t sprayDisinfectionStatus = 0; +uint8_t sprayDisinfectingMark = 0; //״̬־ + +/* +*********************************************************************** +* : StartUpDisinfection +* ˵: +* Σ +* ֵ: +*********************************************************************** +*/ +void StartUpDisinfection(void) +{ + Unlock(5); + + printf("\r\n\r\n"); + disinfectionStatus = 1; //־ǰ״̬ +} + +/* +*********************************************************************** +* : StopDisinfection +* ˵: ֹͣ +* Σ +* ֵ: +*********************************************************************** +*/ +void StopDisinfection(void) +{ + Locked(5); + + printf("\r\nֹͣ\r\n"); + disinfectionStatus = 0; //־ǰֹͣ״̬ +} + +/* +*********************************************************************** +* : DisinfectingTask +* ˵: +* Σ +* ֵ: +*********************************************************************** +*/ +void DisinfectingTask(void) +{ + static uint8_t executeSteps = 0; + + static timer disinfectingTimer; //ʱ + static timer sleepTimer; //װʱ + static timer waitingTimer; + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&disinfectingTimer, CLOCK_SECOND*60*30); //ʱ䶨ʱ + timer_set(&sleepTimer, CLOCK_SECOND*60*30); //װʱ + timer_set(&waitingTimer, CLOCK_SECOND*2); //1ʱ + } + + + switch(executeSteps) + { + case 0x00: + if(disinfectingMark == 1) + { + StartUpDisinfection(); + printf("\r\n\r\n"); + timer_restart(&disinfectingTimer); + executeSteps = 0x01; + break; + } + break; + + case 0x01: // + if(timer_expired(&disinfectingTimer)) + { + StopDisinfection(); //ʱ䵽ֹͣ + + printf("\r\nɣ\r\n"); + disinfectingMark = 0; + executeSteps = 0x03; + break; + } + + //Ͷţͣ + if(disinfectingMark == 2) + { + StopDisinfection(); + printf("\r\nͣ\r\n"); + executeSteps = 0x02; + break; + } + +// //ͶŻߴţж +// if(disinfectingMark == 0) +// { +// StopDisinfection(); +// printf("\r\nж\r\n"); +// executeSteps = 0x03; +// break; +// } + break; + + case 0x02: //ͣ + if(timer_expired(&disinfectingTimer)) + { + StopDisinfection(); //ʱ䵽ֹͣ + + printf("\r\nʱ䵽\r\n"); + disinfectingMark = 0; + executeSteps = 0x03; + break; + } + + if(disinfectingMark == 1) + { + StartUpDisinfection(); + printf("\r\n\r\n"); + executeSteps = 0x01; + break; + } + break; + + case 0x03: //װ߶ʱ + printf("\r\nװýߣ\r\n"); + timer_restart(&sleepTimer); + executeSteps = 0x04; + break; + + case 0x04: //װý + if(timer_expired(&sleepTimer)) + { + printf("\r\nװʱ䵽\r\n"); + executeSteps = 0x00; + } + break; + + default: + StopDisinfection(); + disinfectingMark = 0; + executeSteps = 0x00; + break; + } +} + + +/* +*********************************************************************** +* : StartUpDisinfection +* ˵: +* Σ +* ֵ: +*********************************************************************** +*/ +void StartUpSprayDisinfection(void) +{ + DoorClose(3); + + printf("\r\n\r\n"); + sprayDisinfectionStatus = 1; //־ǰ״̬ +} + +/* +*********************************************************************** +* : StopDisinfection +* ˵: ֹͣ +* Σ +* ֵ: +*********************************************************************** +*/ +void StopSprayDisinfection(void) +{ + DoorStop(3); + + printf("\r\nֹͣ\r\n"); + sprayDisinfectionStatus = 0; //־ǰֹͣ״̬ +} + +/* +*********************************************************************** +* : SprayDisinfectingTask +* ˵: +* Σ +* ֵ: +*********************************************************************** +*/ +void SprayDisinfectingTask(void) +{ + static uint8_t executeSteps = 0; + + static timer disinfectingTimer; //ʱ + static timer sleepTimer; //װʱ + static timer waitingTimer; + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&disinfectingTimer, CLOCK_SECOND*3); //ʱ䶨ʱ +// timer_set(&sleepTimer, CLOCK_SECOND*60*30); //װʱ + timer_set(&sleepTimer, CLOCK_SECOND*1); //װʱ + timer_set(&waitingTimer, CLOCK_SECOND*2); //1ʱ + } + + + switch(executeSteps) + { + case 0x00: + if(sprayDisinfectingMark == 1) + { + StartUpSprayDisinfection(); + printf("\r\n\r\n"); + timer_restart(&disinfectingTimer); + executeSteps = 0x01; + break; + } + break; + + case 0x01: // + if(timer_expired(&disinfectingTimer)) + { + StopSprayDisinfection(); //ʱ䵽ֹͣ + + printf("\r\nɣ\r\n"); + sprayDisinfectingMark = 0; + executeSteps = 0x03; + break; + } + + //Ͷţͣ + if(sprayDisinfectingMark == 2) + { + StopSprayDisinfection(); + printf("\r\nͣ\r\n"); + executeSteps = 0x02; + break; + } + +// //ͶŻߴţж +// if(disinfectingMark == 0) +// { +// StopDisinfection(); +// printf("\r\nж\r\n"); +// executeSteps = 0x03; +// break; +// } + break; + + case 0x02: //ͣ + if(timer_expired(&disinfectingTimer)) + { + StopSprayDisinfection(); //ʱ䵽ֹͣ + + printf("\r\nʱ䵽\r\n"); + sprayDisinfectingMark = 0; + executeSteps = 0x03; + break; + } + + if(sprayDisinfectingMark == 1) + { + StartUpSprayDisinfection(); + printf("\r\n\r\n"); + executeSteps = 0x01; + break; + } + break; + + case 0x03: //װ߶ʱ + printf("\r\nװýߣ\r\n"); + timer_restart(&sleepTimer); + executeSteps = 0x04; + break; + + case 0x04: //װý + if(timer_expired(&sleepTimer)) + { + printf("\r\nװʱ䵽\r\n"); + executeSteps = 0x00; + } + break; + + default: + StopSprayDisinfection(); + sprayDisinfectingMark = 0; + executeSteps = 0x00; + break; + } +} + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/Disinfection/disinfection.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/Disinfection/disinfection.h new file mode 100755 index 0000000..e0d7c39 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/Disinfection/disinfection.h @@ -0,0 +1,28 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ disinfection.h + * Ƴͷļ + * V1.0 + * XuZhongPing + * 2020/04/17 +*********************************************************************************/ +#ifndef __DISINFECTION_H +#define __DISINFECTION_H + +#include "stm32f10x.h" +#include "stdio.h" + +extern uint8_t disinfectionStatus; +extern uint8_t disinfectingMark; //״̬ +extern uint8_t sprayDisinfectingMark; //״̬־ + +void StartUpDisinfection(void); // +void StopDisinfection(void); //ֹͣ +void DisinfectingTask(void); // + +void StartUpSprayDisinfection(void); // +void StopSprayDisinfection(void); //ֹͣ +void SprayDisinfectingTask(void); + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/EXTI/exti.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/EXTI/exti.c new file mode 100755 index 0000000..a34b970 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/EXTI/exti.c @@ -0,0 +1,55 @@ +#include "exti.h" +#include "led.h" +#include "key.h" +#include "delay.h" +#include "usart.h" + + +//ⲿжϳʼ +//ʼPA0,PA13,PA15Ϊж. +void EXTIX_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + EXTI_InitTypeDef EXTI_InitStructure; + NVIC_InitTypeDef NVIC_InitStructure; + + + GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE); //رjtag + + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_AFIO,ENABLE); + + //init GPIOC.7 + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; + GPIO_Init(GPIOC, &GPIO_InitStructure); + + + //GPIOC.7 + GPIO_EXTILineConfig(GPIO_PortSourceGPIOC,GPIO_PinSource7); + + EXTI_InitStructure.EXTI_Line=EXTI_Line7; + EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; + EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; + EXTI_InitStructure.EXTI_LineCmd = ENABLE; + EXTI_Init(&EXTI_InitStructure); + + + NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn; //ʹܰڵⲿжͨ + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x02; //ռȼ4λ,16 + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02; //ռȼ0λ,ȼ4λ + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //ʹⲿжͨ + NVIC_Init(&NVIC_InitStructure); +} + + +void EXTI9_5_IRQHandler(void) +{ + delay_ms(10); // + if(EXTI_GetITStatus(EXTI_Line7) != RESET) //ָEXTI7· + { + LED0=!LED0; + LED1=!LED1; + } + EXTI_ClearITPendingBit(EXTI_Line7); //EXTI7·λ +} + diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/EXTI/exti.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/EXTI/exti.h new file mode 100755 index 0000000..0878cc8 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/EXTI/exti.h @@ -0,0 +1,21 @@ +#ifndef __EXTI_H +#define __EXIT_H +#include "sys.h" +////////////////////////////////////////////////////////////////////////////////// +//ֻѧϰʹãδɣκ; +//Mini STM32 +//ⲿж +//ԭ@ALIENTEK +//̳:www.openedv.com +//޸:2010/12/01 +//汾V1.0 +//ȨУؾ +//Copyright(C) ԭ 2009-2019 +//All rights reserved +////////////////////////////////////////////////////////////////////////////////// + + +void EXTIX_Init(void);//IOʼ + +#endif + diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/ElectronicLock/ElectronicLock.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/ElectronicLock/ElectronicLock.c new file mode 100755 index 0000000..c68c227 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/ElectronicLock/ElectronicLock.c @@ -0,0 +1,270 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ ElectronicLock.c + * + * V1.0 + * XuZhongPing + * 2017/05/06 +*********************************************************************************/ +#include "ElectronicLock.h" +#include "RFID_IC.h" +#include "timer.h" + +#define ELE_LOCK1_PeriphClock RCC_APB2Periph_GPIOC +#define ELE_LOCK1_PORT GPIOC +#define ELE_LOCK1_PIN GPIO_Pin_2 + +#define ELE_LOCK2_PeriphClock RCC_APB2Periph_GPIOC +#define ELE_LOCK2_PORT GPIOC +#define ELE_LOCK2_PIN GPIO_Pin_3 + +#define ELE_LOCK3_PeriphClock RCC_APB2Periph_GPIOA +#define ELE_LOCK3_PORT GPIOA +#define ELE_LOCK3_PIN GPIO_Pin_0 + +#define ELE_LOCK4_PeriphClock RCC_APB2Periph_GPIOA +#define ELE_LOCK4_PORT GPIOA +#define ELE_LOCK4_PIN GPIO_Pin_1 + +#define ELE_LOCK5_PeriphClock RCC_APB2Periph_GPIOB +#define ELE_LOCK5_PORT GPIOB +#define ELE_LOCK5_PIN GPIO_Pin_13 + +#define ELE_LOCK6_PeriphClock RCC_APB2Periph_GPIOB +#define ELE_LOCK6_PORT GPIOB +#define ELE_LOCK6_PIN GPIO_Pin_14 + + +uint8_t lockStatus_1 = 0; +uint8_t lockStatus_2 = 0; +uint8_t lockStatus_3 = 0; +uint8_t lockStatus_4 = 0; +uint8_t lockStatus_5 = 0; +uint8_t lockStatus_6 = 0; + +uint8_t isUnlockingMark = 0; + +/* +*********************************************************************** +* : ElectronicLock_Init +* ˵: IOڳʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void ElectronicLock_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + RCC_APB2PeriphClockCmd(ELE_LOCK1_PeriphClock, ENABLE); //ʹܶ˿ʱ + RCC_APB2PeriphClockCmd(ELE_LOCK2_PeriphClock, ENABLE); + RCC_APB2PeriphClockCmd(ELE_LOCK3_PeriphClock, ENABLE); + RCC_APB2PeriphClockCmd(ELE_LOCK4_PeriphClock, ENABLE); + RCC_APB2PeriphClockCmd(ELE_LOCK5_PeriphClock, ENABLE); + RCC_APB2PeriphClockCmd(ELE_LOCK6_PeriphClock, ENABLE); + + //һ·IO + GPIO_InitStructure.GPIO_Pin = ELE_LOCK1_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(ELE_LOCK1_PORT, &GPIO_InitStructure); + + GPIO_ResetBits(ELE_LOCK1_PORT, ELE_LOCK1_PIN); + + //ڶ·IO + GPIO_InitStructure.GPIO_Pin = ELE_LOCK2_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(ELE_LOCK2_PORT, &GPIO_InitStructure); + + GPIO_ResetBits(ELE_LOCK2_PORT, ELE_LOCK2_PIN); + + //·IO + GPIO_InitStructure.GPIO_Pin = ELE_LOCK3_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(ELE_LOCK3_PORT, &GPIO_InitStructure); + + GPIO_ResetBits(ELE_LOCK3_PORT, ELE_LOCK3_PIN); + + //·IO + GPIO_InitStructure.GPIO_Pin = ELE_LOCK4_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(ELE_LOCK4_PORT, &GPIO_InitStructure); + + GPIO_ResetBits(ELE_LOCK4_PORT, ELE_LOCK4_PIN); + + //·IO + GPIO_InitStructure.GPIO_Pin = ELE_LOCK5_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(ELE_LOCK5_PORT, &GPIO_InitStructure); + + GPIO_ResetBits(ELE_LOCK5_PORT, ELE_LOCK5_PIN); + + //·IO + GPIO_InitStructure.GPIO_Pin = ELE_LOCK6_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(ELE_LOCK6_PORT, &GPIO_InitStructure); + + GPIO_ResetBits(ELE_LOCK6_PORT, ELE_LOCK6_PIN); +} + +/* +*********************************************************************** +* : Unlock +* ˵: +* Σnum -> һ· +* ֵ: +*********************************************************************** +*/ +void Unlock(uint8_t num) +{ + switch(num) + { + case 1: + GPIO_SetBits(ELE_LOCK1_PORT, ELE_LOCK1_PIN); + lockStatus_1 = 1; + break; + + case 2: + GPIO_SetBits(ELE_LOCK2_PORT, ELE_LOCK2_PIN); + lockStatus_2 = 1; + break; + + case 3: + GPIO_SetBits(ELE_LOCK3_PORT, ELE_LOCK3_PIN); + lockStatus_3 = 1; + break; + + case 4: + GPIO_SetBits(ELE_LOCK4_PORT, ELE_LOCK4_PIN); + lockStatus_4 = 1; + break; + + case 5: + GPIO_SetBits(ELE_LOCK5_PORT, ELE_LOCK5_PIN); + lockStatus_5 = 1; + break; + + case 6: + GPIO_SetBits(ELE_LOCK6_PORT, ELE_LOCK6_PIN); + lockStatus_6 = 1; + break; + + default: + printf("\r\nûдͨ-> %d\r\n", num); + break; + } +} + +/* +*********************************************************************** +* : Locked +* ˵: +* Σnum -> һ· +* ֵ: +*********************************************************************** +*/ +void Locked(uint8_t num) +{ + switch(num) + { + case 1: + GPIO_ResetBits(ELE_LOCK1_PORT, ELE_LOCK1_PIN); + lockStatus_1 = 0; + break; + + case 2: + GPIO_ResetBits(ELE_LOCK2_PORT, ELE_LOCK2_PIN); + lockStatus_2 = 0; + break; + + case 3: + GPIO_ResetBits(ELE_LOCK3_PORT, ELE_LOCK3_PIN); + lockStatus_3 = 0; + break; + + case 4: + GPIO_ResetBits(ELE_LOCK4_PORT, ELE_LOCK4_PIN); + lockStatus_4 = 0; + break; + + case 5: + GPIO_ResetBits(ELE_LOCK5_PORT, ELE_LOCK5_PIN); + lockStatus_5 = 0; + break; + + case 6: + GPIO_ResetBits(ELE_LOCK6_PORT, ELE_LOCK6_PIN); + lockStatus_6 = 0; + break; + + default: + printf("\r\nûдͨ-> %d\r\n", num); + break; + } +} + +/* +*********************************************************************** +* : ElectronicLockCtrlTask +* ˵: +* Σ +* ֵ: +*********************************************************************** +*/ +void ElectronicLockCtrlTask(void) +{ + static uint8_t eleLockNum = 1; + static uint8_t EleLockStatus = 0x00; + + static timer waitingTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&waitingTimer, 2); + } + + switch(EleLockStatus) + { + case 0x00: + if(timer_expired(&waitingTimer)) + { + Unlock(eleLockNum); + + printf("\r\n -> %d\r\n", eleLockNum); + timer_restart(&waitingTimer); + EleLockStatus = 0x01; + } + break; + + case 0x01: + if(timer_expired(&waitingTimer)) + { + Locked(eleLockNum); + printf("\r\n -> %d\r\n", eleLockNum); + + eleLockNum++; + if(eleLockNum >= 7) + { + eleLockNum = 1; + } + timer_restart(&waitingTimer); + EleLockStatus = 0x00; + break; + } + break; + + default: + break; + + } +} + + + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/ElectronicLock/ElectronicLock.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/ElectronicLock/ElectronicLock.h new file mode 100755 index 0000000..ee1a768 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/ElectronicLock/ElectronicLock.h @@ -0,0 +1,29 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ ElectronicLock.c + * + * V1.0 + * XuZhongPing + * 2017/05/06 +*********************************************************************************/ +#ifndef __ELE_LOCK_H +#define __ELE_LOCK_H +#include "stm32f10x.h" +#include "stdio.h" + +extern uint8_t lockStatus_1; +extern uint8_t lockStatus_2; +extern uint8_t lockStatus_3; +extern uint8_t lockStatus_4; +extern uint8_t lockStatus_5; +extern uint8_t lockStatus_6; + +extern uint8_t isUnlockingMark; + +void ElectronicLock_Init(void); //ʼ +void Unlock(uint8_t num); +void Locked(uint8_t num); +void ElectronicLockCtrlTask(void); + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/FLASH/flash.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/FLASH/flash.c new file mode 100755 index 0000000..5895922 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/FLASH/flash.c @@ -0,0 +1,257 @@ +#include "flash.h" +#include "spi.h" +#include "delay.h" + +uint16_t SPI_FLASH_TYPE = W25Q64; //ĬϾ25Q64 + +//4KbytesΪһSector +//16Ϊ1Block +//W25X16 +//Ϊ2Mֽ,32Block,512Sector + +//ʼSPI FLASHIO +void SPI_Flash_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);//PORTBʱʹ + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; // PA4 + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(GPIOE, &GPIO_InitStructure); + GPIO_SetBits(GPIOE, GPIO_Pin_7); + +// SPI1_Init(); //ʼSPI +// SPI_SetSpeed(SPI_BaudRatePrescaler_2);//Ϊ18Mʱ,ģʽ + SPI_FLASH_TYPE = SPI_Flash_ReadID();//ȡFLASH ID. + +} + +//ȡSPI_FLASH״̬Ĵ +//BIT7 6 5 4 3 2 1 0 +//SPR RV TB BP2 BP1 BP0 WEL BUSY +//SPR:Ĭ0,״̬Ĵλ,WPʹ +//TB,BP2,BP1,BP0:FLASHд +//WEL:дʹ +//BUSY:æλ(1,æ;0,) +//Ĭ:0x00 +uint8_t SPI_Flash_ReadSR(void) +{ + uint8_t byte=0; + SPI_FLASH_CS=0; //ʹ + SPI1_ReadWriteByte(W25X_ReadStatusReg); //Ͷȡ״̬Ĵ + byte=SPI1_ReadWriteByte(0Xff); //ȡһֽ + SPI_FLASH_CS=1; //ȡƬѡ + return byte; +} +//дSPI_FLASH״̬Ĵ +//ֻSPR,TB,BP2,BP1,BP0(bit 7,5,4,3,2)д!!! +void SPI_FLASH_Write_SR(uint8_t sr) +{ + SPI_FLASH_CS=0; //ʹ + SPI1_ReadWriteByte(W25X_WriteStatusReg); //дȡ״̬Ĵ + SPI1_ReadWriteByte(sr); //дһֽ + SPI_FLASH_CS=1; //ȡƬѡ +} + +//SPI_FLASHдʹ +//WELλ +void SPI_FLASH_Write_Enable(void) +{ + SPI_FLASH_CS=0; //ʹ + SPI1_ReadWriteByte(W25X_WriteEnable); //дʹ + SPI_FLASH_CS=1; //ȡƬѡ +} + +//SPI_FLASHдֹ +//WEL +void SPI_FLASH_Write_Disable(void) +{ + SPI_FLASH_CS=0; //ʹ + SPI1_ReadWriteByte(W25X_WriteDisable); //дָֹ + SPI_FLASH_CS=1; //ȡƬѡ +} +//ȡоƬID W25X16ID:0XEF14 +uint16_t SPI_Flash_ReadID(void) +{ + uint16_t Temp = 0; + SPI_FLASH_CS=0; + SPI1_ReadWriteByte(0x90);//ͶȡID + SPI1_ReadWriteByte(0x00); + SPI1_ReadWriteByte(0x00); + SPI1_ReadWriteByte(0x00); + Temp|=SPI1_ReadWriteByte(0xFF)<<8; + Temp|=SPI1_ReadWriteByte(0xFF); + SPI_FLASH_CS=1; + return Temp; +} +//ȡSPI FLASH +//ַָʼȡָȵ +//pBuffer:ݴ洢 +//ReadAddr:ʼȡĵַ(24bit) +//NumByteToRead:Ҫȡֽ(65535) +void SPI_Flash_Read(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead) +{ + uint16_t i; + SPI_FLASH_CS=0; //ʹ + SPI1_ReadWriteByte(W25X_ReadData); //Ͷȡ + SPI1_ReadWriteByte((uint8_t)((ReadAddr)>>16)); //24bitַ + SPI1_ReadWriteByte((uint8_t)((ReadAddr)>>8)); + SPI1_ReadWriteByte((uint8_t)ReadAddr); + for(i=0;i>16)); //24bitַ + SPI1_ReadWriteByte((uint8_t)((WriteAddr)>>8)); + SPI1_ReadWriteByte((uint8_t)WriteAddr); + for(i=0;ipageremain + { + pBuffer+=pageremain; + WriteAddr+=pageremain; + + NumByteToWrite-=pageremain; //ȥѾд˵ֽ + if(NumByteToWrite>256)pageremain=256; //һοд256ֽ + else pageremain=NumByteToWrite; //256ֽ + } + }; +} +//дSPI FLASH +//ַָʼдָȵ +//ú! +//pBuffer:ݴ洢 +//WriteAddr:ʼдĵַ(24bit) +//NumByteToWrite:Ҫдֽ(65535) +uint8_t SPI_FLASH_BUF[4096]; +void SPI_Flash_Write(uint8_t* pBuffer,uint32_t WriteAddr,uint16_t NumByteToWrite) +{ + uint32_t secpos; + uint16_t secoff; + uint16_t secremain; + uint16_t i; + + secpos=WriteAddr/4096;//ַ 0~511 for w25x16 + secoff=WriteAddr%4096;//ڵƫ + secremain=4096-secoff;//ʣռС + + if(NumByteToWrite<=secremain)secremain=NumByteToWrite;//4096ֽ + while(1) + { + SPI_Flash_Read(SPI_FLASH_BUF,secpos*4096,4096);// + for(i=0;i4096)secremain=4096; //һд + else secremain=NumByteToWrite; //һд + } + }; +} +//оƬ +//Ƭʱ: +//W25X16:25s +//W25X32:40s +//W25X64:40s +//ȴʱ䳬... +void SPI_Flash_Erase_Chip(void) +{ + SPI_FLASH_Write_Enable(); //SET WEL + SPI_Flash_Wait_Busy(); + SPI_FLASH_CS=0; //ʹ + SPI1_ReadWriteByte(W25X_ChipErase); //Ƭ + SPI_FLASH_CS=1; //ȡƬѡ + SPI_Flash_Wait_Busy(); //ȴоƬ +} +//һ +//Dst_Addr:ַ 0~511 for w25x16 +//һɽʱ:150ms +void SPI_Flash_Erase_Sector(uint32_t Dst_Addr) +{ + Dst_Addr*=4096; + SPI_FLASH_Write_Enable(); //SET WEL + SPI_Flash_Wait_Busy(); + SPI_FLASH_CS=0; //ʹ + SPI1_ReadWriteByte(W25X_SectorErase); //ָ + SPI1_ReadWriteByte((uint8_t)((Dst_Addr)>>16)); //24bitַ + SPI1_ReadWriteByte((uint8_t)((Dst_Addr)>>8)); + SPI1_ReadWriteByte((uint8_t)Dst_Addr); + SPI_FLASH_CS=1; //ȡƬѡ + SPI_Flash_Wait_Busy(); //ȴ +} +//ȴ +void SPI_Flash_Wait_Busy(void) +{ + while ((SPI_Flash_ReadSR()&0x01)==0x01); // ȴBUSYλ +} +//ģʽ +void SPI_Flash_PowerDown(void) +{ + SPI_FLASH_CS=0; //ʹ + SPI1_ReadWriteByte(W25X_PowerDown); //͵ + SPI_FLASH_CS=1; //ȡƬѡ + delay_us(3); //ȴTPD +} +// +void SPI_Flash_WAKEUP(void) +{ + SPI_FLASH_CS=0; //ʹ + SPI1_ReadWriteByte(W25X_ReleasePowerDown); // send W25X_PowerDown command 0xAB + SPI_FLASH_CS=1; //ȡƬѡ + delay_us(3); //ȴTRES1 +} + + diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/FLASH/flash.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/FLASH/flash.h new file mode 100755 index 0000000..aded2df --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/FLASH/flash.h @@ -0,0 +1,81 @@ +#ifndef __FLASH_H +#define __FLASH_H +#include "stm32f10x.h" +////////////////////////////////////////////////////////////////////////////////// +//ֻѧϰʹãδɣκ; +//ALIENTEKսSTM32 +//W25Q64 +//ԭ@ALIENTEK +//̳:www.openedv.com +//޸:2012/9/9 +//汾V1.0 +//ȨУؾ +//Copyright(C) ӿƼ޹˾ 2009-2019 +//All rights reserved +////////////////////////////////////////////////////////////////////////////////// + +//W25Xϵ/QϵоƬб +//W25Q80 ID 0XEF13 +//W25Q16 ID 0XEF14 +//W25Q32 ID 0XEF15 +//W25Q32 ID 0XEF16 +#define W25Q80 0XEF13 +#define W25Q16 0XEF14 +#define W25Q32 0XEF15 +#define W25Q64 0XEF16 + +extern u16 SPI_FLASH_TYPE;//ʹõflashоƬͺ + +#define SPI_FLASH_CS PEout(7) //ѡFLASH + +//////////////////////////////////////////////////////////////////////////// + +//ָ +#define W25X_WriteEnable 0x06 +#define W25X_WriteDisable 0x04 +#define W25X_ReadStatusReg 0x05 +#define W25X_WriteStatusReg 0x01 +#define W25X_ReadData 0x03 +#define W25X_FastReadData 0x0B +#define W25X_FastReadDual 0x3B +#define W25X_PageProgram 0x02 +#define W25X_BlockErase 0xD8 +#define W25X_SectorErase 0x20 +#define W25X_ChipErase 0xC7 +#define W25X_PowerDown 0xB9 +#define W25X_ReleasePowerDown 0xAB +#define W25X_DeviceID 0xAB +#define W25X_ManufactDeviceID 0x90 +#define W25X_JedecDeviceID 0x9F + +void SPI_Flash_Init(void); +u16 SPI_Flash_ReadID(void); //ȡFLASH ID +u8 SPI_Flash_ReadSR(void); //ȡ״̬Ĵ +void SPI_FLASH_Write_SR(u8 sr); //д״̬Ĵ +void SPI_FLASH_Write_Enable(void); //дʹ +void SPI_FLASH_Write_Disable(void); //д +void SPI_Flash_Write_NoCheck(u8* pBuffer,u32 WriteAddr,u16 NumByteToWrite); +void SPI_Flash_Read(u8* pBuffer,u32 ReadAddr,u16 NumByteToRead); //ȡflash +void SPI_Flash_Write(u8* pBuffer,u32 WriteAddr,u16 NumByteToWrite);//дflash +void SPI_Flash_Erase_Chip(void); //Ƭ +void SPI_Flash_Erase_Sector(u32 Dst_Addr);// +void SPI_Flash_Wait_Busy(void); //ȴ +void SPI_Flash_PowerDown(void); //ģʽ +void SPI_Flash_WAKEUP(void); // +#endif + + + + + + + + + + + + + + + + diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/GPS/gps.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GPS/gps.c new file mode 100755 index 0000000..89bfb27 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GPS/gps.c @@ -0,0 +1,265 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ gps.c + * GPS + * V1.0 + * XuZhongPing + * 2017/03/05 +*********************************************************************************/ +#include "gps.h" +#include "delay.h" +#include "usart4.h" +#include "stdio.h" +#include "stdarg.h" +#include "string.h" +#include "math.h" + +nmea_msg gpsx; //GPSϢ +__align(4) u8 dtbuf[50]; //ӡ + +/* +*********************************************************************** +* : NMEA_Comma_Pos +* ˵: bufõcxڵλ +* : buf,ݻ +* cx,ڼڵλ +* ֵ: 0~0XFE,λõƫ +* 0XFF,ڵcx +*********************************************************************** +*/ +u8 NMEA_Comma_Pos(u8 *buf, u8 cx) +{ + u8 *p = buf; + while(cx) + { + if((*buf == '*') || (*buf < ' ') || (*buf > 'z')) return 0XFF; //'*'߷Ƿַ,򲻴ڵcx + if(*buf == ',') cx--; + buf++; + } + return buf - p; +} + +/* +*********************************************************************** +* : NMEA_Pow +* ˵: m^n +* : m, +* n,ָ +* ֵ: Ľ +*********************************************************************** +*/ +u32 NMEA_Pow(u8 m, u8 n) +{ + u32 result = 1; + while(n--)result *= m; + return result; +} + +/* +*********************************************************************** +* : NMEA_Str2num +* ˵: strתΪ,',''*' +* : buf:ִ洢 +* dx:Сλ,ظú +* ֵ: תĽ +*********************************************************************** +*/ +int NMEA_Str2num(u8 *buf, u8 *dx) +{ + u8 *p = buf; + u32 ires = 0, fres = 0; + u8 ilen = 0, flen = 0, i; + u8 mask = 0; + int res; + while(1) //õСij + { + if(*p == '-'){mask |= 0X02; p++;}//Ǹ + if(*p == ',' || (*p == '*'))break;// + if(*p == '.'){mask |= 0X01; p++;}//С + else if((*p > '9') || (*p < '0')) //зǷַ + { + ilen = 0; + flen = 0; + break; + } + if(mask & 0X01)flen++; + else ilen++; + p++; + } + if(mask & 0X02)buf++; //ȥ + for(i = 0; i 5)flen = 5; //ȡ5λС + *dx = flen; //Сλ + for(i = 0; igpssta = NMEA_Str2num(p1+posx, &dx); + + posx = NMEA_Comma_Pos(p1, 7); //õڶλ + if(posx != 0XFF)gpsx->posslnum = NMEA_Str2num(p1+posx, &dx); + + posx = NMEA_Comma_Pos(p1, 9); //õθ߶ + if(posx != 0XFF)gpsx->altitude = NMEA_Str2num(p1+posx, &dx); + gpsx->altitude *= 1000; +} + + +/* +*********************************************************************** +* : NMEA_GPRMC_Analysis +* ˵: GPRMCϢGPSƼλϢ +* : *gpsx:nmeaϢṹ壨ȫֱ +* *buf:յGPSݻ׵ַ +* ֵ: +*********************************************************************** +*/ +void NMEA_GPRMC_Analysis(nmea_msg *gpsx, u8 *buf) +{ + u8 *p1,dx; + u8 posx; + u32 temp; + float rs; + p1 = (u8*)strstr((const char *)buf, "$GPRMC"); + posx = NMEA_Comma_Pos(p1, 1); //õUTCʱ + if(posx != 0XFF) + { + temp = NMEA_Str2num(p1+posx, &dx)/NMEA_Pow(10,dx); //õUTCʱ,ȥms + gpsx->utc.hour = temp/10000; + gpsx->utc.min = (temp/100)%100; + gpsx->utc.sec = temp%100; + } + + posx = NMEA_Comma_Pos(p1,3); //õγ + if(posx != 0XFF) + { + temp = NMEA_Str2num(p1+posx, &dx); + gpsx->latitude = temp/NMEA_Pow(10, dx+2); //õ + rs = temp%NMEA_Pow(10, dx+2); //õ' + gpsx->latitude = gpsx->latitude*NMEA_Pow(10, 5)+(rs*NMEA_Pow(10, 5-dx))/60;//תΪ + gpsx->latitude /= 10; //С10ڴ䣬շŴ10000 + } + + posx = NMEA_Comma_Pos(p1, 4); //γDZγ + if(posx != 0XFF)gpsx->nshemi = *(p1 + posx); + + posx = NMEA_Comma_Pos(p1, 5); //õ + if(posx != 0XFF) + { + temp = NMEA_Str2num(p1+posx, &dx); + gpsx->longitude = temp/NMEA_Pow(10, dx+2); //õ + rs = temp%NMEA_Pow(10, dx+2); //õ' + gpsx->longitude = gpsx->longitude * NMEA_Pow(10, 5)+(rs * NMEA_Pow(10, 5-dx))/60;//תΪ + gpsx->longitude /= 10; //С10ڴ䣬շŴ10000 + } + + posx = NMEA_Comma_Pos(p1, 6); // + if(posx != 0XFF)gpsx->ewhemi = *(p1 + posx); + + posx = NMEA_Comma_Pos(p1, 9); //õUTC + if(posx != 0XFF) + { + temp = NMEA_Str2num(p1+posx, &dx); //õUTC + gpsx->utc.date = temp/10000; + gpsx->utc.month = (temp/100)%100; + gpsx->utc.year = 2000 + temp%100; + } +} + +/* +*********************************************************************** +* : GPS_Analysis +* ˵: ȡNMEA-0183Ϣ +* : *gpsx:nmeaϢṹ壨ȫֱ +* *buf:յGPSݻ׵ַ +* ֵ: +*********************************************************************** +*/ +void GPS_Analysis(nmea_msg *gpsx, u8 *buf) +{ + NMEA_GPGGA_Analysis(gpsx, buf); //GPGGA + NMEA_GPRMC_Analysis(gpsx, buf); //GPRMC +} + +void PrinterfGpsInfo(void) +{ + float tp; + + printf("\r\nλ״̬%d\r\n", gpsx.gpssta); + if(gpsx.gpssta == 1) + { + printf("\r\nѶλ\r\n"); + + tp = gpsx.longitude; + printf("\r\nȣ%.4f %1c\r\n", tp/=10000, gpsx.ewhemi); //õַ + + tp = gpsx.latitude; + printf("\r\nγȣ%.4f %1c\r\n", tp/=10000, gpsx.nshemi); //õγַ + + tp = gpsx.altitude; + printf("\r\n߶ȣ%.4f\r\n", tp/=10000); //õγַ + }else{ + printf("\r\nδλ\r\n"); + } +} + +/******************** (C) COPYRIGHT 2014 CHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/GPS/gps.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GPS/gps.h new file mode 100755 index 0000000..4714cc0 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GPS/gps.h @@ -0,0 +1,54 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ gps.h + * GPSͷļ + * V1.0 + * XuZhongPing + * 2013/11/21 +*********************************************************************************/ +#ifndef __GPS_H +#define __GPS_H + +#include "stm32f10x.h" + +//GPS NMEA-0183ЭҪṹ嶨 + +//UTCʱϢ +typedef struct +{ + uint16_t year; // + uint8_t month; //· + uint8_t date; // + uint8_t hour; //Сʱ + uint8_t min; // + uint8_t sec; // +}nmea_utc_time; + +//NMEA 0183 ЭݴŽṹ +typedef struct +{ + nmea_utc_time utc; //UTCʱ + uint32_t latitude; //γ 10000,ʵҪ10000 + uint8_t nshemi; //γ/γ,N:γ;S:γ + uint32_t longitude; // 10000,ʵҪ10000 + uint8_t ewhemi; ///,E:;W: + uint8_t gpssta; //GPS״̬:0,δλ;1,Dzֶλ;2,ֶλ;6,ڹ + uint8_t posslnum; //ڶλ,0~12 + + uint32_t altitude; //θ߶,Ŵ10000,ʵʳ10000.λ:0.1m +}nmea_msg; + +extern nmea_msg gpsx; + +void GPS_Analysis(nmea_msg *gpsx,uint8_t *buf); +void NMEA_GPGGA_Analysis(nmea_msg *gpsx,uint8_t *buf); +void NMEA_GPRMC_Analysis(nmea_msg *gpsx,uint8_t *buf); + +void PrinterfGpsInfo(void); //ʾGPSλϢ + +void gps_control(void); +void open_gps(void); +void close_gps(void); + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/at_proc.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/at_proc.c new file mode 100755 index 0000000..d6870b2 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/at_proc.c @@ -0,0 +1,544 @@ +#include "at_proc.h" +#include "gsm_uart.h" +#include "gsm_uart_conf.h" +#include "my_math.h" +#include "ec200x.h" +#include "data_typedef.h" + +char command_CIPSEND[16]; + +AT_CMD_PARAM at_cmd_table[]={ + {AT_CMD_AT_NO, "AT", "OK", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_ATE0_NO, "ATE0", "OK", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_CGSN_NO, "AT+CGSN", "OK", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_CPIN_NO, "AT+CPIN?", "+CPIN: READY", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_ICCID_NO, "AT+QCCID", "+QCCID:", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_CSQ_NO, "AT+CSQ", "+CSQ:", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_CREG_NO, "AT+CREG?", "+CREG: 0,1", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_CGREG_NO, "AT+CGREG?", "+CGREG: 0,1", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_COPS_NO, "AT+COPS?", "OK", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_QICSGP_NO, "AT+QICSGP=1,1,\"UNINET\","","",1", "OK", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_QIACT_NO, "AT+QIACT=1", "OK", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_QIDEACT_NO, "AT+QIDEACT=1", "OK", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_CHECK_QIACT_NO, "AT+QIACT?", "OK", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_QIOPEN, TCP_IP_COM, "+QIOPEN: 0,0", "CONNECT FAIL", AT_CMD_UNKNOWN}, + {AT_CMD_QICLOSE_NO, "AT+QICLOSE=0", "OK", "SEND FAIL", AT_CMD_UNKNOWN}, + {AT_CMD_QISEND, "AT+QISEND=0,4", ">", "SEND OK", AT_CMD_UNKNOWN}, + {AT_CMD_CHECK_QISEND_NO, "AT+QISEND=0,0", "+QISEND:", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_QIRD_NO, "AT+QIRD=0,1500", "+QIRD:", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_QNTP_NO, "AT+QNTP", "+QNTP:", "ERROR", AT_CMD_UNKNOWN}, + {AT_CMD_CCLK_NO, "AT+CCLK?", "+CCLK:", "+CME ERROR", AT_CMD_UNKNOWN}, +}; + +#define AT_RX_BUFFER 100 + +uint8_t rx_buffer[AT_RX_BUFFER]; +uint8_t sendAtCmdNo=0; + +uint8_t networkIsReg=0; +uint8_t receiveDataReady = 0; +uint8_t receiveDataLen = 0; + +#define AT_COMMON_ERROR_STRING "+CME ERROR:" + + + +void show_buf(uint8_t num[], uint8_t n) +{ + uint8_t i; + printf("\r\n"); + for(i=0; iԭַ +* dst->Ŀַ +* len->ַij +* ֵ: 0->ͬ,1ͬ +*********************************************************************** +*/ +static uint8_t mem_cmp(uint8_t *src, uint8_t *dst, uint8_t len) +{ + uint8_t i = 0, ret = 0; + + while(iַ +* ֵ: ַ +*********************************************************************** +*/ +static uint8_t str_len(uint8_t* string) +{ + uint8_t i=0; + + while(string[i] != 0) i++; + + return i; +} + +/* +*********************************************************************** +* : GSM_SendAtCmd +* ˵: GSMģ鷢ATָ +* : cmd->͵ַ +* atCmdNo->ATָ +* ֵ: 0->ͳɹ(õڴӦ) +* 1->ʧ +*********************************************************************** +*/ +void GSM_SendAtCmd(char *cmd, uint8_t atCmdNo) +{ + sendAtCmdNo = atCmdNo; + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_UNKNOWN; + GSM_GPRS_printf("%s\r\n", cmd); // +} + +/* +*********************************************************************** +* : getCommand_CIPSEND +* ˵: ݷ͵ݳԶɶӦAT+CIPSEND= +* Σmsg +* ֵ: +*********************************************************************** +*/ +void getCommand_CIPSEND(uint16_t len) +{ + char lenNum[4]; + + sprintf((char*)command_CIPSEND, "AT+CIPSEND="); + sprintf((char*)lenNum, "%d", len); + strcat((char*)command_CIPSEND, lenNum); +} + +/* +*********************************************************************** +* : IMEI_TO_HEX +* ˵: IMEIתHEX +* ΣַIMEI +* ֵ: +*********************************************************************** +*/ +void IMEI_TO_HEX(char *pStrData) +{ + uint8_t i; + uint64_t imeiNum = 0; + uint32_t imeiNumH = 0; + uint32_t imeiNumL = 0; + + for(i = 0; i < 15; i++){ + imeiNum += ((*pStrData++) - 0x30) * Pow(10, 14-i); + } + imeiNumH = imeiNum/4294967296; + imeiNumL = (uint32_t)imeiNum; + +// printf("\r\n%x \r\n", imeiNumH); +// printf("\r\n%x \r\n", imeiNumL); + + gsm_msg.IMEI_HEX[0] = imeiNumH >> 24; + gsm_msg.IMEI_HEX[1] = imeiNumH >> 16; + gsm_msg.IMEI_HEX[2] = imeiNumH >> 8; + gsm_msg.IMEI_HEX[3] = imeiNumH; + + gsm_msg.IMEI_HEX[4] = imeiNumL >> 24; + gsm_msg.IMEI_HEX[5] = imeiNumL >> 16; + gsm_msg.IMEI_HEX[6] = imeiNumL >> 8; + gsm_msg.IMEI_HEX[7] = imeiNumL; + +// for(i = 0; i < 8; i++){ +// printf("%x ", gsm_msg.IMEI_HEX[i]); +// } +} + + +void AT_Protocol(uint8_t* pCdmStr, uint8_t length) +{ + uint8_t i = 0; + char *p; + uint8_t *pSuccStr; //ATָɹӦַ; + uint8_t succStrLen; + + uint8_t *pFailedStr; //ATָʧܵӦַ; + uint8_t failedStrLen; + + if(length == 2) return; //У + + if(sendAtCmdNo >= CMD_TABLE_LENGTH) return; //жǷǰ淢͹atҪ + + if(!((pCdmStr[length-2] == '\r') && (pCdmStr[length-1] == '\n'))) //ǻسУ"\r\n"β + { + if(!((sendAtCmdNo == AT_CMD_QISEND) && (GPRS_RX_BUF[length - 1] == '>'))) return; //IPSENDָӦ> + } + + i = 0; + while(*pCdmStr == '\0') //˵ǰĿո + { + pCdmStr = pCdmStr++; + i++; + if(i >= length) break; + } + + pSuccStr = at_cmd_table[sendAtCmdNo-1].success; + succStrLen = str_len(pSuccStr); + + pFailedStr = at_cmd_table[sendAtCmdNo-1].failed; + failedStrLen = str_len(pFailedStr); + + if((char*)strstr((const char*)pCdmStr, "+QIURC") != NULL) //URC ATָ + { + if((char*)strstr((const char*)pCdmStr, "recv") != NULL) //ݽURC + { + if(mem_cmp(pCdmStr, (uint8_t*)RECEIVE_SERVER_DATA, strlen(RECEIVE_SERVER_DATA)) == 0) + { + p = (char*)strstr((const char*)pCdmStr, ","); + p = (char*)strstr((const char*)p+1, ","); + recDataLen = atoi(p+1); + GSM_ReceiveType = 1; +// printf("\r\nURC\r\n"); +// printf("\r\nlen=%d\r\n", recDataLen); + } + }else if((char*)strstr((const char*)pCdmStr, "closed") != NULL){ //ӶϿURC + connectionClosedMark = 1; +// printf("\r\nӶϿURC\r\n"); + }else if((char*)strstr((const char*)pCdmStr, "incoming full") != NULL){ //ͻURC + printf("\r\nURC\r\n"); + }else if((char*)strstr((const char*)pCdmStr, "ncoming") != NULL){ //ͻURC + printf("\r\nͻURC\r\n"); + }else if((char*)strstr((const char*)pCdmStr, "pdpdeact") != NULL){ //PDPȥURC + printf("\r\nPDPȥURC\r\n"); + }else{} + }else{ //ATָ + switch(sendAtCmdNo) + { + case AT_CMD_AT_NO: //AT + if(mem_cmp(pCdmStr, (uint8_t*)AT_CMD_AT_AT, strlen(AT_CMD_AT_AT)) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + // printf("\r\nat\r\n"); + sendAtCmdNo = 0; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_CMD_AT_OK, strlen(AT_CMD_AT_OK)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + // printf("\r\nok\r\n"); + sendAtCmdNo = 0; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + case AT_CMD_ATE0_NO: //رջ + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + case AT_CMD_CGSN_NO: //AT+CGSN ȡIMEI + if(length == 17) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; //õǰATָɹ + sendAtCmdNo = 0; //ATָ + memcpy(gsm_msg.IMEI, pCdmStr, 15); + gsm_msg.IMEI[15] = '\0'; + IMEI_TO_HEX(gsm_msg.IMEI); //ַIMEIתHEXʽΪ洫 + } + break; + + case AT_CMD_CPIN_NO: //AT+CPIN? ѯSIM״̬ + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + case AT_CMD_ICCID_NO: //AT+QCCID ѯSIMICCID + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) + { + memcpy(gsm_msg.ICCID, pCdmStr+8, 20); + gsm_msg.ICCID[20] = '\0'; + // show_buf((uint8_t*)gsm_msg.ICCID, 20); + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + case AT_CMD_CSQ_NO: //AT+CSQ ѯźǿ + // printf("\r\ncsq = %s\r\n", pCdmStr); + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + signal = atoi((const char *)(pCdmStr+6)); + // printf("\r\nrssi = %d\r\n", signal); + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + case AT_CMD_CREG_NO: //AT+CREG? ѯע״̬ + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) //עģ + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp((uint8_t*)AT_CMD_AT_CREG, pCdmStr, succStrLen) == 0){ //עģ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + case AT_CMD_CGREG_NO: //AT+CGREG? GPRS״̬ + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) //עģ + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp((uint8_t*)AT_CMD_AT_CGREG, pCdmStr, succStrLen) == 0){ //עģ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + case AT_CMD_COPS_NO: //ѯӪ + if((char*)strstr((const char*)pCdmStr, "CHINA MOBILE") != NULL){ + gsm_msg.OperatorType = 1; + memcpy(gsm_msg.Operator, "CHINA MOBILE", strlen("CHINA MOBILE")); + }else if((char*)strstr((const char*)pCdmStr, "CHN-UNICOM") != NULL){ + gsm_msg.OperatorType = 2; + memcpy(gsm_msg.Operator, "CHN-UNICOM", strlen("CHN-UNICOM")); + }else{ + } + + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp(pFailedStr, pCdmStr, failedStrLen) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + case AT_CMD_QICSGP_NO: //ʼAPN + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp(pFailedStr, pCdmStr, failedStrLen) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + case AT_CMD_QIDEACT_NO: //PDP + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp(pFailedStr, pCdmStr, failedStrLen) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + case AT_CMD_QIACT_NO: //· + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp(pFailedStr, pCdmStr, failedStrLen) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + case AT_CMD_CHECK_QIACT_NO: //ѯǰIP + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp(pFailedStr, pCdmStr, failedStrLen) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + } + break; + + case AT_CMD_QIOPEN: //ʼԶ˷ + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp(pFailedStr, pCdmStr, failedStrLen) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + sendAtCmdNo = 0; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + } + break; + + case AT_CMD_QISEND: // + if(mem_cmp((uint8_t*)SEND_STATUS_READY, pCdmStr, 1) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_CIPSEND_READY; + // sendAtCmdNo = 0; + } + else if(mem_cmp((uint8_t*)SEND_STATUS_SEND_OK, pCdmStr, 7) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_CIPSEND_OK; + sendAtCmdNo = 0; + } + else if(mem_cmp((uint8_t*)SEND_STATUS_SEND_FAIL, pCdmStr, 9) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SEND_FAIL; + sendAtCmdNo = 0; + } + else if(mem_cmp((uint8_t*)AT_CMD_AT_ERROR, pCdmStr, 5) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SEND_FAIL; + sendAtCmdNo = 0; + } + else if(mem_cmp((uint8_t*)SEND_STATUS_CLOSED, pCdmStr, 6) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = TCP_STATUS_CLOSED; + sendAtCmdNo = 0; + } + else if(mem_cmp((uint8_t*)AT_COMMON_ERROR_STRING, pCdmStr, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SEND_FAIL; + sendAtCmdNo = 0; + }else{} + + break; + + case AT_CMD_CHECK_QISEND_NO: //ѯ͵ + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) + { + // printf("\r\nbyt=%s\r\n", pCdmStr); + p = (char*)strstr((const char*)pCdmStr, ":"); + if(p != NULL) + { + total_send_length = atoi((const char *)(p+2)); + // printf("\r\nsendBytes = %d\r\n", total_send_length); + } + + p = (char*)strstr((const char*)pCdmStr, ","); + if(p != NULL) + { + ackedBytes = atoi((const char *)(p+1)); + // printf("\r\nackedBytes = %d\r\n", ackedBytes); + } + + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp(pFailedStr, pCdmStr, failedStrLen) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + case AT_CMD_QIRD_NO: //ȡյ + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) + { + p = (char*)strstr((const char*)pCdmStr, ": "); + receiveDataLen = atoi((p+1)); + // printf("\r\nlen=%d\r\n", receiveDataLen); + receiveDataReady = 1; + }else if(mem_cmp((uint8_t *)"OK", pCdmStr, 2) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + + receiveDataReady = 0; + sendAtCmdNo = 0; + }else if(mem_cmp(pFailedStr, pCdmStr, failedStrLen) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + case AT_CMD_QICLOSE_NO: //"AT+CIPCLOSE=1" ر + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp(pFailedStr, pCdmStr, failedStrLen) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + case AT_CMD_QNTP_NO: //ͬNTPʱ + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + }else if(mem_cmp(pFailedStr, pCdmStr, failedStrLen) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + case AT_CMD_CCLK_NO: //ѯʱ +// printf("\r\nT=%s\r\n", pCdmStr); + if(mem_cmp(pSuccStr, pCdmStr, succStrLen) == 0) + { + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_SUCCESS; + sendAtCmdNo = 0; + + //صĸʽΪ+CCLK: "20/08/26,08:42:39+32" + p = (char*)strstr((const char*)pCdmStr, "\""); + + GMT_Time.year = 2000 + (*(p+1)-'0')*10 + (*(p+2)-'0'); + GMT_Time.month = (*(p+4)-'0')*10 + (*(p+5)-'0'); + GMT_Time.day = (*(p+7)-'0')*10 + (*(p+8)-'0'); + + GMT_Time.hour = (*(p+10)-'0')*10 + (*(p+11)-'0'); + GMT_Time.minute = (*(p+13)-'0')*10 + (*(p+14)-'0'); + GMT_Time.second = (*(p+16)-'0')*10 + (*(p+17)-'0'); + }else if(mem_cmp(pCdmStr, (uint8_t*)AT_COMMON_ERROR_STRING, strlen(AT_CMD_AT_ERROR)) == 0){ + at_cmd_table[sendAtCmdNo-1].result = AT_CMD_FAILED; + }else{} + break; + + default: + break; + } + } +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/at_proc.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/at_proc.h new file mode 100755 index 0000000..490b870 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/at_proc.h @@ -0,0 +1,126 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ at_proc.h + * GSM ATָ + * V1.0 + * XuZhongPing + * 2017/02/05 +*********************************************************************************/ +#ifndef _AT_PROC_H_ +#define _AT_PROC_H_ + +#include "stm32f10x.h" +#include "stdio.h" + +#define AT_CMD_COMMON_ERROR "+CME ERROR:" + +#define AT_CMD_SEND_OK "SEND OK" +#define AT_CMD_AT_OK "OK" +#define AT_CMD_AT_AT "AT" +#define AT_CMD_AT_ATE0 "ATE0\r" +#define AT_CMD_AT_CREG "+CREG: 0,5" +#define AT_CMD_AT_CGREG "+CGREG: 0,5" +#define AT_CMD_AT_ERROR "ERROR" + +//GPRSݷ͹Ӧַ +#define SEND_STATUS_READY ">" +#define SEND_STATUS_SEND_OK "SEND OK" +#define SEND_STATUS_SEND_FAIL "SEND FAIL" +#define SEND_STATUS_CLOSED "CLOSED" + +//GPRS״̬ +#define CIPSTATUS_IP_INITIAL "STATE: IP INITIAL" +#define CIPSTATUS_IP_START "STATE: IP START" +#define CIPSTATUS_IP_CONFIG "STATE: IP CONFIG" +#define CIPSTATUS_IP_GPRSACT "STATE: IP GPRSACT" +#define CIPSTATUS_IP_STATUS "STATE: IP STATUS" +#define CIPSTATUS_TCP_CONNECTING "STATE: TCP CONNECTING" +#define CIPSTATUS_CONNECT_OK "STATE: CONNECT OK" +#define CIPSTATUS_TCP_CLOSING "STATE: TCP CLOSING" +#define CIPSTATUS_TCP_CLOSED "STATE: TCP CLOSED" +#define CIPSTATUS_PDP_DEACT "STATE: PDP DEACT" + +//ģϱURC +#define RECEIVE_URC "+QIURC: " //ģϱURC +#define RECEIVE_SERVER_DATA "+QIURC: \"recv\"" //ݽURC + +typedef enum +{ + AT_CMD_AT_NO = 1, //ATָ + AT_CMD_ATE0_NO, //ָ + AT_CMD_CGSN_NO, //IMEIŲѯָ + AT_CMD_CPIN_NO, //ѯSIM״̬ + AT_CMD_ICCID_NO, //ѯSIMICCID + AT_CMD_CSQ_NO, //ѯźǿ + AT_CMD_CREG_NO, //ѯע״̬ + AT_CMD_CGREG_NO, //ѯGPRS״̬ + AT_CMD_COPS_NO, //ѯӪ + AT_CMD_QICSGP_NO, //TCP/IP + AT_CMD_QIACT_NO, //PDP + AT_CMD_QIDEACT_NO, //PDP + AT_CMD_CHECK_QIACT_NO, //ѯPDP״̬ + AT_CMD_QIOPEN, //TCPͻ + AT_CMD_QICLOSE_NO, //ر + AT_CMD_QISEND, // + AT_CMD_CHECK_QISEND_NO, //ѯݷ״̬ + AT_CMD_QIRD_NO, //ȡյ + AT_CMD_QNTP_NO, //ͬNTPʱ + AT_CMD_CCLK_NO, //ѯʱ +}_AT_CMD_Number; + + +//GPRSģӦĽ +typedef enum +{ + AT_CMD_SUCCESS = 1, + AT_CMD_CIPSEND_READY = 10, + AT_CMD_CIPSEND_OK = 11, + AT_CMD_SEND_FAIL = 12, + TCP_STATUS_CLOSED = 13, + + AT_CMD_FAILED = 100, + AT_CMD_TIMEOUE = 101, + AT_CMD_UNKNOWN = 255 + +}AT_CMD_RESULT; + +//GPRS״̬ +typedef enum +{ + GPRS_STATUS_IP_INITIAL = 20, + GPRS_STATUS_IP_START, + GPRS_STATUS_IP_CONFIG, + GPRS_STATUS_IP_GPRSACT, + GPRS_STATUS_IP_STATUS, + GPRS_STATUS_TCP_CONNECTING, + GPRS_STATUS_CONNECT_OK, + GPRS_STATUS_TCP_CLOSING, + GPRS_STATUS_TCP_CLOSED, + GPRS_STATUS_PDP_DEACT, +}AT_CMD_RESULT_GPRS_STATUS; + +typedef struct +{ + uint8_t cmdNo; + uint8_t cmd[64]; + uint8_t success[15]; + uint8_t failed[15]; + uint8_t result; +}AT_CMD_PARAM; + +extern uint8_t sendAtCmdNo; +extern uint8_t networkIsReg; + +extern uint8_t receiveDataReady; +extern uint8_t receiveDataLen; + +#define CMD_TABLE_LENGTH 30 + +extern AT_CMD_PARAM at_cmd_table[CMD_TABLE_LENGTH]; + +void GSM_SendAtCmd(char *cmd, uint8_t atCmdNo); +void getCommand_CIPSEND(uint16_t len); +void AT_Protocol(uint8_t* pCdmStr, uint8_t length); //ATֵ + + +#endif +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/ec200x.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/ec200x.c new file mode 100755 index 0000000..849d527 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/ec200x.c @@ -0,0 +1,1569 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ gsm_gprs.c + * gsm_gprs + * V1.0 + * XuZhongPing + * 2017/06/12 +*********************************************************************************/ +#include "ec200x.h" +#include "gsm_uart.h" +#include "gsm_uart_conf.h" +#include "delay.h" +#include "led.h" +#include "string.h" +#include "stdio.h" +#include "stdlib.h" + +#include "timer.h" +#include "data_typedef.h" +#include "message.h" +#include "tcp_protocol.h" +#include "at_proc.h" +#include "netwer_appcall.h" + + +#define RCC_PeriphClock RCC_APB2Periph_GPIOB +#define GSM_POW_KEY_Port GPIOB +#define GSM_POW_KEY_Pin GPIO_Pin_12 + +uint8_t GSM_isPowerON = 0x00; //GSMģǷڿ־ +uint8_t ConnectionStatus = OFFLINE; //״̬ݰͳɹλΪ״̬ +uint8_t connectionClosedMark = 0; //ӶϿ־ + +uint16_t networkConnectionCount = 0; //Ӵ + +static uint8_t GSM_GPRS_Status = 0x00; //GSM_GPRSĹ״̬ +static uint8_t GSM_GPRS_initStatus = 0x00; //GSMģʱĹ״̬ + +static uint8_t GSM_GPRS_workingState = 0x00; //GSMģTCPͻ˵շ״̬ +static uint8_t errorStatus = 0x00; //GSMģ쳣״̬ +static uint8_t errorProcessCount = 0; // +static uint8_t sendFailureCount = 0; //ʧܼ +static uint8_t seriousError = 0; //صĴ + +uint8_t lteLoadCompletedFlag = 0; //LTEģɱ־ +uint8_t lteLoadResetFlag = 0; //LTEģع̸λ + +uint8_t lteCreateSocketOkFlag = 0; //Socketɱ־ +uint8_t lteCreateSocketResetFlag = 0; //Socketӹ̸λ־ + +uint8_t lteHandlerResetFlag = 0; //շ̸λ־ + + +/* +*********************************************************************** +* : LTE_Init +* ˵: LTEģʼ +* : +* ֵ: +*********************************************************************** +*/ +void LTE_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + RCC_APB2PeriphClockCmd(RCC_PeriphClock, ENABLE); //ʹPB˿ʱ + + //GSMػųʼ + GPIO_InitStructure.GPIO_Pin = GSM_POW_KEY_Pin; //˿ + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(GSM_POW_KEY_Port, &GPIO_InitStructure); + GPIO_ResetBits(GSM_POW_KEY_Port, GSM_POW_KEY_Pin); //Ĭͣ൱ڿûа״̬ + + GSM_GPRS_Uart_Init(); + gsm_msg.Running = 0; +} + +/* +*********************************************************************** +* : LTE_StatusReset +* ˵: LTEģ״̬λ +* Σ +* ֵ: +*********************************************************************** +*/ +void LTE_StatusReset(void) +{ + lteLoadResetFlag = 1; + lteCreateSocketResetFlag = 1; + GSM_GPRS_Status = 0x00; + errorStatus = 0x00; //GSMģ쳣ʱ״̬λ +} + +/* +*********************************************************************** +* : GSM_PowerON +* ˵: GSMģ鿪 +* : +* ֵ: 1ڿ0 +*********************************************************************** +*/ +uint8_t GSM_PowerON(void) +{ + uint8_t returnData = 0; + static timer pullDown_Time; + static timer pullUp_Time; + static uint8_t timer_ok = 0; + + static uint8_t powerOnStatus = 0x00; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&pullDown_Time, CLOCK_SECOND*3); //1ʱڼΪ͵ƽʱ + timer_set(&pullUp_Time, CLOCK_SECOND*8); //1ʱڼΪߵƽʱ + } + switch(powerOnStatus) + { + case 0x00: //״̬ + printf("\r\nGSMģڿ\r\n"); + GPIO_SetBits(GSM_POW_KEY_Port, GSM_POW_KEY_Pin); +// GPIO_ResetBits(GSM_POW_KEY_Port, GSM_POW_KEY_Pin); + + timer_restart(&pullDown_Time); + powerOnStatus = 0x01; + break; + + case 0x01: //Լȴ2Sӵʱ䣬power_key2Sɿģ + if(timer_expired(&pullDown_Time)) + { +// GPIO_SetBits(GSM_POW_KEY_Port, GSM_POW_KEY_Pin); + GPIO_ResetBits(GSM_POW_KEY_Port, GSM_POW_KEY_Pin); + + timer_restart(&pullUp_Time); + powerOnStatus = 0x02; + break; + } + break; + + case 0x02: + if(timer_expired(&pullUp_Time)) + { + returnData = 1; + powerOnStatus = 0x00; + } + break; + + default:break; + } + return returnData; +} + +/* +*********************************************************************** +* : GSM_PowerOFF +* ˵: GSMģػ +* : +* ֵ: +*********************************************************************** +*/ +uint8_t GSM_PowerOFF(void) +{ + uint8_t returnData = 0; + + return returnData; +} + +/* +*********************************************************************** +* : GSM_SignalCheck +* ˵: ѯź +* Σ +* ֵ: +*********************************************************************** +*/ +void GSM_SignalCheck(void) +{ + uint8_t cnt = 0; + GSM_SendAtCmd("AT+CSQ", AT_CMD_CSQ_NO); + while((at_cmd_table[AT_CMD_CSQ_NO-1].result != AT_CMD_SUCCESS) && (cnt < 10)) + { + delay_ms(1); + cnt++; + } + + if(at_cmd_table[AT_CMD_CSQ_NO-1].result == AT_CMD_SUCCESS) + { + if(signal > 0) + { + printf("\r\nGSMźǿ = %d\r\n", signal); + if(signal < 5) + { + printf("\r\nGSMźǷ\r\n"); + } + }else{ + printf("\r\nGSMźţ\r\n"); + } + } +} + +/* +*********************************************************************** +* : GSM_GetHardInfo +* ˵: ȡGSMģӲϢIMEI +* : msgGSMģϢṹ +* ֵ: +*********************************************************************** +*/ +void GSM_GetHardInfo(_gsm_msg *msg) +{ +} + +/* +*********************************************************************** +* : GPRS_OnlineCheck +* ˵: GPRS̨飨⣩ +* Σ +* ֵ: +*********************************************************************** +*/ +static void GPRS_OnlineCheck(void) +{ + sendMsg.msgType = 1001; // + MessageSend(MSG_FIFO_PROTOCOL, sendMsg); +} + +uint8_t startSyncNTP_Mark = 0; //ͬNTP־ +uint8_t syncNTP_SuccessMark = 0; //ͬNTPɹ־ +typedef enum +{ + LTE_STA_NTP_INIT = 0, //LTEģNTPʱͬʼ״̬ + LTE_STA_NTP_QIACT, //PDP + LTE_STA_NTP_QIACT_ACK, //PDPӦ + LTE_STA_NTP_QIDEACT, //PDP + LTE_STA_NTP_QIDEACT_ACK, //PDPӦ + + LTE_STA_QNTP, //ͬNTPʱ + LTE_STA_QNTP_ACK, //ͬNTPʱӦ + LTE_STA_GET_CLK, //ȡʱ + LTE_STA_GET_CLK_ACK, //ȡʱӦ + + LTE_STA_NTP_OK, //LTEģ״̬ + LTE_STA_NTP_FAILURE, //LTEģʧ״̬ +}_LTE_NTP_Status; +/* +*********************************************************************** +* : EC200X_NTP_SyncHandler +* ˵: EC200XģͬNTPʱ +* Σ +* ֵ: ޣͬʱɹȫֱsyncNTP_SuccessMark = 1 +*********************************************************************** +*/ +void EC200X_NTP_SyncHandler(void) +{ + static _LTE_NTP_Status currentStatus = LTE_STA_NTP_INIT; + static _LTE_NTP_Status nextStatus = LTE_STA_NTP_INIT; + + static uint8_t GSM_GPRS_initStatus = 0; + static uint8_t waitTimeOutCount = 0; + + static timer responseTimeout; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&responseTimeout, CLOCK_SECOND*10); //1ʱڷATȴӦʱ + } + + currentStatus = nextStatus; + switch(currentStatus) + { + case LTE_STA_NTP_INIT: //ʼ״̬ + if(startSyncNTP_Mark == 1) + { + startSyncNTP_Mark = 0; + syncNTP_SuccessMark = 0; + printf("\r\nʼͬNTP\r\n"); + nextStatus = LTE_STA_NTP_QIACT; + break; + } + break; + + case LTE_STA_NTP_QIACT: //PDP + GSM_SendAtCmd("AT+QIACT=1", AT_CMD_QIACT_NO); + timer_restart(&responseTimeout); + nextStatus = LTE_STA_NTP_QIACT_ACK; + break; + + case LTE_STA_NTP_QIACT_ACK: //ȴPDPӦ + if(at_cmd_table[AT_CMD_QIACT_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nPDP OK\r\n"); + nextStatus = LTE_STA_QNTP; + break; + } + if(at_cmd_table[AT_CMD_QIACT_NO-1].result == AT_CMD_FAILED) + { + printf("\r\nPDP ERROR\r\n"); + nextStatus = LTE_STA_NTP_FAILURE; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nӦʱPDPʧ\r\n"); + nextStatus = LTE_STA_NTP_FAILURE; + break; + } + break; + + case LTE_STA_QNTP: //ͬNTPʱ +// printf("\r\nͬʱ\r\n"); + GSM_SendAtCmd("AT+QNTP=1,\"202.112.10.36\",123", AT_CMD_QNTP_NO); + timer_restart(&responseTimeout); + nextStatus = LTE_STA_QNTP_ACK; + break; + + case LTE_STA_QNTP_ACK: //ȴͬʱӦ + if(at_cmd_table[AT_CMD_QNTP_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nʱͬOK\r\n"); + nextStatus = LTE_STA_GET_CLK; + break; + } + if(at_cmd_table[AT_CMD_QNTP_NO-1].result == AT_CMD_FAILED) + { + printf("\r\nʱͬ ERROR\r\n"); + nextStatus = LTE_STA_NTP_QIDEACT; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nӦʱʱͬʧ\r\n"); + nextStatus = LTE_STA_NTP_QIDEACT; + break; + } + break; + + case LTE_STA_GET_CLK: //ȡʱ + GSM_SendAtCmd("AT+CCLK?", AT_CMD_CCLK_NO); + timer_restart(&responseTimeout); + nextStatus = LTE_STA_GET_CLK_ACK; + break; + + case LTE_STA_GET_CLK_ACK: //ȴȡʱӦ + if(at_cmd_table[AT_CMD_CCLK_NO-1].result == AT_CMD_SUCCESS) + { + GMT_To_Beijing(&GMT_Time); + printf("\r\nTime:%s\r\n", systemTime); + nextStatus = LTE_STA_NTP_QIDEACT; + break; + } + if(at_cmd_table[AT_CMD_CCLK_NO-1].result == AT_CMD_FAILED) + { + printf("\r\nGet Time ERROR\r\n"); + nextStatus = LTE_STA_NTP_QIDEACT; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nӦʱGet Timeʧ\r\n"); + nextStatus = LTE_STA_NTP_QIDEACT; + break; + } + break; + + case LTE_STA_NTP_QIDEACT: //PDPȥ + GSM_SendAtCmd("AT+QIDEACT=1", AT_CMD_QIDEACT_NO); + timer_restart(&responseTimeout); + nextStatus = LTE_STA_NTP_QIDEACT_ACK; + break; + + case LTE_STA_NTP_QIDEACT_ACK: //ȴPDPȥӦ + if(at_cmd_table[AT_CMD_QIDEACT_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nPDPȥ OK\r\n"); + nextStatus = LTE_STA_NTP_OK; + break; + } + if(at_cmd_table[AT_CMD_QIDEACT_NO-1].result == AT_CMD_FAILED) + { + printf("\r\nPDPȥ ERROR\r\n"); + nextStatus = LTE_STA_NTP_FAILURE; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nӦʱPDPȥʧ\r\n"); + nextStatus = LTE_STA_NTP_FAILURE; + break; + } + break; + + case LTE_STA_NTP_OK: + startSyncNTP_Mark = 0; + syncNTP_SuccessMark = 1; + printf("\r\nͬNTPɣ\r\n"); + nextStatus = LTE_STA_NTP_INIT; + break; + + case LTE_STA_NTP_FAILURE: + startSyncNTP_Mark = 0; + syncNTP_SuccessMark = 0; + nextStatus = LTE_STA_NTP_INIT; + break; + } +} + +typedef enum +{ + LTE_STA_LOADING_INIT = 0, //LTEģسʼ״̬ + LTE_STA_AT_TEST, //ATָLTEģǷ + LTE_STA_AT_TEST_ACK, //ATָLTEģǷӦ + LTE_STA_AT_ECHO, //ATָģʽ + LTE_STA_AT_ECHO_ACK, //ATָģʽӦ + LTE_STA_CHECK_IMEI, //ѯIMEI + LTE_STA_CHECK_IMEI_ACK, //ѯIMEIӦ + LTE_STA_CHECK_SIM, //ѯSIM״̬ + LTE_STA_CHECK_SIM_ACK, //ѯSIM״̬Ӧ + LTE_STA_CHECK_ICCID, //ѯSIMICCID + LTE_STA_CHECK_ICCID_ACK, //ѯSIMICCIDӦ + LTE_STA_CHECK_CSQ, //ѯźǿ + LTE_STA_CHECK_CSQ_ACK, //ѯźǿӦ + LTE_STA_CHECK_CREG, //ѯCSҵע״̬Ƿע磩 + LTE_STA_CHECK_CREG_ACK, //ѯCSҵע״̬Ӧ + LTE_STA_CHECK_CGREG, //ѯPSҵע״̬ǷGPRSҵ + LTE_STA_CHECK_CGREG_ACK, //ѯPSҵע״̬Ӧ + LTE_STA_QUERY_OPERATOR, //ѯӪ + LTE_STA_QUERY_OPERATOR_ACK, //ѯӪӦ + LTE_STA_SYNC_NTP, //ͬNTPʱ + LTE_STA_SYNC_NTP_ACK, //ȴͬNTPʱӦ + LTE_STA_LOADING_OK, //LTEģ״̬ + LTE_STA_LOADING_FAILURE, //LTEģʧ״̬ + LTE_STA_LOADING_IDLE, //LTEģп״̬ +}_LTE_LoadingStatus; +/* +*********************************************************************** +* : EC200X_Loading +* ˵: EC200Xģأѯģ״̬ +* Σ +* ֵ: +*********************************************************************** +*/ +void EC200X_Loading(void) +{ + static _LTE_LoadingStatus currentStatus = LTE_STA_LOADING_INIT; + static _LTE_LoadingStatus nextStatus = LTE_STA_LOADING_INIT; + + static uint8_t GSM_GPRS_initStatus = 0; + static uint8_t waitTimeOutCount = 0; + + static timer responseTimeout; + static timer queryTime; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&responseTimeout, CLOCK_SECOND*10); //1ʱڷATȴӦʱ + timer_set(&queryTime, CLOCK_SECOND*2); //1ʱڲѯע + } + + currentStatus = nextStatus; + switch(currentStatus) + { + case LTE_STA_LOADING_INIT: //ʼ״̬ + if(GSM_PowerON()) + { + lteLoadCompletedFlag = 0; + + signal = 0; + gsm_msg.simCardStatus = 0; //δ֪״̬ + nextStatus = LTE_STA_AT_TEST; + break; + } + break; + + case LTE_STA_AT_TEST: //ģǷ + printf("\r\nģ\r\n"); + GSM_SendAtCmd("AT", AT_CMD_AT_NO); + timer_restart(&responseTimeout); + nextStatus = LTE_STA_AT_TEST_ACK; + break; + + case LTE_STA_AT_TEST_ACK: //ȴģӦOK + if(at_cmd_table[AT_CMD_AT_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nģ\r\n"); + nextStatus = LTE_STA_AT_ECHO; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nʱδģӦ\r\n"); + nextStatus = LTE_STA_LOADING_FAILURE; + break; + } + break; + + case LTE_STA_AT_ECHO: //رջ + printf("\r\nرջ\r\n"); + GSM_SendAtCmd("ATE0", AT_CMD_ATE0_NO); + timer_restart(&responseTimeout); //ӵǰʱ¿ʱ + nextStatus = LTE_STA_AT_ECHO_ACK; + break; + + case LTE_STA_AT_ECHO_ACK: //ȴģӦOK + if(at_cmd_table[AT_CMD_ATE0_NO-1].result == AT_CMD_SUCCESS) + { +// printf("\r\nرջOK\r\n"); + nextStatus = LTE_STA_CHECK_IMEI; //յӦת0x + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nرջԳʱδӦ\r\n"); + nextStatus = LTE_STA_LOADING_FAILURE; + break; + } + break; + + case LTE_STA_CHECK_IMEI: //ȡģIMEI + GSM_SendAtCmd("AT+CGSN", AT_CMD_CGSN_NO); + timer_restart(&responseTimeout); + nextStatus = LTE_STA_CHECK_IMEI_ACK; + break; + + case LTE_STA_CHECK_IMEI_ACK: //ȴATָӦ + if(at_cmd_table[AT_CMD_CGSN_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nIMEI = %s\r\n", gsm_msg.IMEI); + waitTimeOutCount = 0; + + gsm_msg.Running = 1; //־ģѾGPRS + nextStatus = 0xFF; +// nextStatus = LTE_STA_CHECK_SIM; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nȡӲϢʱ\r\n"); + nextStatus = LTE_STA_LOADING_FAILURE; + break; + } + break; + + case 0xFF: //еȴ + break; + + case LTE_STA_CHECK_SIM: //ѯSIM״̬ + if(waitTimeOutCount > 5) //ʱδѯע״̬ + { + waitTimeOutCount = 0; + gsm_msg.simCardStatus = 4; //ûм⵽SIM + printf("\r\nѯSIM״̬ʱSIMЧ\r\n"); + nextStatus = LTE_STA_LOADING_FAILURE; //صʼ״̬ + break; + } + GSM_SendAtCmd("AT+CPIN?", AT_CMD_CPIN_NO); + nextStatus = LTE_STA_CHECK_SIM_ACK; + timer_restart(&queryTime); + break; + + case LTE_STA_CHECK_SIM_ACK: //ȴѯSIMATָӦ + if(at_cmd_table[AT_CMD_CPIN_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nSIMѾ\r\n"); + printf("\r\nѯICCID\r\n"); + waitTimeOutCount = 0; + nextStatus = LTE_STA_CHECK_ICCID; + break; + } + + if(timer_expired(&queryTime)) //ʱδյӦ + { + waitTimeOutCount++; //ȴʱ+1 + nextStatus = LTE_STA_CHECK_SIM; + break; + } + break; + + case LTE_STA_CHECK_ICCID: //ѯSIMICCID + GSM_SendAtCmd("AT+QCCID", AT_CMD_ICCID_NO); + timer_restart(&responseTimeout); + nextStatus = LTE_STA_CHECK_ICCID_ACK; + break; + + case LTE_STA_CHECK_ICCID_ACK: //ѯSIMICCIDӦ + if(at_cmd_table[AT_CMD_ICCID_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nICCID = %s\r\n", gsm_msg.ICCID); + nextStatus = LTE_STA_CHECK_CSQ; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nȡSIMICCIDʱ\r\n"); + nextStatus = LTE_STA_LOADING_FAILURE; + break; + } + break; + + case LTE_STA_CHECK_CSQ: //ѯźǿ + if(waitTimeOutCount > 10) //ʱδѯע״̬ + { + waitTimeOutCount = 0; + gsm_msg.simCardStatus = 2; //޷ע + printf("\r\nѯźţ\r\n"); + nextStatus = LTE_STA_LOADING_FAILURE; + break; + } + GSM_SendAtCmd("AT+CSQ", AT_CMD_CSQ_NO); + timer_restart(&queryTime); //ӵǰʱ¿ʱ + nextStatus = LTE_STA_CHECK_CSQ_ACK; + break; + + case LTE_STA_CHECK_CSQ_ACK: //ȴźӦ + if(at_cmd_table[AT_CMD_CSQ_NO-1].result == AT_CMD_SUCCESS) + { + if((signal > 0) && (signal != 99)) + { + printf("\r\nźǿ = %d\r\n", signal); + printf("\r\nѯע״̬\r\n"); + waitTimeOutCount = 0; //ȴʱ + nextStatus = LTE_STA_CHECK_CREG; + break; + } + } + + if(timer_expired(&queryTime)) //ʱδյӦ + { + waitTimeOutCount++; //ȴʱ+1 + nextStatus = LTE_STA_CHECK_CSQ; + break; + } + break; + + case LTE_STA_CHECK_CREG: //ѯע״̬ + if(waitTimeOutCount > 20) //ʱδѯע״̬ + { + waitTimeOutCount = 0; + gsm_msg.simCardStatus = 2; //޷ע + printf("\r\nȴʱδע磡\r\n"); + nextStatus = LTE_STA_LOADING_FAILURE; + break; + } + + GSM_SendAtCmd("AT+CREG?", AT_CMD_CREG_NO); + timer_restart(&queryTime); //ӵǰʱ¿ʱ + nextStatus = LTE_STA_CHECK_CREG_ACK; + break; + + case LTE_STA_CHECK_CREG_ACK: //ȴעɹ + if(at_cmd_table[AT_CMD_CREG_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nѾע\r\n"); + printf("\r\nѯǷGPRSҵ\r\n"); + waitTimeOutCount = 0; //ȴʱ + nextStatus = LTE_STA_CHECK_CGREG; + break; + } + + if(timer_expired(&queryTime)) //ʱδյӦ + { + waitTimeOutCount++; //ȴʱ+1 + printf("\r\nCnt = %d\r\n", waitTimeOutCount); + nextStatus = LTE_STA_CHECK_CREG; + break; + } + break; + + case LTE_STA_CHECK_CGREG: //GPRS״̬ + if(waitTimeOutCount > 10) //ʱδѯGPRS״̬ + { + waitTimeOutCount = 0; + gsm_msg.simCardStatus = 3; //SIMûGPRSҵ + printf("\r\nȴʱδGPRS\r\n"); + nextStatus = LTE_STA_LOADING_FAILURE; + break; + } + GSM_SendAtCmd("AT+CGREG?", AT_CMD_CGREG_NO); //GPRS״̬ + timer_restart(&queryTime); //ӵǰʱ¿ʱ + nextStatus = LTE_STA_CHECK_CGREG_ACK; + break; + + case LTE_STA_CHECK_CGREG_ACK: //ȴGPRSҵ + if(at_cmd_table[AT_CMD_CGREG_NO-1].result == AT_CMD_SUCCESS) + { + gsm_msg.simCardStatus = 1; //SIM + printf("\r\nѾGPRSҵ\r\n"); + + nextStatus = LTE_STA_QUERY_OPERATOR; + break; + } + + if(timer_expired(&queryTime)) //ʱδյӦ + { + waitTimeOutCount++; //ȴʱ+1 + printf("\r\nCnt = %d\r\n", waitTimeOutCount); + nextStatus = LTE_STA_CHECK_CGREG; + break; + } + break; + + case LTE_STA_QUERY_OPERATOR: //ѯӪ + GSM_SendAtCmd("AT+COPS?", AT_CMD_COPS_NO); //ѯӪ + timer_restart(&responseTimeout); + nextStatus = LTE_STA_QUERY_OPERATOR_ACK; + break; + + case LTE_STA_QUERY_OPERATOR_ACK: //ѯӪӦ + if(at_cmd_table[AT_CMD_COPS_NO-1].result == AT_CMD_SUCCESS) + { + if(gsm_msg.OperatorType == 1) + { + printf("\r\nйƶ\r\n"); + }else if(gsm_msg.OperatorType == 2){ + printf("\r\nйͨ\r\n"); + }else{} + + nextStatus = LTE_STA_SYNC_NTP; +// nextStatus = LTE_STA_LOADING_OK; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nӦʱ\r\n"); + nextStatus = LTE_STA_SYNC_NTP; +// nextStatus = LTE_STA_LOADING_OK; + break; + } + break; + + case LTE_STA_SYNC_NTP: //ͬNTP + startSyncNTP_Mark = 1; + syncNTP_SuccessMark = 0; + timer_restart(&responseTimeout); + nextStatus = LTE_STA_SYNC_NTP_ACK; + break; + + case LTE_STA_SYNC_NTP_ACK: //ȴNTPͬʱ + EC200X_NTP_SyncHandler(); + if(syncNTP_SuccessMark == 1) + { + syncNTP_SuccessMark = 0; + nextStatus = LTE_STA_LOADING_OK; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nNTP ͬʱ\r\n"); + nextStatus = LTE_STA_LOADING_OK; + break; + } + break; + + case LTE_STA_LOADING_OK: //LTEģسɹ + waitTimeOutCount = 0; //ȴʱ + lteLoadCompletedFlag = 1; //־LTEģѾ + nextStatus = LTE_STA_LOADING_IDLE; + break; + + case LTE_STA_LOADING_FAILURE: //LTEģʧ + printf("\r\nģʧܣ\r\n"); + nextStatus = LTE_STA_LOADING_INIT; + break; + + case LTE_STA_LOADING_IDLE: //״̬ + if(lteLoadResetFlag == 1) + { + lteLoadResetFlag = 0; + lteLoadCompletedFlag = 0; + printf("\r\nģع̸λ\r\n"); + nextStatus = LTE_STA_LOADING_INIT; + break; + } + break; + + default: + nextStatus = LTE_STA_LOADING_FAILURE; + break; + } + + //عҪλ + if(lteLoadResetFlag == 1) + { + lteLoadResetFlag = 0; + lteLoadCompletedFlag = 0; + printf("\r\nģع̸λ\r\n"); + nextStatus = LTE_STA_LOADING_INIT; + } +} + +typedef enum +{ + LTE_STA_TCP_CREATE_INIT = 0, //ʼ״̬ + LTE_STA_SET_PDP_CONTEXT, //TCP/IP + LTE_STA_SET_PDP_CONTEXT_ACK, //TCP/IPӦ + LTE_STA_QIACT, //PDP + LTE_STA_QIACT_ACK, //PDPӦ + LTE_STA_QIDEACT, //PDP + LTE_STA_QIDEACT_ACK, //PDPӦ + LTE_STA_CHECK_QIACT, //ѯPDP״̬ + LTE_STA_CHECK_QIACT_ACK, //ѯPDP״̬Ӧ + LTE_STA_OPEN_SOCKET, //Socket + LTE_STA_OPEN_SOCKET_ACK, //SocketӦ +// LTE_STA_CLOSE_SOCKET, //رSocket +// LTE_STA_CLOSE_SOCKET_ACK, //رSocketӦ + LTE_STA_CREATE_OK, //Socket + LTE_STA_CREATE_FAILURE, //Socketʧ + LTE_STA_CREATE_IDLE, //Socketӹ̿״̬ +}_LTE_TCP_CreateStatus; +/* +*********************************************************************** +* : TCP_ClientCreate +* ˵: TCPͻ +* Σ +* ֵ: +*********************************************************************** +*/ +void TCP_ClientCreate(void) +{ + static _LTE_TCP_CreateStatus currentStatus = LTE_STA_TCP_CREATE_INIT; + static _LTE_TCP_CreateStatus nextStatus = LTE_STA_TCP_CREATE_INIT; + + static timer responseTimeout; + static timer responseTimeout_3s; + static timer registrationTime; + static timer connectionWaitTime; + static timer waitingTime_2s; + static timer reconnectTimeout; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&responseTimeout, CLOCK_SECOND*3); //1ʱڷATȴӦʱ + timer_set(&responseTimeout_3s, CLOCK_SECOND*3); //1ʱڷATȴӦʱ + timer_set(&connectionWaitTime, CLOCK_SECOND*10); //1ʱڽӵȴijʱʱ + timer_set(®istrationTime, CLOCK_SECOND*10); //1ʱڼעĵȴʱʱ + timer_set(&waitingTime_2s, CLOCK_SECOND*2); + timer_set(&reconnectTimeout, CLOCK_SECOND*20); + } + + currentStatus = nextStatus; + switch(currentStatus) + { + case LTE_STA_TCP_CREATE_INIT: //ʼTCP + if(lteLoadCompletedFlag == 1) + { + printf("\r\n׼TCP/IP Socket!\r\n"); + nextStatus = LTE_STA_SET_PDP_CONTEXT; + break; + } + break; + + case LTE_STA_SET_PDP_CONTEXT: + printf("\r\nʼAPN\r\n"); + if(gsm_msg.OperatorType == 1) + { + GSM_SendAtCmd("AT+QICSGP=1,1,\"CMNET\","","",1", AT_CMD_QICSGP_NO); //APNйƶ + }else if(gsm_msg.OperatorType == 2){ + GSM_SendAtCmd("AT+QICSGP=1,1,\"UNINET\","","",1", AT_CMD_QICSGP_NO); //APNйͨ + }else{ + GSM_SendAtCmd("AT+QICSGP=1,1,\"CMNET\","","",1", AT_CMD_QICSGP_NO); //APNйƶ + } + timer_restart(&responseTimeout); //ӵǰʱ¿2붨ʱ + timer_restart(&reconnectTimeout); //ʼȳʼʱʱˣҪ¿ + nextStatus = LTE_STA_SET_PDP_CONTEXT_ACK; + break; + + case LTE_STA_SET_PDP_CONTEXT_ACK: //ȴӦ + if(at_cmd_table[AT_CMD_QICSGP_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nAPN OK\r\n"); + nextStatus = LTE_STA_QIDEACT; + break; + } + if(at_cmd_table[AT_CMD_QICSGP_NO-1].result == AT_CMD_FAILED) + { + printf("\r\nAPN ERROR\r\n"); + nextStatus = LTE_STA_CREATE_FAILURE; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nȴӦʱAPN\r\n"); + nextStatus = LTE_STA_CREATE_FAILURE; + break; + } + break; + + case LTE_STA_QIDEACT: + printf("\r\n\r\n"); + GSM_SendAtCmd("AT+QIDEACT=1", AT_CMD_QIDEACT_NO); //PDP,Э,Ϣ + timer_restart(&responseTimeout); + nextStatus = LTE_STA_QIDEACT_ACK; + break; + + case LTE_STA_QIDEACT_ACK: + if(at_cmd_table[AT_CMD_QIDEACT_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nOK\r\n"); + nextStatus = LTE_STA_QIACT; + break; + } + if(at_cmd_table[AT_CMD_QIACT_NO-1].result == AT_CMD_FAILED) + { + printf("\r\n· ERROR\r\n"); + nextStatus = LTE_STA_CREATE_FAILURE; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nӦOKʱ·ʧ\r\n"); + nextStatus = LTE_STA_CREATE_FAILURE; + break; + } + break; + + case LTE_STA_QIACT: //PDP + printf("\r\n·\r\n"); + GSM_SendAtCmd("AT+QIACT=1", AT_CMD_QIACT_NO); + timer_restart(&responseTimeout); + nextStatus = LTE_STA_QIACT_ACK; + break; + + case LTE_STA_QIACT_ACK: //ȴӦ + if(at_cmd_table[AT_CMD_QIACT_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\n·OK\r\n"); + nextStatus = LTE_STA_CHECK_QIACT; + break; + } + if(at_cmd_table[AT_CMD_QIACT_NO-1].result == AT_CMD_FAILED) + { + printf("\r\n· ERROR\r\n"); + nextStatus = LTE_STA_CREATE_FAILURE; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nӦOKʱ·ʧ\r\n"); + nextStatus = LTE_STA_CREATE_FAILURE; + break; + } + break; + + case LTE_STA_CHECK_QIACT: + printf("\r\nñIP\r\n"); + GSM_SendAtCmd("AT+QIACT?", AT_CMD_CHECK_QIACT_NO); + nextStatus = LTE_STA_CHECK_QIACT_ACK; + timer_restart(&responseTimeout); + break; + + case LTE_STA_CHECK_QIACT_ACK: + if(at_cmd_table[AT_CMD_CHECK_QIACT_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nѻIPַ\r\n"); + nextStatus = LTE_STA_OPEN_SOCKET; + break; + } + if(at_cmd_table[AT_CMD_CHECK_QIACT_NO-1].result == AT_CMD_FAILED) + { + printf("\r\nñIPʧ ERROR\r\n"); + nextStatus = LTE_STA_CREATE_FAILURE; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nӦOKʱñIPʧ\r\n"); + nextStatus = LTE_STA_CREATE_FAILURE; + break; + } + break; + + case LTE_STA_OPEN_SOCKET: //ʼԶ˷ + printf("\r\nʼԶ˷\r\n"); + GSM_SendAtCmd(TCP_IP_COM, AT_CMD_QIOPEN); + nextStatus = LTE_STA_OPEN_SOCKET_ACK; + timer_restart(&connectionWaitTime); + break; + + case LTE_STA_OPEN_SOCKET_ACK: //ȴӦCONNECT OK + if(at_cmd_table[AT_CMD_QIOPEN-1].result == AT_CMD_SUCCESS) + { + printf("\r\nӳɹ\r\n"); + nextStatus = LTE_STA_CREATE_OK; + break; + } + + if(at_cmd_table[AT_CMD_QIOPEN-1].result == AT_CMD_FAILED) + { + printf("\r\nʧ\r\n"); + nextStatus = LTE_STA_CREATE_FAILURE; + break; + } + + if(timer_expired(&connectionWaitTime)) //ʱδյӦ + { + printf("\r\nӳʱ!!!\r\n"); + nextStatus = LTE_STA_CREATE_FAILURE; + break; + } + break; + + case LTE_STA_CREATE_OK: //Socket + ConnectionStatus = ONLINE; + lteCreateSocketOkFlag = 1; + + networkConnectionCount++; //罨ɹӴ+1 + if(networkConnectionCount >= 0xFFFF) + { + networkConnectionCount = 2; + } + printf("\r\nnetworkConnectionCount = %d\r\n", networkConnectionCount); + + //ʧܼӴΪ˷ֹڳйгִģ鸴λ + sendFailureCount = 0; + errorProcessCount = 0; + + gsm_msg.Running = 1; //־ģѾGPRS + + nextStatus = LTE_STA_CREATE_IDLE; + break; + + case LTE_STA_CREATE_FAILURE: //Socketʧ + printf("\r\nSocketʧܣ\r\n"); + errorProcessCount++; + printf("\r\nSocketʧܴ = %d\r\n", errorProcessCount); + nextStatus = LTE_STA_TCP_CREATE_INIT; + break; + + case LTE_STA_CREATE_IDLE: //Socketɺ״̬ + if(lteCreateSocketResetFlag == 1) + { + lteCreateSocketResetFlag = 0; + printf("\r\nSocket̸λ\r\n"); + + ConnectionStatus = OFFLINE; + lteCreateSocketOkFlag = 0; + gsm_msg.Running = 0; + + //ʧܼӴ + sendFailureCount = 0; + errorProcessCount = 0; + + nextStatus = LTE_STA_TCP_CREATE_INIT; + break; + } + break; + + default: //״̬ + printf("\r\nδ֪״̬ģ飡\r\n"); + LTE_StatusReset(); //GSMģ鸴λ + break; + } + + if(lteCreateSocketResetFlag == 1) + { + lteCreateSocketResetFlag = 0; + printf("\r\nSocket̸λ\r\n"); + + ConnectionStatus = OFFLINE; + lteCreateSocketOkFlag = 0; + gsm_msg.Running = 0; + + //ʧܼӴ + sendFailureCount = 0; + errorProcessCount = 0; + + nextStatus = LTE_STA_TCP_CREATE_INIT; + } +} + +typedef enum +{ + LTE_STA_Handler_INIT = 0, //ʼ״̬ + LTE_STA_SEND_DATA, //TCP + LTE_STA_LOAD_DATA_READY, //ȴģӦ">"׼ + LTE_STA_LOAD_DATA, //Ҫ͵ + LTE_STA_SEND_DATA_ACK, //TCPӦ + LTE_STA_WAITING_SEND_TIME, //ȴʱ + LTE_STA_CHECK_SEND_DATA, //TCPǷѾ + LTE_STA_CHECK_SEND_DATA_ACK, //TCPǷѾӦ + LTE_STA_REPEAT_CHECK_SEND_DATA, //¼TCPǷѾ + LTE_STA_CLOSE_SOCKET, //رSocket + LTE_STA_CLOSE_SOCKET_ACK, //رSocketӦ + LTE_STA_WQITING_RECEIVE_DATA, //ȴظ + LTE_STA_READ_DATA, //TCPȡյ + LTE_STA_READ_DATA_ACK, //TCPȡյӦ + LTE_STA_SEND_DATA_OK, //ͳɹ + LTE_STA_HANDLER_FAILURE, //ʧ + LTE_STA_HANDLER_RESTART, //ݷλ + LTE_STA_GET_SIGNAL, //ȡź + LTE_STA_GET_SIGNAL_ACK, //ȡźӦ + LTE_STA_GET_DATE_TIME, //ȡʱ + LTE_STA_GET_DATE_TIME_ACK, //ȡʱӦ +}_LTE_TCP_HandlerStatus; +/* +*********************************************************************** +* : TCP_ClientHandler +* ˵: TCPͻ˵շ +* Σ +* ֵ: +*********************************************************************** +*/ +void TCP_ClientHandler(void) +{ + static _LTE_TCP_HandlerStatus currentStatus = LTE_STA_Handler_INIT; + static _LTE_TCP_HandlerStatus nextStatus = LTE_STA_Handler_INIT; + + char atCmdBuf[32]; //ATָ + static uint8_t waitTimeOutCount = 0; + + static timer getSignalTime; //ȡźżʱ + static timer getDateTime; //ȡʱʱ + static timer responseTimeout; //Ӧʱʱ + static timer sendTimeout; //ͳʱʱ + static timer checkSendAckTimer; + static timer receiveTimer; + static timer waitingTimer; + + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&getSignalTime, CLOCK_SECOND*60); + timer_set(&getDateTime, CLOCK_SECOND*60); + timer_set(&responseTimeout, CLOCK_SECOND*3); + timer_set(&sendTimeout, CLOCK_SECOND*10); + timer_set(&receiveTimer, CLOCK_SECOND*20); + timer_set(&checkSendAckTimer, CLOCK_SECOND*5); + timer_set(&waitingTimer, CLOCK_SECOND*1); + } + + currentStatus = nextStatus; + switch(currentStatus) + { + case LTE_STA_Handler_INIT: //ǰǷҪͣоͶݽз + if((isSendDataMark == 1) && (ConnectionStatus == ONLINE)) + { + isSendDataMark = 0; + isReceiveDataMark = 0; + nextStatus = LTE_STA_SEND_DATA; + break; + } + + if(ConnectionStatus == ONLINE) + { + //ȡʱ + if(timer_expired(&getDateTime)) + { +// printf("\r\nȡʱ䣡\r\n"); + timer_restart(&getDateTime); + nextStatus = LTE_STA_GET_DATE_TIME; + break; + } + + //ȡźǿ + if(timer_expired(&getSignalTime)) + { + timer_restart(&getSignalTime); + nextStatus = LTE_STA_GET_SIGNAL; + break; + } + } + break; + + case LTE_STA_SEND_DATA: // + sprintf(atCmdBuf, "AT+QISEND=0,%d", sendDataLen); +// printf("\r\n%s\r\n", atCmdBuf); + + GSM_SendAtCmd(atCmdBuf, AT_CMD_QISEND); + timer_restart(&responseTimeout); + nextStatus = LTE_STA_LOAD_DATA_READY; + break; + + case LTE_STA_LOAD_DATA_READY: //ȴӦ> + if(at_cmd_table[AT_CMD_QISEND-1].result == AT_CMD_CIPSEND_READY) + { + printf("\r\nӦ > OK\r\n"); + nextStatus = LTE_STA_LOAD_DATA; //յӦ + break; + } + + if(at_cmd_table[AT_CMD_QISEND-1].result == AT_CMD_SEND_FAIL) + { + printf("\r\nӦ> ERROR\r\n"); + seriousError = 1; +// errorProcessCount ++; //ʧ+1 + printf("\r\nERROR = %d\r\n", errorProcessCount); + + nextStatus = LTE_STA_HANDLER_FAILURE; + break; + } + + if(at_cmd_table[AT_CMD_QISEND-1].result == TCP_STATUS_CLOSED) + { + printf("\r\nѾرգʧ\r\n"); + seriousError = 1; +// errorProcessCount ++; //ʧ+1 + printf("\r\nERROR = %d\r\n", errorProcessCount); + + nextStatus = LTE_STA_HANDLER_FAILURE; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nʱδӦ>ȡ\r\n"); + errorProcessCount ++; //ʧ+1 + printf("\r\nERROR = %d\r\n", errorProcessCount); + + nextStatus = LTE_STA_HANDLER_FAILURE; + break; + } + break; + + case LTE_STA_LOAD_DATA: //ͨģ鷢Ҫ͵ + receiveDataMark = 0; + memcpy(GPRS_TX_BUF, GPRS_DATA_BUF, sendDataLen); + GSM_GPRS_SendOne(GPRS_TX_BUF, sendDataLen); + printf("\r\nڷ......\r\n"); +// printf("\r\nStartTime = %d\r\n", time_value); + + timer_restart(&sendTimeout); + nextStatus = LTE_STA_SEND_DATA_ACK; + break; + + case LTE_STA_SEND_DATA_ACK: //ȴӦSEND OK + if(at_cmd_table[AT_CMD_QISEND-1].result == AT_CMD_CIPSEND_OK) + { +// printf("\r\nEndTime = %d\r\n", time_value); + printf("\r\nͼسɹ\r\n"); + + timer_restart(&waitingTimer); + nextStatus = LTE_STA_WAITING_SEND_TIME; + break; + } + + if(at_cmd_table[AT_CMD_QISEND-1].result == AT_CMD_SEND_FAIL) + { + printf("\r\nEndTime = %d\r\n", time_value); + printf("\r\nͼʧ\r\n"); + + sendFailureCount ++; //ʧ+1 + printf("\r\nʧܴ = %d\r\n", sendFailureCount); + + nextStatus = LTE_STA_HANDLER_FAILURE; + break; + } + + if(timer_expired(&sendTimeout)) //ʱδյӦ + { + printf("\r\nEndTime = %d\r\n", time_value); + printf("\r\nʱδʧ\r\n"); + + sendFailureCount ++; //ʧ+1 + printf("\r\nʧܴ = %d\r\n", sendFailureCount); + + nextStatus = LTE_STA_HANDLER_FAILURE; + break; + } + break; + + case LTE_STA_WAITING_SEND_TIME: //ȴһСʱٲѯǷѾɹ͸Է + //յ̨Ӧݣתȡ + if(receiveDataMark == 1) + { + receiveDataMark = 0; + + printf("\r\nյserverݣ\r\n"); + nextStatus = LTE_STA_SEND_DATA_OK; + break; + } + + if(timer_expired(&waitingTimer)) //ʱδյӦ + { + waitTimeOutCount = 0; + nextStatus = LTE_STA_CHECK_SEND_DATA; + break; + } + break; + + case LTE_STA_CHECK_SEND_DATA: //ѯǷѷ͵Է + printf("\r\nѯǷѷͳɹ\r\n"); + + if(waitTimeOutCount > 6) + { + printf("\r\nʱδܷ\r\n"); + sendFailureCount ++; //ʧ+1 + printf("\r\nʧܴ = %d\r\n", sendFailureCount); + + nextStatus = LTE_STA_HANDLER_FAILURE; + break; + } + + total_send_length = 0; + ackedBytes = 0; + GSM_SendAtCmd("AT+QISEND=0,0", AT_CMD_CHECK_QISEND_NO); + timer_restart(&checkSendAckTimer); + nextStatus = LTE_STA_CHECK_SEND_DATA_ACK; + break; + + case LTE_STA_CHECK_SEND_DATA_ACK: + if(at_cmd_table[AT_CMD_CHECK_QISEND_NO-1].result == AT_CMD_SUCCESS) + { + at_cmd_table[AT_CMD_CHECK_QISEND_NO-1].result = AT_CMD_UNKNOWN; + printf("\r\nBytes: tx = %d, ack = %d\r\n", total_send_length, ackedBytes); + + if(total_send_length == ackedBytes) + { + printf("\r\nѳɹ͵Է\r\n"); + timer_restart(&receiveTimer); + nextStatus = LTE_STA_WQITING_RECEIVE_DATA; + break; + } + } + + //յ̨Ӧݣתȡ + if(receiveDataMark == 1) + { + receiveDataMark = 0; + + printf("\r\nյserverݣ\r\n"); + nextStatus = LTE_STA_SEND_DATA_OK; + break; + } + + if(timer_expired(&checkSendAckTimer)) //ʱδյӦ + { + printf("\r\nѯݷͳʱ\r\n"); + waitTimeOutCount++; + + nextStatus = LTE_STA_CHECK_SEND_DATA; //صӳɹ״̬ + break; + } + break; + + case LTE_STA_WQITING_RECEIVE_DATA: //ȴظ + if(receiveDataMark == 1) + { + receiveDataMark = 0; + + printf("\r\nյserverݣ\r\n"); + nextStatus = LTE_STA_SEND_DATA_OK; + break; + } + + if(timer_expired(&receiveTimer)) + { + dataSendOkButNoAckMark = 1; + printf("\r\nѾͣûյظ\r\n"); + sendFailureCount ++; //ʧ+1 + printf("\r\nʧܴ = %d\r\n", sendFailureCount); + nextStatus = LTE_STA_Handler_INIT; + break; + } + break; + + case LTE_STA_SEND_DATA_OK: //ݷͳɹ + isReceiveDataMark = 1; //־յ + errorProcessCount = 0; + sendFailureCount = 0; + + nextStatus = LTE_STA_Handler_INIT; + break; + + case LTE_STA_GET_SIGNAL: //ѯźǿ + GSM_SendAtCmd("AT+CSQ", AT_CMD_CSQ_NO); + timer_restart(&responseTimeout); + nextStatus = LTE_STA_GET_SIGNAL_ACK; + break; + + case LTE_STA_GET_SIGNAL_ACK: //ȴźӦ + if(at_cmd_table[AT_CMD_CSQ_NO-1].result == AT_CMD_SUCCESS) + { + if((signal > 0) && (signal != 99)) + { + printf("\r\nźǿ = %d\r\n", signal); + nextStatus = LTE_STA_Handler_INIT; + break; + } + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + nextStatus = LTE_STA_Handler_INIT; + break; + } + break; + + case LTE_STA_GET_DATE_TIME: //ȡʱ + GSM_SendAtCmd("AT+CCLK?", AT_CMD_CCLK_NO); + timer_restart(&responseTimeout); + nextStatus = LTE_STA_GET_DATE_TIME_ACK; + break; + + case LTE_STA_GET_DATE_TIME_ACK: //ȡʱӦ + if(at_cmd_table[AT_CMD_CCLK_NO-1].result == AT_CMD_SUCCESS) + { + getDateTimeMark = 1; + GMT_To_Beijing(&GMT_Time); + printf("\r\nTime:%s\r\n", systemTime); + nextStatus = LTE_STA_Handler_INIT; + break; + } + if(at_cmd_table[AT_CMD_CCLK_NO-1].result == AT_CMD_FAILED) + { + printf("\r\nGet Time ERROR\r\n"); + nextStatus = LTE_STA_Handler_INIT; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nӦʱGet Timeʧ\r\n"); + nextStatus = LTE_STA_Handler_INIT; + break; + } + break; + + case LTE_STA_HANDLER_FAILURE: //ݷʧ + printf("\r\nݷʧܷأ\r\n"); + + dataSendFailureMark = 1; //־ݷʧ + + nextStatus = LTE_STA_Handler_INIT; + break; + + default: //δ֪״̬ + printf("\r\nException_δ֪״̬ģ飡\r\n"); + nextStatus = LTE_STA_Handler_INIT; + break; + } + + if(lteHandlerResetFlag == 1) + { + lteHandlerResetFlag = 0; + + printf("\r\nշ̸λ\r\n"); + + dataSendFailureMark = 1; //־ݷʧ + + nextStatus = LTE_STA_Handler_INIT; + } +} + +/* +*********************************************************************** +* : LTE_WorkingStatusReset +* ˵: LTEͨģ鹤״̬λ +* Σ +* ֵ: +*********************************************************************** +*/ +static void LTE_WorkingStatusReset(void) +{ + //ģ鹤̸λ + lteLoadResetFlag = 1; //־ģعҪ¸λ + lteCreateSocketResetFlag = 1; //־SocketҪ¸λ + lteLoadCompletedFlag = 0; //ģɱ־ + lteCreateSocketOkFlag = 0; //ģ鴴Socketɱ־ + lteHandlerResetFlag = 1; //־շ̸λ + + //ģ״̬־λ + ConnectionStatus = OFFLINE; + gsm_msg.Running = 0; + + //̱ + seriousError = 0; + sendFailureCount = 0; + errorProcessCount = 0; + connectionClosedMark = 0; +} + +typedef enum +{ + LTE_ER_STA_INIT = 0, //LTEģ쳣ʼ״̬ + LTE_ER_STA_HANDLER, //LTEģ쳣״̬ + LTE_ER_STA_IDLE, //LTEģ쳣״̬ +}_LTE_ErrorStatus; +/* +*********************************************************************** +* : LTE_ErrorHandler +* ˵: LTEͨģ쳣 +* Σ +* ֵ: +*********************************************************************** +*/ +void LTE_ErrorHandler(void) +{ + static _LTE_ErrorStatus currentStatus = LTE_ER_STA_INIT; + static _LTE_ErrorStatus nextStatus = LTE_ER_STA_INIT; + + static timer responseTimeout; //Ӧʱʱ + static timer sendTimeout; //ͳʱʱ + static timer waitingTimer; + + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&responseTimeout, CLOCK_SECOND*3); + timer_set(&sendTimeout, CLOCK_SECOND*10); + timer_set(&waitingTimer, CLOCK_SECOND*1); + } + + if(seriousError == 1) + { + seriousError = 0; + printf("\r\nش-->\r\n"); + LTE_WorkingStatusReset(); + } + + if(sendFailureCount >= 3) //ʧܳ3ΣͨѶģ + { + sendFailureCount = 0; + printf("\r\nʧܴԤֵ-->\r\n"); + LTE_WorkingStatusReset(); + } + + if(errorProcessCount >= 3) //ʧܳ3ΣͨѶģ + { + errorProcessCount = 0; + printf("\r\nйERRORԤֵ-->\r\n"); + LTE_WorkingStatusReset(); + } + + if(connectionClosedMark == 1) //ѶϿ + { + connectionClosedMark = 0; + printf("\r\nѶϿ\r\n"); + LTE_WorkingStatusReset(); + } +} + +/* +*********************************************************************** +* : GSM_GPRS_Task +* ˵: GSM_GPRSͨѶ +* Σ +* ֵ: +*********************************************************************** +*/ +void GSM_GPRS_Task(void) +{ + EC200X_Loading(); + TCP_ClientCreate(); + TCP_ClientHandler(); + LTE_ErrorHandler(); +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/ec200x.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/ec200x.h new file mode 100755 index 0000000..066b910 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/ec200x.h @@ -0,0 +1,37 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ gsm_gprs.h + * SIM900Aͷļ + * V1.0 + * XuZhongPing + * 2013/11/21 +*********************************************************************************/ +#ifndef __EC200X_H__ +#define __EC200X_H__ +#include "stm32f10x.h" +#include "stdio.h" +#include "gsm_uart_conf.h" + +#define GSM_PW_KEY PBout(12) + +//豸״̬ +typedef enum +{ + OFFLINE = 0, // + ONLINE = 1 // + +}_ConnectionStatus; + +extern uint8_t GSM_isPowerON; //GSMģǷڿ +extern uint8_t ConnectionStatus; //״̬ݰͳɹλΪ״̬ +extern uint8_t connectionClosedMark; //ӶϿ־ + +extern uint16_t networkConnectionCount; //Ӵ + +void LTE_Init(void); +uint8_t GSM_PowerON(void); +uint8_t GSM_PowerOFF(void); + +void GSM_GPRS_Task(void); +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_gprs.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_gprs.c new file mode 100755 index 0000000..a6b7b11 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_gprs.c @@ -0,0 +1,1356 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ gsm_gprs.c + * gsm_gprs + * V1.0 + * XuZhongPing + * 2017/06/12 +*********************************************************************************/ +#include "gsm_gprs.h" +#include "gsm_uart.h" +#include "gsm_uart_conf.h" +#include "delay.h" +#include "led.h" +#include "string.h" +#include "stdio.h" +#include "stdlib.h" + +#include "timer.h" +#include "data_typedef.h" +#include "message.h" +#include "tcp_protocol.h" +#include "at_proc.h" + + +#define RCC_PeriphClock RCC_APB2Periph_GPIOB +#define GSM_POW_KEY_Port GPIOB +#define GSM_POW_KEY_Pin GPIO_Pin_12 + +uint8_t GSM_isPowerON = 0x00; //GSMģǷڿ־ +uint8_t ConnectionStatus = OFFLINE; //״̬ݰͳɹλΪ״̬ + +static uint8_t GSM_GPRS_Status = 0x00; //GSM_GPRSĹ״̬ +static uint8_t GSM_GPRS_initStatus = 0x00; //GSMģʱĹ״̬ +static uint8_t TCP_createStatus = 0x00; //GSMģ齨TCPʱĹ״̬ +static uint8_t GSM_GPRS_workingState = 0x00; //GSMģTCPͻ˵շ״̬ +static uint8_t errorStatus = 0x00; //GSMģ쳣״̬ +static uint8_t errorProcessCount = 0; // +static uint8_t sendFailureCount = 0; //ʧܼ +static uint8_t connectionFailureCount = 0; //ʧܼ + + +/* +*********************************************************************** +* : GSM_GPRS_Init +* ˵: GSM_GPRSģʼ +* : +* ֵ: +*********************************************************************** +*/ +void GSM_GPRS_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + RCC_APB2PeriphClockCmd(RCC_PeriphClock, ENABLE); //ʹPB˿ʱ + + //GSMػųʼ + GPIO_InitStructure.GPIO_Pin = GSM_POW_KEY_Pin; //˿ + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(GSM_POW_KEY_Port, &GPIO_InitStructure); + GPIO_ResetBits(GSM_POW_KEY_Port, GSM_POW_KEY_Pin); //Ĭͣ൱ڿûа״̬ + + GSM_GPRS_Uart_Init(); + gsm_msg.Running = 0; +} + +/* +*********************************************************************** +* : GSM_StatusReset +* ˵: GSM״̬λ +* Σ +* ֵ: +*********************************************************************** +*/ +void GSM_StatusReset(void) +{ + GSM_GPRS_Status = 0x00; //GSMģʱ״̬λ + GSM_GPRS_initStatus = 0x00; //GSMģʱ״̬λ + TCP_createStatus = 0x00; //GSMģ鴴TCPͻʱ״̬λ + GSM_GPRS_workingState = 0x00; //GSMģTCPͻ˵շ״̬λ + errorStatus = 0x00; //GSMģ쳣ʱ״̬λ +} + +/* +*********************************************************************** +* : GSM_PowerON +* ˵: GSMģ鿪 +* : +* ֵ: 1ڿ0 +*********************************************************************** +*/ +uint8_t GSM_PowerON(void) +{ + uint8_t returnData = 0; + static timer pullDown_Time; + static timer pullUp_Time; + static uint8_t timer_ok = 0; + + static uint8_t powerOnStatus = 0x00; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&pullDown_Time, CLOCK_SECOND*2); //1ʱڼΪ͵ƽʱ + timer_set(&pullUp_Time, CLOCK_SECOND*5); //1ʱڼΪߵƽʱ + } + switch(powerOnStatus) + { + case 0x00: //״̬ + printf("\r\nGSMģڿ\r\n"); + GPIO_SetBits(GSM_POW_KEY_Port, GSM_POW_KEY_Pin); //GSMģpower_key + powerOnStatus = 0x01; + timer_restart(&pullDown_Time); //ӵǰʱ¿ʱ + break; + case 0x01: //Լȴ2Sӵʱ䣬power_key2Sɿģ + if(timer_expired(&pullDown_Time)) + { + GPIO_ResetBits(GSM_POW_KEY_Port, GSM_POW_KEY_Pin); //GSMģpower_key + powerOnStatus = 0x02; + timer_restart(&pullUp_Time); //ӵǰʱ¿ʱ + break; + } + break; + case 0x02: + if(timer_expired(&pullUp_Time)) + { + powerOnStatus = 0x00; + returnData = 1; + } + break; + default:break; + } + return returnData; +} + +/* +*********************************************************************** +* : GSM_PowerOFF +* ˵: GSMģػ +* : +* ֵ: +*********************************************************************** +*/ +// uint8_t GSM_PowerOFF(void) +// { +// uint8_t returnData = 0; +// static timer pullDown_Time; +// static timer pullUp_Time; +// static timer responseTimeout; +// static uint8_t timer_ok = 0; +// +// static uint8_t powerOffStatus = 0x00; +// +// if(timer_ok == 0) +// { +// timer_ok = 1; +// timer_set(&pullDown_Time, CLOCK_SECOND*2); //1ʱڼΪ͵ƽʱ +// timer_set(&pullUp_Time, CLOCK_SECOND*2); //1ʱڼΪߵƽʱ +// timer_set(&responseTimeout, CLOCK_SECOND*2); +// } +// switch(powerOffStatus) +// { +// case 0x00: +// printf("\r\nGSMģڹػ\r\n"); +// GPIO_SetBits(GSM_POW_KEY_Port, GSM_POW_KEY_Pin); //GSMģpower_key +// powerOffStatus = 0x01; +// timer_restart(&pullDown_Time); //ӵǰʱ¿ʱ +// break; +// +// case 0x01: +// if(timer_expired(&pullDown_Time)) +// { +// GPIO_ResetBits(GSM_POW_KEY_Port, GSM_POW_KEY_Pin); //GSMģpower_key +// powerOffStatus = 0x02; +// timer_restart(&pullUp_Time); +// } +// break; +// case 0x02: +// if(timer_expired(&pullUp_Time)) +// { +// GSM_SendCmd("AT", 0, 0); +// powerOffStatus = 0x03; +// timer_restart(&responseTimeout); //ӵǰʱ¿ʱ +// } +// break; +// +// case 0x03: //ȴģӦOK +// if(timer_expired(&responseTimeout)) //ʱδյӦ +// { +// printf("\r\nģѹػ\r\n"); +// powerOffStatus = 0x00; +// GSM_StatusReset(); //λֹ״̬ +// returnData = 1; +// break; +// }else{ +// if(GSM_CheckCmd("OK")) +// { +// printf("\r\nģ黹\r\n"); +// powerOffStatus = 0x00; +// break; +// } +// if(GSM_CheckCmd("AT")) +// { +// printf("\r\nģ黹\r\n"); +// powerOffStatus = 0x00; +// break; +// } +// } +// break; +// } +// return returnData; +// } + +/* +*********************************************************************** +* : GSM_SignalCheck +* ˵: ѯź +* Σ +* ֵ: +*********************************************************************** +*/ +void GSM_SignalCheck(void) +{ + uint8_t cnt = 0; + GSM_SendAtCmd("AT+CSQ", AT_CMD_CSQ_NO); + while((at_cmd_table[AT_CMD_CSQ_NO-1].result != AT_CMD_SUCCESS) && (cnt < 10)) + { + delay_ms(1); + cnt++; + } + + if(at_cmd_table[AT_CMD_CSQ_NO-1].result == AT_CMD_SUCCESS) + { + if(signal > 0) + { + printf("\r\nGSMźǿ = %d\r\n", signal); + if(signal < 5) + { + printf("\r\nGSMźǷ\r\n"); + } + }else{ + printf("\r\nGSMźţ\r\n"); + } + } +} + +/* +*********************************************************************** +* : GSM_GetHardInfo +* ˵: ȡGSMģӲϢIMEI +* : msgGSMģϢṹ +* ֵ: +*********************************************************************** +*/ +void GSM_GetHardInfo(_gsm_msg *msg) +{ +// uint8_t *p; +// +// printf("\r\nȡIMEI\r\n"); +// if(GSM_SendCmd("AT+CGSN", "OK", 200) == 0) //ѯƷк +// { +// p = (uint8_t*)strstr((const char*)(GPRS_RX_BUF+2),"\r\n"); //һس +// p[0] = 0;// +// sprintf(msg->IMEI, "%s", GPRS_RX_BUF+2); +// IMEI_TO_HEX(msg->IMEI); //ַIMEIתHEXʽΪ洫 +// // printf("\r\nIMEI:%s\r\n", msg->IMEI); +// } +} + +/* +*********************************************************************** +* : GSM_Check +* ˵: GSMģ +* Σ +* ֵ: 10 +*********************************************************************** +*/ +// uint8_t GSM_Check(void) +// { +// if(GSM_SendCmd("AT", "OK", 500)) +// { +// return 0; +// }else{ +// return 1; +// } +// } + +/* +*********************************************************************** +* : GPRS_OnlineCheck +* ˵: GPRS̨飨⣩ +* Σ +* ֵ: +*********************************************************************** +*/ +static void GPRS_OnlineCheck(void) +{ + sendMsg.msgType = 1001; // + MessageSend(MSG_FIFO_PROTOCOL, sendMsg); +} + +/* +*********************************************************************** +* : GSM_GPRS_Reset +* ˵: GSMģֹ״̬λ +* Σ +* ֵ: +*********************************************************************** +*/ +static void GSM_GPRS_Reset(void) +{ + GSM_GPRS_Status = 0x00; //תʼ״̬ģ + GSM_GPRS_initStatus = 0x00; + TCP_createStatus = 0x00; + GSM_GPRS_workingState = 0x00; + errorStatus = 0x00; + + sendFailureCount = 0; + errorProcessCount = 0; + connectionFailureCount = 0; + + ConnectionStatus = OFFLINE; + signal = 0; +} + +/* +*********************************************************************** +* : GSM_GPRS_Loading +* ˵: GSM_GPRSģأѯģ״̬ +* Σ +* ֵ: +*********************************************************************** +*/ +void GSM_GPRS_Loading(void) +{ +// static uint8_t GSM_GPRS_initStatus = 0; + static uint8_t waitTimeOutCount = 0; + + static timer responseTimeout; + static timer queryTime; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&responseTimeout, 3); //1ʱڷATȴӦʱ + timer_set(&queryTime, CLOCK_SECOND*2); //1ʱڲѯע + } + + switch(GSM_GPRS_initStatus) + { + case 0x00: //״̬ + if(GSM_PowerON()) + { + GSM_GPRS_initStatus = 0x01; + } + break; + + case 0x01: //ģǷ + printf("\r\nģ\r\n"); + GSM_SendAtCmd("AT", AT_CMD_AT_NO); + GSM_GPRS_initStatus = 0x02; + timer_restart(&responseTimeout); //ӵǰʱ¿ʱ + break; + + case 0x02: //ȴģӦOK + if(at_cmd_table[AT_CMD_AT_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nģ\r\n"); + GSM_GPRS_initStatus = 0x03; //յӦת0x + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nʱδģӦ\r\n"); + GSM_GPRS_initStatus = 0x00; + break; + } + break; + + case 0x03: //ò + printf("\r\nò\r\n"); + GSM_SendAtCmd("ATE0", AT_CMD_ATE0_NO); // + GSM_GPRS_initStatus = 0x04; + timer_restart(&responseTimeout); + break; + + case 0x04: //ȴATָӦ + if(at_cmd_table[AT_CMD_ATE0_NO-1].result == AT_CMD_SUCCESS) + { + GSM_GPRS_initStatus = 0x05; //յӦת0x + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nòʧ\r\n"); + GSM_GPRS_initStatus = 0x00; + break; + } + break; + + case 0x05: //ȡӲϢ + GSM_SendAtCmd("AT+CGSN", AT_CMD_CGSN_NO); + GSM_GPRS_initStatus = 0x06; + timer_restart(&responseTimeout); + break; + + case 0x06: //ȴATָӦ + if(at_cmd_table[AT_CMD_CGSN_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nIMEI = %s\r\n", gsm_msg.IMEI); + waitTimeOutCount = 0; + GSM_GPRS_initStatus = 0x07; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nȡӲϢʱ\r\n"); + GSM_GPRS_initStatus = 0x00; + break; + } + break; + + case 0x07: //ѯSIM״̬ + if(waitTimeOutCount > 3) //ʱδѯע״̬ + { + waitTimeOutCount = 0; + GSM_GPRS_initStatus = 0x00; //صʼ״̬ + printf("\r\nѯSIM״̬ʱSIMЧ\r\n"); + break; + } + GSM_SendAtCmd("AT+CPIN?", AT_CMD_CPIN_NO); + GSM_GPRS_initStatus = 0x08; + timer_restart(&queryTime); + break; + + case 0x08: //ȴATָӦ + if(at_cmd_table[AT_CMD_CPIN_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nSIMѾ\r\n"); + printf("\r\nѯźǿ\r\n"); + waitTimeOutCount = 0; + GSM_GPRS_initStatus = 0x09; + break; + } + + if(timer_expired(&queryTime)) //ʱδյӦ + { + GSM_GPRS_initStatus = 0x07; + waitTimeOutCount++; //ȴʱ+1 + break; + } + break; + + case 0x09: //ѯźǿ + if(waitTimeOutCount > 10) //ʱδѯע״̬ + { + waitTimeOutCount = 0; + GSM_GPRS_initStatus = 0x00; //صʼ״̬ + printf("\r\nѯźţ\r\n"); + break; + } + GSM_SendAtCmd("AT+CSQ", AT_CMD_CSQ_NO); + GSM_GPRS_initStatus = 0x10; + timer_restart(&queryTime); //ӵǰʱ¿ʱ + break; + + case 0x10: //ȴźӦ + if(at_cmd_table[AT_CMD_CSQ_NO-1].result == AT_CMD_SUCCESS) + { + if(signal > 0) + { + printf("\r\nźǿ = %d\r\n", signal); + printf("\r\nѯע״̬\r\n"); + waitTimeOutCount = 0; //ȴʱ + GSM_GPRS_initStatus = 0x11; + break; + } + } + + if(timer_expired(&queryTime)) //ʱδյӦ + { + GSM_GPRS_initStatus = 0x09; + waitTimeOutCount++; //ȴʱ+1 + break; + } + break; + + case 0x11: //ѯע״̬ + if(waitTimeOutCount > 10) //ʱδѯע״̬ + { + waitTimeOutCount = 0; + GSM_GPRS_initStatus = 0x00; //صʼ״̬ + printf("\r\nȴʱδע磡\r\n"); + break; + } + GSM_SendAtCmd("AT+CREG?", AT_CMD_CREG_NO); + GSM_GPRS_initStatus = 0x12; + timer_restart(&queryTime); //ӵǰʱ¿ʱ + break; + + case 0x12: //ȴעɹ + if(at_cmd_table[AT_CMD_CREG_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nѾע\r\n"); + printf("\r\nѯǷGPRSҵ\r\n"); + waitTimeOutCount = 0; //ȴʱ + GSM_GPRS_initStatus = 0x13; + break; + } + + if(timer_expired(&queryTime)) //ʱδյӦ + { + GSM_GPRS_initStatus = 0x11; + waitTimeOutCount++; //ȴʱ+1 + break; + } + break; + + case 0x13: //GPRS״̬ + if(waitTimeOutCount > 10) //ʱδѯGPRS״̬ + { + waitTimeOutCount = 0; + GSM_GPRS_initStatus = 0x00; //صʼ״̬ + printf("\r\nȴʱδGPRS\r\n"); + break; + } + GSM_SendAtCmd("AT+CGATT?", AT_CMD_CGATT_NO); //GPRS״̬ + GSM_GPRS_initStatus = 0x14; + timer_restart(&queryTime); //ӵǰʱ¿ʱ + break; + + case 0x14: //ȴGPRSҵ + if(at_cmd_table[AT_CMD_CGATT_NO-1].result == AT_CMD_SUCCESS) + { + waitTimeOutCount = 0; //ȴʱ + GSM_GPRS_initStatus = 0x00; + printf("\r\nѾGPRSҵ\r\n"); + GSM_GPRS_Status = 0x01; + break; + } + + if(timer_expired(&queryTime)) //ʱδյӦ + { + GSM_GPRS_initStatus = 0x13; + waitTimeOutCount++; //ȴʱ+1 + break; + } + break; + + default: + GSM_GPRS_initStatus = 0x00; + break; + } +} + +/* +*********************************************************************** +* : TCP_ClientCreate +* ˵: TCPͻ +* Σ +* ֵ: +*********************************************************************** +*/ +void TCP_ClientCreate(void) +{ +// static uint8_t createStatus = 0x00; + + static timer responseTimeout; + static timer responseTimeout_3s; + static timer registrationTime; + static timer connectionWaitTime; + static timer waitingTime_2s; + static timer reconnectTimeout; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&responseTimeout, 3); //1ʱڷATȴӦʱ + timer_set(&responseTimeout_3s, CLOCK_SECOND*3); //1ʱڷATȴӦʱ + timer_set(&connectionWaitTime, CLOCK_SECOND*10); //1ʱڽӵȴijʱʱ + timer_set(®istrationTime, CLOCK_SECOND*10); //1ʱڼעĵȴʱʱ + timer_set(&waitingTime_2s, CLOCK_SECOND*2); + timer_set(&reconnectTimeout, CLOCK_SECOND*20); + } + + switch(TCP_createStatus) + { + case 0x00: //ʼTCP + printf("\r\nʼAPN\r\n"); + GSM_SendAtCmd("AT+CSTT=\"CMNET\"", AT_CMD_CSTT_NO); //GPRSƶ̨ΪB,ְ֧ݽ + TCP_createStatus = 0x01; + timer_restart(&responseTimeout); //ӵǰʱ¿2붨ʱ + timer_restart(&reconnectTimeout); //ʼȳʼʱʱˣҪ¿ + break; + + case 0x01: //ȴӦ + if(at_cmd_table[AT_CMD_CSTT_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nAPN OK\r\n"); + TCP_createStatus = 0x02; //յӦת0x02 + break; + } + if(at_cmd_table[AT_CMD_CSTT_NO-1].result == AT_CMD_FAILED) + { + printf("\r\nAPN ERROR\r\n"); + TCP_createStatus = 0x20; //Ӧת0x + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nȴӦʱAPN\r\n"); + TCP_createStatus = 0x20; + break; + } + break; + + case 0x02: //· + printf("\r\n·\r\n"); + GSM_SendAtCmd("AT+CIICR", AT_CMD_CIICR_NO); //PDP,Э,Ϣ + TCP_createStatus = 0x03; + timer_restart(&responseTimeout_3s); //ӵǰʱ¿2붨ʱ + break; + + case 0x03: //ȴӦ + if(at_cmd_table[AT_CMD_CIICR_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\n·OK\r\n"); + TCP_createStatus = 0x04; //յӦת0x + break; + } + if(at_cmd_table[AT_CMD_CIICR_NO-1].result == AT_CMD_FAILED) + { + printf("\r\n· ERROR\r\n"); + TCP_createStatus = 0x20; //Ӧת0x00 + break; + } + + if(timer_expired(&responseTimeout_3s)) //ʱδյӦ + { + printf("\r\nӦOKʱ·ʧ\r\n"); + TCP_createStatus = 0x20; + break; + } + break; + + case 0x04: //ýʾIPͷ + printf("\r\nýʾIPͷ\r\n"); + GSM_SendAtCmd("AT+CIPHEAD=1", AT_CMD_CIPHEAD_NO); //ýʾIPͷ(жԴ) + TCP_createStatus = 0x05; + timer_restart(&responseTimeout); //ӵǰʱ¿2붨ʱ + break; + + case 0x05: + if(at_cmd_table[AT_CMD_CIPHEAD_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nýʾIPͷOK\r\n"); + TCP_createStatus = 0x06; //յӦת0x + break; + } + if(at_cmd_table[AT_CMD_CIPHEAD_NO-1].result == AT_CMD_FAILED) + { + printf("\r\nýʾIPͷʧ\r\n"); + TCP_createStatus = 0x20; //Ӧת0x + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nӦOKʱýʾIPͷʧ\r\n"); + TCP_createStatus = 0x20; + break; + } + break; + + case 0x06: //ñIP + printf("\r\nñIP\r\n"); + GSM_SendAtCmd("AT+CIFSR", AT_CMD_CIFSR_NO); + TCP_createStatus = 0x07; + timer_restart(&responseTimeout); //ӵǰʱ¿n붨ʱ + break; + + case 0x07: + if(at_cmd_table[AT_CMD_CIFSR_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nѻIPַ\r\n"); + TCP_createStatus = 0x08; //յӦת0x + break; + } + if(at_cmd_table[AT_CMD_CIFSR_NO-1].result == AT_CMD_FAILED) + { + printf("\r\nñIPʧ ERROR\r\n"); + TCP_createStatus = 0x20; //Ӧת0x00 + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nӦOKʱñIPʧ\r\n"); + TCP_createStatus = 0x20; + break; + } + break; + + case 0x08: //ʼԶ˷ + printf("\r\nʼԶ˷\r\n"); + GSM_SendAtCmd(TCP_IP_COM, AT_CMD_CIPSTART_NO); //ʼԶ˷ + TCP_createStatus = 0x09; + timer_restart(&connectionWaitTime); //ӵǰʱ¿ʱ + break; + + case 0x09: //ȴӦCONNECT OK + if(at_cmd_table[AT_CMD_CIPSTART_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nӳɹ\r\n"); + + //ʧܼӴΪ˷ֹڳйгִģ鸴λ + sendFailureCount = 0; + errorProcessCount = 0; + connectionFailureCount = 0; + + TCP_createStatus = 0x00; + gsm_msg.Running = 1; //־ģѾGPRS + + //ӳɹ + sendMsg.msgType = 1001; // + MessageSend(MSG_FIFO_PROTOCOL, sendMsg); + + sendMsg.msgType = 6004; //ϴ豸״̬Ϣ¶ȡźšࣩ + MessageSend(MSG_FIFO_PROTOCOL, sendMsg); + +// GSM_SendCmd("AT+CSCLK=2", "OK", 200); //ģʽ +// GSM_SendCmd("AT+CFUN=1", "OK", 200); + + GSM_GPRS_Status = 0x02; //TCPӳɹתշĴ״̬ + break; + } + + if(at_cmd_table[AT_CMD_CIPSTART_NO-1].result == AT_CMD_FAILED) + { + printf("\r\nʧ\r\n"); + TCP_createStatus = 0x20; + break; + } + + if(timer_expired(&connectionWaitTime)) //ʱδյӦ + { + printf("\r\nӳʱ!!!\r\n"); + TCP_createStatus = 0x20; + break; + } + + break; + + case 0x10: //ѯGPRS״̬ʱ + timer_restart(&waitingTime_2s); + TCP_createStatus = 0x11; + break; + + case 0x11: + if(timer_expired(&waitingTime_2s)) + { + TCP_createStatus = 0x20; + } + break; + + case 0x20: //ѯGPRS״̬ + if(timer_expired(&reconnectTimeout)) + { + printf("\r\nTCPӳʱģ飡\r\n"); + + GSM_GPRS_Reset(); //GSMģ鸴λ + break; + } + + connectionFailureCount++; //ʧܼ + printf("\r\n쳣 %d \r\n", connectionFailureCount); + if(connectionFailureCount >= 10) //5λָģ + { + //ִеһתģ鸴λ + GSM_GPRS_Reset(); //GSMģ鸴λ + printf("\r\n쳣쳣ģ飡\r\n"); + break; + } + + printf("\r\nѯGPRS״̬\r\n"); + GSM_SendAtCmd("AT+CIPSTATUS", AT_CMD_CIPSTATUS_NO); //ѯ״̬ + TCP_createStatus = 0x21; + timer_restart(&responseTimeout_3s); //ӵǰʱ¿ʱ + break; + + case 0x21: //GPRSĸ״̬ + switch(at_cmd_table[AT_CMD_CIPSTATUS_NO-1].result) + { + case GPRS_STATUS_IP_INITIAL: //GPRSʼ + printf("\r\nGPRSʼ\r\n"); + TCP_createStatus = 0x00; + break; + + case GPRS_STATUS_IP_START: //ʼTCP/UDPỰ + printf("\r\nʼTCP/UDPỰ\r\n"); + TCP_createStatus = 0x02; + break; + + case GPRS_STATUS_IP_CONFIG: //PDP + printf("\r\nPDP\r\n"); + TCP_createStatus = 0x10; //ѯGPRS״̬ + break; + + case GPRS_STATUS_IP_GPRSACT: + TCP_createStatus = 0x04; + printf("\r\nѾ\r\n"); + break; + + case GPRS_STATUS_IP_STATUS: //õIPַ + printf("\r\nõIPַ\r\n"); + TCP_createStatus = 0x08; + break; + + case GPRS_STATUS_TCP_CONNECTING: // + printf("\r\nӷ\r\n"); + TCP_createStatus = 0x10; + break; + + case GPRS_STATUS_CONNECT_OK: // + printf("\r\n\r\n"); + //ʧܼӴΪ˷ֹڳйгִģ鸴λ + sendFailureCount = 0; + errorProcessCount = 0; + + TCP_createStatus = 0x00; + gsm_msg.Running = 1; //־ģѾGPRS + + GSM_GPRS_Status = 0x02; //TCPӳɹתշĴ״̬ + + break; + + case GPRS_STATUS_TCP_CLOSING: + printf("\r\nڹر\r\n"); + TCP_createStatus = 0x10; //ѯGPRS״̬ + break; + + case GPRS_STATUS_TCP_CLOSED: + printf("\r\nѾر\r\n"); + TCP_createStatus = 0x30; + break; + + case GPRS_STATUS_PDP_DEACT: //Ѿر + printf("\r\nPDPȥ\r\n"); + TCP_createStatus = 0x30; + break; + + default: + break; + } + + if(timer_expired(&responseTimeout_3s)) //ʱδյӦ + { + printf("\r\nGPRS״̬ѯʱûӦ\r\n"); + TCP_createStatus = 0x20; + break; + } + + break; + + case 0x30: //رƶ + printf("\r\nرƶ\r\n"); + GSM_SendAtCmd("AT+CIPSHUT", AT_CMD_CIPSHUT_NO); //رƶ + TCP_createStatus = 0x31; + timer_restart(&responseTimeout_3s); //ӵǰʱ¿ʱ + break; + + case 0x31: //ȴرƶӦ + if(at_cmd_table[AT_CMD_CIPSHUT_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nرƶɹ\r\n"); + TCP_createStatus = 0x00; //յӦת0x + break; + } + if(at_cmd_table[AT_CMD_CIPSHUT_NO-1].result == AT_CMD_FAILED) + { + printf("\r\nرƶʧ\r\n"); + TCP_createStatus = 0x20; + break; + } + + if(timer_expired(&responseTimeout_3s)) //ʱδյӦ + { + printf("\r\nرƶʱδӦ\r\n"); + TCP_createStatus = 0x20; + break; + } + break; + + default: //״̬ + printf("\r\nδ֪״̬ģ飡\r\n"); + GSM_GPRS_Reset(); //GSMģ鸴λ + break; + } +} + +/* +*********************************************************************** +* : TCP_ClientHandler +* ˵: TCPͻ˵շ +* Σ +* ֵ: +*********************************************************************** +*/ +void TCP_ClientHandler(void) +{ + static Com_ProtocolMessage *pMsg; +// static uint8_t GSM_GPRS_workingState = 0x00; + static uint16_t sendDataSize = 0; +// static uint8_t sendFailureCount = 0; //ʧܼ + + static timer uploadIntervalTime; //ϴʱƣͬһʱظϴ + static timer responseTimeout; //Ӧʱʱ + static timer sendTimeout; //ͳʱʱ + + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&uploadIntervalTime, CLOCK_SECOND*3); + timer_set(&responseTimeout, CLOCK_SECOND*3); + timer_set(&sendTimeout, CLOCK_SECOND*10); + } + + switch(GSM_GPRS_workingState) + { + case 0x00: //ǰǷҪͣоͶݽз + pMsg = MessageGet(MSG_FIFO_PROTOCOL); //ȡϢ + if(pMsg){ //ϢϢݷ +// printf("\r\nҪͣڼ......\r\n"); + GSM_GPRS_workingState = 0x01; //ת +// printf("\r\npThis->msgType = %x\r\n", pThis->msgType); +// printf("\r\npThis->msgData = %x\r\n", pThis->msgData); + }else{ + GSM_GPRS_workingState = 0x00; + } + break; + + case 0x01: //AT+CIPSEND + sendOrderCode = pMsg->msgType; //ȡ÷͵Э + + //ʱϿӻѹδͬһʱظ + if(sendOrderCode == 1001) + { + if(ConnectionStatus == ONLINE) //ǰ״̬ + { + if(timer_expired(&uploadIntervalTime)) //һηʱ䳬趨ֵͣ + { + timer_restart(&uploadIntervalTime); + }else{ //һηʱ̣ϴ + GSM_GPRS_workingState = 0x00; + printf("\r\nȡ\r\n"); + timer_restart(&uploadIntervalTime); //¿ʱΪһ´ж׼ + break; // + } + }else{ //ǰ״̬зʧܾ״̬Ϊ״̬ + timer_restart(&uploadIntervalTime); //¿ʱΪһ´ж׼ + } + } + + sendDataSize = ProtocolPackaging(sendOrderCode); //ͨϢͽӦЭ + getCommand_CIPSEND(sendDataSize); //ȡ÷ָATָ + + //ֹ̨ͣݵ +// GSM_GPRS_workingState = 0x00; + +// printf("\r\n %s\r\n", command_CIPSEND); + GSM_SendAtCmd(command_CIPSEND, AT_CMD_CIPSEND_NO); //"AT+CIPSEND=" + GSM_GPRS_workingState = 0x02; + timer_restart(&responseTimeout); //ӵǰʱ¿ʱ + break; + + case 0x02: //ȴӦ> + if(at_cmd_table[AT_CMD_CIPSEND_NO-1].result == AT_CMD_CIPSEND_READY) + { + printf("\r\nӦ > OK\r\n"); + GSM_GPRS_workingState = 0x03; //յӦ + break; + } + + if(at_cmd_table[AT_CMD_CIPSEND_NO-1].result == AT_CMD_SEND_FAIL) + { + printf("\r\nӦ> ERROR\r\n"); + sendFailureCount ++; //ʧ+1 + printf("\r\nʧܴ = %d\r\n", sendFailureCount); + + //յERRORӦʱֱת + GSM_GPRS_Status = 0x03; //ת + GSM_GPRS_workingState = 0x00; //صʼ״̬ɺӳʼ + break; + } + + if(at_cmd_table[AT_CMD_CIPSEND_NO-1].result == TCP_STATUS_CLOSED) + { + printf("\r\nѾرգʧ\r\n"); + sendFailureCount ++; //ʧ+1 + printf("\r\nʧܴ = %d\r\n", sendFailureCount); + + //յCLOSEDӦʱֱת + GSM_GPRS_Status = 0x03; //ת + GSM_GPRS_workingState = 0x00; //صʼ״̬ɺӳʼ + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nʱδӦ>ȡ\r\n"); + sendFailureCount ++; //ʧ+1 + + GSM_GPRS_workingState = 0x06; //صӳɹ״̬ + break; + } + break; + + case 0x03: //ͨģ鷢Ҫ͵ + memcpy(GPRS_TX_BUF, GPRS_DATA_BUF, sendDataSize); + GSM_GPRS_SendOne(sendDataSize); + printf("\r\nTCP Sending data......\r\n"); +// printf("\r\nStartTime = %d\r\n", time_value); + GSM_GPRS_workingState = 0x04; + break; + + case 0x04: //ͽݷ + GSM_GPRS_workingState = 0x05; + timer_restart(&sendTimeout); //ӵǰʱ¿N붨ʱ + break; + + case 0x05: //ȴӦSEND OK + if(at_cmd_table[AT_CMD_CIPSEND_NO-1].result == AT_CMD_CIPSEND_OK) + { +// printf("\r\nEndTime = %d\r\n", time_value); + printf("\r\nͳɹ\r\n"); + + ConnectionStatus = ONLINE; //ͳɹʱ״̬Ϊ״̬ + + SetSendProcotolSuccess(); //ñη͵Эѳɹ + + sendFailureCount = 0; //ͳɹʧܼ + errorProcessCount = 0; //ݳɹ + + if(sendOrderCode == 1001) //ɹѯGSMźǿ + { + GSM_SignalCheck(); //ѯź + } + GSM_GPRS_workingState = 0x00; //յӦ + break; + } + + if(at_cmd_table[AT_CMD_CIPSEND_NO-1].result == AT_CMD_SEND_FAIL) + { + printf("\r\nEndTime = %d\r\n", time_value); + printf("\r\nʧ\r\n"); + + ConnectionStatus = OFFLINE; //ʧʱ״̬Ϊ״̬ + sendFailureCount ++; //ʧ+1 + + //ʧʱGPRS̨Ƿ + GPRS_OnlineCheck(); + + GSM_GPRS_workingState = 0x06; + break; + } + + if(timer_expired(&sendTimeout)) //ʱδյӦ + { + printf("\r\nEndTime = %d\r\n", time_value); + printf("\r\nʱδʧ\r\n"); + + ConnectionStatus = OFFLINE; //ʧʱ״̬Ϊ״̬ + sendFailureCount ++; //ʧ+1 + + //ʧʱGPRS̨Ƿ + GPRS_OnlineCheck(); + + GSM_GPRS_workingState = 0x06; //صӳɹ״̬ + break; + } + break; + + case 0x06: //Ƿ񳬳ʧܴ + printf("\r\nǰѷʧܴ = %d\r\n", sendFailureCount); + if(sendFailureCount > 0) //ݷʧȼGSMźǷ + { + GSM_SignalCheck(); + } + + if(sendFailureCount >= 3) //ʧܴҪд + { + printf("\r\nʧܴת\r\n"); + GSM_GPRS_workingState = 0x00; + GSM_GPRS_Status = 0x03; //ת + break; + }else{ + GSM_GPRS_workingState = 0x00; + } + break; + + default: //δ֪״̬ + GSM_GPRS_Reset(); //GSMģ鸴λ + + printf("\r\nException_δ֪״̬ģ飡\r\n"); + break; + } +} + +/* +*********************************************************************** +* : TCP_ErrorHandler +* ˵: TCPӹеĴ +* Σ +* ֵ: +*********************************************************************** +*/ +void TCP_ErrorHandler(void) +{ +// static uint8_t errorStatus = 0x00; + + static timer responseTimeout; + static timer waitTCPConnectTime; + static timer waitingTime2s; //2Sʱ + + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&responseTimeout, CLOCK_SECOND*3); + timer_set(&waitTCPConnectTime, CLOCK_SECOND*10); + timer_set(&waitingTime2s, CLOCK_SECOND*2); + } + + switch(errorStatus) + { + case 0x00: //ѯGPRS״̬ + ConnectionStatus = OFFLINE; //ʧʱ״̬Ϊ״̬ + + //Ƚ쳣飬ģ + errorProcessCount++; //+1 + printf("\r\nException_쳣 %d \r\n", errorProcessCount); + if(errorProcessCount >= 5) //5λָģ + { + //ִеһתģ鸴λ + GSM_GPRS_Reset(); //GSMģ鸴λ + printf("\r\nException_쳣ģ飡\r\n"); + break; + } + + printf("\r\nException_ѯGPRS״̬\r\n"); + GSM_SendAtCmd("AT+CIPSTATUS", AT_CMD_CIPSTATUS_NO); //ѯ״̬ + errorStatus = 0x01; + timer_restart(&responseTimeout); //ӵǰʱ¿ʱ + break; + + case 0x01: //ݵǰGPRSĹ״̬Ӧ + switch(at_cmd_table[AT_CMD_CIPSTATUS_NO-1].result) + { + case GPRS_STATUS_IP_INITIAL: + printf("\r\nException_GPRSʼ\r\n"); + errorStatus = 0x12; //תرƶ + break; + + case GPRS_STATUS_IP_START: + printf("\r\nException_ʼTCP/UDPỰ\r\n"); + errorStatus = 0x10; //תرƶ + break; + + case GPRS_STATUS_IP_CONFIG: + printf("\r\nException_PDP\r\n"); + errorStatus = 0x20; //תжϺٴβѯGPRS״̬ + break; + + case GPRS_STATUS_IP_GPRSACT: + printf("\r\nException_Ѿ\r\n"); + errorStatus = 0x10; + break; + + case GPRS_STATUS_IP_STATUS: + printf("\r\nException_õIPַ\r\n"); + errorStatus = 0x12; + break; + + case GPRS_STATUS_TCP_CONNECTING: // + printf("\r\nException_ӷ\r\n"); + errorStatus = 0x20; + break; + + case GPRS_STATUS_CONNECT_OK: // + printf("\r\nException_\r\n"); + + //⵽ӻжGPRS̨Ƿ + GPRS_OnlineCheck(); + + //һȻѯ״̬ΪӻпѾ쳣 + //Դͷʧܼı + errorStatus = 0x00; //ӳɹ + GSM_GPRS_Status = 0x02; //תTCPͻշ + break; + + case GPRS_STATUS_TCP_CLOSING: + printf("\r\nException_ڹر\r\n"); + errorStatus = 0x20; + break; + + case GPRS_STATUS_TCP_CLOSED: + printf("\r\nException_Ѿر\r\n"); + errorStatus = 0x10; + break; + + case GPRS_STATUS_PDP_DEACT: //Ѿر + printf("\r\nException_PDPȥ\r\n"); + errorStatus = 0x20; + break; + + default: + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nException_״̬ѯʱ\r\n"); + errorStatus = 0x20; + break; + } + break; + + case 0x10: //رƶAT+CIPSHUT + GSM_SendAtCmd("AT+CIPSHUT", AT_CMD_CIPSHUT_NO); //رƶ + errorStatus = 0x11; + timer_restart(&responseTimeout); //ӵǰʱ¿ʱ + printf("\r\nException_ڹرճ\r\n"); + break; + + case 0x11: + if(at_cmd_table[AT_CMD_CIPSHUT_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nException_Ѿر\r\n"); + errorStatus = 0x12; + } + if(at_cmd_table[AT_CMD_CIPSHUT_NO-1].result == AT_CMD_FAILED) + { + printf("\r\nException_رմ\r\n"); + errorStatus = 0x20; + break; + } + + if(timer_expired(&responseTimeout)) //ʱδյӦ + { + printf("\r\nException_رճʱδӦ\r\n"); + errorStatus = 0x20; + break; + } + break; + + case 0x12: //TCPAT+CIPSTART='IPַ' + printf("\r\nException_\r\n"); + GSM_SendAtCmd(TCP_IP_COM, AT_CMD_CIPSTART_NO); //ʼԶ˷ + errorStatus = 0x13; + timer_restart(&waitTCPConnectTime); //ӵǰʱ¿ʱ + printf("\r\nException_ȴӦCONNECT OK\r\n"); + break; + + case 0x13: //ȴӦCONNECT OK + if(at_cmd_table[AT_CMD_CIPSTART_NO-1].result == AT_CMD_SUCCESS) + { + printf("\r\nException_ӳɹ\r\n"); + + GPRS_OnlineCheck(); + + errorProcessCount = 0; +// sendFailureCount = 0; //ͳɹʧܼ + + errorStatus = 0x00; //յӦת0x10 + GSM_GPRS_Status = 0x02; //תTCPͻ˴״̬ + break; + } + + if(at_cmd_table[AT_CMD_CIPSTART_NO-1].result == AT_CMD_FAILED) + { + printf("\r\nException_ʧ\r\n"); + errorStatus = 0x20; + break; + } + + if(timer_expired(&waitTCPConnectTime)) //ʱδյӦ + { + printf("\r\nException_ȴӦCONNECT OKʱ\r\n"); + errorStatus = 0x20; + break; + } + break; + + case 0x20: //2Sʱ2S²ѯGPRS״̬ + errorStatus = 0x21; + timer_restart(&waitingTime2s); + break; + + case 0x21: //2S²ѯGPRS״̬ + if(timer_expired(&waitingTime2s)) + { + errorStatus = 0x00; + } + break; + + default: //δ֪״̬ + GSM_GPRS_Reset(); //GSMģ鸴λ + + printf("\r\nException_δ֪״̬ģ飡\r\n"); + break; + } +} + +/* +*********************************************************************** +* : GSM_GPRS_Task +* ˵: GSM_GPRSͨѶ +* Σ +* ֵ: +*********************************************************************** +*/ +void GSM_GPRS_Task(void) +{ + switch(GSM_GPRS_Status) + { + case 0x00: //ʼ״̬ģп״̬IJѯ + GSM_GPRS_Loading(); + break; + + case 0x01: //TCPͻ + TCP_ClientCreate(); + break; + + case 0x02: //TCPͻ˴ݵշ + TCP_ClientHandler(); + break; + + case 0x03: //TCPڼֵĴ + TCP_ErrorHandler(); + break; + + default: //δ֪״̬ + GSM_GPRS_Reset(); //GSMģ鸴λ + + printf("\r\nException_δ֪״̬ģ飡\r\n"); + break; + } +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_gprs.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_gprs.h new file mode 100755 index 0000000..e88410e --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_gprs.h @@ -0,0 +1,33 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ gsm_gprs.h + * SIM900Aͷļ + * V1.0 + * XuZhongPing + * 2013/11/21 +*********************************************************************************/ +#ifndef __GSM_GPRS_H__ +#define __GSM_GPRS_H__ + +// #include "gsm_uart_conf.h" +// +// #define GSM_PW_KEY PBout(12) + +// //豸״̬ +// typedef enum +// { +// OFFLINE = 0, // +// ONLINE = 1 // + +// }_ConnectionStatus; + +// extern uint8_t GSM_isPowerON; //GSMģǷڿ +// extern uint8_t ConnectionStatus; //״̬ݰͳɹλΪ״̬ + +// void GSM_GPRS_Init(void); +// uint8_t GSM_PowerON(void); +// uint8_t GSM_PowerOFF(void); + +// void GSM_GPRS_Task(void); +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart.c new file mode 100755 index 0000000..28376d6 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart.c @@ -0,0 +1,170 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ gsm_uart.c + * GSMƴڣ3 + * V1.0 + * XuZhongPing + * 2017/04/26 +*********************************************************************************/ +#include "delay.h" +#include "usart1.h" +#include "stdarg.h" +#include "stdio.h" +#include "stdlib.h" +#include "string.h" +#include "gsm_uart.h" +#include "gsm_uart_conf.h" +#include "usart3.h" +#include "at_proc.h" +#include "tcp_protocol.h" + +//ڷͻ +__align(8) uint8_t GPRS_TX_BUF[GPRS_MAX_SEND_LEN]; //ͻ,GPRS_MAX_SEND_LENֽ +uint8_t GPRS_RX_BUF[GPRS_MAX_RECV_LEN]; //ջ,GPRS_MAX_RECV_LENֽ + +uint8_t GPRS_DATA_BUF[GPRS_MAX_SEND_LEN]; //GPRSݴ,GPRS_MAX_SEND_LENֽ +uint8_t GPRS_RECV_DATA_BUF[GPRS_MAX_RECV_LEN]; + +_gsm_msg gsm_msg; +uint8_t signal; + +uint16_t total_send_length = 0; //ܳ +uint16_t ackedBytes = 0; //յܳ +uint16_t unackedbytes = 0; //δյܳ + +uint8_t receiveDataMark = 0; + +uint8_t GSM_ReceiveType = 0; // GSMģյͣ0ΪATӦ1ΪTCPݣ + +uint16_t GPRS_RX_STA; //״̬ +uint16_t GPRS_RX_Cnt = 0; +uint16_t recDataLen = 0; + +/* +*********************************************************************** +* : GSM_Uart_Init +* ˵: GSMƴڳʼ +* : +* ֵ: +*********************************************************************** +*/ +void GSM_GPRS_Uart_Init(void) +{ + USART3_Init(115200); //ⲿʵЩ +} + +/* +*********************************************************************** +* : GSM_GPRS_SendOne +* ˵: GSMڷһ +* : +* ֵ: +*********************************************************************** +*/ +void GSM_GPRS_SendOne(uint8_t pDataBuf[], uint16_t len) +{ + UART3_Send_One(len); //ⲿʵЩ +} + +/* +*********************************************************************** +* : GSM_GPRS_SendByteData +* ˵: GSMһֽ +* : +* ֵ: +*********************************************************************** +*/ +void GSM_GPRS_SendByteData(uint8_t cmd) +{ + while(DMA1_Channel2->CNDTR != 0); //ȴͨ7 + USART3->DR = (uint32_t)cmd; +} + +/* +*********************************************************************** +* : GSM_GPRS_printf +* ˵: GSM +* : +* ֵ: +*********************************************************************** +*/ +void GSM_GPRS_printf(char* fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vsprintf((char*)GPRS_TX_BUF, fmt, ap); + va_end(ap); +// while(DMA1_Channel2->CNDTR!=0); //ȴͨ7 + GSM_GPRS_SendOne(GPRS_TX_BUF, strlen((const char*)GPRS_TX_BUF)); //ͨdmaͳȥ +} + + +void show_buf1(uint8_t num[], uint8_t n) +{ + uint8_t i; + printf("\r\n"); + for(i=0; i= 4) + { + GPRS_RX_BUF[GPRS_RX_Cnt] = 0; //ڽյݺַ'\0' + + AT_Protocol(GPRS_RX_BUF, GPRS_RX_Cnt); //ATָӦ + } + GPRS_RX_Cnt = 0; + } + + if((sendAtCmdNo == AT_CMD_QISEND) && (GPRS_RX_BUF[GPRS_RX_Cnt - 1] == '>')) + { + GPRS_RX_BUF[GPRS_RX_Cnt] = 0; //ڽյݺַ'\0' + AT_Protocol(GPRS_RX_BUF, GPRS_RX_Cnt); //ATָӦ + GPRS_RX_Cnt = 0; + } + }else{ //յģURCϱ + if(GPRS_RX_Cnt >= recDataLen) + { +// show_buf1(GPRS_RX_BUF, GPRS_RX_Cnt); + GPRS_RX_BUF[GPRS_RX_Cnt] = 0; //ڽյݺַ'\0' + + TCP_Protocol(GPRS_RX_BUF, GPRS_RX_Cnt); + GPRS_RX_Cnt = 0; + GSM_ReceiveType = 0; + } + } + }else{ + GPRS_RX_Cnt = 0; + GSM_ReceiveType = 0; + receiveStatus = 0x00; + printf("\r\nData out\r\n"); + } +} + + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ + diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart.h new file mode 100755 index 0000000..f5cf86c --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart.h @@ -0,0 +1,20 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ gsm_uart.h + * GSMƶ˿ڣ3 + * V1.0 + * XuZhongPing + * 2017/04/26 +*********************************************************************************/ +#ifndef __GSM_UART_H +#define __GSM_UART_H +#include "stm32f10x.h" + +void GSM_GPRS_Uart_Init(void); //GSM_GPRSʹõĴڳʼ +void GSM_GPRS_SendOne(uint8_t pDataBuf[], uint16_t len); //GSMʹõĴڷһlenȵ +void GSM_GPRS_SendByteData(uint8_t cmd); //GSMʹõĴڷһֽ +void GSM_GPRS_printf(char* fmt, ...); //GSMʹõĴڷ +void GSM_GPRS_ReceiveData(uint8_t rxData); + +#endif + +/******************** (C) COPYRIGHT 2014 GLHF *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart_conf.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart_conf.c new file mode 100755 index 0000000..2038180 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart_conf.c @@ -0,0 +1,23 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ gsm_uart.c + * GSMƴڣ3 + * V1.0 + * XuZhongPing + * 2017/04/26 +*********************************************************************************/ +#include "delay.h" +#include "sys.h" +#include "usart.h" +#include "stdarg.h" +#include "stdio.h" +#include "string.h" +#include "gsm_uart_conf.h" + +//ڷͻ +// __align(8) uint8_t GPRS_TX_BUF[GPRS_MAX_SEND_LEN]; //ͻ,GPRS_MAX_SEND_LENֽ +// uint8_t GPRS_RX_BUF[GPRS_MAX_RECV_LEN]; //ջ,GPRS_MAX_RECV_LENֽ + +// uint16_t GPRS_RX_STA; //״̬ + + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart_conf.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart_conf.h new file mode 100755 index 0000000..4597a16 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/gsm_uart_conf.h @@ -0,0 +1,58 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ gsm_uart.h + * GSMƶ˿ + * V1.0 + * XuZhongPing + * 2017/04/26 +*********************************************************************************/ +#ifndef __GSM_UART_CONF_H +#define __GSM_UART_CONF_H +#include "stdint.h" + +#define TCP_IP_COM "AT+QIOPEN=1,0,\"TCP\",\"112.74.41.228\",9956,0,1" +// #define TCP_IP_COM "AT+QIOPEN=1,0,\"TCP\",\"xzp71.xicp.net\",41149,0,1" //ת +// #define TCP_IP_COM "AT+QIOPEN=1,0,\"TCP\",\"218.59.175.31\",9956,0,1" //ൺ + +// #define TCP_IP_COM "AT+CIPSTART=\"TCP\",\"112.74.41.228\",\"9956\"" +// #define TCP_IP_COM "AT+CIPSTART=\"TCP\",\"112.74.41.228\",\"1111\"" +// #define TCP_IP_COM "AT+CIPSTART=\"TCP\",\"115.28.185.180\",\"8956\"" +// #define TCP_IP_COM "AT+CIPSTART=\"TCP\",\"xzp71.xicp.net\",\"50062\"" + +typedef struct +{ + uint8_t Running; //GSMģ״̬ + char IMEI [16]; //豸 + char IMEI_HEX[8]; //IMEI豸ʮƱ棬ϴ̨ + uint8_t Operator[16]; //ͨӪ + uint8_t OperatorType; //0:δ֪1йƶ2йͨ + char ICCID[24]; //SIMICCID + uint8_t simCardStatus; //sim״̬0δ֪״̬12޷ע磬3ûGPRSҵ4ûм⵽ +}_gsm_msg; + +extern _gsm_msg gsm_msg; +extern uint8_t signal; + +extern uint16_t total_send_length; //ܳ +extern uint16_t ackedBytes; //յܳ +extern uint16_t unackedbytes; //δյܳ + +extern uint8_t receiveDataMark; + +extern char command_CIPSEND[16]; + +#define GPRS_MAX_SEND_LEN 1024 //ͻֽ +#define GPRS_MAX_RECV_LEN 1024 //ջֽ + +extern uint8_t GPRS_TX_BUF[GPRS_MAX_SEND_LEN]; //ͻ,GPRS_MAX_SEND_LENֽ +extern uint8_t GPRS_RX_BUF[GPRS_MAX_RECV_LEN]; //ջ,GPRS_MAX_RECV_LENֽ + +extern uint8_t GPRS_DATA_BUF[GPRS_MAX_SEND_LEN]; //GPRSݴ,GPRS_MAX_SEND_LENֽ +extern uint8_t GPRS_RECV_DATA_BUF[GPRS_MAX_RECV_LEN]; + +extern uint16_t GPRS_RX_STA; //״̬ +extern uint8_t GSM_ReceiveType; // GSMģյͣATӦTCPݣ +extern uint16_t recDataLen; + +#endif + +/******************** (C) COPYRIGHT 2014 GLHF *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/netwer_appcall.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/netwer_appcall.c new file mode 100755 index 0000000..f6603ce --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/netwer_appcall.c @@ -0,0 +1,341 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ gsm_uart.c + * GSMƴڣ2 + * V1.0 + * XuZhongPing + * 2017/04/26 +*********************************************************************************/ +#include "netwer_appcall.h" +#include "timer.h" +#include "data_typedef.h" +#include "tcp_protocol.h" +#include "message.h" +#include "gsm_uart_conf.h" +#include "ec200x.h" +#include "at_proc.h" + +uint8_t isSendDataMark = 0; //ǷҪͱ־ +uint8_t isReceiveDataMark = 0; //Ƿнյݱ־ +uint8_t dataSendSuccessMark = 0; //ݷͳɹ־ +uint8_t dataSendFailureMark = 0; //ݷʧܱ־ +uint8_t dataSendOkButNoAckMark = 0; //ݷͳɹûӦ + +uint16_t sendDataLen = 0; //͵ݳ + + +void show_hex(uint8_t num[], uint8_t n) +{ + uint8_t i; + printf("\r\n"); + for(i=0; i= 5) //ϢпռʱŷͣȻᷢͲɹ + { + printf("\r\nǰ״̬%d\r\n", msgBufSurplus); + reuploadICCID = 0; + + sendMsg.msgType = 1003; + MessageSend(MSG_FIFO_PROTOCOL, sendMsg); + } + } + + currentStatus = nextStatus; + switch(currentStatus) + { + case 0x00: //ʼ״̬ + //жϵǰûг + if(preNetworkConnectionCount != networkConnectionCount) + { + preNetworkConnectionCount = networkConnectionCount; + + if(networkConnectionCount != 1) //״ν磬־ǰ + { + printf("\r\n\r\n"); + delaySendMark = 1; //־ǰ + + if(ChackIccidNumber(preICCID, gsm_msg.ICCID)) + { + printf("\r\nICCIDŷı䣡\r\n"); + reuploadICCID = 1; + + printf("\r\nǰ״̬%d\r\n", GetMessageRemainingSpace(MSG_FIFO_PROTOCOL)); + + memcpy(preICCID, gsm_msg.ICCID, 20); + } + + timer_restart(&delayRandomSendTimer); + timer_restart(&waitingTimer); + nextStatus = 0x01; + } + } + break; + + case 0x01: //ж磬ӳʱٷ + if(timer_expired(&delayRandomSendTimer)) + { + printf("\r\nȴʱʱ䵽\r\n"); + delaySendMark = 0; + nextStatus = 0x00; + break; + } + + if(timer_expired(&waitingTimer)) + { + printf("\r\nʱ͵ȴʱ\r\n"); + delaySendMark = 0; + nextStatus = 0x00; + break; + } + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : SendNetworkData +* ˵: +* Σ +* ֵ: +*********************************************************************** +*/ +void SendNetworkData(uint8_t *sendBuf, uint16_t dataLength) +{ + sendDataLen = dataLength; +// memcpy(GPRS_TX_BUF, sendBuf, GPRS_sendDataLength); + isSendDataMark = 1; +} + +/* +*********************************************************************** +* : DataUploadPollingTask +* ˵: ϴѯ +* Σ +* ֵ: +*********************************************************************** +*/ +void DataUploadPollingTask(void) +{ + static uint8_t currentStatus = 0x00; + static uint8_t nextStatus = 0x00; + + uint8_t sendFailureFlag = 0; + + static MESSAGE *pMsg; + static uint16_t dataBufLength = 0; + + static uint32_t nowTime = 0; //ǰָʱ + static uint32_t preSendTime_1001 = 0; //ǰһηָʱ + static uint32_t preSendTime_6004 = 0; + uint16_t repeatCmdIntervalTime = 600; //ظָʱ䣨λΪ0.1룩 + + static timer uploadIntervalTime; //ϴʱƣͬһʱظϴ + static timer responseTimeout; //Ӧʱʱ + static timer sendTimeout; //ͳʱʱ + + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&uploadIntervalTime, CLOCK_SECOND*3); + timer_set(&responseTimeout, CLOCK_SECOND*3); + timer_set(&sendTimeout, CLOCK_SECOND*120); + } + + NetReconnectDelaySendHandler(); + + currentStatus = nextStatus; + switch(currentStatus) + { + case 0x00: + if(ConnectionStatus == ONLINE) + { + if(delaySendMark == 0) //ǷҪӳٷ + { + pMsg = MessageGet(MSG_FIFO_PROTOCOL); //ȡϢ + if(pMsg) //ϢϢݷ + { + sendOrderCode = pMsg->msgType; //ȡ÷͵Э + + nowTime = time_value; //ȡǰָʱ + if(sendOrderCode == 1001) //ǰ͵1001ָ + { + if((preSendTime_1001 != 0) && ((nowTime - preSendTime_1001) < repeatCmdIntervalTime)) + { + printf("\r\nظ1001ָȡͣ\r\n"); + nextStatus = 0x00; + break; + } + preSendTime_1001 = nowTime; + } + + if(sendOrderCode == 6004) //ǰ͵6004ָ + { + if((preSendTime_6004 != 0) && ((nowTime - preSendTime_6004) < repeatCmdIntervalTime)) + { + printf("\r\nظ6004ָȡͣ\r\n"); + nextStatus = 0x00; + break; + } + preSendTime_6004 = nowTime; + } + + printf("\r\nTCP Sending data......\r\n"); + nextStatus = 0x01; //ת + break; + } + } + } + break; + + case 0x01: + dataBufLength = SendProtocolPackaging(sendOrderCode); //ͨϢͽӦЭ + SendNetworkData(GPRS_DATA_BUF, dataBufLength); + + isReceiveDataMark = 0; + dataSendSuccessMark = 0; + dataSendFailureMark = 0; + timer_restart(&sendTimeout); + nextStatus = 0x02; + break; + + case 0x02: //ȴ + if(isReceiveDataMark == 1) + { + isReceiveDataMark = 0; + printf("\r\nݷͳɹ\r\n"); +// show_hex(GPRS_RECV_DATA_BUF, receiveDataLen); +// printf("\r\ndata=%s\r\n", GPRS_DATA_BUF); +// TCP_Protocol(GPRS_RECV_DATA_BUF, receiveDataLen); +// memset(GPRS_RECV_DATA_BUF, 0x00, 1024); + nextStatus = 0x00; + break; + } + + //ѷ͵ûյӦ + if(dataSendOkButNoAckMark == 1) + { + printf("\r\nѷͣûӦ\r\n"); + dataSendOkButNoAckMark = 0; + + nextStatus = 0x00; + break; + } + + //ʧ + if(dataSendFailureMark == 1) + { + dataSendFailureMark = 0; + printf("\r\nݷʧܣ\r\n"); + sendFailureFlag = 1; + } + + //ͳʱ + if(timer_expired(&sendTimeout)) //ʱδյӦ + { + printf("\r\nͳʱ\r\n"); + sendFailureFlag = 1; + } + + if(sendFailureFlag == 1) + { + printf("\r\nTCP send data failure!\r\n"); + nextStatus = 0x00; + break; + } + + break; + + default: + break; + } +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ + diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/netwer_appcall.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/netwer_appcall.h new file mode 100755 index 0000000..fc629bf --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/GSM/netwer_appcall.h @@ -0,0 +1,26 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ netwer_appcall.h + * GSMƶ˿ڣ3 + * V1.0 + * XuZhongPing + * 2017/04/26 +*********************************************************************************/ +#ifndef __NETWER_APPCALL_H +#define __NETWER_APPCALL_H +#include "stdio.h" +#include "stdint.h" +#include "stdlib.h" + +extern uint8_t isSendDataMark; //ǷҪͱ־ +extern uint8_t isReceiveDataMark; //Ƿнյݱ־ +extern uint8_t dataSendSuccessMark; //ݷͳɹ־ +extern uint8_t dataSendFailureMark; //ݷʧܱ־ +extern uint8_t dataSendOkButNoAckMark; //ݷͳɹûӦ + +extern uint16_t sendDataLen; //͵ݳ + +void DataUploadPollingTask(void); + +#endif + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/IR_Distancer/IR_Distancer.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/IR_Distancer/IR_Distancer.c new file mode 100755 index 0000000..82b77c7 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/IR_Distancer/IR_Distancer.c @@ -0,0 +1,421 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ UltrasonicWave.c + * HC-SR04 + * V1.0 + * XuZhongPing + * 2017/08/04 +*********************************************************************************/ +#include "IR_Distancer.h" +#include "timer.h" +#include "delay.h" +#include "adc.h" +#include "my_math.h" +#include "data_typedef.h" + +#define IR_AdcValSize 100 +uint16_t IR_AdcValBuf_1[IR_AdcValSize]; +uint16_t IR_AdcVal_1 = 0; + +uint16_t IR_AdcValBuf_2[IR_AdcValSize]; +uint16_t IR_AdcVal_2 = 0; + +uint8_t IR_GetAdcValMake = 0; + +#define IR_GetDataCount 5 + +uint8_t ir_Distance1 = 0; +uint8_t ir_dataOutState1 = 0; +uint8_t ir_Distance2 = 0; +uint8_t ir_dataOutState2 = 0; + + + +/* +*********************************************************************** +* : show +* ˵: ʮʾ +* : +* ֵ: +*********************************************************************** +*/ +void showBuf(uint16_t num[], uint8_t n) +{ + uint8_t i; + printf("\r\n"); + for(i=0; i Ӧĸͨ +* ֵ: ǰͨIJֵ +*********************************************************************** +*/ +uint8_t IR_GetDistanceData(uint8_t num) +{ + float distanceTemp; + float adToVdcVal; + int index = 0; + + switch(num) + { + case 1: + IR_GetAdcVal_1(); + + if(IR_AdcVal_1 < 120) + { + return 255; + }else{ + adToVdcVal = IR_AdcVal_1/4096.0 * 3.34; +// printf("\r\nV1 = %1.2f, ADC1 = %d ", adToVdcVal, IR_AdcVal_1); + } + break; + + case 2: + IR_GetAdcVal_2(); + + if(IR_AdcVal_2 < 120) + { + return 255; + }else{ + adToVdcVal = IR_AdcVal_2/4096.0 * 3.34; +// printf("\r\nV2 = %1.2f, ADC2 = %d ", adToVdcVal, IR_AdcVal_2); + } + break; + + default: + break; + } + +// printf("ADC = %4d, %4d, V = %1.2f\r\n", IR_AdcVal_1, IR_AdcVal_2, adToVdcVal); + + for(index = 0; index < 14; index++) + { + if(adToVdcVal >= voltageMap[index]) + { + break; + } + } + +// printf("\r\nindex = %d\r\n", index); + if(index == 0) + { + distanceTemp = 20; + }else if(index == 14){ + distanceTemp = 150; + }else{ + distanceTemp = LookupTable(adToVdcVal, voltageMap[index-1], voltageMap[index], distanceMap[index-1], distanceMap[index]); + } + +// printf("D = %d cm\r\n", (uint8_t)distanceTemp); + + return distanceTemp; + +} + +/* +*********************************************************************** +* : ULT_DataProcessing +* ˵: Բɼݴƽ +* Σ +* *p: Ҫָ +* n: ij +* ֵ: մĽ +*********************************************************************** +*/ +uint8_t IR_DataProcessing(uint8_t *p, uint16_t n, uint8_t discardVal) +{ + uint8_t retData = 0; + + sort_8(p, n); //ԴڻеIJɼݽ + retData = average_8(p, n, discardVal); //ȥͷβƽ +// printf("\r\nValue = %d\r\n", retData); + return retData; +} + +/* +*********************************************************************** +* : IR_GetDistanceTask_01 +* ˵: ȡ +* Σ +* ֵ: ݴ״̬ 1Ѵɿ0δ +*********************************************************************** +*/ +void IR_GetDistanceTask_01(void) +{ + static uint8_t step = 0x00; + static uint8_t getDataCnt = 0x00; + + static uint8_t newValue = 0x00; + static uint8_t oleValue = 0x00; + static uint8_t IR_DistanceDataBuf[IR_GetDataCount]; + + static timer waitingTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&waitingTimer, 1); + } + + switch(step) + { + case 0x00: + if(timer_expired(&waitingTimer)) + { + newValue = IR_GetDistanceData(1); +// printf("\r\nValue = %3.1f cm\r\n",(float)newValue); + step = 0x01; + timer_restart(&waitingTimer); + } + break; + case 0x01: + if(DifferenceCompare(newValue, oleValue, 10)) //Ƚ¾ֵIJֵǰֵ - ֮ǰֵ> 趨ֵʱ²ɼ + { + getDataCnt = 0; + } +// printf("\r\nCnt1 = %d, newValue = %d, oleValue = %d\r\n", getDataCnt, newValue, oleValue); + oleValue = newValue; + + IR_DistanceDataBuf[getDataCnt] = newValue; + getDataCnt++; + if(IR_GetDataCount == getDataCnt) //IR_GetDataCountݶΪѾȶ + { + getDataCnt = 0; + step = 0x02; //תݴ + }else{ + step = 0x00; + } + break; + + case 0x02: + ir_Distance1 = IR_DataProcessing(IR_DistanceDataBuf, IR_GetDataCount, 0); +// printf("\r\nNo1 ---> %3.1f cm\r\n",(float)ir_Distance1); + ir_dataOutState1 = 1; + step = 0x00; + break; + + default: + step = 0x00; + break; + } +} + +/* +*********************************************************************** +* : IR_GetDistanceTask_02 +* ˵: ȡ +* Σ +* ֵ: ݴ״̬ 1Ѵɿ0δ +*********************************************************************** +*/ +void IR_GetDistanceTask_02(void) +{ + static uint8_t step = 0x00; + static uint8_t getDataCnt = 0x00; + + static uint8_t newValue = 0x00; + static uint8_t oleValue = 0x00; + static uint8_t IR_DistanceDataBuf[IR_GetDataCount]; + + static timer waitingTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&waitingTimer, 1); + } + + switch(step) + { + case 0x00: + if(timer_expired(&waitingTimer)) + { + newValue = IR_GetDistanceData(2); +// printf("\r\nValue = %3.1f cm\r\n",(float)newValue); + step = 0x01; + timer_restart(&waitingTimer); + } + break; + case 0x01: + if(DifferenceCompare(newValue, oleValue, 10)) //Ƚ¾ֵIJֵǰֵ - ֮ǰֵ> 趨ֵʱ²ɼ + { + getDataCnt = 0; + } +// printf("\r\nCnt2 = %d, newValue = %d, oleValue = %d\r\n", getDataCnt, newValue, oleValue); + oleValue = newValue; + + IR_DistanceDataBuf[getDataCnt] = newValue; + getDataCnt++; + if(IR_GetDataCount == getDataCnt) //10ݶΪѾȶ + { + getDataCnt = 0; + step = 0x02; //תݴ + }else{ + step = 0x00; + } + break; + + case 0x02: + ir_Distance2 = IR_DataProcessing(IR_DistanceDataBuf, IR_GetDataCount, 0); +// printf("\r\nNo2 ---> %3.1f cm\r\n",(float)ir_Distance2); + ir_dataOutState2 = 1; + step = 0x00; + break; + + default: + step = 0x00; + break; + } +} + +// /* +// *********************************************************************** +// * : IR_GetDistanceTask +// * ˵: +// * Σ +// * ֵ: +// *********************************************************************** +// */ +// void IR_GetDistanceTask(void) +// { +// static uint8_t ULT_getDataStatus = 0x00; +// +// static uint8_t distance_1 = 255; +// static uint8_t distance_2 = 255; +// +// static timer waitingTimer; +// static timer responsTimer; +// static uint8_t timer_ok = 0; +// +// if(timer_ok == 0) +// { +// timer_ok = 1; +// timer_set(&waitingTimer, CLOCK_SECOND*2); +// timer_set(&responsTimer, 3); +// } +// +// switch(ULT_getDataStatus) +// { +// case 0x00: +// if(timer_expired(&waitingTimer)) +// { +// ULT_getDataStatus = 0x01; +// } +// break; +// +// case 0x01: +// distance_1 = IR_GetDistanceData(1); +// // if(dataOutState1 == 1) //һ·ݲɼɹ +// // { +// // dataOutState1 = 0; +// ULT_getDataStatus = 0x02; +// // // printf("\r\n1·ɼOK\r\n"); +// // } +// break; +// +// case 0x02: +// distance_2 = IR_GetDistanceData(2); +// // if(dataOutState2 == 1) //һ·ݲɼɹ +// // { +// // dataOutState2 = 0; +// ULT_getDataStatus = 0x03; +// // // printf("\r\n2·ɼOK\r\n"); +// // } +// break; +// +// case 0x03: +// getDistance1 = distance_1; +// getDistance2 = distance_2; +// +// // printf("\r\nࣺNo1 = %3.1f cm, ", (float)distance_1); +// // printf("No2 = %3.1f cm\r\n", (float)distance_2); +// // printf("No3 = %3.1f cm, ", (float)distance3); +// // printf("No4 = %3.1f cm\r\n", (float)distance4); +// ULT_getDataStatus = 0x00; +// timer_restart(&waitingTimer); +// break; +// } +// } + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/IR_Distancer/IR_Distancer.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/IR_Distancer/IR_Distancer.h new file mode 100755 index 0000000..e632316 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/IR_Distancer/IR_Distancer.h @@ -0,0 +1,25 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ IR_Distancer.h + * + * V1.0 + * XuZhongPing + * 2017/08/04 +*********************************************************************************/ +#ifndef __IR_Distancer_H +#define __IR_Distancer_H +#include "stm32f10x.h" + +extern uint8_t ir_Distance1; +extern uint8_t ir_dataOutState1; +extern uint8_t ir_Distance2; +extern uint8_t ir_dataOutState2; + +void IR_GetAdc(void); + +uint8_t IR_GetDistanceData(uint8_t num); +void IR_GetDistanceTask_01(void); +void IR_GetDistanceTask_02(void); + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/key.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/key.c new file mode 100755 index 0000000..242c1d8 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/key.c @@ -0,0 +1,648 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ key.c + * + * V1.0 + * XuZhongPing + * 2020/03/30 +*********************************************************************************/ +#include "key.h" +#include "timer.h" + +//ӿ +#define KEY1_PORT_PeriphClock RCC_APB2Periph_GPIOA +#define KEY1_PORT GPIOA +#define KEY1_PIN GPIO_Pin_5 + +#define KEY2_PORT_PeriphClock RCC_APB2Periph_GPIOA +#define KEY2_PORT GPIOA +#define KEY2_PIN GPIO_Pin_7 + +#define KEY3_PORT_PeriphClock RCC_APB2Periph_GPIOC +#define KEY3_PORT GPIOC +#define KEY3_PIN GPIO_Pin_5 + +#define KEY4_PORT_PeriphClock RCC_APB2Periph_GPIOB +#define KEY4_PORT GPIOB +#define KEY4_PIN GPIO_Pin_1 + +//LEDָʾƽӿ +#define KEY1_LED_PeriphClock RCC_APB2Periph_GPIOA +#define KEY1_LED_PORT GPIOA +#define KEY1_LED_PIN GPIO_Pin_4 + +#define KEY2_LED_PeriphClock RCC_APB2Periph_GPIOA +#define KEY2_LED_PORT GPIOA +#define KEY2_LED_PIN GPIO_Pin_6 + +#define KEY3_LED_PeriphClock RCC_APB2Periph_GPIOC +#define KEY3_LED_PORT GPIOC +#define KEY3_LED_PIN GPIO_Pin_4 + +#define KEY4_LED_PeriphClock RCC_APB2Periph_GPIOB +#define KEY4_LED_PORT GPIOB +#define KEY4_LED_PIN GPIO_Pin_0 + +//λ +#define LIMI_KEY1_PeriphClock RCC_APB2Periph_GPIOB +#define LIMI_KEY1_PORT GPIOB +#define LIMI_KEY1_PIN GPIO_Pin_8 + +#define LIMI_KEY2_PeriphClock RCC_APB2Periph_GPIOB +#define LIMI_KEY2_PORT GPIOB +#define LIMI_KEY2_PIN GPIO_Pin_9 + +#define LIMI_KEY3_PeriphClock RCC_APB2Periph_GPIOC +#define LIMI_KEY3_PORT GPIOC +#define LIMI_KEY3_PIN GPIO_Pin_0 + +#define LIMI_KEY4_PeriphClock RCC_APB2Periph_GPIOC +#define LIMI_KEY4_PORT GPIOC +#define LIMI_KEY4_PIN GPIO_Pin_1 + +uint8_t keyBit = 0; //ɼλϺֵ +uint8_t keyReleaseMark = 0; //ɿ־ +uint8_t keyValue; //ťֵ + +uint8_t keyNum = 0; //İ +uint8_t keyStatus = 0; //Ӧİ״̬ + +uint8_t optoKeyStatus = 0; //翪״̬MCU2룩 + +uint8_t humanSensingKeyStatus = 0; //Ӧ״̬ + +uint8_t keyType = 1; //0:е1 + +/* +*********************************************************************** +* : KeyInit +* ˵: IOڳʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void KeyInit(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + RCC_APB2PeriphClockCmd(KEY1_PORT_PeriphClock, ENABLE); //ʹIOʱ + RCC_APB2PeriphClockCmd(KEY2_PORT_PeriphClock, ENABLE); + RCC_APB2PeriphClockCmd(KEY3_PORT_PeriphClock, ENABLE); + RCC_APB2PeriphClockCmd(KEY4_PORT_PeriphClock, ENABLE); + + RCC_APB2PeriphClockCmd(KEY1_LED_PeriphClock, ENABLE); //ʹIOʱ + RCC_APB2PeriphClockCmd(KEY2_LED_PeriphClock, ENABLE); + RCC_APB2PeriphClockCmd(KEY3_LED_PeriphClock, ENABLE); + RCC_APB2PeriphClockCmd(KEY4_LED_PeriphClock, ENABLE); + + RCC_APB2PeriphClockCmd(LIMI_KEY1_PeriphClock, ENABLE); //ʹIOʱ + RCC_APB2PeriphClockCmd(LIMI_KEY2_PeriphClock, ENABLE); + RCC_APB2PeriphClockCmd(LIMI_KEY3_PeriphClock, ENABLE); + RCC_APB2PeriphClockCmd(LIMI_KEY4_PeriphClock, ENABLE); + +// GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE); //رJTAGPB3,PB4ù + +//ӿڳʼ---------------- + //һ·IO + GPIO_InitStructure.GPIO_Pin = KEY1_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(KEY1_PORT, &GPIO_InitStructure); + + //ڶ·IO + GPIO_InitStructure.GPIO_Pin = KEY2_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(KEY2_PORT, &GPIO_InitStructure); + + //·IO + GPIO_InitStructure.GPIO_Pin = KEY3_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(KEY3_PORT, &GPIO_InitStructure); + + //·IO + GPIO_InitStructure.GPIO_Pin = KEY4_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(KEY4_PORT, &GPIO_InitStructure); + +//LEDƽӿڳʼ---------------- + //һ·IO + GPIO_InitStructure.GPIO_Pin = KEY1_LED_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(KEY1_LED_PORT, &GPIO_InitStructure); + GPIO_SetBits(KEY1_LED_PORT, KEY1_LED_PIN); + + //ڶ·IO + GPIO_InitStructure.GPIO_Pin = KEY2_LED_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(KEY2_LED_PORT, &GPIO_InitStructure); + GPIO_SetBits(KEY2_LED_PORT, KEY2_LED_PIN); + + //·IO + GPIO_InitStructure.GPIO_Pin = KEY3_LED_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(KEY3_LED_PORT, &GPIO_InitStructure); + GPIO_SetBits(KEY3_LED_PORT, KEY3_LED_PIN); + + //·IO + GPIO_InitStructure.GPIO_Pin = KEY4_LED_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(KEY4_LED_PORT, &GPIO_InitStructure); + GPIO_SetBits(KEY4_LED_PORT, KEY4_LED_PIN); + +//λؽӿڳʼ---------------- + //һ·λIO + GPIO_InitStructure.GPIO_Pin = LIMI_KEY1_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(LIMI_KEY1_PORT, &GPIO_InitStructure); + + //ڶ·λIO + GPIO_InitStructure.GPIO_Pin = LIMI_KEY2_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(LIMI_KEY2_PORT, &GPIO_InitStructure); + + //·λIO + GPIO_InitStructure.GPIO_Pin = LIMI_KEY3_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(LIMI_KEY3_PORT, &GPIO_InitStructure); + + //·λIO + GPIO_InitStructure.GPIO_Pin = LIMI_KEY4_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(LIMI_KEY4_PORT, &GPIO_InitStructure); +} + +/* +*********************************************************************** +* : KeysCanning +* ˵: ɨ +* Σ +* ֵ: ضӦصļֵ +*********************************************************************** +*/ +uint8_t KeyScanning(void) +{ + static uint8_t key_state = 0, key_value; + uint8_t key_press, key_return = 0; + + static timer keyLongPressTimer; + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&keyLongPressTimer, CLOCK_SECOND*2); //趨ʱΪ2S + } + + switch (key_state) + { + case 0x00: // ʼ̬ + if(KEY1 == 0) + { + key_value = 1; + key_state = 0x01; // £״̬תȷ̬ + }else if(KEY2 == 0){ + key_value = 2; + key_state = 0x01; // £״̬תȷ̬ + } + else if(KEY3 == 0){ + key_value = 3; + key_state = 0x01; // £״̬תȷ̬ + } + else if(KEY4 == 0){ + key_value = 4; + key_state = 0x01; // £״̬תȷ̬ + }else{ + key_value = 0; + } + break; + + case 0x01: // ȷ̬ + if(KEY1 == 0) + { + key_press = 1; + }else if(KEY2 == 0){ + key_press = 2; + } + else if(KEY3 == 0){ + key_press = 3; + } + else if(KEY4 == 0){ + key_press = 4; + }else{ + key_press = 0; + } + + if(key_value == key_press) + { + key_return = key_value; + key_state = 0x02; // £״̬תȷ̬ +// printf("\r\n̰KEY = %d\r\n", key_return); + timer_restart(&keyLongPressTimer); + break; + }else{ + key_state = 0x00; + } + break; + + case 0x02: // + if(timer_expired(&keyLongPressTimer)) + { + if(key_value == 1) //111 + { + key_return = 0x11; + }else if(key_value == 2){ + key_return = 0x22; + }else if(key_value == 3){ + key_return = 0x33; + }else if(key_value == 4){ + key_return = 0x44; + } + key_state = 0x03; + +// printf("\r\nKEY = %d\r\n", key_return); + break; + } + + if((KEY1 == 1) && (KEY2 == 1) && (KEY3 == 1) && (KEY4 == 1)) + { + keyReleaseMark = 1; + key_state = 0x00; // ͷţתʼ̬ +// printf("\r\n̰ɿ\r\n"); + break; + } + break; + + case 0x03: // ͷ + if((KEY1 == 1) && (KEY2 == 1) && (KEY3 == 1) && (KEY4 == 1)) + { + keyReleaseMark = 1; + key_state = 0x00; // ͷţתʼ̬ +// printf("\r\nɿ\r\n"); + } + break; + } + return key_return; +} + +/* +*********************************************************************** +* : TouchKeyScanning +* ˵: ɨ +* Σ +* ֵ: ضӦصļֵ +*********************************************************************** +*/ +uint8_t TouchKeyScanning(void) +{ + static uint8_t key_state = 0, key_value; + uint8_t key_press = 0, key_return = 0; + + static timer keyLongPressTimer; + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&keyLongPressTimer, CLOCK_SECOND*2); //趨ʱΪ2S + } + + keyBit = (KEY3 << 2) | (KEY2 << 1) | KEY1; +// printf("\r\nswkey = %x\r\n", keyBit); + switch (key_state) + { + case 0x00: // ʼ̬ + if(keyBit > 0) + { + switch(keyBit) + { + case 0x01: key_value = 1; break; + case 0x02: key_value = 2; break; + case 0x03: key_value = 3; break; + case 0x04: key_value = 4; break; + case 0x05: key_value = 5; break; + default: key_value = 0; break; + } + key_state = 0x01; // £״̬תȷ̬ + }else{ + key_value = 0; + } + break; + + case 0x01: // ȷ̬ + if(keyBit > 0) + { + switch(keyBit) + { + case 0x01: key_press = 1; break; + case 0x02: key_press = 2; break; + case 0x03: key_press = 3; break; + case 0x04: key_press = 4; break; + case 0x05: key_press = 5; break; + default: key_press = 0; break; + } + }else{ + key_value = 0; + } + + if(key_value == key_press) + { + key_return = key_value; + key_state = 0x02; // £״̬תȷ̬ +// printf("\r\n̰KEY = %d\r\n", key_return); + timer_restart(&keyLongPressTimer); + break; + }else{ + key_state = 0x00; + } + break; + + case 0x02: // + if(timer_expired(&keyLongPressTimer)) + { + if(key_value == 1) //111 + { + key_return = 0x11; + }else if(key_value == 2){ + key_return = 0x22; + }else if(key_value == 3){ + key_return = 0x33; + }else if(key_value == 4){ + key_return = 0x44; + }else if(key_value == 5){ + key_return = 0x55; + } + key_state = 0x03; + +// printf("\r\nKEY = %d\r\n", key_return); + break; + } + + if(keyBit == 0x00) + { + key_state = 0x00; // ͷţתʼ̬ + keyReleaseMark = 1; +// printf("\r\n̰ɿ\r\n"); + break; + } + break; + + case 0x03: // ͷ + if(keyBit == 0x00) + { + key_state = 0x00; // ͷţתʼ̬ + keyReleaseMark = 1; +// printf("\r\nɿ\r\n"); + } + break; + } + return key_return; +} + +/* +*********************************************************************** +* : SetKeyLedON +* ˵: ӦLED +* : whichOne -> ָLED +* ֵ: +*********************************************************************** +*/ +void SetKeyLedON(uint8_t whichOne) +{ + switch(whichOne) + { + case 1: + GPIO_ResetBits(KEY1_LED_PORT, KEY1_LED_PIN); + break; + + case 2: + GPIO_ResetBits(KEY2_LED_PORT, KEY2_LED_PIN); + break; + + case 3: + GPIO_ResetBits(KEY3_LED_PORT, KEY3_LED_PIN); + break; + + case 4: + GPIO_ResetBits(KEY4_LED_PORT, KEY4_LED_PIN); + break; + +// case 1: +// GPIO_SetBits(KEY1_LED_PORT, KEY1_LED_PIN); +// break; +// +// case 2: +// GPIO_SetBits(KEY2_LED_PORT, KEY2_LED_PIN); +// break; +// +// case 3: +// GPIO_SetBits(KEY3_LED_PORT, KEY3_LED_PIN); +// break; +// +// case 4: +// GPIO_SetBits(KEY4_LED_PORT, KEY4_LED_PIN); +// break; + + default: + break; + } +} + +/* +*********************************************************************** +* : SetKeyLedAllON +* ˵: ȫLED +* : +* ֵ: +*********************************************************************** +*/ +void SetKeyLedAllON(void) +{ + GPIO_ResetBits(KEY1_LED_PORT, KEY1_LED_PIN); + GPIO_ResetBits(KEY2_LED_PORT, KEY2_LED_PIN); + GPIO_ResetBits(KEY3_LED_PORT, KEY3_LED_PIN); + GPIO_ResetBits(KEY4_LED_PORT, KEY4_LED_PIN); + +// GPIO_SetBits(KEY1_LED_PORT, KEY1_LED_PIN); +// GPIO_SetBits(KEY2_LED_PORT, KEY2_LED_PIN); +// GPIO_SetBits(KEY3_LED_PORT, KEY3_LED_PIN); +// GPIO_SetBits(KEY4_LED_PORT, KEY4_LED_PIN); +} + +/* +*********************************************************************** +* : SetKeyLedOFF +* ˵: ϨưӦLED +* : whichOne -> ָLED +* ֵ: +*********************************************************************** +*/ +void SetKeyLedOFF(uint8_t whichOne) +{ + switch(whichOne) + { + case 1: + GPIO_SetBits(KEY1_LED_PORT, KEY1_LED_PIN); + break; + + case 2: + GPIO_SetBits(KEY2_LED_PORT, KEY2_LED_PIN); + break; + + case 3: + GPIO_SetBits(KEY3_LED_PORT, KEY3_LED_PIN); + break; + + case 4: + GPIO_SetBits(KEY4_LED_PORT, KEY4_LED_PIN); + break; + +// case 1: +// GPIO_ResetBits(KEY1_LED_PORT, KEY1_LED_PIN); +// break; +// +// case 2: +// GPIO_ResetBits(KEY2_LED_PORT, KEY2_LED_PIN); +// break; +// +// case 3: +// GPIO_ResetBits(KEY3_LED_PORT, KEY3_LED_PIN); +// break; +// +// case 4: +// GPIO_ResetBits(KEY4_LED_PORT, KEY4_LED_PIN); +// break; + + default: + break; + } +} + +/* +*********************************************************************** +* : SetKeyLedAllOFF +* ˵: ϨȫLED +* : +* ֵ: +*********************************************************************** +*/ +void SetKeyLedAllOFF(void) +{ + GPIO_SetBits(KEY1_LED_PORT, KEY1_LED_PIN); + GPIO_SetBits(KEY2_LED_PORT, KEY2_LED_PIN); + GPIO_SetBits(KEY3_LED_PORT, KEY3_LED_PIN); + GPIO_SetBits(KEY4_LED_PORT, KEY4_LED_PIN); + +// GPIO_ResetBits(KEY1_LED_PORT, KEY1_LED_PIN); +// GPIO_ResetBits(KEY2_LED_PORT, KEY2_LED_PIN); +// GPIO_ResetBits(KEY3_LED_PORT, KEY3_LED_PIN); +// GPIO_ResetBits(KEY4_LED_PORT, KEY4_LED_PIN); +} + +/* +*********************************************************************** +* : KeysTest +* ˵: ָʾƲ +* : +* ֵ: +*********************************************************************** +*/ +void KeysTest(void) +{ + static uint8_t keyStatus1 = 0; + + if(keyValue > 0) + { + SetKeyLedAllOFF(); + SetKeyLedON(keyValue); + + keyValue = 0; + } + +// if((keyStatus1 != keyValue)) +// { +// keyStatus1 = keyValue; +// +// SetKeyLedAllOFF(); +// SetKeyLedON(keyValue); +// } +} + +/* +*********************************************************************** +* : LimitKeysTest +* ˵: λز +* : +* ֵ: +*********************************************************************** +*/ +void LimitKeysTest(void) +{ + uint8_t limitKeySta1 = 0; + uint8_t limitKeySta2 = 0; + uint8_t limitKeySta3 = 0; + uint8_t limitKeySta4 = 0; + + static uint8_t limitKeyStaPre1 = 0; + static uint8_t limitKeyStaPre2 = 0; + static uint8_t limitKeyStaPre3 = 0; + static uint8_t limitKeyStaPre4 = 0; + + if(LIMI_KEY1 == 0) + { + limitKeySta1 = 1; + }else{ + limitKeySta1 = 0; + } + + if(LIMI_KEY2 == 0) + { + limitKeySta2 = 1; + }else{ + limitKeySta2 = 0; + } + + if(LIMI_KEY3 == 0) + { + limitKeySta3 = 1; + }else{ + limitKeySta3 = 0; + } + + if(LIMI_KEY4 == 0) + { + limitKeySta4 = 1; + }else{ + limitKeySta4 = 0; + } + + + if((limitKeySta1 != limitKeyStaPre1) || + (limitKeySta2 != limitKeyStaPre2) || + (limitKeySta3 != limitKeyStaPre3) || + (limitKeySta4 != limitKeyStaPre4)) + { + limitKeyStaPre1 = limitKeySta1; + limitKeyStaPre2 = limitKeySta2; + limitKeyStaPre3 = limitKeySta3; + limitKeyStaPre4 = limitKeySta4; + + if(limitKeySta1) + { + printf("\r\nλ1λ\r\n"); + } + if(limitKeySta2) + { + printf("\r\nλ2λ\r\n"); + } + if(limitKeySta3) + { + printf("\r\nλ3λ\r\n"); + } + if(limitKeySta4) + { + printf("\r\nλ4λ\r\n"); + } + } +} + +/******************** (C) COPYRIGHT 2018 Ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/key.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/key.h new file mode 100755 index 0000000..98bf447 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/key.h @@ -0,0 +1,62 @@ +/*************************** (C) COPYRIGHT 2018 Ping **************************** + * ļ key.h + * ͷļ + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#ifndef __KEY_H +#define __KEY_H +#include "stm32f10x.h" +#include "stdio.h" +#include "device.h" + +#define KEY1 GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_5) //1 +#define KEY2 GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_7) //2 +#define KEY3 GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_5) //3 +#define KEY4 GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1) //4 + +//ע234·λӲӿڽ˳ӦתӦ +//ԭ˳ +#ifdef FOUR_CHANNEL_AND_HARMFUL +#define LIMI_KEY1 GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_8) //λ1 +#define LIMI_KEY2 GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_9) //λ2 +#define LIMI_KEY3 GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_0) //λ3 +#define LIMI_KEY4 GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_1) //λ4 + +#else +#define LIMI_KEY1 GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_8) //λ1 +#define LIMI_KEY4 GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_9) //λ4 +#define LIMI_KEY2 GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_0) //λ2 +#define LIMI_KEY3 GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_1) //λ3 +#endif + +extern uint8_t keyBit; //ɼλϺֵ +extern uint8_t keyReleaseMark; //ɿ־ +extern uint8_t keyValue; //ťֵ + +extern uint8_t keyNum; //İ +extern uint8_t keyStatus; //Ӧİ״̬ + +extern uint8_t limitKey1Value; //λؼֵ +extern uint8_t limitKey2Value; //λؼֵ + +extern uint8_t optoKeyStatus; //翪״̬MCU2룩 +extern uint8_t humanSensingKeyStatus; //Ӧ״̬ + +extern uint8_t keyType; //0:е1 + +void KeyInit(void); //ʼ +uint8_t KeyScanning(void); //еɨ +uint8_t TouchKeyScanning(void); //ɨ +void SetKeyLedON(uint8_t whichOne); //Ӧָʾ +void SetKeyLedAllON(void); //ȫָʾ +void SetKeyLedOFF(uint8_t whichOne); //ϨӦָʾ +void SetKeyLedAllOFF(void); //Ϩȫָʾ + +void KeysTest(void); +void LimitKeysTest(void); + +#endif + +/******************** (C) COPYRIGHT 2018 Ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/sw_key.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/sw_key.c new file mode 100755 index 0000000..1e76452 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/sw_key.c @@ -0,0 +1,117 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ key.c + * 뿪 + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#include "sw_key.h" +#include "delay.h" +#include "usart.h" + +//뿪 +#define SW_KEY1_PORT GPIOB +#define SW_KEY1_PIN GPIO_Pin_4 +#define SW_KEY2_PORT GPIOB +#define SW_KEY2_PIN GPIO_Pin_3 +#define SW_KEY3_PORT GPIOD +#define SW_KEY3_PIN GPIO_Pin_7 +#define SW_KEY4_PORT GPIOD +#define SW_KEY4_PIN GPIO_Pin_6 +#define SW_KEY5_PORT GPIOD +#define SW_KEY5_PIN GPIO_Pin_5 +#define SW_KEY6_PORT GPIOD +#define SW_KEY6_PIN GPIO_Pin_4 + +/* +*********************************************************************** +* : SwKeyInit +* ˵: 뿪IOڳʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void SwKeyInit(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO, ENABLE); + + GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE); + + GPIO_InitStructure.GPIO_Pin = SW_KEY1_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(SW_KEY1_PORT, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = SW_KEY2_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(SW_KEY2_PORT, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = SW_KEY3_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(SW_KEY3_PORT, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = SW_KEY4_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(SW_KEY4_PORT, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = SW_KEY5_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(SW_KEY5_PORT, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = SW_KEY6_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(SW_KEY6_PORT, &GPIO_InitStructure); +} + +/* +*********************************************************************** +* : SwKeysCanning +* ˵: 뿪ɨ +* Σ +* ֵ: ضӦصļֵ +*********************************************************************** +*/ +uint8_t SwKeysCanning(void) +{ + uint8_t res = 0; + + uint8_t res1 = 0; + uint8_t res2 = 0; + uint8_t res3 = 0; + uint8_t res4 = 0; + uint8_t res5 = 0; + uint8_t res6 = 0; + + delay_ms(10); + if(SW_KEY1 == 0) + { + res1 = 1; + } + if(SW_KEY2 == 0) + { + res2 = 1; + } + if(SW_KEY3 == 0) + { + res3 = 1; + } + if(SW_KEY4 == 0) + { + res4 = 1; + } + if(SW_KEY5 == 0) + { + res5 = 1; + } + if(SW_KEY6 == 0) + { + res6 = 1; + } + + res = (res6 << 5) | (res5 << 4) | (res4 << 3) | (res3 << 2) | (res2 << 1) | res1; + printf("\r\nswkey = %x\r\n", res); + + return res; +} + +/******************** (C) COPYRIGHT 2018 Ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/sw_key.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/sw_key.h new file mode 100755 index 0000000..11d4b5f --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/KEY/sw_key.h @@ -0,0 +1,26 @@ +/*************************** (C) COPYRIGHT 2018 Ping **************************** + * ļ key.h + * ͷļ + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#ifndef __SW_KEY_H +#define __SW_KEY_H + +#include "stm32f10x.h" + +#define SW_KEY1 GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_4) +#define SW_KEY2 GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) +#define SW_KEY3 GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_7) +#define SW_KEY4 GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_6) +#define SW_KEY5 GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_5) +#define SW_KEY6 GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_4) + + +void SwKeyInit(void); //ʼ +uint8_t SwKeysCanning(void); + +#endif + +/******************** (C) COPYRIGHT 2018 Ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/BMP.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/BMP.h new file mode 100755 index 0000000..8f24f14 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/BMP.h @@ -0,0 +1,216 @@ +#ifndef __BMP_H__ +#define __BMP_H__ + + + +u8 BMP1[]={ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x18, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x78, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF3,0xF8, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xC0, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xF8, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xF8, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x18, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x78, +0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x18, +0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0xCF,0x98, +0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0xC6,0x18, +0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0x01,0xFF,0xF0,0x00,0x00,0x00,0x00,0xFF,0xF8, +0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x1F,0xFE,0x00,0x00,0x00,0x00,0xFF,0xF8, +0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x03,0xFF,0xC0,0x00,0x00,0x00,0x80,0x08, +0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0xF8,0x00,0x00,0x00,0x78,0x00, +0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x3F,0xFF,0x00,0x00,0x00,0xE0,0x00, +0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x0F,0xFF,0xC0,0x00,0x00,0xC0,0x18, +0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x07,0xFF,0xF8,0x00,0x00,0xFF,0xF8, +0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x01,0xFF,0xFE,0x00,0x00,0xFF,0xF8, +0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0xFF,0xFF,0x80,0x00,0xC0,0x18, +0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x7F,0xFF,0xE0,0x00,0xF8,0x00, +0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x3F,0xFF,0xF8,0x00,0x00,0x00, +0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x1F,0xFF,0xFC,0x00,0xFF,0xF8, +0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x1F,0xFF,0xFF,0x00,0xFF,0xF8, +0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x87,0xE0, +0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x7E,0x00, +0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0xF8,0x18, +0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0xFF,0xF8, +0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x80,0x08, +0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x10,0xE0, +0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x1F,0xFF,0xFF,0x00,0xF0,0x38, +0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x1F,0xFF,0xFE,0x00,0xCF,0x98, +0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x3F,0xFF,0xF8,0x00,0xC6,0x18, +0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x7F,0xFF,0xE0,0x00,0xC6,0x18, +0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x7F,0xFF,0x80,0x00,0xFF,0xF8, +0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x01,0xFF,0xFE,0x00,0x00,0xC0,0x18, +0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x03,0xFF,0xF0,0x00,0x00,0x00,0x00, +0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x0F,0xFF,0xC0,0x00,0x00,0xC0,0x18, +0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x3F,0xFE,0x00,0x00,0x00,0xFF,0xF8, +0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0xF0,0x00,0x00,0x00,0xFF,0xF8, +0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x03,0xFF,0xC0,0x00,0x00,0x00,0xC0,0x18, +0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,0xF0, +0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0x03,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x38, +0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x18, +0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0xC0,0x18, +0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xF8, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x18, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF8, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xD8, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF1,0x80, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x88, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xF8, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + +}; + + +u8 BMP2[]={ +0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFE,0x07, +0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xC0,0x01, +0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFC,0x1C,0x00,0x00, +0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xE0,0x00,0x00,0x00, +0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xE0,0x00,0x00,0x00, +0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xC0,0x00,0x00,0x00, +0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xF8,0x00,0x00,0x00,0x00, +0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x07,0x00,0x00,0x3F,0xFF,0x00,0x00,0x00,0x3F,0xC3, +0xFF,0xFF,0xFF,0x00,0x00,0x00,0x1F,0x80,0x00,0x3F,0xF8,0x00,0x00,0x03,0xFF,0xFF, +0xFF,0xFF,0xFF,0x00,0x00,0x00,0x3F,0x80,0x00,0x7F,0xE0,0x00,0x00,0x0F,0xFF,0xFF, +0xFF,0xFF,0xFE,0x00,0x00,0x00,0xFF,0xC0,0x00,0x7F,0x80,0x00,0x00,0x1F,0xFF,0xFF, +0xFF,0xFF,0xFC,0x00,0x00,0x1F,0xFF,0xC0,0x00,0xFE,0x00,0x00,0x03,0xFF,0xFF,0xFF, +0xF0,0x7F,0xFC,0x00,0x00,0x1F,0xFF,0xE0,0x01,0xFE,0x00,0x00,0x07,0xF8,0x00,0x7F, +0xC0,0x0F,0xFC,0x00,0x03,0xFF,0xFF,0xF8,0x03,0xF8,0x00,0x00,0x1F,0xE0,0x00,0x7F, +0x80,0x03,0xF8,0x00,0x0F,0xFF,0xFF,0xFF,0x1E,0x00,0x00,0x00,0x1F,0xC0,0x00,0x7F, +0x80,0x01,0xF0,0x00,0x0F,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x3F,0x80,0x00,0x7F, +0x00,0x00,0xF0,0x00,0x07,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x7F,0x80,0x07,0xFF, +0x00,0x00,0x60,0x00,0x07,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x7F,0x03,0xC7,0xFF, +0x00,0x00,0x00,0x00,0x01,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0xFF,0x80,0x07,0xFF, +0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0x80,0x00,0x7F, +0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xC0,0x00,0x7F, +0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xE0,0x00,0x7F, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xF8,0x00,0x7F, +0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF, +0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF, +0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0x01,0x00,0x7F, +0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x00,0x00,0x7F, +0xFE,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0x00,0x00,0x7F, +0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0x04,0x00,0x7F, +0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x0C,0x38,0x7F, +0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x0C,0x78,0x7F, +0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0x00,0x00,0x7F, +0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0x00,0x00,0x7F, +0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0x00,0x00,0x7F, +0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0x00,0x00,0x7F, +0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0x00,0x00,0x7F, +0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xFF,0x00,0x00,0x7F, +0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x00,0x00,0x7F, +0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0x00,0x00,0x7F, +0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFE,0x00,0x7F, +0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xF8,0x01,0xFF, +0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xC0,0x0F,0xFF, +0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0x00,0x1F,0xFF, +0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0x00,0x00,0x7F, +0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x7F, +0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x7F, +0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x80,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x7F, +0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xC0,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xFF,0xFF,0x80,0x00,0xE0,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0xFE,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xFF,0xFF,0xE0,0x01,0xFE,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xFF,0xFF,0xF8,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, +0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF + + +}; + + +u8 BMP3[]={ +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xF0,0x3F,0x00,0x00,0x0F,0xE0,0x00,0x00,0x00, +0x00,0x00,0x00,0x07,0xFF,0x80,0x00,0x39,0xE1,0xD8,0x00,0x00,0x78,0x00,0x00,0x00, +0x00,0x00,0x00,0x7F,0x80,0x05,0xF0,0x00,0x00,0x01,0xC0,0x00,0x1E,0x00,0x00,0x00, +0x00,0x00,0x03,0xF0,0x00,0x00,0x00,0x0B,0xFF,0xA0,0x1C,0x00,0x07,0x80,0x00,0x00, +0x00,0x00,0x0F,0x86,0x03,0xFF,0xFF,0x80,0x00,0x03,0x81,0x80,0x03,0xC0,0x00,0x00, +0x00,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0xA0,0xE0,0x18,0x30,0x00,0xE0,0x00,0x00, +0x00,0x00,0xF0,0x00,0x1F,0xC0,0x00,0x00,0x40,0x03,0xC3,0x0C,0x00,0x70,0x00,0x00, +0x00,0x01,0xE0,0x01,0x80,0x01,0x00,0x00,0x80,0x00,0x1C,0x41,0x00,0x38,0x00,0x00, +0x00,0x01,0xC0,0x06,0x00,0x00,0x00,0x01,0x00,0x00,0x03,0x10,0x40,0x38,0x00,0x00, +0x00,0x01,0xC0,0x08,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0xC4,0x00,0x1C,0x00,0x00, +0x00,0x01,0x80,0x00,0x00,0x03,0x00,0x00,0x00,0x7E,0x00,0x20,0x00,0x0E,0x00,0x00, +0x00,0x03,0x80,0x00,0x00,0x01,0x00,0x00,0x1F,0xFF,0xF8,0x00,0x00,0x07,0x00,0x00, +0x00,0x07,0x00,0x00,0xFF,0x80,0x00,0x00,0x7C,0x3F,0xFF,0x00,0x00,0x03,0xC0,0x00, +0x00,0x1E,0x00,0x07,0xFF,0xF8,0x00,0x01,0xE0,0x3F,0xFB,0xC0,0x00,0x01,0xF0,0x00, +0x00,0x78,0x3F,0xEF,0xFF,0xFE,0x00,0x07,0x81,0xFF,0xFF,0xE3,0x80,0x3F,0xF8,0x00, +0x00,0xF1,0x00,0x00,0xFF,0xFF,0xF8,0x07,0x1F,0xE0,0x0F,0xC8,0x00,0x00,0x5E,0x00, +0x01,0xC4,0x00,0x00,0x00,0x1F,0xE0,0x03,0xFC,0x07,0x00,0x00,0x3F,0xF0,0x37,0x00, +0x01,0x91,0x80,0x00,0x00,0x03,0x80,0x00,0xE0,0x03,0xC0,0x03,0xFF,0xFC,0x0B,0x80, +0x03,0xA2,0x3F,0xE0,0x00,0x03,0x80,0x00,0x00,0x01,0xF8,0x7F,0xC0,0x0F,0x09,0xC0, +0x03,0xA2,0xF8,0xF8,0x60,0x03,0x80,0x00,0x00,0x00,0x3F,0xF8,0x06,0x03,0x84,0xE0, +0x03,0x84,0x00,0x3F,0xE0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x01,0x84,0x60, +0x03,0xA4,0x01,0x0F,0x80,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x01,0xC4,0x60, +0x03,0xA6,0x03,0x80,0x00,0xF8,0x00,0x03,0xFB,0x00,0x00,0x03,0xF7,0xE1,0xC4,0x60, +0x01,0xF1,0x03,0x80,0x03,0xF0,0x00,0x00,0x3C,0xFF,0x80,0x3F,0x87,0xF9,0xC4,0x60, +0x01,0xD8,0x07,0x80,0x0F,0xF0,0x00,0x3E,0x0C,0x00,0x03,0xF8,0x07,0x01,0x88,0xE0, +0x00,0xE6,0x0F,0xC0,0x61,0x78,0x00,0xFF,0x1C,0x00,0x7F,0xE0,0x0E,0x03,0x88,0xE0, +0x00,0x70,0xCF,0xF1,0x00,0x1E,0x00,0x00,0x38,0x0F,0xF8,0xC0,0x3E,0x03,0x11,0xC0, +0x00,0x38,0x0F,0xFC,0x00,0x07,0xF0,0x00,0x03,0xFF,0x00,0xC1,0xFC,0x00,0x63,0x80, +0x00,0x38,0x1F,0xBF,0x80,0x01,0xE0,0x00,0x7F,0xE0,0x03,0xCF,0xF8,0x03,0x0F,0x00, +0x00,0x1C,0x1F,0xBB,0xFE,0x00,0x01,0xFF,0xFF,0x80,0x07,0xFE,0x70,0x00,0x7C,0x00, +0x00,0x0C,0x1F,0x38,0x7F,0xFF,0xFF,0xF8,0x03,0x80,0x7F,0xF0,0xE0,0x00,0x78,0x00, +0x00,0x0C,0x1F,0x38,0x70,0x1F,0x81,0xC0,0x01,0xC7,0xFF,0xC3,0xC0,0x00,0xE0,0x00, +0x00,0x0C,0x1F,0xF8,0x60,0x0E,0x01,0xC0,0x01,0xFF,0xF9,0x87,0x80,0x01,0xC0,0x00, +0x00,0x0C,0x0F,0xFC,0xE0,0x0E,0x01,0xC0,0x1F,0xFF,0x81,0xCE,0x00,0x03,0x80,0x00, +0x00,0x0C,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0xFC,0x00,0x07,0x00,0x00, +0x00,0x0C,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xE0,0x00,0xF0,0x00,0x0E,0x00,0x00, +0x00,0x0C,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0xE0,0x03,0xE0,0x00,0x1C,0x00,0x00, +0x00,0x0C,0x0E,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x70,0x0F,0x80,0x00,0x38,0x00,0x00, +0x00,0x0C,0x06,0x67,0xFF,0xFF,0xF8,0x30,0x00,0x70,0x3E,0x00,0x00,0x70,0x00,0x00, +0x00,0x0C,0x07,0x73,0x8E,0x07,0x00,0x30,0x00,0x39,0xF0,0x00,0x01,0xE0,0x00,0x00, +0x00,0x0C,0x03,0xE1,0xC7,0x03,0x80,0x30,0x00,0x1F,0xC0,0x00,0x07,0x80,0x00,0x00, +0x00,0x0C,0x01,0xF1,0xC3,0x83,0x80,0x30,0x01,0xFE,0x01,0x83,0x1F,0x00,0x00,0x00, +0x00,0x0C,0x00,0x3F,0xF3,0xC3,0x80,0x38,0xFF,0xE0,0x1C,0x18,0x7C,0x00,0x00,0x00, +0x00,0x0C,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0xE0,0xC1,0xF0,0x00,0x00,0x00, +0x00,0x1C,0x00,0x00,0x00,0x0F,0xFC,0x00,0x00,0x0E,0x0E,0x0F,0x80,0x00,0x00,0x00, +0x00,0x1C,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0xE0,0x60,0x7E,0x00,0x00,0x00,0x00, +0x00,0x1C,0x00,0x30,0x00,0x00,0x00,0x00,0x0E,0x0F,0x03,0xF0,0x00,0x00,0x00,0x00, +0x00,0x18,0x10,0x06,0x00,0x00,0x00,0x03,0xC0,0xE0,0x3F,0x80,0x00,0x00,0x00,0x00, +0x00,0x18,0x0C,0x00,0x5F,0xFF,0xDC,0x00,0xB8,0x03,0xF8,0x00,0x00,0x00,0x00,0x00, +0x00,0x18,0x03,0x80,0x00,0x00,0x00,0x78,0x00,0x1F,0x80,0x00,0x00,0x00,0x00,0x00, +0x00,0x1C,0x00,0x3F,0xFF,0xFF,0xC0,0x00,0x01,0xFC,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x03,0x80,0x00,0x00,0x00,0x00,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x01,0xF0,0x00,0x00,0x00,0x1F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x7E,0x00,0x00,0x0F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x0F,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + + +}; + + +#endif + diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/SDWe_LCD.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/SDWe_LCD.c new file mode 100755 index 0000000..32925c1 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/SDWe_LCD.c @@ -0,0 +1,302 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ LCD_SDWe.c + * 7LCDʾ + * V1.0 + * XuZhongPing + * 2017/10/23 +*********************************************************************************/ +#include "SDWe_LCD.h" +#include "usart5.h" +#include "timer.h" +#include "string.h" +#include "stdlib.h" +#include "delay.h" + + +/* +*********************************************************************** +* : LCD_PackProcotol +* ˵: LCDʾƴЭ +* Σ +* ֵ: +*********************************************************************** +*/ +void SDWe_LCD_PackProcotol(uint8_t* data, uint16_t dataLen) +{ + int index = 0; + uint8_t buf[128]; + + buf[index++] = 0xA5; + buf[index++] = 0x5A; + buf[index++] = dataLen; + if (data != NULL) + { + memcpy(&buf[index], data, dataLen); + index += dataLen; + } + + UART5_Printf((uint8_t*)buf, index); +} + +/* +*********************************************************************** +* : LCD_WriteReg +* ˵: дLCDĴ +* Σ +* ֵ: +*********************************************************************** +*/ +void SDWe_LCD_WriteReg(uint8_t addr, uint8_t *data, uint8_t dataLen) +{ + int index = 0; + uint8_t buf[128]; + + buf[index++] = 0x80; + buf[index++] = addr; + if (data != NULL) + { + memcpy(&buf[index], data, dataLen); + index += dataLen; + } + + SDWe_LCD_PackProcotol(buf, index); +} + +/* +*********************************************************************** +* : LCD_WriteMem +* ˵: дLCD洢 +* Σ +* ֵ: +*********************************************************************** +*/ +void SDWe_LCD_WriteMem(uint16_t addr, uint8_t *data, uint8_t dataLen) +{ + int index = 0; + uint8_t buf[128]; + + buf[index++] = 0x82; + buf[index++] = (uint8_t)(addr >> 8); //ͱַ + buf[index++] = (uint8_t)addr; + if (data != NULL) + { + memcpy(&buf[index], data, dataLen); + index += dataLen; + } + + SDWe_LCD_PackProcotol(buf, index); +} + +/* +*********************************************************************** +* : LCD_SetBacklight +* ˵: LCD +* Σval -> ֵ0x00-0x40 +* ֵ: +*********************************************************************** +*/ +void SDWe_LCD_SetBacklight(uint8_t val) +{ + SDWe_LCD_WriteReg(0x01, &val, 1); //0x01Ϊñ +} + +/* +*********************************************************************** +* : LCD_ConfigEN +* ˵: ʹ +* Σval -> ֵ0x00-0x40 +* ֵ: +*********************************************************************** +*/ +void SDWe_LCD_ConfigEN(uint8_t cmd) +{ + static uint8_t ctrlReg; + if(cmd) + { + ctrlReg = 0x5A; + }else{ + ctrlReg = 0xA5; + } + SDWe_LCD_WriteReg(0x1D, &ctrlReg, 1); //0x01Ϊñ +} + +/* +*********************************************************************** +* : LCD_SetDisplayPage +* ˵: ʾҳ +* Σpage -> ߶ֵ0x00-0x40 +* ֵ: +*********************************************************************** +*/ +void SDWe_LCD_SetBound(uint32_t baudrate) +{ + uint8_t val; + switch(baudrate) + { + case 1200: + val = 0x00; + break; + + case 9600: + val = 0x03; + break; + + case 19200: + val = 0x04; + break; + + case 38400: + val = 0x05; + break; + + default: + val = 0x07; + } + SDWe_LCD_WriteReg(0x11, &val, 1); //0x03-0x04Ϊʾҳ +} + +/* +*********************************************************************** +* : LCD_SetDisplayPage +* ˵: ʾҳ +* Σpage -> ߶ֵ0x00-0x40 +* ֵ: +*********************************************************************** +*/ +void SDWe_LCD_SetDisplayPage(uint16_t page) +{ + uint8_t pageBuf[2]; + + pageBuf[0] = (uint8_t)(page >> 8); + pageBuf[1] = (uint8_t)page; + SDWe_LCD_WriteReg(0x03, pageBuf, 2); //0x03-0x04Ϊʾҳ +} + +/* +*********************************************************************** +* : SDWe_LCD_ShowNum +* ˵: ʾֱ +* Σ +* ֵ: +*********************************************************************** +*/ +void SDWe_LCD_ShowNum(uint16_t addr, uint32_t num) +{ + uint8_t numBuf[4]; + + numBuf[0] = (uint8_t)(num >> 24); + numBuf[1] = (uint8_t)(num >> 16); + numBuf[2] = (uint8_t)(num >> 8); + numBuf[3] = (uint8_t)num; + + SDWe_LCD_WriteMem(addr, numBuf, 4); +} + +/* +*********************************************************************** +* : LCD_ShowString +* ˵: ʾַ +* Σ +* ֵ: +*********************************************************************** +*/ +void SDWe_LCD_ShowString(uint16_t addr, char *p) +{ + uint8_t len; + + len = strlen(p); + + printf("len = %d ", len); + + SDWe_LCD_WriteMem(addr, (uint8_t *)p, len); +} + + +/* +*********************************************************************** +* : LCD_GetReturnData +* ˵: ȡLCDʾص +* Σ +* ֵ: +*********************************************************************** +*/ +void SDWe_LCD_GetReturnData(void) +{ + uint8_t i; + uint32_t tempData; + uint8_t dataLen; //ָ + uint8_t instructionType; //ָ롡 + uint8_t regAddr; //Ĵַ + uint16_t memoryAddr; //洢ַ + uint8_t returnDataLen; //ݳ + + static uint8_t iValue = 0; + + if(USART5_RX_STA == 0xfd) //յһ + { + printf("\r\nյLCDʾصڽ\r\n"); + USART5_RX_STA = 0; //һν + + dataLen = USART5_RX_BUF[0]; + instructionType = USART5_RX_BUF[1]; //ȡָ + + printf("\r\nָ = %d \r\n", dataLen); + printf("\r\nָ = 0x%x \r\n", instructionType); + + switch(instructionType) + { + case 0x81: + regAddr = USART5_RX_BUF[2]; + switch(regAddr) + { + case 0x00: + printf("\r\nVersion = V%x \r\n", USART5_RX_BUF[4]); + break; + + case 0x01: + break; + } + + break; + + case 0x82: + break; + + case 0x83: + break; + } + } +} + +/* +*********************************************************************** +* : LCD_DisplayControlTask +* ˵: LCDʾԳ +* Σ +* ֵ: +*********************************************************************** +*/ +void SDWe_LCD_DisplayControlTask(void) +{ + static uint32_t page = 0; + + delay_ms(100); + +// LCD_ShowString(0x0021, "show string"); + + +// LCD_SetDisplayPage(page); +// delay_ms(100); +// page++; +// if(page > 0xfffffffe) +// { +// page = 0; +// } + + + +// printf("\r\nLCD\r\n"); +} + + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/SDWe_LCD.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/SDWe_LCD.h new file mode 100755 index 0000000..8940817 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/SDWe_LCD.h @@ -0,0 +1,20 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ LCD_SDWe.h + * 7LCDʾͷļ + * V1.0 + * XuZhongPing + * 2017/10/23 +*********************************************************************************/ +#ifndef __LCD_SDWe_H +#define __LCD_SDWe_H +#include "sys.h" + +void SDWe_LCD_SetDisplayPage(uint16_t page); +void SDWe_LCD_ShowNum(uint16_t addr, uint32_t num); +void SDWe_LCD_ShowString(uint16_t addr, char *p); +void SDWe_LCD_GetReturnData(void); +void SDWe_LCD_DisplayControlTask(void); + +#endif + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/display.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/display.c new file mode 100755 index 0000000..27858cb --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/display.c @@ -0,0 +1,1082 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ display.c + * ʾӦó + * V1.0 + * XuZhongPing + * 2017/10/16 +*********************************************************************************/ +#include "timer.h" +#include "device.h" +#include "lcd.h" +#include "display.h" +#include "key.h" +#include "gsm_gprs.h" +#include "data_typedef.h" + +/* +*********************************************************************** +* : Screen_SystemInit +* ˵: ϵͳʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void Screen_SystemInit(void) +{ + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + + LCD_ShowString(0, 0, " ɫ "); + LCD_ShowString(2, 0, "--ϵͳ--"); +} + +/* +*********************************************************************** +* : GetDeviceTypeSimplifyString +* ˵: ȡ豸ַݣ򻯣 +* Σ +* ֵ: +*********************************************************************** +*/ +void GetDeviceTypeSimplifyString(char *strOut, uint8_t type) +{ + switch(type) + { + case PAPER: + sprintf(strOut, "%s", "ֽ"); + break; + + case PLASTIC: + sprintf(strOut, "%s", ""); + break; + + case GLASS: + sprintf(strOut, "%s", ""); + break; + + case METAL: + sprintf(strOut, "%s", ""); + break; + + case RECYCLED: + sprintf(strOut, "%s", ""); + break; + + case KITCHEN: + sprintf(strOut, "%s", ""); + break; + + case SMALL_BOTTLE: + sprintf(strOut, "%s", "ƿ"); + break; + +// case BIG_BOTTLE: +// sprintf(strOut, "%s", "ƿ"); +// break; +// +// case CANS: +// sprintf(strOut, "%s", "ƿ"); +// break; + + case BATTERY: + sprintf(strOut, "%s", ""); + break; + + case FABRIC: + sprintf(strOut, "%s", "֯"); + break; + + case BOOK: + sprintf(strOut, "%s", ""); + break; + + case NEWSPAPER: + sprintf(strOut, "%s", ""); + break; + + case PLASTIC_2: + sprintf(strOut, "%s", ""); + break; + + case OTHER: + sprintf(strOut, "%s", ""); + break; + + case HARMFUL: + sprintf(strOut, "%s", ""); + break; + + case DRY_WASTES: + sprintf(strOut, "%s", ""); + break; + + case WET_WASTES: + sprintf(strOut, "%s", "ʪ"); + break; + + default: + sprintf(strOut, "%2d", type); + break; + } +} + +/* +*********************************************************************** +* : GetDeviceTypeString +* ˵: ȡ豸ַ +* Σ +* ֵ: +*********************************************************************** +*/ +void GetDeviceTypeString(char *strOut, uint8_t type) +{ + switch(type) + { + case PAPER: + sprintf(strOut, "%s", "ֽ"); + break; + + case PLASTIC: + sprintf(strOut, "%s", ""); + break; + + case GLASS: + sprintf(strOut, "%s", ""); + break; + + case METAL: + sprintf(strOut, "%s", ""); + break; + + case RECYCLED: + sprintf(strOut, "%s", "ɻ"); + break; + + case KITCHEN: + sprintf(strOut, "%s", ""); + break; + + case SMALL_BOTTLE: + sprintf(strOut, "%s", "ƿ"); + break; + + case BIG_BOTTLE: + sprintf(strOut, "%s", "ƿ"); + break; + + case CANS: + sprintf(strOut, "%s", "ƿ"); + break; + + case BATTERY: + sprintf(strOut, "%s", ""); + break; + + case FABRIC: + sprintf(strOut, "%s", "֯"); + break; + + case BOOK: + sprintf(strOut, "%s", "鱾"); + break; + + case NEWSPAPER: + sprintf(strOut, "%s", "ֽ"); + break; + + case PLASTIC_2: + sprintf(strOut, "%s", ""); + break; + + case OTHER: + sprintf(strOut, "%s", ""); + break; + + case HARMFUL: + sprintf(strOut, "%s", "к"); + break; + + case DRY_WASTES: + sprintf(strOut, "%s", ""); + break; + + case WET_WASTES: + sprintf(strOut, "%s", "ʪ"); + break; + + default: + sprintf(strOut, "%s", " "); + break; + } +} + +/* +*********************************************************************** +* : Screen_ShowDeviceInfo +* ˵: ʾ豸Ϣ +* Σ +* ֵ: +*********************************************************************** +*/ +void Screen_ShowDeviceInfo(char *ver, uint8_t type1, uint8_t type2, uint8_t type3, uint8_t type4) +{ + char str[17]; + char str1[17]; + char str2[17]; + char str3[17]; + char str4[17]; + + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + + //õҪʾϢ + GetDeviceTypeSimplifyString(str1, type1); + GetDeviceTypeSimplifyString(str2, type2); + GetDeviceTypeSimplifyString(str3, type3); + GetDeviceTypeSimplifyString(str4, type4); + + switch(deviceType) + { + case THREE_CLASSIFICATION: // + sprintf(str, "ͣ%s%s%s", str1, str2, str3); + break; + + case FOUR_CLASSIFICATION: //ķ + sprintf(str, "ͣ%s%s%s%s", str1, str2, str3, str4); + break; + } + + LCD_ShowString(0, 2, "豸Ϣ"); + LCD_ShowString(2, 0, VersionStr); + +// LCD_ShowString(3, 0, str); +} + +/* +*********************************************************************** +* : BootScreen +* ˵: +* Σ +* ֵ: +*********************************************************************** +*/ +void BootScreen(void) +{ + static uint8_t displayStatus = 0x00; + static uint8_t connectingOK = 0; + + static timer switchScreenTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&switchScreenTimer, CLOCK_SECOND*1); + + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + + LCD_ShowString(0, 2, "ӭʹ"); + LCD_ShowString(2, 0, " "); + + } + + if(connectingOK == 0) //ǷѾϺ̨ + { + if(gsm_msg.Running == 1) //ѾϺ̨˳ + { + connectingOK = 1; + } + + if(timer_expired(&switchScreenTimer)) + { + timer_restart(&switchScreenTimer); + switch(displayStatus) + { + case 0x00: + LCD_ShowString(2, 0, " "); + LCD_ShowString(2, 0, " . "); + break; + + case 0x01: + LCD_ShowString(2, 0, " .. "); + break; + + case 0x02: + LCD_ShowString(2, 0, " ... "); + break; + + case 0x03: + LCD_ShowString(2, 0, " "); + LCD_ShowString(2, 0, " "); + break; + } + + displayStatus++; + if(displayStatus > 3) + { + displayStatus = 0; + } + } + } +} + +/* +*********************************************************************** +* : Screen_Default +* ˵: ĬϽ棨棩 +* Σ +* ֵ: +*********************************************************************** +*/ +void Screen_Default(void) +{ + LCD_Init(); + + LCD_ShowString(0, 0, " "); + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + +// LCD_ShowString(0, 2, "𴴿Ƽ"); +// LCD_ShowString(0, 2, "ܻ"); +// LCD_ShowString(0, 2, ""); + + +// LCD_ShowString(0, 2, "ɫ"); +// LCD_ShowString(2, 0, " ɨˢ "); +// LCD_ShowString(3, 0, " Ͷ "); + + + LCD_ShowString(0, 1, " ɫ "); + LCD_ShowString(2, 0, "ӭɨˢ"); + LCD_ShowString(3, 0, " Ͷ "); + + +// LCD_ShowString(0, 1, "ൺε"); +// LCD_ShowString(2, 0, "ӭɨˢ"); +// LCD_ShowString(3, 0, " Ͷ "); + + if((signal > 0) && (signal <= 32)) + { + LCD_ShowSignal((signal+3)/8); + } +} + +/* +*********************************************************************** +* : Screen_DeviceDisable +* ˵: 豸ý +* Σ +* ֵ: +*********************************************************************** +*/ +void Screen_DeviceDisable(void) +{ + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + + + LCD_ShowString(0, 2, "ɫ"); + LCD_ShowString(2, 0, " 豸ά "); + LCD_ShowString(3, 0, " ͣʹ "); +} + +/* +*********************************************************************** +* : Screen_Landing +* ˵: ڵ½û +* Σ +* ֵ: +*********************************************************************** +*/ +void Screen_Landing(void) +{ + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + + LCD_ShowString(2, 0, " ڼ... "); +} + +/* +*********************************************************************** +* : Screen_Query +* ˵: ûϢѯ +* Σauth -> Ƿͨ +* mode -> ʾ˺ŻICţ0˺ţ1ICţ +* inputAccount -> û˺ +* inputBalance -> û +* ֵ: +*********************************************************************** +*/ +void Screen_Query(uint8_t auth, uint8_t mode, uint8_t *icCard, uint32_t inputAccount, uint32_t inputBalance) +{ + uint8_t i; + double tempData; + char str1[17]; + char str2[17]; + char icCardNumAfter6[7] = {0, 0, 0, 0, 0, 0, '\0'}; //ź6λ + + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + + switch(auth) + { + case 0x01: +// printf("\r\n֤ͨ\r\n"); + + if(mode) + { + for(i = 0; i < 6; i++) //ȡIC6λʾ + { + icCardNumAfter6[i] = icCard[11 + i] + '0'; + } + + sprintf(str1, "ţ***%s ", icCardNumAfter6); + sprintf(str2, "%.2f", (float)inputBalance/100); + }else{ + sprintf(str1, "˺ţ%d", inputAccount); + sprintf(str2, "%.2f", (float)inputBalance/100); + } + + if(synchronousOpenDoorMark == 0) + { + LCD_ShowString(1, 0, "ѡͶͣ"); + } + LCD_ShowString(2, 0, str1); + LCD_ShowString(3, 0, str2); + break; + + case 0x02: + printf("\r\n\r\n"); + LCD_ShowString(2, 0, " 㣩 "); + break; + + case 0x03: + printf("\r\nű\r\n"); + LCD_ShowString(2, 0, " ã "); + break; + + case 0x04: + printf("\r\n\r\n"); + LCD_ShowString(2, 0, " ICЧ "); + break; + + case 0x05: + printf("\r\nЧ\r\n"); + LCD_ShowString(2, 0, " Ч "); + LCD_ShowString(3, 0, "Ͷ޷ý"); + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : Screen_Query +* ˵: ûϢѯ +* Σauth -> Ƿͨ +* mode -> ʾ˺ŻICţ0˺ţ1ICţ +* inputAccount -> û˺ +* inputBalance -> û +* ֵ: +*********************************************************************** +*/ +void Screen_UserInfo(uint8_t auth, uint8_t mode, uint8_t *icCard, uint32_t inputAccount, uint32_t inputBalance) +{ + uint8_t i; + double tempData; + char str1[17]; + char str2[17]; + char icCardNumAfter6[7] = {0, 0, 0, 0, 0, 0, '\0'}; //ź6λ + + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + + switch(auth) + { + case 0x01: + printf("\r\n֤ͨ\r\n"); + + if(mode) + { + for(i = 0; i < 6; i++) //ȡIC6λʾ + { + icCardNumAfter6[i] = icCard[11 + i] + '0'; + } + + sprintf(str1, "ţ***%s ", icCardNumAfter6); + sprintf(str2, "%.2f", (float)inputBalance/100); + }else{ + sprintf(str1, "˺ţ%d", inputAccount); + sprintf(str2, "%.2f", (float)inputBalance/100); + } + + LCD_ShowString(1, 0, str1); + LCD_ShowString(2, 0, str2); + break; + + case 0x02: +// printf("\r\n\r\n"); + LCD_ShowString(2, 0, " 㣩 "); + break; + + case 0x03: +// printf("\r\nű\r\n"); + LCD_ShowString(2, 0, " ã "); + break; + + case 0x04: +// printf("\r\n\r\n"); + LCD_ShowString(2, 0, " ICЧ "); + break; + + case 0x05: +// printf("\r\nЧ\r\n"); + LCD_ShowString(1, 0, " Ч "); + LCD_ShowString(2, 0, "Ͷ޷ý"); + break; + + case 0x06: +// printf("\r\nڼ...\r\n"); + LCD_ShowString(2, 0, " ڼ... "); + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : Screen_Query +* ˵: ûϢѯ +* ΣtimerVal -> ʣʱ +* ֵ: +*********************************************************************** +*/ +void Screen_Countdown(uint8_t timerVal) +{ + double tempData; + char str1[17]; + + LCD_ShowString(3, 0, " "); + + if(timerVal != 0) + { + sprintf(str1, " %3d", timerVal); + }else{ + sprintf(str1, " ڹ"); + } + + LCD_ShowString(3, 0, str1); + +} + +/* +*********************************************************************** +* : ShowWeightInfo +* ˵: ʾӦͶϢ +* Σnum -> һ壨0䣻1䣩 +* type -> ɻ +* inputVal -> Ӧֵ +* ֵ: +*********************************************************************** +*/ +static void ShowWeightInfo(uint8_t num, uint8_t type, uint16_t inputVal) +{ + char str[17]; + + //õҪʾϢ + switch(type) + { + case PAPER: + sprintf(str, "ֽࣺ%2.2f Kg", (float)inputVal/100); + break; + + case PLASTIC: + sprintf(str, "ϣ%2.2f Kg", (float)inputVal/100); + break; + + case GLASS: + sprintf(str, "%2.2f Kg", (float)inputVal/100); + break; + + case METAL: + sprintf(str, "%2.2f Kg", (float)inputVal/100); + break; + + case RECYCLED: + sprintf(str, "ɻգ%2.2f Kg", (float)inputVal/100); + break; + + case KITCHEN: + if((leftBarrelType == RECYCLED) || (rightBarrelType == RECYCLED)) + { + sprintf(str, " ࣺ%2.2f Kg", (float)inputVal/100); + }else{ + sprintf(str, "ࣺ%2.2f Kg", (float)inputVal/100); + } + break; + + case SMALL_BOTTLE: + sprintf(str, "ƿӣ%3d ", inputVal); + break; + + case BIG_BOTTLE: + sprintf(str, "ƿӣ%3d ", inputVal); + break; + + case CANS: + sprintf(str, "ƿӣ%3d ", inputVal); + break; + + case BATTERY: + sprintf(str, "أ%2.2f Kg", (float)inputVal/100); + break; + + case FABRIC: + sprintf(str, "֯%2.2f Kg", (float)inputVal/100); + break; + + case BOOK: + sprintf(str, "鱾%2.2f Kg", (float)inputVal/100); + break; + + case NEWSPAPER: + sprintf(str, "ֽ%2.2f Kg", (float)inputVal/100); + break; + + case KITCHEN_1: + sprintf(str, "%2.2f Kg", (float)inputVal/100); + break; + + case KITCHEN_2: + sprintf(str, "%2.2f Kg", (float)inputVal/100); + break; + + case PLASTIC_2: + sprintf(str, "ϣ%2.2f Kg", (float)inputVal/100); + break; + + case OTHER: + if((leftBarrelType == RECYCLED) || (rightBarrelType == RECYCLED)) + { + sprintf(str, " %2.2f Kg", (float)inputVal/100); + }else{ + sprintf(str, "%2.2f Kg", (float)inputVal/100); + } + break; + + case HARMFUL: + if((leftBarrelType == RECYCLED) || (rightBarrelType == RECYCLED)) + { + sprintf(str, " %2.2f Kg", (float)inputVal/100); + }else{ + sprintf(str, "к%2.2f Kg", (float)inputVal/100); + } + break; + + case DRY_WASTES: + sprintf(str, "%2.2f Kg", (float)inputVal/100); + break; + + case WET_WASTES: + sprintf(str, "ʪ%2.2f Kg", (float)inputVal/100); + break; + + default: + sprintf(str, "%2.2f Kg", (float)inputVal/100); + break; + } + + //Ӧʾֱʾڲͬ + switch(num) + { + case 0: // + LCD_ShowString(2, 0, str); + break; + + case 1: // + LCD_ShowString(3, 0, str); + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : Screen_ShowPutInInfo +* ˵: ʾͶŵϢ +* Σtype -> +* leftType -> ɻ +* rightType -> ɻ +* leftVal -> Ͷֵ +* rightVal -> Ͷֵ +* ֵ: +*********************************************************************** +*/ +void Screen_ShowPutInInfo(uint8_t type, uint8_t leftType, uint8_t rightType, uint16_t leftVal, uint16_t rightVal) +{ + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + + switch(type) + { + case DOUBLE_CLASSIFICATION: //˫Ͱ480L + ShowWeightInfo(0, leftType, leftVal); + ShowWeightInfo(1, rightType, rightVal); + break; + + case DOUBLE_CLASSIFICATION_BOTTLE: //˫Ͱ480Lƿ + ShowWeightInfo(0, leftType, leftVal); + ShowWeightInfo(1, rightType, rightVal); + break; + + case SINGLE_CLASSIFICATION: //Ͱ660L + ShowWeightInfo(0, leftType, leftVal); + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : Screen_ShowPutInInfo +* ˵: ʾͶŵϢ +* Σtype -> +* leftType -> ɻ +* rightType -> ɻ +* leftVal -> Ͷֵ +* rightVal -> Ͷֵ +* ֵ: +*********************************************************************** +*/ +void Screen_ShowPutInInfo2(uint16_t val1, uint16_t val2, uint16_t val3, uint16_t val4) +{ + char str[17]; + char str1[17]; + char str2[17]; + char str3[17]; + char str4[17]; + + LCD_DrawModeCtrl(0); + + LCD_ShowString(0, 0, " "); + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + + GetDeviceTypeString(str, devChannel1Type); + sprintf(str1, "%s%2.2f Kg", str, (float)val1/100); + GetDeviceTypeString(str, devChannel2Type); + sprintf(str2, "%s%2.2f Kg", str, (float)val2/100); + GetDeviceTypeString(str, devChannel3Type); + sprintf(str3, "%s%2.2f Kg", str, (float)val3/100); + GetDeviceTypeString(str, devChannel4Type); + sprintf(str4, "%s%2.2f Kg", str, (float)val4/100); + + switch(deviceType) + { + case THREE_CLASSIFICATION: // + LCD_ShowString(1, 0, str1); + LCD_ShowString(2, 0, str2); + LCD_ShowString(3, 0, str3); + break; + + case FOUR_CLASSIFICATION: //ķ + LCD_ShowString(0, 0, str1); + LCD_ShowString(1, 0, str2); + LCD_ShowString(2, 0, str3); + LCD_ShowString(3, 0, str4); + break; + } +} + +/* +*********************************************************************** +* : Screen_ShowPutInReward +* ˵: ʾͶŽϢ +* ΣbeforeCapital -> ͶǰĽ +* afterCapital -> ͶźĽ +* ֵ: +*********************************************************************** +*/ +void Screen_ShowPutInReward(uint32_t beforeCapital, uint32_t afterCapital) +{ + char str1[17]; + char str2[17]; + uint32_t temp = 0; + + if(beforeCapital <= afterCapital) + { + temp = afterCapital - beforeCapital; + } + + sprintf(str1, "%.2f", (float)temp/100); + sprintf(str2, "%.2f", (float)afterCapital/100); + + LCD_ShowString(0, 0, " "); + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + + LCD_ShowString(0, 2, "ɫ"); + LCD_ShowString(2, 0, str1); + LCD_ShowString(3, 0, str2); + + LCD_DrawModeCtrl(1); +} + +/* +*********************************************************************** +* : Screen_Exit +* ˵: ˳ʹ +* Σ +* ֵ: +*********************************************************************** +*/ +void Screen_Exit(void) +{ + LCD_ShowString(0, 0, " "); + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + +// LCD_ShowString(2, 0, " ллʹ "); + + LCD_ShowString(0, 2, "ɫ"); + LCD_ShowString(2, 0, "лΪ"); + LCD_ShowString(3, 0, " һ "); + + LCD_DrawModeCtrl(1); +} + +/* +*********************************************************************** +* : Screen_ShowFull +* ˵: ʾװ +* Σ +* ֵ: +*********************************************************************** +*/ +void Screen_ShowFull(void) +{ + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + + LCD_ShowString(2, 0, "װͣʹ"); + +// LCD_ShowString(2, 0, " װ "); +// LCD_ShowString(3, 0, " ͣʹ "); +} + +/* +*********************************************************************** +* : Screen_Error +* ˵: ʾ豸ת +* Σtype -> ͣ0Ͱ1˫Ͱ +* pre1 -> +* pre2 -> ұ +* ֵ: +*********************************************************************** +*/ +void Screen_Error(uint8_t type, uint8_t pre1, uint8_t pre2) +{ + char str[17]; + + if(type) //˫Ͱ + { + sprintf(str, "룺%3d %3d", pre1, pre2); + }else{ //Ͱ + sprintf(str, "룺%3d", pre1); + } + + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + + LCD_ShowString(2, 0, "豸ͣʹ"); + LCD_ShowString(3, 0, str); +} + +/* +*********************************************************************** +* : Screen_ScaleCalibraEnter +* ˵: ʾڽУ׼ +* Σnum -> ̱ +* ֵ: +*********************************************************************** +*/ +void Screen_ScaleCalibraEnter(uint8_t num) +{ + char str1[17]; + + sprintf(str1, "У׼̣%d", num); + + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + + LCD_ShowString(2, 0, str1); + LCD_ShowString(3, 0, "->ڽУ׼"); +} + +/* +*********************************************************************** +* : Screen_ScaleCalibraStart +* ˵: ʾڽУ׼ +* Σnum -> ̱ +* ֵ: +*********************************************************************** +*/ +void Screen_ScaleCalibraStart(uint8_t num) +{ + char str1[17]; + + sprintf(str1, "У׼̣%d", num); + + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + + LCD_ShowString(2, 0, str1); + LCD_ShowString(3, 0, "->10Kg"); +} + +/* +*********************************************************************** +* : Screen_ScaleCalibraFinish +* ˵: ʾڽУ׼ +* Σnum -> ̱ +* ֵ: +*********************************************************************** +*/ +void Screen_ScaleCalibraFinish(uint8_t num) +{ + char str1[17]; + + sprintf(str1, "У׼̣%d", num); + + LCD_ShowString(1, 0, " "); + LCD_ShowString(2, 0, " "); + LCD_ShowString(3, 0, " "); + + LCD_ShowString(2, 0, str1); + LCD_ShowString(3, 0, "->У׼ɣ"); +} + +/* +*********************************************************************** +* : DispalyTask +* ˵: ʾҪʵʱµĽ棩 +* Σ +* ֵ: +*********************************************************************** +*/ +void DispalyTask(void) +{ + static uint8_t preSignal = 0; + static uint8_t preSimCardStatus = 0; + static uint8_t initScreen = 0; + static uint8_t showStatus = 0x00; + + static timer showVersionTimer; + static timer waitingTimer_5S; + static timer waitingTimer; + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&showVersionTimer, CLOCK_SECOND*5); + timer_set(&waitingTimer_5S, CLOCK_SECOND*5); + timer_set(&waitingTimer, CLOCK_SECOND*60); + } + + switch(showStatus) + { + case 0x00: + if(timer_expired(&showVersionTimer)) + { + showStatus = 0x02; + } + break; + + case 0x01: + if(timer_expired(&showVersionTimer)) + { + showStatus = 0x02; + } + break; + + case 0x02: + if(initScreen == 0) + { + BootScreen(); + + if(gsm_msg.Running == 1) //ѾϺ̨˳ + { + initScreen = 1; + Screen_Default(); + showStatus = 0x03; + } + + if(timer_expired(&waitingTimer)) + { + initScreen = 1; + Screen_Default(); + showStatus = 0x03; + } + } + break; + + case 0x03: + + break; + } + +//SIM״̬ʾ + if(gsm_msg.simCardStatus != preSimCardStatus) + { + preSimCardStatus = gsm_msg.simCardStatus; + + if(gsm_msg.simCardStatus == 2) + { + LCD_ShowSignal(5); //ʾ޷ע + }else if(gsm_msg.simCardStatus == 3){ + LCD_ShowSignal(6); //ûGPRSҵ + }else if(gsm_msg.simCardStatus == 4){ + LCD_ShowSignal(7); //ûм⵽ + }else{ + } + } + + if(signal != preSignal) + { +// printf("\r\nźʾ%d\r\n", signal); + preSignal = signal; + if((signal > 0) && (signal <= 32)) + { + LCD_ShowSignal((signal+3)/8); + } + } +} + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/display.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/display.h new file mode 100755 index 0000000..5678bac --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/display.h @@ -0,0 +1,33 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ display.h + * ʾ + * V1.0 + * XuZhongPing + * 2017/10/16 +*********************************************************************************/ +#ifndef __DISPLAY_H +#define __DISPLAY_H +#include "stdint.h" + +void Screen_SystemInit(void); +void Screen_ShowDeviceInfo(char *ver, uint8_t type1, uint8_t type2, uint8_t type3, uint8_t type4); +void Screen_Default(void); +void Screen_DeviceDisable(void); +void Screen_Landing(void); +void Screen_Query(uint8_t auth, uint8_t mode, uint8_t *icCard, uint32_t inputAccount, uint32_t inputBalance); +void Screen_UserInfo(uint8_t auth, uint8_t mode, uint8_t *icCard, uint32_t inputAccount, uint32_t inputBalance); +void Screen_Countdown(uint8_t timerVal); +void Screen_ShowPutInInfo(uint8_t type, uint8_t leftType, uint8_t rightType, uint16_t leftVal, uint16_t rightVal); +void Screen_ShowPutInInfo2(uint16_t val1, uint16_t val2, uint16_t val3, uint16_t val4); +void Screen_ShowPutInReward(uint32_t beforeCapital, uint32_t afterCapital); +void Screen_Exit(void); +void Screen_ShowFull(void); +void Screen_Error(uint8_t type, uint8_t pre1, uint8_t pre2); + +void Screen_ScaleCalibraEnter(uint8_t num); +void Screen_ScaleCalibraStart(uint8_t num); +void Screen_ScaleCalibraFinish(uint8_t num); + +void DispalyTask(void); + +#endif diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/icon.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/icon.h new file mode 100755 index 0000000..6afd0f3 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/icon.h @@ -0,0 +1,192 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ icon.h + * ͼƬϢͷļ + * V1.0 + * XuZhongPing + * 2017/10/17 +*********************************************************************************/ +#ifndef __ICON_H__ +#define __ICON_H__ +#include "stdint.h" + +//ȡģ +//źͼ +const unsigned char signalIcon[8][32] = { +{0x00,0x00,0x7C,0x00,0x38,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //ź + +{0x00,0x00,0x7C,0x00,0x38,0x00,0x10,0x00,0x10,0x00,0x12,0x00,0x12,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //1ź + +{0x00,0x00,0x7C,0x00,0x38,0x00,0x10,0x00,0x10,0x80,0x12,0x80,0x12,0x80,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //2ź + +{0x00,0x00,0x7C,0x00,0x38,0x00,0x10,0x20,0x10,0xA0,0x12,0xA0,0x12,0xA0,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //3ź + +{0x00,0x00,0x7C,0x00,0x38,0x08,0x10,0x28,0x10,0xA8,0x12,0xA8,0x12,0xA8,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //4ź + +{0x00,0x00,0x7C,0x00,0x38,0x11,0x10,0x0A,0x10,0x84,0x12,0x8A,0x12,0x91,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //޷ע磨ʶ + +{0x00,0x00,0x7C,0x04,0x38,0x04,0x10,0x04,0x10,0x84,0x12,0x80,0x12,0x84,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //ûGPRSҵ + +{0x00,0x00,0x7C,0x74,0x38,0x94,0x11,0x14,0x11,0x14,0x11,0x10,0x11,0xF4,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //ûм⵽ +}; + +//¶ȷš +const uint8_t temperatureIcon[32] = { +0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x6E,0x00,0x1B,0x00,0x31,0x00,0x30,0x00,0x30, +0x00,0x30,0x00,0x31,0x00,0x1B,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + +//Ͱͼ +const uint8_t Icon2[11][192] = { +{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x78,0x3F,0xFF,0xFF,0xF8, + 0x3F,0xFF,0xFF,0xFC,0x08,0x00,0x00,0xD4,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x8C,0x08,0x00,0x00,0x8C,0x04,0x00,0x01,0x0C,0x04,0x00,0x01,0x1C, + 0x04,0x00,0x01,0x04,0x04,0x00,0x01,0x04,0x04,0x00,0x01,0x00,0x04,0x00,0x01,0x00, + 0x04,0x00,0x01,0x00,0x04,0x00,0x01,0x00,0x04,0x00,0x01,0x00,0x04,0x00,0x01,0x00, + 0x04,0x00,0x01,0x00,0x04,0x00,0x03,0x80,0x04,0x00,0x04,0x40,0x04,0x00,0x09,0x20, + 0x04,0x00,0x0B,0xA0,0x07,0xFF,0xF9,0x20,0x03,0x80,0x04,0x40,0x03,0x80,0x03,0x80, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //0% + +{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x78,0x3F,0xFF,0xFF,0xF8, + 0x3F,0xFF,0xFF,0xFC,0x08,0x00,0x00,0xD4,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x8C,0x08,0x00,0x00,0x8C,0x04,0x00,0x01,0x0C,0x04,0x00,0x01,0x1C, + 0x04,0x00,0x01,0x04,0x04,0x00,0x01,0x04,0x04,0x00,0x01,0x00,0x04,0x00,0x01,0x00, + 0x04,0x00,0x01,0x00,0x04,0x00,0x01,0x00,0x04,0x00,0x01,0x00,0x04,0x00,0x01,0x00, + 0x04,0x00,0x01,0x00,0x05,0xFF,0xFB,0x80,0x05,0xFF,0xF4,0x40,0x05,0xFF,0xE9,0x20, + 0x04,0x00,0x0B,0xA0,0x07,0xFF,0xF9,0x20,0x03,0x80,0x04,0x40,0x03,0x80,0x03,0x80, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //10% + +{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x78,0x3F,0xFF,0xFF,0xF8, + 0x3F,0xFF,0xFF,0xFC,0x08,0x00,0x00,0xD4,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x8C,0x08,0x00,0x00,0x8C,0x04,0x00,0x01,0x0C,0x04,0x00,0x01,0x1C, + 0x04,0x00,0x01,0x04,0x04,0x00,0x01,0x04,0x04,0x00,0x01,0x00,0x04,0x00,0x01,0x00, + 0x04,0x00,0x01,0x00,0x04,0x00,0x01,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFB,0x80,0x05,0xFF,0xF4,0x40,0x05,0xFF,0xE9,0x20, + 0x04,0x00,0x0B,0xA0,0x07,0xFF,0xF9,0x20,0x03,0x80,0x04,0x40,0x03,0x80,0x03,0x80, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //20% + +{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x78,0x3F,0xFF,0xFF,0xF8, + 0x3F,0xFF,0xFF,0xFC,0x08,0x00,0x00,0xD4,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x8C,0x08,0x00,0x00,0x8C,0x04,0x00,0x01,0x0C,0x04,0x00,0x01,0x1C, + 0x04,0x00,0x01,0x04,0x04,0x00,0x01,0x04,0x04,0x00,0x01,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFB,0x80,0x05,0xFF,0xF4,0x40,0x05,0xFF,0xE9,0x20, + 0x04,0x00,0x0B,0xA0,0x07,0xFF,0xF9,0x20,0x03,0x80,0x04,0x40,0x03,0x80,0x03,0x80, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //30% + +{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x78,0x3F,0xFF,0xFF,0xF8, + 0x3F,0xFF,0xFF,0xFC,0x08,0x00,0x00,0xD4,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x8C,0x08,0x00,0x00,0x8C,0x04,0x00,0x01,0x0C,0x04,0x00,0x01,0x1C, + 0x05,0xFF,0xFD,0x04,0x05,0xFF,0xFD,0x04,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFB,0x80,0x05,0xFF,0xF4,0x40,0x05,0xFF,0xE9,0x20, + 0x04,0x00,0x0B,0xA0,0x07,0xFF,0xF9,0x20,0x03,0x80,0x04,0x40,0x03,0x80,0x03,0x80, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //40% + +{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x78,0x3F,0xFF,0xFF,0xF8, + 0x3F,0xFF,0xFF,0xFC,0x08,0x00,0x00,0xD4,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x8C,0x0B,0xFF,0xFE,0x8C,0x05,0xFF,0xFD,0x0C,0x05,0xFF,0xFD,0x1C, + 0x05,0xFF,0xFD,0x04,0x05,0xFF,0xFD,0x04,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFB,0x80,0x05,0xFF,0xF4,0x40,0x05,0xFF,0xE9,0x20, + 0x04,0x00,0x0B,0xA0,0x07,0xFF,0xF9,0x20,0x03,0x80,0x04,0x40,0x03,0x80,0x03,0x80, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //50% + +{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x78,0x3F,0xFF,0xFF,0xF8, + 0x3F,0xFF,0xFF,0xFC,0x08,0x00,0x00,0xD4,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94,0x0B,0xFF,0xFE,0x94,0x0B,0xFF,0xFE,0x94, + 0x0B,0xFF,0xFE,0x8C,0x0B,0xFF,0xFE,0x8C,0x05,0xFF,0xFD,0x0C,0x05,0xFF,0xFD,0x1C, + 0x05,0xFF,0xFD,0x04,0x05,0xFF,0xFD,0x04,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFB,0x80,0x05,0xFF,0xF4,0x40,0x05,0xFF,0xE9,0x20, + 0x04,0x00,0x0B,0xA0,0x07,0xFF,0xF9,0x20,0x03,0x80,0x04,0x40,0x03,0x80,0x03,0x80, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //60% + +{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x78,0x3F,0xFF,0xFF,0xF8, + 0x3F,0xFF,0xFF,0xFC,0x08,0x00,0x00,0xD4,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x0B,0xFF,0xFE,0xA4, + 0x0B,0xFF,0xFE,0x94,0x0B,0xFF,0xFE,0x94,0x0B,0xFF,0xFE,0x94,0x0B,0xFF,0xFE,0x94, + 0x0B,0xFF,0xFE,0x8C,0x0B,0xFF,0xFE,0x8C,0x05,0xFF,0xFD,0x0C,0x05,0xFF,0xFD,0x1C, + 0x05,0xFF,0xFD,0x04,0x05,0xFF,0xFD,0x04,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFB,0x80,0x05,0xFF,0xF4,0x40,0x05,0xFF,0xE9,0x20, + 0x04,0x00,0x0B,0xA0,0x07,0xFF,0xF9,0x20,0x03,0x80,0x04,0x40,0x03,0x80,0x03,0x80, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //70% + +{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x78,0x3F,0xFF,0xFF,0xF8, + 0x3F,0xFF,0xFF,0xFC,0x08,0x00,0x00,0xD4,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x94,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4,0x08,0x00,0x00,0xA4, + 0x0B,0xFF,0xFE,0xA4,0x0B,0xFF,0xFE,0xA4,0x0B,0xFF,0xFE,0xA4,0x0B,0xFF,0xFE,0xA4, + 0x0B,0xFF,0xFE,0x94,0x0B,0xFF,0xFE,0x94,0x0B,0xFF,0xFE,0x94,0x0B,0xFF,0xFE,0x94, + 0x0B,0xFF,0xFE,0x8C,0x0B,0xFF,0xFE,0x8C,0x05,0xFF,0xFD,0x0C,0x05,0xFF,0xFD,0x1C, + 0x05,0xFF,0xFD,0x04,0x05,0xFF,0xFD,0x04,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFB,0x80,0x05,0xFF,0xF4,0x40,0x05,0xFF,0xE9,0x20, + 0x04,0x00,0x0B,0xA0,0x07,0xFF,0xF9,0x20,0x03,0x80,0x04,0x40,0x03,0x80,0x03,0x80, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //80% + +{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x78,0x3F,0xFF,0xFF,0xF8, + 0x3F,0xFF,0xFF,0xFC,0x08,0x00,0x00,0xD4,0x08,0x00,0x00,0x94,0x08,0x00,0x00,0x94, + 0x08,0x00,0x00,0x94,0x0B,0xFF,0xFE,0xA4,0x0B,0xFF,0xFE,0xA4,0x0B,0xFF,0xFE,0xA4, + 0x0B,0xFF,0xFE,0xA4,0x0B,0xFF,0xFE,0xA4,0x0B,0xFF,0xFE,0xA4,0x0B,0xFF,0xFE,0xA4, + 0x0B,0xFF,0xFE,0x94,0x0B,0xFF,0xFE,0x94,0x0B,0xFF,0xFE,0x94,0x0B,0xFF,0xFE,0x94, + 0x0B,0xFF,0xFE,0x8C,0x0B,0xFF,0xFE,0x8C,0x05,0xFF,0xFD,0x0C,0x05,0xFF,0xFD,0x1C, + 0x05,0xFF,0xFD,0x04,0x05,0xFF,0xFD,0x04,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFB,0x80,0x05,0xFF,0xF4,0x40,0x05,0xFF,0xE9,0x20, + 0x04,0x00,0x0B,0xA0,0x07,0xFF,0xF9,0x20,0x03,0x80,0x04,0x40,0x03,0x80,0x03,0x80, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //90% + +{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x78,0x3F,0xFF,0xFF,0xF8, + 0x3F,0xFF,0xFF,0xFC,0x08,0x00,0x00,0xD4,0x0B,0xFF,0xFE,0x94,0x0B,0xFF,0xFE,0x94, + 0x0B,0xFF,0xFE,0x94,0x0B,0xFF,0xFE,0xA4,0x0B,0xFF,0xFE,0xA4,0x0B,0xFF,0xFE,0xA4, + 0x0B,0xFF,0xFE,0xA4,0x0B,0xFF,0xFE,0xA4,0x0B,0xFF,0xFE,0xA4,0x0B,0xFF,0xFE,0xA4, + 0x0B,0xFF,0xFE,0x94,0x0B,0xFF,0xFE,0x94,0x0B,0xFF,0xFE,0x94,0x0B,0xFF,0xFE,0x94, + 0x0B,0xFF,0xFE,0x8C,0x0B,0xFF,0xFE,0x8C,0x05,0xFF,0xFD,0x0C,0x05,0xFF,0xFD,0x1C, + 0x05,0xFF,0xFD,0x04,0x05,0xFF,0xFD,0x04,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFD,0x00, + 0x05,0xFF,0xFD,0x00,0x05,0xFF,0xFB,0x80,0x05,0xFF,0xF4,0x40,0x05,0xFF,0xE9,0x20, + 0x04,0x00,0x0B,0xA0,0x07,0xFF,0xF9,0x20,0x03,0x80,0x04,0x40,0x03,0x80,0x03,0x80, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} //100% +}; + +#endif + diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd.c new file mode 100755 index 0000000..e7ec060 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd.c @@ -0,0 +1,136 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ lcd.c + * LCDʾӿӦó + * V1.0 + * XuZhongPing + * 2017/10/23 +*********************************************************************************/ +#include "lcd.h" +#include "lcd12864.h" +#include "string.h" +#include "stdlib.h" +#include "delay.h" + +/* +*********************************************************************** +* : LCD_SetBacklight +* ˵: LCDʾʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void LCD_Init(void) +{ + LCD12864_Init(); +} + +/* +*********************************************************************** +* : LCD_SetBacklight +* ˵: LCD +* Σval -> ֵٷֱȣ +* ֵ: +*********************************************************************** +*/ +void LCD_SetBacklight(uint8_t val) +{ + +} + +/* +*********************************************************************** +* : LCD_Clear +* ˵: ʾ +* Σ +* ֵ: +*********************************************************************** +*/ +void LCD_Clear(void) +{ + LCD12864_Clear(); +} + +/* +*********************************************************************** +* : LCD_DrawModeCtrl +* ˵: ͼģʽ +* Σparam -> 0رջͼģʽ1򿪻ͼģʽ +* ֵ: +*********************************************************************** +*/ +void LCD_DrawModeCtrl(uint8_t param) +{ + LCD12864_DrawModeCtrl(param); +} + +/* +*********************************************************************** +* : LCD_ShowChar +* ˵: ʾһַ +* Σnum -> Ҫʾַ +* ֵ: +*********************************************************************** +*/ +void LCD_ShowChar(uint8_t num) +{ + LCD12864_ShowChar(num); +} + +/* +*********************************************************************** +* : LCD_ShowString +* ˵: ʾַ +* Σx -> +* y -> +* p -> Ҫʾָ +* ֵ: +*********************************************************************** +*/ +void LCD_ShowString(uint8_t x, uint8_t y, char *p) +{ + LCD12864_ShowString(x, y, p); +} + +/* +*********************************************************************** +* : LCD_ShowNum +* ˵: ʾֱ +* Σ +* ֵ: +*********************************************************************** +*/ +void LCD_ShowNum(uint8_t num) +{ + LCD12864_ShowNum(num); +} + +/* +*********************************************************************** +* : LCD_ShowxNum +* ˵: ʾ +* Σx,y -> ʾ +* num -> Ҫʾ +* len -> ʾijȣλ +* ֵ: +*********************************************************************** +*/ +void LCD_ShowxNum(uint8_t x, uint8_t y, uint32_t num, uint8_t len) +{ + LCD12864_ShowxNum(x, y, num, len); +} + +/* +*********************************************************************** +* : LCD_ShowSignal +* ˵: ʾGSMźǿ +* Σval -> źŵǿȣ0-4ʾ +* ֵ: +*********************************************************************** +*/ +void LCD_ShowSignal(uint8_t val) +{ + LCD12864_ShowSignal(val); +} + + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd.h new file mode 100755 index 0000000..3d63c5f --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd.h @@ -0,0 +1,25 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ lcd.h + * LCDʾӿӦó + * V1.0 + * XuZhongPing + * 2017/10/23 +*********************************************************************************/ +#ifndef __LCD_H +#define __LCD_H +#include "stdint.h" +#include "string.h" + +void LCD_Init(void); +void LCD_SetBacklight(uint8_t val); +void LCD_Clear(void); +void LCD_DrawModeCtrl(uint8_t param); +void LCD_ShowChar(uint8_t num); +void LCD_ShowString(uint8_t x, uint8_t y, char *p); +void LCD_ShowNum(uint8_t num); +void LCD_ShowxNum(uint8_t x, uint8_t y, uint32_t num, uint8_t len); +void LCD_ShowSignal(uint8_t val); + +#endif + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd12864.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd12864.c new file mode 100755 index 0000000..5d3175e --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd12864.c @@ -0,0 +1,523 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ lcd12864.c + * lcd12864ʾ + * V1.0 + * XuZhongPing + * 2017/10/16 +*********************************************************************************/ +#include "lcd12864.h" +#include "delay.h" +#include "icon.h" + +#define LCD12864_E_PORT_PeriphClock RCC_APB2Periph_GPIOB +#define LCD12864_E_PORT GPIOB +#define LCD12864_E_PORT_PIN GPIO_Pin_5 + +#define LCD12864_RW_PORT_PeriphClock RCC_APB2Periph_GPIOB +#define LCD12864_RW_PORT GPIOB +#define LCD12864_RW_PORT_PIN GPIO_Pin_6 + +#define LCD12864_RS_PORT_PeriphClock RCC_APB2Periph_GPIOB +#define LCD12864_RS_PORT GPIOB +#define LCD12864_RS_PORT_PIN GPIO_Pin_7 +/* +*********************************************************************** +* : LCD12864_Init +* ˵: LCD12864ӳʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void LCD12864_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + RCC_APB2PeriphClockCmd(LCD12864_E_PORT_PeriphClock, ENABLE); + RCC_APB2PeriphClockCmd(LCD12864_RW_PORT_PeriphClock, ENABLE); + RCC_APB2PeriphClockCmd(LCD12864_RS_PORT_PeriphClock, ENABLE); + + //E(CLK), + GPIO_InitStructure.GPIO_Pin = LCD12864_E_PORT_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(LCD12864_E_PORT, &GPIO_InitStructure); + + //R/W(SID), + GPIO_InitStructure.GPIO_Pin = LCD12864_RW_PORT_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(LCD12864_RW_PORT, &GPIO_InitStructure); + + //RS/CS,Ƭѡ + GPIO_InitStructure.GPIO_Pin = LCD12864_RS_PORT_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(LCD12864_RS_PORT, &GPIO_InitStructure); + + + +/*--------------------LCDָ-----------------------*/ + delay_ms(2); + LCD12864_WriteCommand(0x30); //30--ָ + delay_ms(5); + LCD12864_WriteCommand(0x0c); //ƻ治 + delay_ms(5); + LCD12864_WriteCommand(0x01); // + delay_ms(5); //ʱϳ + LCD12864_WriteCommand(0x06); //ʾ򿪣꿪׹ + delay_ms(5); + +// LCD12864_WriteCommand(0x34); // ָ +// LCD12864_WriteCommand(0x36); // 򿪻ͼָ + LCD12864_Clear(); // +} + +/* +*********************************************************************** +* : LCD12864_SendByte +* ˵: дһֽݵLCD +* Σzdata -> Ҫд +* ֵ: +*********************************************************************** +*/ +void LCD12864_SendByte(uint8_t zdata) +{ + uint16_t i; + for(i=0; i<8; i++) + { + if((zdata << i) & 0x80) + { + SID_H; + }else{ + SID_L; + } + + SCLK_H; + SCLK_L; + } +} + +/* +*********************************************************************** +* : LCD12864_ReceiveByte +* ˵: LCD +* Σ +* ֵ: +*********************************************************************** +*/ +uint8_t LCD12864_ReceiveByte(void) +{ + uint8_t i, temp1, temp2, value; +// temp1 = 0; +// temp2 = 0; +// for(i = 0; i < 8; i++) +// { +// temp1 = temp1<<1; +// SCLK_L; +// SCLK_H; +// SCLK_L; +// if(PAout(7) == 1) +// { +// temp1++; +// } +// } +// for(i = 0; i < 8; i++) +// { +// temp2 = temp2<<1; +// SCLK_L; +// SCLK_H; +// SCLK_L; +// if(PAout(7) == 1) +// { +// temp2++; +// } +// } +// temp1 = 0xf0&temp1; +// temp2 = 0x0f&temp2; +// value = temp1+temp2; + return value; +} + +/* +*********************************************************************** +* : LCD12864_CheckBusy +* ˵: LCDæ +* Σ +* ֵ: +*********************************************************************** +*/ +void LCD12864_CheckBusy(void) +{ + do{ + LCD12864_SendByte(0xfc); //11111,RW(1),RS(0),0 + }while(0x80 & LCD12864_ReceiveByte()); +} + +/* +*********************************************************************** +* : LCD12864_WriteCommand +* ˵: дLCD +* Σcmdcode -> д +* ֵ: +*********************************************************************** +*/ +void LCD12864_WriteCommand(uint8_t cmdcode) +{ + CS_H; + LCD12864_CheckBusy(); + LCD12864_SendByte(0xf8); + LCD12864_SendByte(cmdcode & 0xf0); + LCD12864_SendByte((cmdcode << 4) & 0xf0); + delay_us(100); + CS_L; +} + +/* +*********************************************************************** +* : LCD12864_WriteData +* ˵: дʾݵLCD +* Σdispdata -> д +* ֵ: +*********************************************************************** +*/ +void LCD12864_WriteData(uint8_t dispdata) +{ + CS_H; + LCD12864_CheckBusy(); + LCD12864_SendByte(0xfa); //11111,RW(0),RS(1),0 + LCD12864_SendByte(dispdata & 0xf0); + LCD12864_SendByte((dispdata << 4) & 0xf0); + delay_us(100); + CS_L; +} + +/* +*********************************************************************** +* : LCD12864_ReadData +* ˵: ȡLCDʾ +* Σ +* ֵ: LCDյ +*********************************************************************** +*/ +uint8_t LCD12864_ReadData(void) +{ + LCD12864_CheckBusy(); + LCD12864_SendByte(0xfe); //11111RW(1),RS(1),0 LCD->MCU + return LCD12864_ReceiveByte(); +} + +/* +*********************************************************************** +* : LCD12864_SetPos +* ˵: ʾλ +* Σx,yʾ +* ֵ: +*********************************************************************** +*/ +void LCD12864_SetPos(uint8_t x, uint8_t y) +{ + uint8_t pos; + switch(x) + { + case 0: x=0x80;break; + case 1: x=0x90;break; + case 2: x=0x88;break; + case 3: x=0x98;break; + } + pos = x + y; + LCD12864_WriteCommand(pos); +} + +/* +*********************************************************************** +* : LCD12864_DrawPoint +* ˵: LCD +* : x,y-> +* color -> ɫ0ʾ1ʾ +* ֵ: +*********************************************************************** +*/ +void LCD12864_DrawPoint(uint16_t x, uint16_t y, uint8_t color) +{ + +} + +/* +*********************************************************************** +* : LCD12864_DrawLine +* ˵: ֱ +* : x1,y1-> +* x2,y2->յ +* ֵ: +*********************************************************************** +*/ +void LCD12864_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) +{ + +} + +/* +*********************************************************************** +* : LCD12864_DrawRectangle +* ˵: +* : x1,y1->Ͻ +* x2,y2->½ +* ֵ: +*********************************************************************** +*/ +void LCD12864_DrawRectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2) +{ + +} + +/* +*********************************************************************** +* : LCD12864_Clear +* ˵: ʾ +* Σ +* ֵ: +*********************************************************************** +*/ +void LCD12864_Clear(void) +{ + uint8_t i, j; + LCD12864_WriteCommand(0x34); //8Bitָ,ʹ36HҲҪд + LCD12864_WriteCommand(0x36); //ͼON,ָ36Hܿͼ + for(i = 0; i < 32; i++) //12864ʵΪ256x32 + { + LCD12864_WriteCommand(0x80|i); //λ + LCD12864_WriteCommand(0x80); //λ + for(j = 0; j < 32; j++) //256/8=32 byte + { + LCD12864_WriteData(0x00); + } + } + LCD12864_WriteCommand(0x36); + LCD12864_WriteCommand(0x30); +} + +/* +*********************************************************************** +* : LCD12864_DrawModeCtrl +* ˵: ͼģʽ +* Σparam -> 0رջͼģʽ1򿪻ͼģʽ +* ֵ: +*********************************************************************** +*/ +void LCD12864_DrawModeCtrl(uint8_t param) +{ + if(param == 1) + { + LCD12864_WriteCommand(0x36); + LCD12864_WriteCommand(0x30); + }else{ + LCD12864_WriteCommand(0x34); + LCD12864_WriteCommand(0x30); + } +} + +/* +*********************************************************************** +* : LCD12864_ShowChar +* ˵: ʾһַ +* Σnum -> Ҫʾַ +* ֵ: +*********************************************************************** +*/ +void LCD12864_ShowChar(uint8_t num) +{ + LCD12864_WriteData(num); + delay_us(50); +} + +/* +*********************************************************************** +* : LCD12864_ShowString +* ˵: ʾַ +* Σx -> ꣨0ӦһУ +* y -> ꣨0Ӧʾһֵλãʾ8֣ +* p -> Ҫʾָ +* ֵ: +*********************************************************************** +*/ +void LCD12864_ShowString(uint8_t x, uint8_t y, char *p) +{ + uint8_t addr; + switch(x) + { + case 0: + addr = 0x80; + break; + case 1: + addr = 0x90; + break; + case 2: + addr = 0x88; + break; + case 3: + addr = 0x98; + break; + } + LCD12864_WriteCommand(addr + y); + + while(*p>0) + { + LCD12864_WriteData(*p); + p++; + delay_us(50); + } +} + + + +static uint64_t LCD_Pow(uint8_t m, uint8_t n) +{ + uint64_t result = 1; + while(n--)result *= m; + return result; +} + +const uint8_t numCode[11] = {"0123456789"}; +/* +*********************************************************************** +* : LCD12864_ShowNum +* ˵: ʾ +* Σnum -> Ҫʾ +* ֵ: +*********************************************************************** +*/ +void LCD12864_ShowNum(uint8_t num) +{ + LCD12864_WriteData(numCode[num]); + delay_us(50); +} + +/* +*********************************************************************** +* : LCD12864_ShowxNum +* ˵: ʾ +* Σx,y -> ʾ +* num -> Ҫʾ +* len -> ʾijȣλ +* ֵ: +*********************************************************************** +*/ +void LCD12864_ShowxNum(uint8_t x, uint8_t y, uint32_t num, uint8_t len) +{ + uint8_t t, temp; + + LCD12864_SetPos(x, y); //ʾ + for(t = 0; t < len; t++) + { + temp = (num/LCD_Pow(10, len-t-1))%10; + LCD12864_ShowNum(temp); + } +} + +/* +*********************************************************************** +* : LCD12864_ShowSignal +* ˵: ʾGSMźǿ +* Σval -> źŵǿȣ0-4ʾ5-6Ϊ쳣ʾ +* ֵ: +*********************************************************************** +*/ +void LCD12864_ShowSignal(uint8_t val) +{ + uint8_t i=0, j=0; + LCD12864_WriteCommand(0x34); //8Bitָ,ʹ36HҲҪд + LCD12864_WriteCommand(0x36); //ͼON,ָ36Hܿͼ + + for(i = 0; i < 16; i++) + { + LCD12864_WriteCommand(0x83 + i); //λã˵Ǵӵһпʼʾ + LCD12864_WriteCommand(0x80); //λ + + LCD12864_WriteData((uint8_t)signalIcon[val][j++]); + LCD12864_WriteData((uint8_t)signalIcon[val][j++]); + } + LCD12864_WriteCommand(0x36); + LCD12864_WriteCommand(0x30); +} + + +void LCD_ShowTrash(uint8_t num, uint8_t val) +{ + uint8_t i; + uint16_t addr = 0; + LCD12864_WriteCommand(0x34); //8Bitָ,ʹ36HҲҪд + LCD12864_WriteCommand(0x36); //ͼON,ָ36Hܿͼ + + for(i = 0; i < 16; i++) + { + LCD12864_WriteCommand(0x90 | i); //λ + if(num == 1) + { + LCD12864_WriteCommand(0x92); //λ + }else{ + LCD12864_WriteCommand(0x96); //λ + } + LCD12864_WriteData((uint8_t)Icon2[val][addr++]); + LCD12864_WriteData((uint8_t)Icon2[val][addr++]); + LCD12864_WriteData((uint8_t)Icon2[val][addr++]); + LCD12864_WriteData((uint8_t)Icon2[val][addr++]); + } + + for(i = 0; i < 16; i++) + { + LCD12864_WriteCommand(0x80 | i); //λ + if(num == 1) + { + LCD12864_WriteCommand(0x8A); //λ + }else{ + LCD12864_WriteCommand(0x8E); //λ + } + LCD12864_WriteData((uint8_t)Icon2[val][addr++]); + LCD12864_WriteData((uint8_t)Icon2[val][addr++]); + LCD12864_WriteData((uint8_t)Icon2[val][addr++]); + LCD12864_WriteData((uint8_t)Icon2[val][addr++]); + } + + for(i = 0; i < 16; i++) + { + LCD12864_WriteCommand(0x90 | i); //λ + if(num == 1) + { + LCD12864_WriteCommand(0x9A); //λ + }else{ + LCD12864_WriteCommand(0x9E); //λ + } + LCD12864_WriteData((uint8_t)Icon2[val][addr++]); + LCD12864_WriteData((uint8_t)Icon2[val][addr++]); + LCD12864_WriteData((uint8_t)Icon2[val][addr++]); + LCD12864_WriteData((uint8_t)Icon2[val][addr++]); + } + + LCD12864_WriteCommand(0x36); + LCD12864_WriteCommand(0x30); +} + +void LCD_ShowTemperatureSymbol(uint8_t num) +{ + uint8_t i; + uint16_t addr = 0; + LCD12864_WriteCommand(0x34); //8Bitָ,ʹ36HҲҪд + LCD12864_WriteCommand(0x36); //ͼON,ָ36Hܿͼ + + for(i = 0; i < 16; i++) + { + LCD12864_WriteCommand(0x90 | i); //λ + if(num == 1) + { + LCD12864_WriteCommand(0x91); //λ + }else{ + LCD12864_WriteCommand(0x95); //λ + } + LCD12864_WriteData((uint8_t)temperatureIcon[addr++]); + LCD12864_WriteData((uint8_t)temperatureIcon[addr++]); + } + LCD12864_WriteCommand(0x36); + LCD12864_WriteCommand(0x30); +} + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd12864.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd12864.h new file mode 100755 index 0000000..a530cb2 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LCD/lcd12864.h @@ -0,0 +1,43 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ lcd12864.h + * lcd12864ʾ + * V1.0 + * XuZhongPing + * 2017/10/16 +*********************************************************************************/ +#ifndef __LCD12864_H +#define __LCD12864_H +#include "stm32f10x.h" +#include "stdio.h" + +#define CS_H GPIO_SetBits(GPIOB, GPIO_Pin_7) //RS(CS) +#define CS_L GPIO_ResetBits(GPIOB, GPIO_Pin_7) +#define SID_H GPIO_SetBits(GPIOB, GPIO_Pin_6) //R/W(SID) +#define SID_L GPIO_ResetBits(GPIOB, GPIO_Pin_6) +#define SCLK_H GPIO_SetBits(GPIOB, GPIO_Pin_5) //E(SCLK) +#define SCLK_L GPIO_ResetBits(GPIOB, GPIO_Pin_5) +// #define PSB_L GPIO_ResetBits(GPIOD, GPIO_Pin_4) //PSB + +void LCD12864_Init(void); +void LCD12864_SendByte(uint8_t zdata); +uint8_t LCD12864_ReceiveByte(void); +void LCD12864_CheckBusy(void); +void LCD12864_WriteCommand(uint8_t cmdcode); +void LCD12864_WriteData(uint8_t dispdata); +uint8_t LCD12864_ReadData(void); +void LCD12864_SetPos(uint8_t x, uint8_t y); +void LCD12864_DrawPoint(uint16_t x, uint16_t y, uint8_t color); +void LCD12864_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); +void LCD12864_DrawRectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2); +void LCD12864_Clear(void); +void LCD12864_DrawModeCtrl(uint8_t param); + +void LCD12864_ShowChar(uint8_t num); +void LCD12864_ShowString(uint8_t x, uint8_t y, char *p); +void LCD12864_ShowNum(uint8_t num); +void LCD12864_ShowxNum(uint8_t x, uint8_t y, uint32_t num, uint8_t len); +void LCD12864_ShowSignal(uint8_t val); + +#endif + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/LED/led.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LED/led.c new file mode 100755 index 0000000..417bd17 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LED/led.c @@ -0,0 +1,137 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ led.c + * LED + * V1.0 + * XuZhongPing + * 2017/09/02 +*********************************************************************************/ +#include "led.h" +#include "timer.h" + +#define SYS_RUNNING_LED_PeriphClock RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO +#define SYS_RUNNING_LED_PORT GPIOB +#define SYS_RUNNING_LED_PORT_PIN GPIO_Pin_4 + +uint8_t ledON_OFF_Status = 0; +uint8_t fillLightMask = 0; + +/* +*********************************************************************** +* : LED_Init +* ˵: ʼLEDƽӿ +* : +* ֵ: +*********************************************************************** +*/ +void LED_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + RCC_APB2PeriphClockCmd(SYS_RUNNING_LED_PeriphClock, ENABLE); + + GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE); + + GPIO_InitStructure.GPIO_Pin = SYS_RUNNING_LED_PORT_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(SYS_RUNNING_LED_PORT, &GPIO_InitStructure); + + GPIO_SetBits(SYS_RUNNING_LED_PORT, SYS_RUNNING_LED_PORT_PIN); +} + +/* +*********************************************************************** +* : SetLedOn +* ˵: LED +* : +* ֵ: +*********************************************************************** +*/ +void SetLedOn(void) +{ + GPIO_ResetBits(SYS_RUNNING_LED_PORT, SYS_RUNNING_LED_PORT_PIN); + ledON_OFF_Status = 1; +} + +/* +*********************************************************************** +* : SetLedOff +* ˵: ϨLED +* : +* ֵ: +*********************************************************************** +*/ +void SetLedOff(void) +{ + GPIO_SetBits(SYS_RUNNING_LED_PORT, SYS_RUNNING_LED_PORT_PIN); + ledON_OFF_Status = 0; +} + +/* +*********************************************************************** +* : SetLedToggle +* ˵: LEDƷת +* : +* ֵ: +*********************************************************************** +*/ +void SetLedToggle(void) +{ + if(ledON_OFF_Status) + { + SetLedOff(); + }else{ + SetLedOn(); + } +} + +/* +*********************************************************************** +* : LED_Task +* ˵: LED״ָ̬ʾ +* : +* ֵ: +*********************************************************************** +*/ +void LED_Task(void) +{ + static uint8_t ledStatus = 0; + + static timer ledOnTimer; + static timer ledOffTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&ledOnTimer, 1); + timer_set(&ledOffTimer, 19); + } + + switch(ledStatus) + { + case 0x00: + SetLedOff(); + if(timer_expired(&ledOffTimer)) + { + timer_restart(&ledOnTimer); + ledStatus = 0x01; + } + break; + + case 0x01: + SetLedOn(); + if(timer_expired(&ledOnTimer)) + { + timer_restart(&ledOffTimer); + ledStatus = 0x00; + } + break; + + default: + ledStatus = 0x00; + break; + } +} + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/LED/led.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LED/led.h new file mode 100755 index 0000000..82456e9 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/LED/led.h @@ -0,0 +1,24 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ led.h + * LED + * V1.0 + * XuZhongPing + * 2017/09/02 +*********************************************************************************/ +#ifndef __LED_H +#define __LED_H + +#include "stm32f10x.h" + +extern uint8_t fillLightMask; + +void LED_Init(void); //ʼ +void SetLedOn(void); +void SetLedOff(void); + +void SetLedToggle(void); +void LED_Task(void); + +#endif + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/door_ctrl.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/door_ctrl.c new file mode 100755 index 0000000..4ae6b02 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/door_ctrl.c @@ -0,0 +1,1469 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ motor.c + * Ƴ + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#include "door_ctrl.h" +#include "motor.h" +#include "ElectronicLock.h" +#include "key.h" +#include "timer.h" +#include "data_typedef.h" + +uint8_t doorResetMark = 0; //Ÿλ״̬ + +/* +*********************************************************************** +* : MotorControlTask_1 +* ˵: 1 +* Σ +* ֵ: +*********************************************************************** +*/ +void MotorControlTask_1(void) +{ + uint8_t tempLimKeyVal = 0; + static uint8_t controlSteps = 0; + uint8_t motorStopMark = 0; //ֹͣ־ + uint16_t tempWeight = 0; + + static uint32_t startTimer = 0; //ſʼʱ + static uint32_t endTimer = 0; //Žʱ + + static uint32_t preRemainingTimer = 0; //һλʣʱ + + static timer waitingTimer_100ms; //ȴ100msʱ + static timer waitingTimer_300ms; //ȴ300msʱ + static timer waitingTimer_500ms; //ȴ500msʱ + static timer waitingTimer_1S; //ȴ1Sʱ + static timer waitingUnlockingTimer; //ʱ + static timer unlockingTimer; //ʱ + static timer openDoorTimer; //ڿʱ + static timer closeDoorTimer; //ڹʱ + static timer waitingTimer_300S; //5ӺԶ + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&waitingTimer_100ms, 1); + timer_set(&waitingTimer_300ms, 3); + timer_set(&waitingTimer_500ms, 5); + timer_set(&waitingTimer_1S, CLOCK_SECOND*1); + timer_set(&waitingUnlockingTimer, 2); //1ʱڿȴ򿪵Ȼٿ + timer_set(&unlockingTimer, 25); //1ʱڿƵʱ + timer_set(&openDoorTimer, 16); //1ʱڿʱ + timer_set(&closeDoorTimer, 20); //1ʱڹʱ + timer_set(&waitingTimer_300S, CLOCK_SECOND*300); //1ʱ5ӺԶ + } + + switch(controlSteps) + { + case 0x00: //ʼ״̬ + if(isOpenDoor_1 == 1) //1 + { + printf("\r\n--> 1!\r\n"); + + //ʼʱõı + isOpenDoor_1 = 0; + isCloseDoorMark_1 = 0; + openDoorCtrlEndMark_1 = 0; + + faultCode_1 = 0x14; + + controlSteps = 0x01; //пתͶŲ + } + break; + + case 0x01: //򿪵 +// Unlock(1); //򿪵 + + timer_restart(&waitingUnlockingTimer); + timer_restart(&unlockingTimer); + controlSteps = 0x02; + break; + + case 0x02: //ȴ + if(timer_expired(&waitingUnlockingTimer)) + { + controlSteps = 0x03; + } + break; + + case 0x03: // + printf("\r\n1\r\n"); + DoorOpen(1); + + controlSteps = 0x04; + printf("\r\nλ1\r\n"); + timer_restart(&openDoorTimer); //ӵǰʱ¿ʼn붨ʱ + break; + + case 0x04: //λ + if(timer_expired(&unlockingTimer)) //ʱ䵽 + { +// Locked(1); + } + + if(timer_expired(&openDoorTimer)) //ʱʱ䵽ˣֹͣ + { + DoorStop(1); //ֹͣ +// Locked(1); + + printf("\r\nλʱֹͣ1\r\n"); + printf("\r\nȴͶ1\r\n"); + timer_restart(&waitingTimer_300S); //ӵǰʱ¿ʼn붨ʱ + controlSteps = 0x05; + break; + } + + if(motorRunningStatus_1 == 0) //Ѿֹͣ + { +// Locked(1); + printf("\r\nȴͶ1\r\n"); + + timer_restart(&waitingTimer_300S); //ӵǰʱ¿ʼn붨ʱ + controlSteps = 0x05; + break; + } + + break; + + case 0x05: //ȴź + if(isCloseDoorMark_1 == 1) + { + isCloseDoorMark_1 = 0; + controlSteps = 0x06; //ת + break; + } + + if(timer_expired(&waitingTimer_300S)) //5Ӷʱʱ䵽ˣֹͣ + { + printf("\r\n5ӳʱԶ1\r\n"); + controlSteps = 0x06; //ת + break; + } + break; + + case 0x06: // + printf("\r\n1ر\r\n"); + DoorClose(1); // + +// printf("\r\nλ1\r\n"); + timer_restart(&closeDoorTimer); //ӵǰʱ¿ʼn붨ʱ + controlSteps = 0x07; + break; + + case 0x07: // + if(timer_expired(&closeDoorTimer)) //ʱʱ䵽ˣֹͣ + { + DoorStop(1); //ֹͣ + +// printf("\r\nʱ䵽ֹͣ1\r\n"); + controlSteps = 0x08; + break; + } + + //λؼ + if(LIMI_KEY1 == 0) + { + DoorStop(1); //ֹͣ + } + + if(motorRunningStatus_1 == 0) //Ѿֹͣ + { + DoorStop(1); +// printf("\r\nM1->Stop\r\n"); + controlSteps = 0x08; //תȴ + break; + } + break; + + case 0x08: //λعϼ + if(LIMI_KEY1 != 0) //λؼ + { + faultCode_1 = 0x32; + limitKeyExceptionMark = 0x20; + devChannel1FaultMark = 1; + printf("\r\nͶ1λ쳣\r\n"); + }else{ + faultCode_1 = 0x14; + } + + controlSteps = 0x09; + +// if(LIMI_KEY1 != 0) //λؼ +// { +// controlSteps = 0x30; +// }else{ +// controlSteps = 0x09; +// } + break; + + case 0x09: //ſƽ + isOpenDoor_1 = 0; + isCloseDoorMark_1 = 0; + + openDoorCtrlEndMark_1 = 1; //־ſƽ + printf("\r\nNo.1 OK\r\n"); + controlSteps = 0x00; + break; + +//------------------------------------------------------------------------------------- +//쳣 + case 0x30: + printf("\r\nE->1\r\n"); +// Unlock(1); //򿪵 + timer_restart(&waitingUnlockingTimer); + controlSteps = 0x31; + break; + + case 0x31: + if(timer_expired(&waitingUnlockingTimer)) + { + printf("\r\nE->1\r\n"); + DoorOpen(1); + + controlSteps = 0x32; + timer_restart(&waitingTimer_100ms); + } + break; + + case 0x32: + if(timer_expired(&waitingTimer_100ms)) + { + printf("\r\nE->1ֹͣ\r\n"); +// Locked(1); + DoorStop(1); //ֹͣ + controlSteps = 0x33; + printf("\r\nE->1λ\r\n"); + } + break; + + case 0x33: + if(DoorReset_1() == 1) + { + controlSteps = 0x34; + } + break; + + case 0x34: + if(LIMI_KEY1 != 0) + { + faultCode_1 = 0x32; + limitKeyExceptionMark = 0x20; + devChannel1FaultMark = 1; + controlSteps = 0x09; + break; + }else{ //ѾָصĴ + faultCode_1 = 0x14; + timer_restart(&waitingTimer_100ms); + controlSteps = 0x09; + } + break; + + default: + controlSteps = 0x00; + break; + } +} + +/* +*********************************************************************** +* : MotorControlTask_1 +* ˵: 1 +* Σ +* ֵ: +*********************************************************************** +*/ +void MotorControlTask_2(void) +{ + uint8_t tempLimKeyVal = 0; + static uint8_t controlSteps = 0; + uint8_t motorStopMark = 0; //ֹͣ־ + uint16_t tempWeight = 0; + + static uint32_t startTimer = 0; //ſʼʱ + static uint32_t endTimer = 0; //Žʱ + + static uint32_t preRemainingTimer = 0; //һλʣʱ + + static timer waitingTimer_100ms; //ȴ100msʱ + static timer waitingTimer_300ms; //ȴ300msʱ + static timer waitingTimer_500ms; //ȴ500msʱ + static timer waitingTimer_1S; //ȴ1Sʱ + static timer waitingUnlockingTimer; //ʱ + static timer unlockingTimer; //ʱ + static timer openDoorTimer; //ڿʱ + static timer closeDoorTimer; //ڹʱ + static timer waitingTimer_300S; //5ӺԶ + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&waitingTimer_100ms, 1); + timer_set(&waitingTimer_300ms, 3); + timer_set(&waitingTimer_500ms, 5); + timer_set(&waitingTimer_1S, CLOCK_SECOND*1); + timer_set(&waitingUnlockingTimer, 2); //1ʱڿȴ򿪵Ȼٿ + timer_set(&unlockingTimer, 25); //1ʱڿƵʱ + timer_set(&openDoorTimer, 16); //1ʱڿʱ + timer_set(&closeDoorTimer, 20); //1ʱڹʱ + timer_set(&waitingTimer_300S, CLOCK_SECOND*300); //1ʱ5ӺԶ + } + + switch(controlSteps) + { + case 0x00: //ʼ״̬ + if(isOpenDoor_2 == 1) //1 + { + printf("\r\n--> 2!\r\n"); + + //ʼʱõı + isOpenDoor_2 = 0; + isCloseDoorMark_2 = 0; + openDoorCtrlEndMark_2 = 0; + + faultCode_2 = 0x14; + + controlSteps = 0x01; //пתͶŲ + } + break; + + case 0x01: //򿪵 +// Unlock(2); //򿪵 + + timer_restart(&waitingUnlockingTimer); + timer_restart(&unlockingTimer); + controlSteps = 0x02; + break; + + case 0x02: //ȴ + if(timer_expired(&waitingUnlockingTimer)) + { + controlSteps = 0x03; + } + break; + + case 0x03: // + printf("\r\n2\r\n"); + DoorOpen(2); + + controlSteps = 0x04; + printf("\r\nλ2\r\n"); + timer_restart(&openDoorTimer); //ӵǰʱ¿ʼn붨ʱ + break; + + case 0x04: //λ + if(timer_expired(&unlockingTimer)) //ʱ䵽 + { +// Locked(2); + } + + if(timer_expired(&openDoorTimer)) //ʱʱ䵽ˣֹͣ + { + DoorStop(2); //ֹͣ +// Locked(2); + + printf("\r\nλʱֹͣ2\r\n"); + printf("\r\nȴͶ2\r\n"); + timer_restart(&waitingTimer_300S); //ӵǰʱ¿ʼn붨ʱ + controlSteps = 0x05; + break; + } + + if(motorRunningStatus_2 == 0) //Ѿֹͣ + { +// Locked(2); + printf("\r\nȴͶ2\r\n"); + + timer_restart(&waitingTimer_300S); //ӵǰʱ¿ʼn붨ʱ + controlSteps = 0x05; + break; + } + + break; + + case 0x05: //ȴź + if(isCloseDoorMark_2 == 1) + { + isCloseDoorMark_2 = 0; + controlSteps = 0x06; //ת + break; + } + + if(timer_expired(&waitingTimer_300S)) //5Ӷʱʱ䵽ˣֹͣ + { + printf("\r\n5ӳʱԶ2\r\n"); + controlSteps = 0x06; //ת + break; + } + break; + + case 0x06: // + printf("\r\n2ر\r\n"); + DoorClose(2); // + +// printf("\r\nλ2\r\n"); + timer_restart(&closeDoorTimer); //ӵǰʱ¿ʼn붨ʱ + controlSteps = 0x07; + break; + + case 0x07: // + if(timer_expired(&closeDoorTimer)) //ʱʱ䵽ˣֹͣ + { + DoorStop(2); //ֹͣ + +// printf("\r\nʱ䵽ֹͣ2\r\n"); + controlSteps = 0x08; + break; + } + + //λؼ + if(LIMI_KEY2 == 0) + { + DoorStop(2); //ֹͣ + } + + if(motorRunningStatus_2 == 0) //Ѿֹͣ + { + DoorStop(2); +// printf("\r\nM2->Stop\r\n"); + controlSteps = 0x08; //תȴ + break; + } + break; + + case 0x08: //λعϼ + if(LIMI_KEY2 != 0) //λؼ + { + faultCode_2 = 0x32; + limitKeyExceptionMark = 0x20; + devChannel2FaultMark = 1; + printf("\r\nͶ2λ쳣\r\n"); + }else{ + faultCode_2 = 0x14; + } + + controlSteps = 0x09; + +// if(LIMI_KEY2 != 0) //λؼ +// { +// controlSteps = 0x30; +// }else{ +// controlSteps = 0x09; +// } + break; + + case 0x09: //ſƽ + isOpenDoor_2 = 0; + isCloseDoorMark_2 = 0; + + openDoorCtrlEndMark_2 = 1; //־ſƽ + printf("\r\nNo.2 OK\r\n"); + controlSteps = 0x00; + break; + +//------------------------------------------------------------------------------------- +//쳣 + case 0x30: + printf("\r\nE->2\r\n"); +// Unlock(2); //򿪵 + timer_restart(&waitingUnlockingTimer); + controlSteps = 0x31; + break; + + case 0x31: + if(timer_expired(&waitingUnlockingTimer)) + { + printf("\r\nE->2\r\n"); + DoorOpen(2); + + controlSteps = 0x32; + timer_restart(&waitingTimer_100ms); + } + break; + + case 0x32: + if(timer_expired(&waitingTimer_100ms)) + { + printf("\r\nE->2ֹͣ\r\n"); +// Locked(2); + DoorStop(2); //ֹͣ + controlSteps = 0x33; + printf("\r\nE->2λ\r\n"); + } + break; + + case 0x33: + if(DoorReset_2() == 1) + { + controlSteps = 0x34; + } + break; + + case 0x34: + if(LIMI_KEY2 != 0) + { + faultCode_2 = 0x32; + limitKeyExceptionMark = 0x20; + devChannel2FaultMark = 1; + controlSteps = 0x09; + break; + }else{ //ѾָصĴ + faultCode_2 = 0x14; + timer_restart(&waitingTimer_100ms); + controlSteps = 0x09; + } + break; + + default: + controlSteps = 0x00; + break; + } +} + +/* +*********************************************************************** +* : MotorControlTask_3 +* ˵: 1 +* Σ +* ֵ: +*********************************************************************** +*/ +void MotorControlTask_3(void) +{ + uint8_t tempLimKeyVal = 0; + static uint8_t controlSteps = 0; + uint8_t motorStopMark = 0; //ֹͣ־ + uint16_t tempWeight = 0; + + static uint32_t startTimer = 0; //ſʼʱ + static uint32_t endTimer = 0; //Žʱ + + static uint32_t preRemainingTimer = 0; //һλʣʱ + + static timer waitingTimer_100ms; //ȴ100msʱ + static timer waitingTimer_300ms; //ȴ300msʱ + static timer waitingTimer_500ms; //ȴ500msʱ + static timer waitingTimer_1S; //ȴ1Sʱ + static timer waitingUnlockingTimer; //ʱ + static timer unlockingTimer; //ʱ + static timer openDoorTimer; //ڿʱ + static timer closeDoorTimer; //ڹʱ + static timer waitingTimer_300S; //5ӺԶ + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&waitingTimer_100ms, 1); + timer_set(&waitingTimer_300ms, 3); + timer_set(&waitingTimer_500ms, 5); + timer_set(&waitingTimer_1S, CLOCK_SECOND*1); + timer_set(&waitingUnlockingTimer, 15); //1ʱڿȴ򿪵Ȼٿ + timer_set(&unlockingTimer, 25); //1ʱڿƵʱ + timer_set(&openDoorTimer, 15); //1ʱڿʱ + timer_set(&closeDoorTimer, 20); //1ʱڹʱ + timer_set(&waitingTimer_300S, CLOCK_SECOND*300); //1ʱ5ӺԶ + } + + switch(controlSteps) + { + case 0x00: //ʼ״̬ + if(isOpenDoor_3 == 1) //1 + { + printf("\r\n--> 3!\r\n"); + + //ʼʱõı + isOpenDoor_3 = 0; + isCloseDoorMark_3 = 0; + openDoorCtrlEndMark_3 = 0; + + faultCode_3 = 0x14; + + controlSteps = 0x01; //пתͶŲ + } + break; + + case 0x01: //򿪵 + Unlock(3); //򿪵 + + timer_restart(&waitingUnlockingTimer); + timer_restart(&unlockingTimer); + controlSteps = 0x02; + break; + + case 0x02: //ȴ + if(timer_expired(&waitingUnlockingTimer)) + { + controlSteps = 0x03; + } + break; + + case 0x03: // + printf("\r\n3\r\n"); + DoorOpen(3); + + controlSteps = 0x04; + printf("\r\nλ3\r\n"); + timer_restart(&openDoorTimer); //ӵǰʱ¿ʼn붨ʱ + break; + + case 0x04: //λ + if(timer_expired(&unlockingTimer)) //ʱ䵽 + { + Locked(3); + } + + if(timer_expired(&openDoorTimer)) //ʱʱ䵽ˣֹͣ + { + DoorStop(3); //ֹͣ + Locked(3); + + printf("\r\nλʱֹͣ3\r\n"); + printf("\r\nȴͶ3\r\n"); + timer_restart(&waitingTimer_300S); //ӵǰʱ¿ʼn붨ʱ + controlSteps = 0x05; + break; + } + + if(motorRunningStatus_3 == 0) //Ѿֹͣ + { + Locked(3); + printf("\r\nȴͶ3\r\n"); + + timer_restart(&waitingTimer_300S); //ӵǰʱ¿ʼn붨ʱ + controlSteps = 0x05; + break; + } + + break; + + case 0x05: //ȴź + if(isCloseDoorMark_3 == 1) + { + isCloseDoorMark_3 = 0; + controlSteps = 0x06; //ת + break; + } + + if(timer_expired(&waitingTimer_300S)) //5Ӷʱʱ䵽ˣֹͣ + { + printf("\r\n5ӳʱԶ3\r\n"); + controlSteps = 0x06; //ת + break; + } + break; + + case 0x06: // + printf("\r\n3ر\r\n"); + DoorClose(3); // + +// printf("\r\nλ3\r\n"); + timer_restart(&closeDoorTimer); //ӵǰʱ¿ʼn붨ʱ + controlSteps = 0x07; + break; + + case 0x07: // + if(timer_expired(&closeDoorTimer)) //ʱʱ䵽ˣֹͣ + { + DoorStop(3); //ֹͣ + +// printf("\r\nʱ䵽ֹͣ3\r\n"); + controlSteps = 0x08; + break; + } + + //λؼ + if(LIMI_KEY3 == 0) + { + DoorStop(3); //ֹͣ + } + + if(motorRunningStatus_3 == 0) //Ѿֹͣ + { + DoorStop(3); +// printf("\r\nM3->Stop\r\n"); + controlSteps = 0x08; //תȴ + break; + } + break; + + case 0x08: //λعϼ + if(LIMI_KEY3 != 0) //λؼ + { + controlSteps = 0x30; + }else{ + controlSteps = 0x09; + } + break; + + case 0x09: //ſƽ + isOpenDoor_3 = 0; + isCloseDoorMark_3 = 0; + + openDoorCtrlEndMark_3 = 1; //־ſƽ + printf("\r\nNo.3 OK\r\n"); + controlSteps = 0x00; + break; + +//------------------------------------------------------------------------------------- +//쳣 + case 0x30: + printf("\r\nE->3\r\n"); + Unlock(3); //򿪵 + timer_restart(&waitingUnlockingTimer); + controlSteps = 0x31; + break; + + case 0x31: + if(timer_expired(&waitingUnlockingTimer)) + { + printf("\r\nE->3\r\n"); + DoorOpen(3); + + controlSteps = 0x32; + timer_restart(&waitingTimer_100ms); + } + break; + + case 0x32: + if(timer_expired(&waitingTimer_100ms)) + { + printf("\r\nE->3ֹͣ\r\n"); + Locked(3); + DoorStop(3); //ֹͣ + controlSteps = 0x33; + printf("\r\nE->3λ\r\n"); + } + break; + + case 0x33: + if(DoorReset_3() == 1) + { + controlSteps = 0x34; + } + break; + + case 0x34: + if(LIMI_KEY3 != 0) + { + faultCode_3 = 0x32; + limitKeyExceptionMark = 0x20; + devChannel3FaultMark = 1; + controlSteps = 0x09; + break; + }else{ //ѾָصĴ + faultCode_3 = 0x14; + timer_restart(&waitingTimer_100ms); + controlSteps = 0x09; + } + break; + + default: + controlSteps = 0x00; + break; + } +} + +/* +*********************************************************************** +* : MotorControlTask_4 +* ˵: 1 +* Σ +* ֵ: +*********************************************************************** +*/ +void MotorControlTask_4(void) +{ + uint8_t tempLimKeyVal = 0; + static uint8_t controlSteps = 0; + uint8_t motorStopMark = 0; //ֹͣ־ + uint16_t tempWeight = 0; + + static uint32_t startTimer = 0; //ſʼʱ + static uint32_t endTimer = 0; //Žʱ + + static uint32_t preRemainingTimer = 0; //һλʣʱ + + static timer waitingTimer_100ms; //ȴ100msʱ + static timer waitingTimer_300ms; //ȴ300msʱ + static timer waitingTimer_500ms; //ȴ500msʱ + static timer waitingTimer_1S; //ȴ1Sʱ + static timer waitingUnlockingTimer; //ʱ + static timer unlockingTimer; //ʱ + static timer openDoorTimer; //ڿʱ + static timer closeDoorTimer; //ڹʱ + static timer waitingTimer_300S; //5ӺԶ + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&waitingTimer_100ms, 1); + timer_set(&waitingTimer_300ms, 3); + timer_set(&waitingTimer_500ms, 5); + timer_set(&waitingTimer_1S, CLOCK_SECOND*1); + timer_set(&waitingUnlockingTimer, 15); //1ʱڿȴ򿪵Ȼٿ + timer_set(&unlockingTimer, 25); //1ʱڿƵʱ + timer_set(&openDoorTimer, 15); //1ʱڿʱ + timer_set(&closeDoorTimer, 20); //1ʱڹʱ + timer_set(&waitingTimer_300S, CLOCK_SECOND*300); //1ʱ5ӺԶ + } + + switch(controlSteps) + { + case 0x00: //ʼ״̬ + if(isOpenDoor_4 == 1) //1 + { + printf("\r\n--> 4!\r\n"); + + //ʼʱõı + isOpenDoor_4 = 0; + isCloseDoorMark_4 = 0; + openDoorCtrlEndMark_4 = 0; + + faultCode_4 = 0x14; + + controlSteps = 0x01; //пתͶŲ + } + break; + + case 0x01: //򿪵 + Unlock(4); //򿪵 + + timer_restart(&waitingUnlockingTimer); + timer_restart(&unlockingTimer); + controlSteps = 0x02; + break; + + case 0x02: //ȴ + if(timer_expired(&waitingUnlockingTimer)) + { + controlSteps = 0x03; + } + break; + + case 0x03: // + printf("\r\n4\r\n"); + DoorOpen(4); + + controlSteps = 0x04; + printf("\r\nλ4\r\n"); + timer_restart(&openDoorTimer); //ӵǰʱ¿ʼn붨ʱ + break; + + case 0x04: //λ + if(timer_expired(&unlockingTimer)) //ʱ䵽 + { + Locked(4); + } + + if(timer_expired(&openDoorTimer)) //ʱʱ䵽ˣֹͣ + { + DoorStop(4); //ֹͣ + Locked(4); + + printf("\r\nλʱֹͣ4\r\n"); + printf("\r\nȴͶ4\r\n"); + timer_restart(&waitingTimer_300S); //ӵǰʱ¿ʼn붨ʱ + controlSteps = 0x05; + break; + } + + if(motorRunningStatus_4 == 0) //Ѿֹͣ + { + Locked(4); + printf("\r\nȴͶ4\r\n"); + + timer_restart(&waitingTimer_300S); //ӵǰʱ¿ʼn붨ʱ + controlSteps = 0x05; + break; + } + + break; + + case 0x05: //ȴź + if(isCloseDoorMark_4 == 1) + { + isCloseDoorMark_4 = 0; + controlSteps = 0x06; //ת + break; + } + + if(timer_expired(&waitingTimer_300S)) //5Ӷʱʱ䵽ˣֹͣ + { + printf("\r\n5ӳʱԶ4\r\n"); + controlSteps = 0x06; //ת + break; + } + break; + + case 0x06: // + printf("\r\n4ر\r\n"); + DoorClose(4); // + +// printf("\r\nλ4\r\n"); + timer_restart(&closeDoorTimer); //ӵǰʱ¿ʼn붨ʱ + controlSteps = 0x07; + break; + + case 0x07: // + if(timer_expired(&closeDoorTimer)) //ʱʱ䵽ˣֹͣ + { + DoorStop(4); //ֹͣ + +// printf("\r\nʱ䵽ֹͣ4\r\n"); + controlSteps = 0x08; + break; + } + + //λؼ + if(LIMI_KEY4 == 0) + { + DoorStop(4); //ֹͣ + } + + if(motorRunningStatus_4 == 0) //Ѿֹͣ + { + DoorStop(4); +// printf("\r\nM4->Stop\r\n"); + controlSteps = 0x08; //תȴ + break; + } + break; + + case 0x08: //λعϼ + if(LIMI_KEY4 != 0) //λؼ + { + controlSteps = 0x30; + }else{ + controlSteps = 0x09; + } + break; + + case 0x09: //ſƽ + isOpenDoor_4 = 0; + isCloseDoorMark_4 = 0; + + openDoorCtrlEndMark_4 = 1; //־ſƽ + printf("\r\nNo.4 OK\r\n"); + controlSteps = 0x00; + break; + +//------------------------------------------------------------------------------------- +//쳣 + case 0x30: + printf("\r\nE->4\r\n"); + Unlock(4); //򿪵 + timer_restart(&waitingUnlockingTimer); + controlSteps = 0x31; + break; + + case 0x31: + if(timer_expired(&waitingUnlockingTimer)) + { + printf("\r\nE->4\r\n"); + DoorOpen(4); + + controlSteps = 0x32; + timer_restart(&waitingTimer_100ms); + } + break; + + case 0x32: + if(timer_expired(&waitingTimer_100ms)) + { + printf("\r\nE->4ֹͣ\r\n"); + Locked(4); + DoorStop(4); //ֹͣ + controlSteps = 0x33; + printf("\r\nE->4λ\r\n"); + } + break; + + case 0x33: + if(DoorReset_4() == 1) + { + controlSteps = 0x34; + } + break; + + case 0x34: + if(LIMI_KEY4 != 0) + { + faultCode_4 = 0x32; + limitKeyExceptionMark = 0x20; + devChannel4FaultMark = 1; + controlSteps = 0x09; + break; + }else{ //ѾָصĴ + faultCode_4 = 0x14; + timer_restart(&waitingTimer_100ms); + controlSteps = 0x09; + } + break; + + default: + controlSteps = 0x00; + break; + } +} + +/* +*********************************************************************** +* : OpenDoorControlTask +* ˵: ſ +* Σ +* ֵ: +*********************************************************************** +*/ +void OpenDoorControlTask(void) +{ + MotorControlTask_1(); + MotorControlTask_2(); + MotorControlTask_3(); + MotorControlTask_4(); +} + +/* +*********************************************************************** +* : DoorReset_1 +* ˵: 1λص +* Σ +* ֵ: λɺ󷵻1 +*********************************************************************** +*/ +uint8_t DoorReset_1(void) +{ + static uint8_t resetStatus = 0x00; //Ÿλ״̬ + uint8_t returnVal = 0; + + static timer resetMotorTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&resetMotorTimer, 20); + } + + //λ̿ + switch(resetStatus) + { + case 0x00: //ʼ״̬ +// printf("\r\n1λ\r\n"); + if(LIMI_KEY1 == 0) //λѾλ + { + resetStatus = 0x03; + }else{ + resetStatus = 0x01; + } + break; + + case 0x01: //Ÿλ + DoorClose(1); // + resetStatus = 0x02; +// printf("\r\n1λλ\r\n"); + timer_restart(&resetMotorTimer); //ӵǰʱ¿ʼn붨ʱ + break; + + case 0x02: //Ѹλɹж + if(timer_expired(&resetMotorTimer)) //ʱʱ䵽ˣֹͣ + { + DoorStop(1); //ֹͣ + + resetStatus = 0x03; +// printf("\r\n1λʱ䵽ֹͣ\r\n"); + break; + } + + //λؼ + if(LIMI_KEY1 == 0) //λؼ + { + DoorStop(1); //ֹͣ +// printf("\r\nR->1ѿλֹͣ\r\n"); + } + +// // +// if(motorCurrentVal_1 > M1_CLOSE_MAX_CurrentVal) //λ⣬ͨжλ +// { +// DoorStop(1); //ֹͣ +// // printf("\r\n1λֵֹͣ = %d\r\n", motorCurrentVal_1); +// } + + if(motorRunningStatus_1 == 0) //Ѿֹͣ + { +// printf("\r\n1Ѿֹͣ\r\n"); + resetStatus = 0x03; + break; + } + break; + + case 0x03: //ɸλ + printf("\r\n1ɸλ\r\n"); + + //һֹͣ + DoorStop(1); //ֹͣ + returnVal = 1; + resetStatus = 0x00; + break; + + default: + printf("\r\n 1λδ֪״̬\r\n"); + + //һ費ֹͣ + DoorStop(1); //ֹͣ + returnVal = 1; + resetStatus = 0x00; + break; + } + + return returnVal; +} + +/* +*********************************************************************** +* : DoorReset_2 +* ˵: 2λص +* Σ +* ֵ: λɺ󷵻1 +*********************************************************************** +*/ +uint8_t DoorReset_2(void) +{ + static uint8_t resetStatus = 0x00; //Ÿλ״̬ + uint8_t returnVal = 0; + + static timer resetMotorTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&resetMotorTimer, 20); + } + + //λ̿ + switch(resetStatus) + { + case 0x00: //ʼ״̬ +// printf("\r\n2λ\r\n"); + + if(LIMI_KEY2 == 0) //λѾλ + { + resetStatus = 0x03; + }else{ + resetStatus = 0x01; + } + break; + + case 0x01: //Ÿλ + DoorClose(2); // + resetStatus = 0x02; +// printf("\r\n2λλ\r\n"); + timer_restart(&resetMotorTimer); //ӵǰʱ¿ʼn붨ʱ + break; + + case 0x02: //Ѹλɹж + if(timer_expired(&resetMotorTimer)) //ʱʱ䵽ˣֹͣ + { + DoorStop(2); //ֹͣ + + resetStatus = 0x03; +// printf("\r\n2λʱ䵽ֹͣ\r\n"); + break; + } + + //λؼ + if(LIMI_KEY2 == 0) //λؼ + { + DoorStop(2); //ֹͣ +// printf("\r\nR->2ѿλֹͣ\r\n"); + } + +// // +// if(motorCurrentVal_2 > M2_CLOSE_MAX_CurrentVal) //λ⣬ͨжλ +// { +// DoorStop(2); //ֹͣ +// // printf("\r\n2λֵֹͣ = %d\r\n", motorCurrentVal_2); +// } + + if(motorRunningStatus_2 == 0) //Ѿֹͣ + { +// printf("\r\n2Ѿֹͣ\r\n"); + resetStatus = 0x03; + break; + } + break; + + case 0x03: //ɸλ + printf("\r\n2ɸλ\r\n"); + + //һֹͣ + DoorStop(2); //ֹͣ + returnVal = 1; + resetStatus = 0x00; + break; + + default: + printf("\r\n 2λδ֪״̬\r\n"); + + //һ費ֹͣ + DoorStop(2); //ֹͣ + returnVal = 1; + resetStatus = 0x00; + break; + } + + return returnVal; +} + +/* +*********************************************************************** +* : DoorReset_3 +* ˵: 3λص +* Σ +* ֵ: λɺ󷵻1 +*********************************************************************** +*/ +uint8_t DoorReset_3(void) +{ + static uint8_t resetStatus = 0x00; //Ÿλ״̬ + uint8_t returnVal = 0; + + static timer resetMotorTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&resetMotorTimer, 20); + } + + //λ̿ + switch(resetStatus) + { + case 0x00: //ʼ״̬ +// printf("\r\n3λ\r\n"); + if(LIMI_KEY3 == 0) //λѾλ + { + resetStatus = 0x03; + }else{ + resetStatus = 0x01; + } + break; + + case 0x01: //Ÿλ + DoorClose(3); // + resetStatus = 0x02; +// printf("\r\n3λλ\r\n"); + timer_restart(&resetMotorTimer); //ӵǰʱ¿ʼn붨ʱ + break; + + case 0x02: //Ѹλɹж + if(timer_expired(&resetMotorTimer)) //ʱʱ䵽ˣֹͣ + { + DoorStop(3); //ֹͣ + + resetStatus = 0x03; +// printf("\r\n3λʱ䵽ֹͣ\r\n"); + break; + } + + //λؼ + if(LIMI_KEY3 == 0) //λؼ + { + DoorStop(3); //ֹͣ +// printf("\r\nR->3ѿλֹͣ\r\n"); + } + +// // +// if(motorCurrentVal_2 > M2_CLOSE_MAX_CurrentVal) //λ⣬ͨжλ +// { +// DoorStop(2); //ֹͣ +// // printf("\r\n2λֵֹͣ = %d\r\n", motorCurrentVal_2); +// } + + if(motorRunningStatus_3 == 0) //Ѿֹͣ + { +// printf("\r\n3Ѿֹͣ\r\n"); + resetStatus = 0x03; + break; + } + break; + + case 0x03: //ɸλ + printf("\r\n3ɸλ\r\n"); + + //һֹͣ + DoorStop(3); //ֹͣ + returnVal = 1; + resetStatus = 0x00; + break; + + default: + printf("\r\n 3λδ֪״̬\r\n"); + + //һ費ֹͣ + DoorStop(3); //ֹͣ + returnVal = 1; + resetStatus = 0x00; + break; + } + + return returnVal; +} + +/* +*********************************************************************** +* : DoorReset_4 +* ˵: 4λص +* Σ +* ֵ: λɺ󷵻1 +*********************************************************************** +*/ +uint8_t DoorReset_4(void) +{ + static uint8_t resetStatus = 0x00; //Ÿλ״̬ + uint8_t returnVal = 0; + + static timer resetMotorTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&resetMotorTimer, 20); + } + + //λ̿ + switch(resetStatus) + { + case 0x00: //ʼ״̬ +// printf("\r\n4λ\r\n"); + + if(LIMI_KEY4 == 0) //λѾλ + { + resetStatus = 0x03; + }else{ + resetStatus = 0x01; + } + break; + + case 0x01: //Ÿλ + DoorClose(4); // + resetStatus = 0x02; +// printf("\r\n4λλ\r\n"); + timer_restart(&resetMotorTimer); //ӵǰʱ¿ʼn붨ʱ + break; + + case 0x02: //Ѹλɹж + if(timer_expired(&resetMotorTimer)) //ʱʱ䵽ˣֹͣ + { + DoorStop(4); //ֹͣ + + resetStatus = 0x03; +// printf("\r\n4λʱ䵽ֹͣ\r\n"); + break; + } + + //λؼ + if(LIMI_KEY4 == 0) //λؼ + { + DoorStop(4); //ֹͣ +// printf("\r\nR->2ѿλֹͣ\r\n"); + } + +// // +// if(motorCurrentVal_2 > M2_CLOSE_MAX_CurrentVal) //λ⣬ͨжλ +// { +// DoorStop(2); //ֹͣ +// // printf("\r\n2λֵֹͣ = %d\r\n", motorCurrentVal_2); +// } + + if(motorRunningStatus_4 == 0) //Ѿֹͣ + { +// printf("\r\n4Ѿֹͣ\r\n"); + resetStatus = 0x03; + break; + } + break; + + case 0x03: //ɸλ + printf("\r\n4ɸλ\r\n"); + + //һֹͣ + DoorStop(4); //ֹͣ + returnVal = 1; + resetStatus = 0x00; + break; + + default: + printf("\r\n 4λδ֪״̬\r\n"); + + //һ費ֹͣ + DoorStop(4); //ֹͣ + returnVal = 1; + resetStatus = 0x00; + break; + } + + return returnVal; +} + +/* +*********************************************************************** +* : DoorResetTask +* ˵: ʼϵŸλص +* Σ +* ֵ: ޣıdoorResetMark״̬ +*********************************************************************** +*/ +void DoorResetTask(void) +{ + static uint8_t doorResetStatus_1 = 0; + static uint8_t doorResetStatus_2 = 0; + static uint8_t doorResetStatus_3 = 0; + static uint8_t doorResetStatus_4 = 0; + + if(doorResetStatus_1 == 0) + { + doorResetStatus_1 = DoorReset_1(); + } + + if(doorResetStatus_2 == 0) + { + doorResetStatus_2 = DoorReset_2(); + } + + if(doorResetStatus_3 == 0) + { + doorResetStatus_3 = DoorReset_3(); + } + + if(doorResetStatus_4 == 0) + { + doorResetStatus_4 = DoorReset_4(); + } + + if((doorResetStatus_1 == 1) && (doorResetStatus_2 == 1) && + (doorResetStatus_3 == 1) && (doorResetStatus_4 == 1)) + { + doorResetMark = 1; + } +} + +/******************** (C) COPYRIGHT 2017 ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/door_ctrl.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/door_ctrl.h new file mode 100755 index 0000000..037d791 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/door_ctrl.h @@ -0,0 +1,26 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ door_ctrl.h + * ͶſڿƳ + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#ifndef __DOOR_CTRL_H +#define __DOOR_CTRL_H + +#include "stm32f10x.h" +#include "stdio.h" + +extern uint8_t doorResetMark; //Ÿλ״̬ + +void OpenDoorControlTask(void); + +uint8_t DoorReset_1(void); +uint8_t DoorReset_2(void); +uint8_t DoorReset_3(void); +uint8_t DoorReset_4(void); +void DoorResetTask(void); + +#endif + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/motor.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/motor.c new file mode 100755 index 0000000..c19d681 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/motor.c @@ -0,0 +1,474 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ motor.c + * Ƴ + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#include "motor.h" +#include "delay.h" +#include "timer.h" +#include "adc.h" +#include "my_math.h" +#include "device.h" + +//ʹõIOڶ +#define MOTOR1_PORT_PeriphClock_A RCC_APB2Periph_GPIOB +#define MOTOR1_PORT_A GPIOB +#define MOTOR1_CTRL_PIN_A GPIO_Pin_15 +#define MOTOR1_PORT_PeriphClock_B RCC_APB2Periph_GPIOC +#define MOTOR1_PORT_B GPIOC +#define MOTOR1_CTRL_PIN_B GPIO_Pin_6 + +#define MOTOR2_PORT_PeriphClock_A RCC_APB2Periph_GPIOC +#define MOTOR2_PORT_A GPIOC +#define MOTOR2_CTRL_PIN_A GPIO_Pin_7 +#define MOTOR2_PORT_PeriphClock_B RCC_APB2Periph_GPIOC +#define MOTOR2_PORT_B GPIOC +#define MOTOR2_CTRL_PIN_B GPIO_Pin_8 + +#define MOTOR3_PORT_PeriphClock_A RCC_APB2Periph_GPIOC +#define MOTOR3_PORT_A GPIOC +#define MOTOR3_CTRL_PIN_A GPIO_Pin_9 +#define MOTOR3_PORT_PeriphClock_B RCC_APB2Periph_GPIOA +#define MOTOR3_PORT_B GPIOA +#define MOTOR3_CTRL_PIN_B GPIO_Pin_8 + +#define MOTOR4_PORT_PeriphClock_A RCC_APB2Periph_GPIOA +#define MOTOR4_PORT_A GPIOA +#define MOTOR4_CTRL_PIN_A GPIO_Pin_11 +#define MOTOR4_PORT_PeriphClock_B RCC_APB2Periph_GPIOA +#define MOTOR4_PORT_B GPIOA +#define MOTOR4_CTRL_PIN_B GPIO_Pin_12 + + +#define CurrentValSize 50 +uint16_t motorCurrentValBuf_1[CurrentValSize]; +uint16_t motorCurrentVal_1 = 0; +uint8_t motorRunningStatus_1 = 0; +uint8_t motorPreStatus_1 = 0; + +uint16_t motorCurrentValBuf_2[CurrentValSize]; +uint16_t motorCurrentVal_2 = 0; +uint8_t motorRunningStatus_2 = 0; +uint8_t motorPreStatus_2 = 0; + +uint8_t motorRunningStatus_3 = 0; +uint8_t motorRunningStatus_4 = 0; + +/* +*********************************************************************** +* : MotorInit +* ˵: IOڳʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void MotorInit(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + + RCC_APB2PeriphClockCmd(MOTOR1_PORT_PeriphClock_A, ENABLE); + RCC_APB2PeriphClockCmd(MOTOR1_PORT_PeriphClock_B, ENABLE); + RCC_APB2PeriphClockCmd(MOTOR2_PORT_PeriphClock_A, ENABLE); + RCC_APB2PeriphClockCmd(MOTOR2_PORT_PeriphClock_B, ENABLE); + RCC_APB2PeriphClockCmd(MOTOR3_PORT_PeriphClock_A, ENABLE); + RCC_APB2PeriphClockCmd(MOTOR3_PORT_PeriphClock_B, ENABLE); + RCC_APB2PeriphClockCmd(MOTOR4_PORT_PeriphClock_A, ENABLE); + RCC_APB2PeriphClockCmd(MOTOR4_PORT_PeriphClock_B, ENABLE); + + //1IOڳʼ + GPIO_InitStructure.GPIO_Pin = MOTOR1_CTRL_PIN_A; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(MOTOR1_PORT_A, &GPIO_InitStructure); + GPIO_ResetBits(MOTOR1_PORT_A, MOTOR1_CTRL_PIN_A); + + GPIO_InitStructure.GPIO_Pin = MOTOR1_CTRL_PIN_B; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(MOTOR1_PORT_B, &GPIO_InitStructure); + GPIO_ResetBits(MOTOR1_PORT_B, MOTOR1_CTRL_PIN_B); + + //2IOڳʼ + GPIO_InitStructure.GPIO_Pin = MOTOR2_CTRL_PIN_A; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(MOTOR2_PORT_A, &GPIO_InitStructure); + GPIO_ResetBits(MOTOR2_PORT_A, MOTOR2_CTRL_PIN_A); + + GPIO_InitStructure.GPIO_Pin = MOTOR2_CTRL_PIN_B; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(MOTOR2_PORT_B, &GPIO_InitStructure); + GPIO_ResetBits(MOTOR2_PORT_B, MOTOR2_CTRL_PIN_B); + + //3IOڳʼ + GPIO_InitStructure.GPIO_Pin = MOTOR3_CTRL_PIN_A; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(MOTOR3_PORT_A, &GPIO_InitStructure); + GPIO_ResetBits(MOTOR3_PORT_A, MOTOR3_CTRL_PIN_A); + + GPIO_InitStructure.GPIO_Pin = MOTOR3_CTRL_PIN_B; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(MOTOR3_PORT_B, &GPIO_InitStructure); + GPIO_ResetBits(MOTOR3_PORT_B, MOTOR3_CTRL_PIN_B); + + //4IOڳʼ + GPIO_InitStructure.GPIO_Pin = MOTOR4_CTRL_PIN_A; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(MOTOR4_PORT_A, &GPIO_InitStructure); + GPIO_ResetBits(MOTOR4_PORT_A, MOTOR4_CTRL_PIN_A); + + GPIO_InitStructure.GPIO_Pin = MOTOR4_CTRL_PIN_B; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(MOTOR4_PORT_B, &GPIO_InitStructure); + GPIO_ResetBits(MOTOR4_PORT_B, MOTOR4_CTRL_PIN_B); +} + +/* +*********************************************************************** +* : DoorOpen +* ˵: +* Σnum -> һ +* ֵ: +*********************************************************************** +*/ +void DoorOpen(uint8_t num) +{ + printf("\r\n%dת\r\n", num); + switch(num) + { + case 0x01: + GPIO_ResetBits(MOTOR1_PORT_A, MOTOR1_CTRL_PIN_A); + GPIO_SetBits(MOTOR1_PORT_B, MOTOR1_CTRL_PIN_B); + motorRunningStatus_1 = 1; + break; + + case 0x02: + GPIO_ResetBits(MOTOR2_PORT_A, MOTOR2_CTRL_PIN_A); + GPIO_SetBits(MOTOR2_PORT_B, MOTOR2_CTRL_PIN_B); + motorRunningStatus_2 = 1; + break; + + case 0x03: + GPIO_ResetBits(MOTOR3_PORT_A, MOTOR3_CTRL_PIN_A); + GPIO_SetBits(MOTOR3_PORT_B, MOTOR3_CTRL_PIN_B); + motorRunningStatus_3 = 1; + break; + + case 0x04: + GPIO_ResetBits(MOTOR4_PORT_A, MOTOR4_CTRL_PIN_A); + GPIO_SetBits(MOTOR4_PORT_B, MOTOR4_CTRL_PIN_B); + motorRunningStatus_4 = 1; + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : DoorClose +* ˵: +* Σ +* ֵ: +*********************************************************************** +*/ +void DoorClose(uint8_t num) +{ + printf("\r\n%dת\r\n", num); + switch(num) + { + case 0x01: + GPIO_SetBits(MOTOR1_PORT_A, MOTOR1_CTRL_PIN_A); + GPIO_ResetBits(MOTOR1_PORT_B, MOTOR1_CTRL_PIN_B); + motorRunningStatus_1 = 2; + break; + + case 0x02: + GPIO_SetBits(MOTOR2_PORT_A, MOTOR2_CTRL_PIN_A); + GPIO_ResetBits(MOTOR2_PORT_B, MOTOR2_CTRL_PIN_B); + motorRunningStatus_2 = 2; + break; + + case 0x03: + GPIO_SetBits(MOTOR3_PORT_A, MOTOR3_CTRL_PIN_A); + GPIO_ResetBits(MOTOR3_PORT_B, MOTOR3_CTRL_PIN_B); + motorRunningStatus_3 = 2; + break; + + case 0x04: + GPIO_SetBits(MOTOR4_PORT_A, MOTOR4_CTRL_PIN_A); + GPIO_ResetBits(MOTOR4_PORT_B, MOTOR4_CTRL_PIN_B); + motorRunningStatus_4 = 2; + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : DoorStop +* ˵: ֹͣ +* Σ +* ֵ: +*********************************************************************** +*/ +void DoorStop(uint8_t num) +{ + switch(num) + { + case 0x01: + GPIO_ResetBits(MOTOR1_PORT_A, MOTOR1_CTRL_PIN_A); + GPIO_ResetBits(MOTOR1_PORT_B, MOTOR1_CTRL_PIN_B); + + if(motorRunningStatus_1 > 0) //ԭ״̬תֹͣŴӡʾ + { + printf("\r\n%dֹͣ\r\n", num); + } + motorRunningStatus_1 = 0; + break; + + case 0x02: + GPIO_ResetBits(MOTOR2_PORT_A, MOTOR2_CTRL_PIN_A); + GPIO_ResetBits(MOTOR2_PORT_B, MOTOR2_CTRL_PIN_B); + + if(motorRunningStatus_2 > 0) //ԭ״̬תֹͣŴӡʾ + { + printf("\r\n%dֹͣ\r\n", num); + } + motorRunningStatus_2 = 0; + break; + + case 0x03: + GPIO_ResetBits(MOTOR3_PORT_A, MOTOR3_CTRL_PIN_A); + GPIO_ResetBits(MOTOR3_PORT_B, MOTOR3_CTRL_PIN_B); + + if(motorRunningStatus_3 > 0) //ԭ״̬תֹͣŴӡʾ + { + printf("\r\n%dֹͣ\r\n", num); + } + motorRunningStatus_3 = 0; + break; + + case 0x04: + GPIO_ResetBits(MOTOR4_PORT_A, MOTOR4_CTRL_PIN_A); + GPIO_ResetBits(MOTOR4_PORT_B, MOTOR4_CTRL_PIN_B); + + if(motorRunningStatus_4 > 0) //ԭ״̬תֹͣŴӡʾ + { + printf("\r\n%dֹͣ\r\n", num); + } + motorRunningStatus_4 = 0; + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : Get_MotorCurrentVal +* ˵: ȡ1 +* Σ +* ֵ: +*********************************************************************** +*/ +void Get_MotorCurrentVal_1(void) +{ + Data_collection(motorCurrentValBuf_1, CurrentValSize, ADC_Channel_8); + sort_16(motorCurrentValBuf_1, CurrentValSize); //ԴڻеIJɼݽ + motorCurrentVal_1 = average_16(motorCurrentValBuf_1, CurrentValSize, 20); //ȥͷβƽ +} + +/* +*********************************************************************** +* : Get_MotorCurrentVal +* ˵: ȡ2 +* Σ +* ֵ: +*********************************************************************** +*/ +void Get_MotorCurrentVal_2(void) +{ + Data_collection(motorCurrentValBuf_2, CurrentValSize, ADC_Channel_9); + sort_16(motorCurrentValBuf_2, CurrentValSize); //ԴڻеIJɼݽ + motorCurrentVal_2 = average_16(motorCurrentValBuf_2, CurrentValSize, 20); //ȥͷβƽ +} + + +/* +*********************************************************************** +* : Get_MotorCurrentVal +* ˵: ȡ +* Σ +* ֵ: +*********************************************************************** +*/ +void Get_MotorCurrentVal(void) +{ + Get_MotorCurrentVal_1(); + Get_MotorCurrentVal_2(); +// printf("%4d, %4d\r\n", motorCurrentVal_1, motorCurrentVal_2); +} + +/* +*********************************************************************** +* : MotorTest +* ˵: ƲԳ +* Σ +* ֵ: +*********************************************************************** +*/ +void MotorTest(void) +{ + static uint8_t motorNum = 1; + static uint8_t motorStatus = 0; + + static timer timer_01, timer_02; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&timer_01, 20); + timer_set(&timer_02, CLOCK_SECOND*2); + } + switch(motorStatus) + { + case 0x00: + if(timer_expired(&timer_01)) + { + DoorOpen(motorNum); + timer_restart(&timer_01); + motorStatus = 0x01; + break; + } + break; + + case 0x01: + if(timer_expired(&timer_01)) + { + DoorStop(motorNum); + timer_restart(&timer_02); + motorStatus = 0x02; + break; + } + break; + + case 0x02: + if(timer_expired(&timer_02)) + { + DoorClose(motorNum); + timer_restart(&timer_01); + motorStatus = 0x03; + break; + } + break; + + case 0x03: + if(timer_expired(&timer_01)) + { + DoorStop(motorNum); + timer_restart(&timer_02); + motorStatus = 0x04; + break; + } + break; + + case 0x04: + if(timer_expired(&timer_02)) + { + motorNum++; + if(motorNum >= 5) + { + motorNum = 1; + } + motorStatus = 0x00; + break; + } + break; + } +} + +/* +*********************************************************************** +* : Get_MotorCurrentVal +* ˵: ȡ +* Σ +* ֵ: +*********************************************************************** +*/ +void MotorCtrlTask2(void) +{ + static timer timer_01, timer_02; + static uint8_t timer_ok = 0; + static uint8_t motorStatus = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&timer_01, 1); + timer_set(&timer_02, CLOCK_SECOND*2); + } + switch(motorStatus) + { + case 0x00: + if(motorRunningStatus_2) + { + motorStatus = 0x01; + timer_restart(&timer_01); + } + break; + + case 0x01: + if(timer_expired(&timer_01)) + { + motorStatus = 0x02; + } + break; + + case 0x02: + if(motorCurrentVal_2 > 600) + { + motorPreStatus_2 = motorRunningStatus_2; + motorRunningStatus_2 = 0; + motorStatus = 0x03; + timer_restart(&timer_02); + } + break; + + case 0x03: + if(timer_expired(&timer_02)) + { + if(motorPreStatus_2 == 1) + { + motorRunningStatus_2 = 2; + }else{ + motorRunningStatus_2 = 1; + } + motorStatus = 0x00; + } + break; + } + + if(motorRunningStatus_2 == 0) + { + DoorStop(2); + }else if(motorRunningStatus_2 == 1){ + DoorClose(2); + }else{ + DoorOpen(2); + } +} + +/******************** (C) COPYRIGHT 2017 ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/motor.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/motor.h new file mode 100755 index 0000000..0b08326 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/MOTOR/motor.h @@ -0,0 +1,39 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ motor.h + * Ƴ + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#ifndef __MOTOR_H +#define __MOTOR_H + +#include "stm32f10x.h" + +#define M1_OPEN_MAX_CurrentVal 3000 +#define M1_CLOSE_MAX_CurrentVal 3000 + +#define M2_OPEN_MAX_CurrentVal 3000 +#define M2_CLOSE_MAX_CurrentVal 3000 + +extern uint16_t motorCurrentVal_1; +extern uint8_t motorRunningStatus_1; + +extern uint16_t motorCurrentVal_2; +extern uint8_t motorRunningStatus_2; + +extern uint8_t motorRunningStatus_3; +extern uint8_t motorRunningStatus_4; + +void MotorInit(void); +void DoorOpen(uint8_t num); +void DoorClose(uint8_t num); +void DoorStop(uint8_t num); + +void Get_MotorCurrentVal(void); + +void MotorTest(void); + +#endif + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/NTC_ADC/adc.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/NTC_ADC/adc.c new file mode 100755 index 0000000..cdbe05b --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/NTC_ADC/adc.c @@ -0,0 +1,113 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ adc.c + * ADC + * V1.0 + * XuZhongPing + * 2017/04/30 +*********************************************************************************/ +#include "adc.h" + +/* +*********************************************************************** +* : Adc_Init +* ˵: ʼADC +* Σ +* ֵ: +*********************************************************************** +*/ +void Adc_Init(void) +{ + ADC_InitTypeDef ADC_InitStructure; + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOC | RCC_APB2Periph_ADC1, ENABLE); //ʹADC1ͨʱ + + RCC_ADCCLKConfig(RCC_PCLK2_Div6); //72M/6=12,ADCʱ䲻ܳ14M + + //ⲿ¶ȼ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; //ģ + GPIO_Init(GPIOC, &GPIO_InitStructure); + + //¶ȼ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; //ģ + GPIO_Init(GPIOA, &GPIO_InitStructure); + + // + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; //ģ + GPIO_Init(GPIOB, &GPIO_InitStructure); + + //ADC + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; //ģ + GPIO_Init(GPIOC, &GPIO_InitStructure); + + ADC_DeInit(ADC1); // ADC1 ȫĴΪȱʡֵ + + ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; //ADCģʽ:ADC1ADC2ڶģʽ + ADC_InitStructure.ADC_ScanConvMode = DISABLE; //ģתڵͨģʽ + ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; //ģתڵתģʽ + ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; //תⲿ + ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; //ADCҶ + ADC_InitStructure.ADC_NbrOfChannel = 1; //˳йתADCͨĿ + ADC_Init(ADC1, &ADC_InitStructure); //ADC_InitStructָIJʼADCxļĴ + + + ADC_Cmd(ADC1, ENABLE); //ʹָADC1 + + ADC_ResetCalibration(ADC1); //ָADC1У׼Ĵ + + while(ADC_GetResetCalibrationStatus(ADC1)); //ȡADC1У׼Ĵ״̬,״̬ȴ + + ADC_StartCalibration(ADC1); //ʼָADC1У׼״̬ + + while(ADC_GetCalibrationStatus(ADC1)); //ȡָADC1У׼,״̬ȴ + + ADC_SoftwareStartConvCmd(ADC1, ENABLE); //ʹָADC1ת + +} + +/* +*********************************************************************** +* : Get_Adc +* ˵: ADCֵ +* Σch:ֵͨ 0~3 +* ֵ: +*********************************************************************** +*/ +uint16_t GetADC(uint8_t ch) +{ + //ָADCĹͨǵת˳Ͳʱ + ADC_RegularChannelConfig(ADC1, ch, 1, ADC_SampleTime_28Cycles5); +// ADC_RegularChannelConfig(ADC1, ch, 1, ADC_SampleTime_239Cycles5 ); //ADC1,ADCͨ3,˳ֵΪ1,ʱΪ239.5 + + ADC_SoftwareStartConvCmd(ADC1, ENABLE); //ʹָADC1ת + + while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC)); //ȴת + + return ADC_GetConversionValue(ADC1); //һADC1ת +} + +/* +*********************************************************************** +* : Data_collection +* ˵: ݲɼ +* Σ +* x[]:Ҫ +* n:ɼĴ +* ch:ɼͨ +* ֵ: +*********************************************************************** +*/ +void Data_collection(uint16_t x[], uint16_t n, uint8_t ch) +{ + uint8_t i; + + for(i=0; i Ҫ˲ֵ +* ch -> ɼͨ +* ֵ: ˲Ľ +*********************************************************************** +*/ +uint16_t filter(uint16_t value, uint8_t ch) +{ + uint8_t count=0; + uint16_t new_value; + new_value = data_input(adc_buf, ADC_SIZE, ch); + while (value != new_value) + { + count++; + if (count >= FILTER_SIZE) return new_value; + new_value = data_input(adc_buf, ADC_SIZE, ch); + } + return value; +} + +/* +*********************************************************************** +* : Get_NTC_values +* ˵: ȡAD8,AD9ɼ +* Σ +* ֵ: +*********************************************************************** +*/ +void Get_NTC_values(void) +{ + NTC1_value = filter(NTC1_value, ADC_Channel_14); + NTC2_value = filter(NTC2_value, ADC_Channel_15); + NTC3_value = filter(NTC3_value, ADC_Channel_4); +// printf("\r\nNTC1_value = %d NTC2_value = %d\r\n", NTC1_value, NTC2_value); +} + +/* +*********************************************************************** +* : GetTemperatureTask +* ˵: ¶Ȳɼ +* Σ +* ֵ: +*********************************************************************** +*/ +void GetTemperatureTask(void) +{ + uint8_t i; + + static timer getTemperatureTimer; //ɼʱ + static timer waitingTimer; + + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&getTemperatureTimer, CLOCK_SECOND*10); + timer_set(&waitingTimer, CLOCK_SECOND*30); + } + + if(timer_expired(&getTemperatureTimer)) //ÿ10Sɼһ¶ + { + timer_restart(&getTemperatureTimer); + + +// if((temperature_A > 0) || (temperature_B > 0) || (temperature_C > 0)) +// { +// printf("\r\n¶ȣNo1 = %2.1f , No2 = %2.1f , No3 = %2.1f , Out = %2.1f \r\n", (float)temperature_A, (float)temperature_B, (float)temperature_C, (float)temperature); +// } + +// printf("\r\n¶ȣ%2.1f \r\n", (float)temperature_C); + + } + + if(temperature_A > temperature_B){ + temperature = temperature_A; + }else{ + temperature = temperature_B; + } + + if(temperature < temperature_C) + { + temperature = temperature_C; + } + + if(timer_expired(&waitingTimer)) + { + timer_restart(&waitingTimer); + + printf("\r\n¶ȣ%2.1f \r\n", (float)temperature); + } +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/NTC_ADC/ntc.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/NTC_ADC/ntc.h new file mode 100755 index 0000000..8ed4538 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/NTC_ADC/ntc.h @@ -0,0 +1,26 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ ntc.h + * NTC¶ȴͷļ + * V1.0 + * XuZhongPing + * 2017/04/30 +*********************************************************************************/ +#ifndef __ADC_INPUT_h +#define __ADC_INPUT_h + +#include "adc.h" + +extern uint16_t NTC1_value, NTC2_value; //ͨɼֵ + +extern uint8_t temperature; //¶ +extern uint8_t temperature_A; //A·¶ +extern uint8_t temperature_B; //B·¶ +extern uint8_t temperature_C; //B·¶ + + +void Get_NTC_values(void); //ȡɼ +void GetTemperatureTask(void); //¶Ȳɼ + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/NTC_ADC/ntc_10K_tab.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/NTC_ADC/ntc_10K_tab.h new file mode 100755 index 0000000..61d6b7d --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/NTC_ADC/ntc_10K_tab.h @@ -0,0 +1,31 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ ntc_10K_tab.h + * NTCӦADCֵ + * V1.0 + * XuZhongPing + * 2017/04/30 +*********************************************************************************/ +#ifndef __NTC_10K_TAB_h +#define __NTC_10K_TAB_h + +#include "stdint.h" + +#define TempSize 100 // + +const uint16_t TabNTC_10K[TempSize] = +{ + 2548,2498,2448,2398,2348,2297,2247,2197,2147,2097, + 2047,1998,1949,1900,1852,1805,1758,1711,1666,1620, + 1576,1532,1489,1447,1406,1365,1326,1287,1249,1212, + 1175,1140,1105,1072,1039,1007, 976, 945, 916, 887, + 859, 833, 806, 781, 756, 732, 709, 686, 665, 644, + 623, 603, 584, 565, 547, 530, 513, 497, 481, 466, + 451, 437, 423, 410, 397, 385, 372, 361, 350, 339, + 328, 318, 308, 299, 289, 281, 272, 264, 256, 248, + 241, 233, 226, 220, 213, 207, 201, 195, 189, 183, + 178, 173, 168, 163, 158, 154, 150, 145, 141, 137 +}; + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/OPTO_SWITCH/opto_sw_key.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/OPTO_SWITCH/opto_sw_key.c new file mode 100755 index 0000000..8304874 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/OPTO_SWITCH/opto_sw_key.c @@ -0,0 +1,367 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ opto_sw_key.c + * 翪 + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#include "opto_sw_key.h" +#include "delay.h" +#include "timer.h" +#include "device.h" +#include "data_typedef.h" + +//翪 +#define OPTO_KEY1_PORT GPIOA +#define OPTO_KEY1_PIN GPIO_Pin_8 + +#define OPTO_KEY2_PORT GPIOB +#define OPTO_KEY2_PIN GPIO_Pin_7 + +#define OPTO_KEY3_PORT GPIOD +#define OPTO_KEY3_PIN GPIO_Pin_0 + +#define OPTO_KEY4_PORT GPIOD +#define OPTO_KEY4_PIN GPIO_Pin_3 + + +uint8_t optoKeyValue1 = 0; //翪ؼֵ +uint8_t optoKeyValue2 = 0; //翪ؼֵ +uint8_t optoKeyValue3 = 0; //翪ؼֵ +uint8_t optoKeyValue4 = 0; //翪ؼֵ + +/* +*********************************************************************** +* : OptoKeyInit +* ˵: 翪IOڳʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void OptoKeyInit(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | + RCC_APB2Periph_GPIOB | + RCC_APB2Periph_GPIOD, ENABLE); //ʹPORTAʱ + + //һ·翪IO + GPIO_InitStructure.GPIO_Pin = OPTO_KEY1_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(OPTO_KEY1_PORT, &GPIO_InitStructure); + + //ڶ·翪IO + GPIO_InitStructure.GPIO_Pin = OPTO_KEY2_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(OPTO_KEY2_PORT, &GPIO_InitStructure); + + //·翪IO + GPIO_InitStructure.GPIO_Pin = OPTO_KEY3_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(OPTO_KEY3_PORT, &GPIO_InitStructure); + + //·翪IO + GPIO_InitStructure.GPIO_Pin = OPTO_KEY4_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; + GPIO_Init(OPTO_KEY4_PORT, &GPIO_InitStructure); +} + +/* +*********************************************************************** +* : OptoKeysCanning +* ˵: 翪ؼ +* Σ +* ֵ: +*********************************************************************** +*/ +void OptoKeysCanning(void) +{ + static uint8_t key1_state = 0; + static uint8_t key2_state = 0; + + //1·翪ؼ + switch (key1_state) + { + case 0x00: + if(OPTO_KEY1 == 0) + { + key1_state = 0x01; + } + break; + + case 0x01: + if(OPTO_KEY1 == 0) + { + optoKeyValue1 = 1; + }else{ + optoKeyValue1 = 0; + key1_state = 0x00; + } + break; + + default: + key1_state = 0x00; + break; + } + + //2·翪ؼ + switch (key2_state) + { + case 0x00: + if(OPTO_KEY2 == 0) + { + key2_state = 0x01; + } + break; + + case 0x01: + if(OPTO_KEY2 == 0) + { + optoKeyValue2 = 1; + }else{ + optoKeyValue2 = 0; + key2_state = 0x00; + } + break; + + default: + key2_state = 0x00; + break; + } +} + +/* +*********************************************************************** +* : BottleScanning +* ˵: ƿͶɨ +* Σ +* ֵ: ضӦصļֵ +*********************************************************************** +*/ +void BottleScanning(void) +{ + static uint8_t bottleType = 0; + static uint16_t count; + static uint8_t testStatus = 0x00; + + static timer timerOut; + static timer waitingTimer; + static timer wrongOperationTimer; + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&timerOut, 4); + timer_set(&waitingTimer, CLOCK_SECOND*5); + timer_set(&wrongOperationTimer, CLOCK_SECOND*3); + } + + switch(testStatus) + { + case 0x00: + if((OPTO_KEY3 == 1) && (OPTO_KEY4 == 0)) + { +// printf("\r\n\r\n"); +// printf("%d %d\r\n", OPTO_KEY3, OPTO_KEY4); + timer_restart(&wrongOperationTimer); + testStatus = 0x10; + break; + } + if((OPTO_KEY3 == 0) && (OPTO_KEY4 == 1)) //⵽ʼͶƿ + { +// printf("\r\nʼͶƿ\r\n"); +// printf("%d %d\r\n", OPTO_KEY3, OPTO_KEY4); + timer_restart(&waitingTimer); + testStatus = 0x01; + } + break; + + case 0x01: //ȴƿӾһ̽ͷ + if(timer_expired(&waitingTimer)) + { + printf("\r\n0x01Ͷųʱ\r\n"); + testStatus = 0x00; + break; + } +// if((OPTO_KEY3 == 0) || (OPTO_KEY4 == 0)) +// { +// printf("%d %d\r\n", OPTO_KEY3, OPTO_KEY4); +// } + if((OPTO_KEY3 == 0) && (OPTO_KEY4 == 0)) //̽ͷͬʱ⵽ƿ˵Ϊƿ + { + bottleType = 1; //־Ϊƿ + } + if((OPTO_KEY3 == 1) && (OPTO_KEY4 == 0)) //ȴƿȫͨһ̽ͷ + { + timer_restart(&waitingTimer); + testStatus = 0x02; + break; + } + break; + + case 0x02: //ƿȫͨ̽ͷ˵Ѿͨͨ + if(timer_expired(&waitingTimer)) + { + printf("\r\n0x02Ͷųʱ\r\n"); + testStatus = 0x00; + break; + } + +// if((OPTO_KEY3 == 0) || (OPTO_KEY4 == 0)) +// { +// printf("%d %d\r\n", OPTO_KEY3, OPTO_KEY4); +// } + if((OPTO_KEY3 == 0) && (OPTO_KEY4 == 0)) //̽ͷͬʱ⵽ƿ˵Ϊƿ + { + bottleType = 1; //־Ϊƿ + } + if((OPTO_KEY3 == 1) && (OPTO_KEY4 == 1)) + { + timer_restart(&timerOut); + timer_restart(&waitingTimer); + testStatus = 0x03; + break; + } + break; + + case 0x03: //жѾȫͨͨһСʱûм⵽ƿ˵ѾͶųɹ + if(timer_expired(&timerOut)) + { + if(timer_expired(&waitingTimer)) + { + printf("\r\n0x03Ͷųʱ\r\n"); + testStatus = 0x00; + break; + } + + if((OPTO_KEY3 == 1) || (OPTO_KEY4 == 1)) //ƿѾȫ뿪ͨ + { + printf("\r\nͶųɹ\r\n"); + beep_shortBeepMark = 1; + + //ĿǰֻСƿ +// if(bottleType) +// { +// bigBottleCount++; +// }else{ +// smallBottleCount++; +// } + + smallBottleCount++; + +// printf("\r\nƿӣ%dСƿӣ%d\r\n", bigBottleCount, smallBottleCount); + bottleType = 0; + testStatus = 0x00; + break; + } + } + break; + + case 0x10: // + if(timer_expired(&wrongOperationTimer)) + { + testStatus = 0x00; + printf("\r\nerror return!\r\n"); + break; + } +// if((OPTO_KEY3 == 0) || (OPTO_KEY4 == 0)) +// { +// printf("%d %d\r\n", OPTO_KEY3, OPTO_KEY4); +// } + if((OPTO_KEY3 == 0) && (OPTO_KEY4 == 1)) + { + testStatus = 0x11; + timer_restart(&waitingTimer); + break; + } + break; + + case 0x11: + if(timer_expired(&waitingTimer)) + { + printf("\r\n0x11time out return!\r\n"); + testStatus = 0x00; + break; + } +// if((OPTO_KEY3 == 0) || (OPTO_KEY4 == 0)) +// { +// printf("%d %d\r\n", OPTO_KEY3, OPTO_KEY4); +// } + if((OPTO_KEY3 == 1) && (OPTO_KEY4 == 1)) + { + timer_restart(&timerOut); + timer_restart(&waitingTimer); + testStatus = 0x12; + break; + } + break; + + case 0x12: + if(timer_expired(&timerOut)) + { + if(timer_expired(&waitingTimer)) + { + printf("\r\n0x12time out return!\r\n"); + testStatus = 0x00; + break; + } + + if((OPTO_KEY3 == 1) || (OPTO_KEY4 == 1)) + { + printf("\r\nwarning!\r\n"); + beep_warningBeepMark = 1; //־ + + if(smallBottleCount > 0) + { + smallBottleCount--; + } + testStatus = 0x00; + break; + } + } + break; + default: break; + } +} + +/* +*********************************************************************** +* : OptoKeysTest +* ˵: 翪ز +* : +* ֵ: +*********************************************************************** +*/ +void OptoKeysTest(void) +{ + static uint8_t optoKeyStatus1 = 0; + static uint8_t optoKeyStatus2 = 0; + + if(optoKeyStatus1 != optoKeyValue1) + { + optoKeyStatus1 = optoKeyValue1; + + if(optoKeyValue1) + { + printf("\r\n翪1\r\n"); + }else{ + printf("\r\n翪1ָ\r\n"); + } + } + + if(optoKeyStatus2 != optoKeyValue2) + { + optoKeyStatus2 = optoKeyValue2; + + if(optoKeyValue2) + { + printf("\r\n翪2\r\n"); + }else{ + printf("\r\n翪2ָ\r\n"); + } + } +} + +/******************** (C) COPYRIGHT 2018 Ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/OPTO_SWITCH/opto_sw_key.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/OPTO_SWITCH/opto_sw_key.h new file mode 100755 index 0000000..e3cdd16 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/OPTO_SWITCH/opto_sw_key.h @@ -0,0 +1,30 @@ +/*************************** (C) COPYRIGHT 2018 Ping **************************** + * ļ opto_sw_key.h + * 翪ؿͷļ + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#ifndef __OPTO_SW_KEY_H +#define __OPTO_SW_KEY_H + +#include "stm32f10x.h" + +#define OPTO_KEY1 GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_8) //翪1 +#define OPTO_KEY2 GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_7) //翪2 +#define OPTO_KEY3 GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_0) //翪3 +#define OPTO_KEY4 GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_3) //翪4 + +extern uint8_t optoKeyValue1; //翪ؼֵ +extern uint8_t optoKeyValue2; //翪ؼֵ +extern uint8_t optoKeyValue3; //翪ؼֵ +extern uint8_t optoKeyValue4; //翪ؼֵ + +void OptoKeyInit(void); +void OptoKeysCanning(void); +void BottleScanning(void); +void OptoKeysTest(void); + +#endif + +/******************** (C) COPYRIGHT 2018 Ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/QR_Code/qr_code.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/QR_Code/qr_code.c new file mode 100755 index 0000000..3785136 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/QR_Code/qr_code.c @@ -0,0 +1,202 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ 2code.c + * ά봦 + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#include "qr_code.h" +#include "usart1.h" +#include "timer.h" +#include "string.h" +#include "RFID_IC.h" +#include "my_math.h" + +//Чάʶɹ־״̬ +uint8_t sweep2CodeState = 0; //ɨά״̬ɹΪ1ⲿȡ +uint8_t scanBarCodeState = 0; //ɨά״̬ɹΪ1ⲿȡ +uint8_t scanLabelCodeState = 0; //ɨǩά״̬ɹΪ1ⲿȡ +uint8_t scanIC_2CodeState = 0; //ɨICά뿪״̬ɹΪ1ⲿȡ +uint8_t devSetQrCodeState = 0; //öά + +uint8_t codeBuf[128]; //ȡЧά +uint8_t codeDataLength = 0; //ȡЧάݳ + +uint8_t IC_Code[17]; //ICά +uint8_t IC_HEX_Code[17]; //ICάʮ +uint8_t IC_HEX_ID[9]; + +uint8_t setParamCmd; //òָ +uint8_t setParamCount; //ĸ +char setParamList[16][16]; //б + +/* +*********************************************************************** +* : DeleteStrEndingCode +* ˵: ɾַβĻس +* Σַ׵ַ +* ֵ: +*********************************************************************** +*/ +static void DeleteStrEndingCode(char *pStr) +{ + uint16_t i = 0; + uint16_t len1 = 0, len2; + + len1 = strlen(pStr); + + for(i = 0; i < len1; i++) + { + if((*(pStr + i) == 0x0D) || ((*(pStr + i) == 0x0A))) + { + *(pStr + i) = '\0'; + } + } + + len2 = strlen(pStr); + printf("\r\nqrLen %d, %d\r\n", len1, len2); +} + +/* +*********************************************************************** +* : QR_CodeDecode_StandardFormat +* ˵: ׼ʽάݽ +* ΣpStr -> Ķά +* pCheckStr -> ʽ +* ֵ: ɹ1,ʧܷ0 +*********************************************************************** +*/ +uint8_t QR_CodeDecode_StandardFormat(char *pStr, char *pCheckStr) +{ + uint8_t returnMark = 0; + uint8_t i = 0; + uint8_t len = 0; + char *p; + char *pQRcode; //ϸʽĶά + + pQRcode = (char*)strstr((const char*)pStr, pCheckStr); + + if(pQRcode != NULL) + { + p = (char*)strstr((const char*)pQRcode, "="); //ȡûϢ + + if(p != NULL) + { + len = strlen(p + 1); //ûϢ + if((len > 0) && (len <= 128)) //ΪûAPPάܴ + { + codeDataLength = len; //ûϢ + memset(codeBuf, 0x00, 128); + memcpy(codeBuf, p+1, codeDataLength); + + printf("\r\nLen:%d, data:%s\r\n", codeDataLength, codeBuf); + + returnMark = 1; //־ɹ + } + } + } + + return returnMark; +} + +/* +*********************************************************************** +* : QR_CodeDecode +* ˵: άݽ +* ΣĶά +* ֵ: ޣӰӦЧά־λ +*********************************************************************** +*/ +void QR_CodeDecode(char *pStr) +{ + uint8_t i; + char *p; + + char *pAppQRcode; //APPά + char *pAppQRcode2; //APPά + char *pBagQRcode; //ά + char *pBagQRcodeAtCD; //ɶά + char *pIcCardQRcode; //ɶICά + char *pDevSetQRcode; //öά + + uint8_t len = 0; + + uint32_t IC_HEX01, IC_HEX02; + uint8_t IC_HEX03, IC_HEX04; + + uint8_t successMark = 0; //ɨЧ־ + +// printf("\r\n2code = %s\r\n", (const char*)pStr); + + DeleteStrEndingCode(pStr); //ȥάַβĻس + +// pAppQRcode = (char*)strstr((const char*)pStr, "www.kinglive.com.cn"); +// pAppQRcode2 = (char*)strstr((const char*)pStr, "zoomlion"); +// pBagQRcode = (char*)strstr((const char*)pStr, "YN"); +// pBagQRcodeAtCD = (char*)strstr((const char*)pStr, "yueng"); +// pIcCardQRcode = (char*)strstr((const char*)pStr, "510104"); +// + pDevSetQRcode = (char*)strstr((const char*)pStr, "devSet:"); + +//--------------------------------------------------------------------------------------- + if(strlen(pStr) >= 128) + { + printf("\r\nȣ\r\n"); + }else{ + if(pDevSetQRcode != NULL) //öά + { + len = strlen(pDevSetQRcode); //㳤 + + devSetQrCodeState = 1; //־ɨάɹ + successMark = 1; + + codeDataLength = len; //ûϢ + memcpy(codeBuf, pDevSetQRcode, codeDataLength); + *(codeBuf+len) = '\0'; + + printf("\r\nöά룡\r\n"); + printf("\r\ndata = %s\r\n", codeBuf); + printf("\r\ndataLen = %d\r\n", codeDataLength); + }if(QR_CodeDecode_StandardFormat(pStr, "https://www.wastereduction.gov.hk")){ + printf("\r\nۿͻά룡\r\n"); + + sweep2CodeState = 1; + successMark = 1; + }else{ + len = strlen(pStr); + codeDataLength = len; + memset(codeBuf, 0x00, 128); + memcpy(codeBuf, pStr, codeDataLength); + + sweep2CodeState = 1; //־ΪûAPPά뿪 + successMark = 1; + } + } +//--------------------------------------------------------------------------------------- + + if(successMark == 0) + { + printf("\r\nЧά룡\r\n"); + } +} + +// /* +// *********************************************************************** +// * : Get2Code +// * ˵: ȡݶά +// * Σ +// * ֵ: +// *********************************************************************** +// */ +// void Get2Code(void) +// { +// if(USART1_RX_STA & 0X8000) //յһ +// { +// QR_CodeDecode((char*)USART_RX_BUF); +// +// memset(USART_RX_BUF, 0x00, 128); // +// USART1_RX_STA = 0; //һν +// } +// } + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/QR_Code/qr_code.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/QR_Code/qr_code.h new file mode 100755 index 0000000..789beb4 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/QR_Code/qr_code.h @@ -0,0 +1,29 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ 2code.h + * + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#ifndef __2CODE_H +#define __2CODE_H +#include "stdint.h" +#include "string.h" + +//Чάʶɹ־״̬ +extern uint8_t sweep2CodeState; //ɨά״̬ɹΪ1ⲿȡ +extern uint8_t scanBarCodeState; //ɨά״̬ɹΪ1ⲿȡ +extern uint8_t scanLabelCodeState; //ɨǩά״̬ɹΪ1ⲿȡ +extern uint8_t scanIC_2CodeState; //ɨICά뿪״̬ɹΪ1ⲿȡ +extern uint8_t devSetQrCodeState; //öά + +extern uint8_t codeBuf[128]; //ȡЧά +extern uint8_t codeDataLength; //ȡЧάݳ + +extern uint8_t setParamCmd; //òָ +extern uint8_t setParamCount; //ĸ +extern char setParamList[16][16]; //б + +void QR_CodeDecode(char *pStr); +void Get2Code(void); +#endif diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/RFID_IC.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/RFID_IC.c new file mode 100755 index 0000000..02f98c9 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/RFID_IC.c @@ -0,0 +1,331 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ RFID_IC.c + * RFID_IC + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#include "RFID_IC.h" +#include "rfid_decode_yn.h" +#include "rfid_decode_yhk.h" +#include "rfid_decode_zl.h" +#include "delay.h" +#include "usart1.h" +#include "stdio.h" +#include "string.h" +#include "stdlib.h" +#include "my_math.h" + +#define RFID_PW_CTRL_PORT_PeriphClock RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO +#define RFID_PW_CTRL_PORT GPIOA +#define RFID_PW_CTRL_PIN GPIO_Pin_15 + + +uint8_t RFID_ID[16] = {0}; //RFIDţմICݣʮƱ棩 +uint8_t cardNumberBit[32] = {0}; //ĿţʮƱʾ +uint8_t cardNumberStr[33] = {0}; //Ŀţַʾ +uint8_t createCardNum[16] = {0}; //ɵICű +uint8_t cardNumberLen = 0; //ICݳ +uint8_t RFID_state = 0; //RFID_ICˢ״̬ˢ1ˢ0ˢ2˿ + +uint8_t cardSetWorkMode = 0; //ICģ鹤ģʽ +uint8_t cardSetReadBlock = 0; //ICģȡĿ +uint8_t cardSetUploadMode = 0; //ICϴģʽ + +uint8_t cardSetKeyA[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; //ICдKeyA +uint8_t cardSetKeyCtrlBit[4] = {0xFF, 0x07, 0x80, 0x69}; //ICдλ +uint8_t cardSetKeyB[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; //ICдKeyB + +uint8_t originalPassword[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; //ICԭʼ + +uint32_t cardNumberAreaCode = 0; //ICţǰ6λ +uint32_t cardNumberSerialNum = 0; //ICˮţ7-14λ + +//ICģ +uint8_t Cmd_WorkMode[8] = {0x03, 0x08, 0xC1, 0x20, 0x00, 0x00, 0x00, 0x00}; +uint8_t Cmd_SECRET_KEY[21] = {0x03, 0x15, 0xC3, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, //ICģԿ + 0xFF, 0xFF, 0xFF, 0x07, 0x80, 0x69, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x1B}; + +uint8_t Cmd_Write_Block[23] = {0x01,0x17,0xA4,0x20,0x00,0x01,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //д + +uint8_t Cmd_SectorEncryption[8] = {0x01, 0x08, 0xA5, 0x20, 0x00, 0x01, 0x00, 0x00}; // + +//ICģĬϲ +uint8_t YN_IC_MODE[8] = {0x03, 0x08, 0xC1, 0x20, 0x03, 0x09, 0x00, 0x1F}; //ICģ鹤ģʽ +uint8_t YN_SECRET_KEY[21] = {0x03, 0x15, 0xC3, 0x20, 0x7F, 0xFF, 0xFF, 0xFF, //ICģԿ + 0xFF, 0xFF, 0xFF, 0x07, 0x80, 0x69, 0x6F, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x0B}; + +//ICģĬϲ +uint8_t SET_IC_MODE[8] = {0x03, 0x08, 0xC1, 0x20, 0x03, 0x09, 0x00, 0x1F}; //ICģ鹤ģʽ +uint8_t SET_SECRET_KEY[21] = {0x03, 0x15, 0xC3, 0x20, 0x7F, 0xFF, 0xFF, 0xFF, //ICģԿ + 0xFF, 0xFF, 0xFF, 0x07, 0x80, 0x69, 0x6F, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x0B}; + +//ICģ +// uint8_t SET_IC_MODE[8] = {0x03, 0x08, 0xC1, 0x20, 0x03, 0x02, 0x00, 0x14}; //ICģ鹤ģʽ +// uint8_t SET_SECRET_KEY[21] = {0x03, 0x15, 0xC3, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, //ICģԿ +// 0xFF, 0xFF, 0xFF, 0x07, 0x80, 0x69, 0xFF, 0xFF, +// 0xFF, 0xFF, 0xFF, 0xFF, 0x1B}; + +// //ɶ +// uint8_t SET_IC_MODE[8] = {0x03, 0x08, 0xC1, 0x20, 0x03, 0x16, 0x00, 0x00}; //ICģ鹤ģʽ +// uint8_t SET_SECRET_KEY[21] = {0x03, 0x15, 0xC3, 0x20, 0x8F, 0x7F, 0x6F, 0x5F, //ICģԿ +// 0x4F, 0x3F, 0xFF, 0x07, 0x80, 0x69, 0x1F, 0x2F, +// 0x3F, 0x4F, 0x5F, 0x6F, 0xDB}; + +void showCardHex(uint8_t *buf, uint8_t len) +{ + uint8_t i; + + printf("\r\n"); + for(i=0; i ģʽ +* block -> ȡĿ +* outputMode -> ģʽ +* ֵ: +*********************************************************************** +*/ +void IC_CarderWorkModeSet(uint8_t mode, uint8_t block, uint8_t outputMode) +{ + Cmd_WorkMode[4] = mode; + Cmd_WorkMode[5] = block; + Cmd_WorkMode[6] = outputMode; + TxCheckSum(Cmd_WorkMode, 8); + + delay_ms(300); + USART1_SendFrameData(Cmd_WorkMode, 8); + delay_ms(300); +} + +/* +*********************************************************************** +* : IC_CarderWorkModeSet +* ˵: ICģд +* ΣkeyA -> keyA +* keyCtrlBit -> λ +* keyB -> keyB +* ֵ: +*********************************************************************** +*/ +void IC_CarderKeySet(uint8_t *keyA, uint8_t *keyCtrlBit, uint8_t *keyB) +{ + memcpy(&Cmd_SECRET_KEY[4], keyA, 6); + memcpy(&Cmd_SECRET_KEY[10], keyCtrlBit, 4); + memcpy(&Cmd_SECRET_KEY[14], keyA, 6); + TxCheckSum(Cmd_SECRET_KEY, 21); + + delay_ms(300); + USART1_SendFrameData(Cmd_SECRET_KEY, 21); + delay_ms(300); +} + +/* +*********************************************************************** +* : RFID_SectorEncrypt +* ˵: +* ΣblockNumber -> +* ֵ: +*********************************************************************** +*/ +void RFID_SectorEncrypt(uint8_t blockNumber) +{ + Cmd_SectorEncryption[4] = blockNumber; + TxCheckSum(Cmd_SectorEncryption, Cmd_SectorEncryption[1]); //Уλ + + delay_ms(500); + USART1_SendFrameData(Cmd_SectorEncryption, Cmd_SectorEncryption[1]); + delay_ms(500); +} + +/* +*********************************************************************** +* : RFID_WriteDataToBlock +* ˵: д +* Σ +* ֵ: +*********************************************************************** +*/ +void RFID_WriteDataToBlock(uint8_t *datain, uint8_t block) +{ + uint8_t i; + + Cmd_Write_Block[4] = block; + + for(i=0; i<16; i++) + { + Cmd_Write_Block[6+i] = datain[i]; + } + TxCheckSum(Cmd_Write_Block, Cmd_Write_Block[1]); //Уλ + + delay_ms(500); + USART1_SendFrameData(Cmd_Write_Block, Cmd_Write_Block[1]); + delay_ms(500); +} + +/* +*********************************************************************** +* : SetRFID_Param +* ˵: ICģ +* Σ +* ֵ: +*********************************************************************** +*/ +void SetRFID_Param(void) +{ + delay_ms(200); + USART1_SendFrameData(SET_IC_MODE, 8); + delay_ms(200); + USART1_SendFrameData(SET_SECRET_KEY, 21); + delay_ms(200); +} + +/* +*********************************************************************** +* : ConfigureDoorKey +* ˵: ICԿ +* Σ +* ֵ: +*********************************************************************** +*/ +void ConfigureDoorKey(uint32_t id) +{ + IC_CardEncode_YN(id, 1, 55); + RFID_WriteDataToBlock(createCardNum, 9); + printf("\r\nICԿף\r\n"); +} + +/* +*********************************************************************** +* : WriteIC_CardNumber +* ˵: дIC +* ΣareaCode -> ICţǰ6λ +* serialNum -> ICˮţ7-14λ +* ֵ: +*********************************************************************** +*/ +void WriteIC_CardNumber(uint32_t areaCode, uint32_t serialNum) +{ + IC_CardEncode_YN(areaCode, serialNum, 1); + RFID_WriteDataToBlock(createCardNum, 9); + printf("\r\nдIC\r\n"); +} + +/******************** (C) COPYRIGHT 2017 ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/RFID_IC.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/RFID_IC.h new file mode 100755 index 0000000..da76162 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/RFID_IC.h @@ -0,0 +1,47 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ RFID_IC.h + * RFID_IC + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#ifndef __RFID_IC_H +#define __RFID_IC_H +#include "stm32f10x.h" + +extern uint8_t RFID_ID[16]; //RFIDţմICݣʮƱ棩 +extern uint8_t cardNumberBit[32]; //ĿţʮƱʾ +extern uint8_t cardNumberStr[33]; //Ŀţַʾ +extern uint8_t createCardNum[16]; //ɵICű +extern uint8_t cardNumberLen; //ICݳ +extern uint8_t RFID_state; //RFID_ICˢ״̬ˢ1ˢ0ˢ + +extern uint8_t cardSetWorkMode; //ICģ鹤ģʽ +extern uint8_t cardSetReadBlock; //ICģȡĿ +extern uint8_t cardSetUploadMode; //ICϴģʽ + +extern uint8_t cardSetKeyA[6]; //ICдKeyA +extern uint8_t cardSetKeyCtrlBit[4]; //ICдλ +extern uint8_t cardSetKeyB[6]; //ICдKeyB + +extern uint8_t originalPassword[6]; //ICԭʼ + +extern uint32_t cardNumberAreaCode; //ICţǰ6λ +extern uint32_t cardNumberSerialNum; //ICˮţ7-14λ + +void RFID_Init(void); +void RFID_PowerON(void); +void RFID_PowerOFF(void); +void IC_CardDecode(void); + +void IC_CarderReset(void); +void IC_CarderWorkModeSet(uint8_t mode, uint8_t block, uint8_t outputMode); +void IC_CarderKeySet(uint8_t *keyA, uint8_t *keyCtrlBit, uint8_t *keyB); +void RFID_SectorEncrypt(uint8_t blockNumber); +void RFID_WriteDataToBlock(uint8_t *datain, uint8_t block); +void SetRFID_Param(void); +void ConfigureDoorKey(uint32_t id); +void WriteIC_CardNumber(uint32_t areaCode, uint32_t serialNum); +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yhk.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yhk.c new file mode 100755 index 0000000..003f997 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yhk.c @@ -0,0 +1,127 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ rfid_decode_yhk.c + * п + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#include "rfid_decode_yhk.h" +#include "RFID_IC.h" +#include "string.h" +#include "stdlib.h" +#include "stdbool.h" +#include "my_math.h" +#include "data_typedef.h" + + +void showBufHex1(uint8_t *buf, uint8_t len) +{ + uint8_t i; + + printf("\r\n"); + for(i=0; i 0 ; i--) + { + cDigit[0] = pPurported[i-1]; + nDigit = atoi(cDigit); + + if (nParity == i % 2) + { + nDigit = nDigit * 2; + } + + nSum += nDigit/10; + nSum += nDigit%10; + } + return 0 == nSum % 10; +} + +/* +*********************************************************************** +* : IC_CardDecode_YHK +* ˵: IC +* Σ +* ֵ: ɹ1ɹ0 +*********************************************************************** +*/ +uint8_t IC_CardDecode_YHK(void) +{ + uint8_t res = 0; + uint8_t i, j; + uint32_t dataTemp; + uint8_t icCardBitBuf[32] = {0}; + uint8_t icCardLen = 0; //ݳ + uint32_t supplierID = 0; //Ӧ̴ + + //ŷ + //ŷ + j = 0; + memset(cardNumberStr, 0x00, 33); + memset(cardNumberBit, 0x00, 32); + for(i = 0; i < 16; i++) + { + sprintf((char*)&cardNumberStr[j], "%01X", RFID_ID[i] >> 4); + cardNumberBit[j++] = RFID_ID[i] >> 4; + + sprintf((char*)&cardNumberStr[j], "%01X", RFID_ID[i] & 0x0F); + cardNumberBit[j++] = RFID_ID[i] & 0x0F; + } + + //㿨ų + for(i = 0; i < 32; i++) + { + if(cardNumberStr[i] == 'F') + { + cardNumberLen = i; + break; + } + } + + printf("\r\nlen = %d\r\n", cardNumberLen); + showBufHex1(cardNumberBit, cardNumberLen); + printf("\r\nIC = %s\r\n", cardNumberStr); + + if((cardNumberLen >= 10) && (cardNumberLen <= 20)) //ICͷϢУ + { + memcpy(icCardBitBuf, cardNumberStr, cardNumberLen); + if(CheckLuhn((const char*)icCardBitBuf)) + { + RFID_state = 3; //RFID_ICˢ״̬ + printf("\r\nпû\r\n"); + res = 1; + }else{ + printf("\r\nУ\r\n"); + } + }else{ +// printf("\r\nЧ\r\n"); + } + + return res; +} +/******************** (C) COPYRIGHT 2017 ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yhk.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yhk.h new file mode 100755 index 0000000..8110ed6 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yhk.h @@ -0,0 +1,16 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ rfid_decode_yhk.h + * пͷļ + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#ifndef __RFID_DECODE_YHK_H +#define __RFID_DECODE_YHK_H + +#include "stm32f10x.h" + +uint8_t IC_CardDecode_YHK(void); +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yn.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yn.c new file mode 100755 index 0000000..8cc7e8f --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yn.c @@ -0,0 +1,259 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ RFID_IC.c + * RFID_IC + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#include "rfid_decode_yn.h" +#include "RFID_IC.h" +#include "string.h" +#include "stdlib.h" +#include "my_math.h" +#include "data_typedef.h" + +#define secretKey "1357975312468642" //ICԿ1357975312468642 +// #define secretKey "2468642135797531" //ICԿ2468642135797531 + +uint8_t secretKeyBit[16]; //16λʮԿ +uint8_t checkBit; //Уλ + + +static void SecretCardNumHEX2Bit(uint8_t outputBuf[], uint8_t inputBuf[]); + + +void showCardHex1(uint8_t *buf, uint8_t len) +{ + uint8_t i; + + printf("\r\n"); + for(i=0; i> 16); + createCardNum[1] = (uint8_t)(areaCode >> 8); + createCardNum[2] = (uint8_t)areaCode; + + //ˮ + createCardNum[3] = (uint8_t)(serialNum >> 24); + createCardNum[4] = (uint8_t)(serialNum >> 16); + createCardNum[5] = (uint8_t)(serialNum >> 8); + createCardNum[6] = (uint8_t)serialNum; + + //ɿ + createCardNum[7] = cardType; + + //Уλ + SecretCardNumHEX2Bit(cardNumBitBuf, createCardNum); + SecretKeyHEX2Bit(secretKeyBit, secretKey); + checkBit = CalculateCheckDigit(cardNumBitBuf, secretKeyBit); + createCardNum[8] = checkBit; + cardNumBitBuf[16] = checkBit; + + printf("\r\nɿΪ"); + for(i = 0; i < 17; i++) + { + printf("%d", cardNumBitBuf[i]); + } + printf("\r\n"); +} + +/* +*********************************************************************** +* : IC_CardDecode_YN +* ˵: IC +* Σ +* ֵ: ɹ1ɹ0 +*********************************************************************** +*/ +uint8_t IC_CardDecode_YN(void) +{ + uint8_t res = 0; + uint8_t i; + uint8_t checkBit; + + SecretCardNumHEX2Bit(cardNumberBit, RFID_ID); + SecretKeyHEX2Bit(secretKeyBit, secretKey); + checkBit = CalculateCheckDigit(cardNumberBit, secretKeyBit); + + if(checkBit == cardNumberBit[16]) //ICУȷ־ˢЧ + { + printf("\r\nICţ"); + for(i = 0; i < 17; i++) + { + cardNumberStr[i] = cardNumberBit[i] + '0'; + printf("%d", cardNumberBit[i]); + } + printf("\r\n"); + + if((cardNumberBit[14] == 0) && (cardNumberBit[15] == 1)) + { + RFID_state = 1; //RFID_ICˢ״̬ˢ1->ˢ0->ˢ2->ſⲿȡ + printf("\r\nICЧû\r\n"); + res = 1; + }else if((cardNumberBit[14] == 5) && (cardNumberBit[15] == 5)){ + RFID_state = 2; //RFID_ICˢ״̬ˢ1->ˢ0->ˢ2->ſⲿȡ + printf("\r\nICЧ˿\r\n"); + res = 1; + }else{ + RFID_state = 0; + } + + }else{ +// printf("\r\nICЧ\r\n"); + } + + return res; +} + +/******************** (C) COPYRIGHT 2017 ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yn.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yn.h new file mode 100755 index 0000000..f904cd7 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_yn.h @@ -0,0 +1,19 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ rfid_decode_yn.h + * ICͷļ + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#ifndef __RFID_DECODE_YN_H +#define __RFID_DECODE_YN_H + +#include "stm32f10x.h" + +void SecretKeyHEX2Bit(uint8_t outputBuf[], char *inputStr); +uint8_t CalculateCheckDigit(uint8_t cardNumBit[], uint8_t keyBit[]); +void IC_CardEncode_YN(uint32_t areaCode, uint32_t serialNum, uint8_t cardType); +uint8_t IC_CardDecode_YN(void); +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_zl.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_zl.c new file mode 100755 index 0000000..b17c5f3 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_zl.c @@ -0,0 +1,72 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ rfid_decode_zl.c + * IC + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#include "rfid_decode_zl.h" +#include "RFID_IC.h" +#include "string.h" +#include "stdio.h" +#include "data_typedef.h" + + +void showCardHex2(uint8_t *buf, uint8_t len) +{ + uint8_t i; + + printf("\r\n"); + for(i=0; i> 4); + cardNumberBit[j++] = RFID_ID[i] >> 4; + + sprintf((char*)&cardNumberStr[j], "%01X", RFID_ID[i] & 0x0F); + cardNumberBit[j++] = RFID_ID[i] & 0x0F; + } + + //㿨ų + cardNumberLen = ((cardNumberBit[4]*10) + cardNumberBit[5])*2 + 6; + +// showCardHex2(cardNumberBit, 32); + printf("\r\nIC = %s len = %d\r\n", cardNumberStr, cardNumberLen); + + RFID_state = 3; //RFID_ICˢ״̬ + printf("\r\nICû\r\n"); + res = 1; + }else{ +// printf("\r\nЧ\r\n"); + } + + return res; +} + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_zl.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_zl.h new file mode 100755 index 0000000..ab3782f --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RFID/rfid_decode_zl.h @@ -0,0 +1,18 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ rfid_decode_zl.h + * ICͷļ + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ + + +#ifndef __RFID_DECODE_ZL_H +#define __RFID_DECODE_ZL_H + +#include "stm32f10x.h" + +uint8_t IC_CardDecode_ZL(void); +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/RS485/RS485.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RS485/RS485.c new file mode 100755 index 0000000..90f5e10 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RS485/RS485.c @@ -0,0 +1,672 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ RS485.c + * RS485ͨŴ3֣֡򡢷ִ֡ + * V1.0 + * XuZhongPing + * 2017/02/10 +*********************************************************************************/ +#include "delay.h" +#include "sys.h" +#include "RS485.h" +// #include "usart5.h" +#include "usart.h" +#include "timer.h" +#include "message.h" +#include "device.h" +#include "data_typedef.h" + +/*ͨѶ*/ +#define BaudRate 9600 // +#define DATA_SIZE 32 //ͨѶ + +uint8_t Address = 0x00; //豸ַ +uint8_t Serial_buf[DATA_SIZE]; //ͨѶ +uint8_t RS485_RX_BUF[64]; //ջ,64ֽ +uint8_t RS485_TX_BUF[64]; //ͻ,64ֽ + +// +uint8_t RS485_RX_STA = 0x00; //RS485״̬ +uint8_t RS485_CommunicationState; //RS485ͨѶɹ־ +uint8_t radioCom = 0; //㲥־ +uint8_t responseMark = 0; //Ӧ־ +uint16_t RS485_serialNumber; //RS485ͨˮ +uint8_t rxCmd; //ӻصָ + +uint8_t slaveAddress = 0; //ӻصĵַ + +uint8_t getMCU2DataStatus; //ȡMCU2״̬ +uint8_t getMCU2DistanceStatus; //ȡMCU2IJ״̬ + +/* +*********************************************************************** +* : RS485_Init +* ˵: ʼRS485ӿ +* : +* ֵ: +*********************************************************************** +*/ +void RS485_Init(void) +{ + //GPIO˿ + GPIO_InitTypeDef GPIO_InitStructure; + + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); //ʹGPIOAʱ + + + //RS485_TX_EN RS485ͽտƽ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(GPIOC, &GPIO_InitStructure); + + GPIO_ResetBits(GPIOC, GPIO_Pin_2); //0ĬϽ״̬ + + USART5_Init(BaudRate); //RS485ӦĴڳʼ +} + +/* +*********************************************************************** +* : RS485_ReceiveData +* ˵: RS485 +* : rxData -> յ +* ֵ: +*********************************************************************** +*/ +void RS485_ReceiveData(uint8_t rxData) +{ + static uint8_t RX_State = 0; //״̬ + static uint8_t CS = 0; //պ + static uint8_t RX_Size = 0; //ͨѶݳ + static uint8_t Byte_Count = 0; //ֽڼ + +// printf("R = %x\r\n", rxData); + switch(RX_State) + { + case 0: //һǰֽ + if(rxData == 0xfe){ + RX_State = 1; + }else{ + RX_State = 0; + } + break; + case 1: //ڶǰֽ + if(rxData == 0xfe){ + RX_State = 1; //ת֡ͷ + }else{ + if(rxData == 0x68) + { + RX_State = 3; //ת豸ͨѶַ + CS = 0x68; + }else{ + RX_State = 0; + } + } + break; + case 2: //֡ͷ + if(rxData == 0x68){ + RX_State = 3; //ת豸ͨѶַ + CS = 0x68; + }else{ + RX_State = 0; + } + break; + case 3: //豸ͨѶַ + RS485_RX_BUF[0] = rxData; + CS += rxData; + RX_State = 4; + break; + case 4: //֡ͷ + if(rxData == 0x68){ + RX_State = 5; //תͨѶ + CS += 0x68; + }else{ + RX_State = 0; + } + break; + case 5: //ͨѶ + RS485_RX_BUF[1] = rxData; + CS += rxData; + RX_State = 6; //תݳ + break; + case 6: //ͨѶݳ + RS485_RX_BUF[2] = rxData; + CS += rxData; + RX_Size = rxData; //յݳ + if(RX_Size == 0x00){ //ݳΪ0ֱתУ + RX_State = 8; + }else{ + RX_State = 7; //ת + } + break; + case 7: //Nֽ + if(Byte_Count < RX_Size-1){ + RS485_RX_BUF[Byte_Count + 3] = rxData; + CS += rxData; + Byte_Count++; + }else{ + RS485_RX_BUF[Byte_Count + 3] = rxData; + CS += rxData; + Byte_Count = 0; //Nֽڵݽռ0 + RX_State = 8; //תպ + } + break; + case 8: //У + if(CS != rxData){ + RX_State = 0; + }else{ + RX_State = 9; //ת֡β0x16 + } + break; + case 9: //֡β + if(rxData == 0x16){ //֡β + RS485_RX_STA = 0xfd; //һ֡ճɹUSART_RX_STA=0xfd֪ͨͨѶ + } + RX_State = 0; + break; + default: // + break; + } +} + + +/* +*********************************************************************** +* : Receive_One +* ˵: һ֡ͨѶ +* : մȡַָ +* ֵ: ȷ־1 Ϊյһ֡ݣ0 δյ +*********************************************************************** +*/ +// uint8_t Receive_One(uint8_t *s) +// { +// if(RS485_RX_STA == 0xfd) +// { +// return 1; //һ֡ճɹرսͨѶһ֡ٴ +// }else{ +// return 0; +// } +// } + + +/* +*********************************************************************** +* : RS485_SendData +* ˵: һֽ +* : +* ֵ: +*********************************************************************** +*/ +void RS485_SendData(uint8_t Serial_data) +{ +// CTRL485 = 1; //Ϊģʽ + UART5_Send_Data(Serial_data); +// CTRL485 = 0; //ָΪģʽ +} + +/* +*********************************************************************** +* : RS485_SendOne +* ˵: ͨRS485һ֡ +* : ַָ֡ +* ֵ: +*********************************************************************** +*/ +void RS485_SendOne(uint8_t *s) +{ + uint8_t i; + uint8_t CS = 0x68; //պ + uint8_t TX_Size = 0; //ͨѶݳ + + printf("\r\nRS485 --> %x\r\n", *(s+1)); + + CTRL485 = 1; //RS-485 ͨѶлΪ״̬ + + delay_ms(1); + RS485_SendData(0xfe); //ǰֽ + RS485_SendData(0xfe); + RS485_SendData(0xfe); + RS485_SendData(0xfe); + RS485_SendData(0x68); //֡ͷ + RS485_SendData(*s); //͵ַ + CS += *s; + RS485_SendData(0x68); //֡ͷ + CS += 0x68; + RS485_SendData(*(s+1)); //֡ + CS += *(s+1); + TX_Size = *(s+2); //ȡͨѶݳ + RS485_SendData(TX_Size); //ݳ + CS += *(s+2); + for(i=0; i RS485Ϣ +* msg->msgTypeΪָmsg->msgDataΪҪ͵Ĵӻַ +* 0x01->ȡֵ +* 0x02->ȡֵ +* 0x03->ȡ¶ֵ +* 0x10->ȡ¶ȡࡢˮλϢ +* 0x20->㲥ָ +* ֵ: +*********************************************************************** +*/ +void RS485_PackSendProtocol(Com_ProtocolMessage *msg) +{ + RS485_TX_BUF[0] = msg->msgData; //ôӻͨѶַ + RS485_TX_BUF[1] = msg->msgType; //ָ + RS485_TX_BUF[2] = 0; //ݳ + +// switch(msg->msgType) +// { +// case 0x30: +// RS485_TX_BUF[2] = 27; //ݳ +// +// RS485_TX_BUF[3] = isAuth; // +// RS485_TX_BUF[4] = putInType; +// memcpy(&RS485_TX_BUF[5], icCardNumberBit, 17); +// RS485_TX_BUF[5+17] = (uint8_t)(accountNum >> 24); +// RS485_TX_BUF[6+17] = (uint8_t)(accountNum >> 16); +// RS485_TX_BUF[7+17] = (uint8_t)(accountNum >> 8); +// RS485_TX_BUF[8+17] = (uint8_t)accountNum; +// +// RS485_TX_BUF[9+17] = (uint8_t)(capital >> 24); +// RS485_TX_BUF[10+17] = (uint8_t)(capital >> 16); +// RS485_TX_BUF[11+17] = (uint8_t)(capital >> 8); +// RS485_TX_BUF[12+17] = (uint8_t)capital; +// break; +// +// case 0x31: +// RS485_TX_BUF[2] = 8; //ݳ +// +// RS485_TX_BUF[3] = (uint8_t)(capital >> 24); +// RS485_TX_BUF[4] = (uint8_t)(capital >> 16); +// RS485_TX_BUF[5] = (uint8_t)(capital >> 8); +// RS485_TX_BUF[6] = (uint8_t)capital; +// +// RS485_TX_BUF[7] = (uint8_t)(capitalAfter >> 24); +// RS485_TX_BUF[8] = (uint8_t)(capitalAfter >> 16); +// RS485_TX_BUF[9] = (uint8_t)(capitalAfter >> 8); +// RS485_TX_BUF[10] = (uint8_t)capitalAfter; +// break; +// +// default: +// break; +// } +} + +/* +*********************************************************************** +* : RS485_Task +* ˵: RS485ͨѶ +* : +* ֵ: +*********************************************************************** +*/ +void RS485_Task(void) +{ + uint8_t rs485succeedFlag = 0; + uint8_t timerOut = 0; + static Com_ProtocolMessage *pMsg; + static timer timer_01; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&timer_01, 4); //1ʱ + } + + pMsg = MessageGet(MSG_FIFO_RS485_PROTOCOL); //ϢȡRS485ͨѶЭϢ + if(pMsg) + { +// printf("\r\n----->RS485Ҫڼ......\r\n"); +// printf("\r\n----->RS485msgType = %x\r\n", pMsg->msgType); +// printf("\r\n----->RS485msgData = %x\r\n", pMsg->msgData); + + RS485_PackSendProtocol(pMsg); + RS485_SendOne(RS485_TX_BUF); //ӻһ֡ + + if(pMsg->msgData == 0x99) //㲥ַȴӦ + { + RS485_RX_STA = 0; + }else{ + timer_restart(&timer_01); + while(!timerOut && !rs485succeedFlag) + { + if(timer_expired(&timer_01)) //ʱδյ + { + timerOut = 1; //ʱسʼ״̬ + printf("\r\n----->RS485TimerOut\r\n"); + RS485_RX_STA = 0; + } + if(RS485_RX_STA == 0xfd) //нյӻصݣеַ֤ + { + RS485_RX_STA = 0; + if(RS485_CommandDecoding(RS485_RX_BUF, RS485_TX_BUF)) //ͷص + { +// printf("\r\nmsgType = %x, rxCmd = %x\r\n", pMsg->msgType, rxCmd); + if(pMsg->msgType == rxCmd) + { + rs485succeedFlag = 1; + RS485_CommunicationState = 1; //ñη͵֡ɹ + + printf("\r\n----->RS485<--OK\r\n"); + } + } + } + } + } + } +} + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/RS485/RS485.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RS485/RS485.h new file mode 100755 index 0000000..6f383f7 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/RS485/RS485.h @@ -0,0 +1,44 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ RS485.h + * RS485ͨŴͷļ + * V1.0 + * XuZhongPing + * 2017/02/10 +*********************************************************************************/ +#ifndef __RS485_H +#define __RS485_H + +#include "stdio.h" +#include "sys.h" + +#define CTRL485 PCout(2) //485ģʽ + +extern uint8_t Address; + +extern uint8_t RS485_RX_BUF[64]; //ջ,63ֽ.ĩֽΪз +extern uint8_t RS485_TX_BUF[64]; //ͻ,64ֽ. + +extern uint8_t RS485_RX_STA; //RS485״̬ +extern uint8_t RS485_CommunicationState; //RS485ͨѶɹ־ +extern uint8_t radioCom; //㲥 +extern uint8_t responseMark; //Ӧ־ +extern uint16_t RS485_serialNumber; //RS485ͨˮ + +extern uint8_t getMCU2DataStatus; //ȡMCU2״̬ +extern uint8_t getMCU2DistanceStatus; //ȡMCU2IJ״̬ + +void RS485_Init(void); +void RS485_1(void); +void RS485_ReceiveData(uint8_t rxData); + +void SendDoorCtrlCMD(void); //ӻͿſָ +void SendGetPutInMsgCMD(void); //ӻûͶ +void SendReadyPutInCMD(void); +void SendEndPutInCMD(void); + +void RS485_Task(void); + + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/SCALE/scale.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/SCALE/scale.c new file mode 100755 index 0000000..1ce3b00 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/SCALE/scale.c @@ -0,0 +1,177 @@ +/*************************** (C) COPYRIGHT 2017 Ping **************************** + * ļ scale.c + * + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#include "stdio.h" +#include "scale.h" +#include "timer.h" + +uint16_t weight1 = 0; //ǰŴ100λkg +uint16_t weight2 = 0; +uint16_t weight3 = 0; +uint16_t weight4 = 0; + +uint8_t scaleNum = 0; //̱ +uint8_t receiveScaleNum = 0; //ȡõij̱ + +uint8_t calibrationParam1[16]; //У׼ʱյ +uint8_t calibrationParam2[16]; + +uint8_t getCalibraDataMark1 = 0; //ȡУ׼ָ +uint8_t getCalibraZeroMark1 = 0; //ȡУ׼ +uint8_t getCalibraParamOkMark1 = 0; //ȡУ׼ + +uint8_t getCalibraDataMark2 = 0; +uint8_t getCalibraZeroMark2 = 0; +uint8_t getCalibraParamOkMark2 = 0; + +void ScaleCmdRun1(uint8_t* pRxBuf); +void ScaleCmdRun2(uint8_t* pRxBuf); +void ScaleCmdDecodeTask(void); + +/* +*********************************************************************** +* : Scale_Init +* ˵: ԴIOڳʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void ScaleInit(void) +{ + +} + +/* +*********************************************************************** +* : ScalePowerON +* ˵: 򿪳ƵԴ +* Σѡһ·ӳƵԴ +* ֵ: +*********************************************************************** +*/ +void ScalePowerON(uint8_t whichOne) +{ + +} + +/* +*********************************************************************** +* : ScalePowerOFF +* ˵: رճƵԴ +* ΣwhichOne -> ѡһ·ӳƵԴ +* ֵ: +*********************************************************************** +*/ +void ScalePowerOFF(uint8_t whichOne) +{ + +} + +/* +*********************************************************************** +* : GetWeight +* ˵: ȡó +* Σ +* ֵ: ޣô˺ıȫֱcurrentWeightcurrentWeight2 +*********************************************************************** +*/ +void SendCalibraCmd(uint8_t num) +{ + uint8_t cmd[10] = {0xfe, 0xfe, 0xfe, 0x68, 0x00, 0x68, 0xa1, 0x00, 0x71, 0x16}; + + if(num ==1) + { + USART4_SendFrameData(cmd, 10); + }else if(num == 2){ + USART5_SendFrameData(cmd, 10); + } +} + +/* +*********************************************************************** +* : ScaleCmdRun1 +* ˵: У׼ִָ +* Σ +* ֵ: +*********************************************************************** +*/ +void ScaleCmdRun1(uint8_t* pRxBuf) +{ + uint8_t proNum; + + proNum = *(pRxBuf+1); + + printf("\r\nS1 <-- 0x%02X\r\n", proNum); + switch(proNum) //ͨѶ + { + case 0xA2: //յУ׼ + getCalibraZeroMark1 = 1; + break; + + case 0xA3: + getCalibraParamOkMark1 = 1; + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : ScaleCmdRun2 +* ˵: У׼ִָ +* Σ +* ֵ: +*********************************************************************** +*/ +void ScaleCmdRun2(uint8_t* pRxBuf) +{ + uint8_t proNum; + + proNum = *(pRxBuf+1); + + printf("\r\nS2 <-- 0x%02X\r\n", proNum); + switch(proNum) //ͨѶ + { + case 0xA2: //յУ׼ + getCalibraZeroMark2 = 1; + break; + + case 0xA3: + getCalibraParamOkMark2 = 1; + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : ScaleCmdDecodeTask +* ˵: ģָ +* : +* ֵ: +*********************************************************************** +*/ +void ScaleCmdDecodeTask(void) +{ + if(getCalibraDataMark1 == 1) //нյ + { + ScaleCmdRun1(calibrationParam1); //ͷص + getCalibraDataMark1 = 0; + } + + if(getCalibraDataMark2 == 1) //нյ + { + ScaleCmdRun2(calibrationParam2); //ͷص + getCalibraDataMark2 = 0; + } +} + +/******************** (C) COPYRIGHT 2017 Ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/SCALE/scale.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/SCALE/scale.h new file mode 100755 index 0000000..56cd65f --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/SCALE/scale.h @@ -0,0 +1,53 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ scale.h + * + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#ifndef __SCALE_H +#define __SCALE_H + +#include "stm32f10x.h" +#include "usart1.h" +#include "usart3.h" +#include "usart4.h" +#include "usart5.h" + +extern uint16_t weight1; //ǰŴ100λkg +extern uint16_t weight2; +extern uint16_t weight3; +extern uint16_t weight4; + +extern uint8_t scaleNum; +extern uint8_t receiveScaleNum; //ȡõij̱ + +extern uint8_t calibrationParam1[16]; +extern uint8_t calibrationParam2[16]; + +extern uint8_t getCalibraDataMark1; //ȡУ׼ָ +extern uint8_t getCalibraZeroMark1; //ȡУ׼ +extern uint8_t getCalibraParamOkMark1; //ȡУ׼ + +extern uint8_t getCalibraDataMark2; +extern uint8_t getCalibraZeroMark2; +extern uint8_t getCalibraParamOkMark2; + + + +void ScaleInit(void); //ؽӿڳʼ +void ScalePowerON(uint8_t whichOne); //ӵԴ +void ScalePowerOFF(uint8_t whichOne); //ӵԴر +void Clear_01(void); //һ· +void Clear_02(void); //ڶ· +void ClearWeight(void); // + +void WeightDetection(void); //ؼ +void UpdateWeight(void); //µǰûͶŲʱijر仯 +void GetWeight(void); //ȡõǰͶŹеijر仯 + +void SendCalibraCmd(uint8_t num); + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/SPI/spi.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/SPI/spi.c new file mode 100755 index 0000000..96c325b --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/SPI/spi.c @@ -0,0 +1,87 @@ +/*************************** (C) COPYRIGHT 2014 GLHF **************************** + * ļ spi.h + * SPIӿ + * V1.0 + * 2018-11-24 + * XuZhongPing + * ¼¼ +*********************************************************************************/ +#include "spi.h" + +/* + * SPI1_Init + * ENC28J60 SPI ӿڳʼ + * + * + * + */ +void SPI1_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + SPI_InitTypeDef SPI_InitStructure; + + RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOE, ENABLE ); + RCC_APB2PeriphClockCmd( RCC_APB2Periph_SPI1, ENABLE );//SPI1ʱʹ + + //PA5 -> SCK PA6 -> MISO PA7 -> MOSI + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //PA5/6/7 + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(GPIOA, &GPIO_InitStructure); + + /* PC4-SPI1-NSS:SD-CS */ // Ƭѡ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // + GPIO_Init(GPIOE, &GPIO_InitStructure); + GPIO_SetBits(GPIOE, GPIO_Pin_8); // ȰƬѡߣõʱ + + /* PA4-SPI1-NSS:FLASH-CS */ // Ƭѡ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // + GPIO_Init(GPIOE, &GPIO_InitStructure); + GPIO_SetBits(GPIOE, GPIO_Pin_7); // ȰƬѡߣõʱ + + + /* SPI1 */ + SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; + SPI_InitStructure.SPI_Mode = SPI_Mode_Master; + SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; + SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; + SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; + SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; + SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_64; + SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; + SPI_InitStructure.SPI_CRCPolynomial = 7; + SPI_Init(SPI1, &SPI_InitStructure); + + /* ʹ SPI1 */ + SPI_Cmd(SPI1, ENABLE); +} + +/* + * SPI1_ReadWrite + * SPI1дһֽ + * + * + * SPI1_ReadWriteByte + */ +uint8_t SPI1_ReadWriteByte(uint8_t writedat) +{ + uint8_t retry=0; + while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET) //ָSPI־λ:ͻձ־λ + { + retry++; + if(retry>200)return 0; + } + SPI_I2S_SendData(SPI1, writedat); //ͨSPIxһ + retry=0; + + while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET) //ָSPI־λ:ܻǿձ־λ + { + retry++; + if(retry>200)return 0; + } + return SPI_I2S_ReceiveData(SPI1); //ͨSPIxյ +} diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/SPI/spi.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/SPI/spi.h new file mode 100755 index 0000000..3673ec2 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/SPI/spi.h @@ -0,0 +1,10 @@ +#ifndef __SPI1_H +#define __SPI1_H + +#include "stm32f10x.h" + +void SPI1_Init(void); +uint8_t SPI1_ReadWriteByte(uint8_t writedat); + + +#endif diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/STMFLASH/stmflash.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/STMFLASH/stmflash.c new file mode 100755 index 0000000..b9dfd5e --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/STMFLASH/stmflash.c @@ -0,0 +1,459 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ stmflash.c + * STM32-FLASH + * V1.0 + * XuZhongPing + * 2017/07/23 +*********************************************************************************/ +#include "stmflash.h" +#include "stdio.h" +#include "delay.h" +#include "timer.h" +#include "gsm_gprs.h" +#include "data_typedef.h" + +#if STM32_FLASH_SIZE < 256 //СMCUһҳĴСΪ1Kֽ +#define STM_SECTOR_SIZE 1024 //һҳֽ +#else +#define STM_SECTOR_SIZE 2048 +#endif + +uint16_t STMFLASH_BUF[STM_SECTOR_SIZE/2]; //ڱһݻ棬ʱȶȡԭݣȻд + +/* +*********************************************************************** +* : STMFLASH_ReadHalfWord +* ˵: ȡַָİ(16λ) +* Σfaddr:ַ(˵ַΪ2ı!!) +* ֵ: Ӧַ +*********************************************************************** +*/ +uint16_t STMFLASH_ReadHalfWord(uint32_t faddr) +{ + return *(vu16*)faddr; +} + +/* +*********************************************************************** +* : STMFLASH_Write_NoCheck +* ˵: ַָд +* ΣWriteAddr:ʼַ +* pBuffer:ָ +* NumToWrite:(16λ) +* ֵ: +*********************************************************************** +*/ +void STMFLASH_Write_NoCheck(uint32_t WriteAddr, uint16_t *pBuffer, uint16_t NumToWrite) +{ + uint16_t i; + + for(i = 0; i < NumToWrite; i++) + { + FLASH_ProgramHalfWord(WriteAddr, pBuffer[i]); + WriteAddr += 2; //ַ2. + } +} + +/* +*********************************************************************** +* : STMFLASH_Write +* ˵: ַָʼдָȵ +* ΣWriteAddr:ʼַ(˵ַΪ2ı!!) +* pBuffer:ָ +* NumToWrite:(16λ)(Ҫд16λݵĸ.) +* ֵ: +*********************************************************************** +*/ +void STMFLASH_Write(uint32_t WriteAddr, uint16_t *pBuffer, uint16_t NumToWrite) +{ + uint32_t secpos; //ַ + uint16_t secoff; //ƫƵַ(16λּ) + uint16_t secremain; //ʣַ(16λּ) + uint32_t offaddr; //ȥ0X08000000ĵַ + uint16_t i; + + if((WriteAddr < STM32_FLASH_BASE) || (WriteAddr >= (STM32_FLASH_BASE + 1024*STM32_FLASH_SIZE)))return; //Ƿַ + FLASH_Unlock(); // + offaddr = WriteAddr-STM32_FLASH_BASE; //ʵƫƵַ. + secpos = offaddr/STM_SECTOR_SIZE; //ַ 0~127 for STM32F103RBT6 + secoff = (offaddr%STM_SECTOR_SIZE)/2; //ڵƫ(2ֽΪλ.) + secremain = STM_SECTOR_SIZE/2 - secoff; //ʣռС + if(NumToWrite <= secremain) //ڸΧ + { + secremain = NumToWrite; + } + while(1) + { + STMFLASH_Read(secpos * STM_SECTOR_SIZE + STM32_FLASH_BASE, STMFLASH_BUF, STM_SECTOR_SIZE/2); // + for(i = 0; i < secremain; i++) //У + { + if(STMFLASH_BUF[secoff + i] != 0XFFFF)break; //Ҫ + } + if(i (STM_SECTOR_SIZE/2)) //һд + { + secremain = STM_SECTOR_SIZE/2; + }else{ //һд + secremain = NumToWrite; + } + } + } + FLASH_Lock(); // +} + +/* +*********************************************************************** +* : STMFLASH_Read +* ˵: ַָʼָȵ +* ΣReadAddr:ʼַ +* pBuffer:ָ +* NumToRead:(16λ) +* ֵ: +*********************************************************************** +*/ +void STMFLASH_Read(uint32_t ReadAddr, uint16_t *pBuffer, uint16_t NumToRead) +{ + uint16_t i; + + for(i = 0; i < NumToRead; i++) + { + pBuffer[i] = STMFLASH_ReadHalfWord(ReadAddr); //ȡ2ֽ. + ReadAddr += 2; //ƫ2ֽ. + } +} + + +/* +*********************************************************************** +* : STMFLASH_WriteHalfWord +* ˵: ָFLASHַдһ16λ +* ΣWriteAddr:ʼַ +* WriteData:Ҫд +* ֵ: +*********************************************************************** +*/ +void STMFLASH_WriteHalfWord(uint32_t WriteAddr, uint16_t WriteData) +{ +// STMFLASH_Write(WriteAddr, &WriteData, 1); //дһ֣16λ + FLASH_ProgramHalfWord(WriteAddr, WriteData); +} + +/* +*********************************************************************** +* : DeviceConfigErase +* ˵: flash +* Σ +* ֵ: +*********************************************************************** +*/ +void DeviceConfigErase(uint32_t WriteAddr) +{ + uint32_t secpos; //ַ + uint16_t secoff; //ƫƵַ(16λּ) + uint32_t offaddr; //ȥ0X08000000ĵַ + + if((WriteAddr < STM32_FLASH_BASE) || (WriteAddr >= (STM32_FLASH_BASE + 1024*STM32_FLASH_SIZE)))return; //Ƿַ + + offaddr = WriteAddr-STM32_FLASH_BASE; //ʵƫƵַ. + secpos = offaddr/STM_SECTOR_SIZE; //ַ 0~127 for STM32F103RBT6 + + FLASH_ErasePage(secpos * STM_SECTOR_SIZE + STM32_FLASH_BASE); // +} + +/* +*********************************************************************** +* : SaveDeviceConfig +* ˵: 豸õIJ +* Σ +* ֵ: +*********************************************************************** +*/ +void SaveDeviceConfig(void) +{ + uint8_t i = 0; + uint16_t uTempData = 0; + uint32_t flashSaveAddr = 0; + + flashSaveAddr = FLASH_SAVE_ADDR; + printf("\r\nTime1 = %d\r\n", time_value); + + FLASH_Unlock(); // + DeviceConfigErase(FLASH_SAVE_ADDR); + + //ݱɹ־λ + uTempData = 0xFFFF; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + + //豸 + uTempData = (uint16_t)(setPassword >> 16); + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + uTempData = (uint16_t)setPassword; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + + //豸ͻ + uTempData = (uint16_t)(setCustomerID >> 16); + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + uTempData = (uint16_t)setCustomerID; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + + //豸ͼͨ + uTempData = (uint16_t)(setDeviceType << 8) | setDevChannelNumbers; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + + //1·Ͷز + uTempData = (uint16_t)(setDevChannel1Type << 8) | setDevChannel1DisDepthVal; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + uTempData = (uint16_t)(setDevChannel1DisMaxVal << 8) | setDevChannel1DisAlarmPercent; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + + //2·Ͷز + uTempData = (uint16_t)(setDevChannel2Type << 8) | setDevChannel2DisDepthVal; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + uTempData = (uint16_t)(setDevChannel2DisMaxVal << 8) | setDevChannel2DisAlarmPercent; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + + //3·Ͷز + uTempData = (uint16_t)(setDevChannel3Type << 8) | setDevChannel3DisDepthVal; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + uTempData = (uint16_t)(setDevChannel3DisMaxVal << 8) | setDevChannel3DisAlarmPercent; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + + //4·Ͷز + uTempData = (uint16_t)(setDevChannel4Type << 8) | setDevChannel4DisDepthVal; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + uTempData = (uint16_t)(setDevChannel4DisMaxVal << 8) | setDevChannel4DisAlarmPercent; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + + flashSaveAddr += 24; //Ԥ32ֽڱͶͨ + + //ICûܺICά빦ܱ־λ + uTempData = (uint16_t)(setDisableICCardFunStatus << 8) | setEnableCleanQRCodeStatus; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + + //豸ų + STMFLASH_WriteHalfWord(flashSaveAddr, setDeviceIdLength); + flashSaveAddr += 2; + + printf("\r\nTime2 = %d\r\n", time_value); + //豸 + for(i = 0; i < 32; i+=2) + { + uTempData = (uint16_t)(setDeviceIdBuf[i] << 8) | setDeviceIdBuf[i+1]; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + } + printf("\r\nTime3 = %d\r\n", time_value); + + //IPַ˿ں + uTempData = (uint16_t)(setIpAddr0 << 8) | setIpAddr1; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + uTempData = (uint16_t)(setIpAddr2 << 8) | setIpAddr3; + STMFLASH_WriteHalfWord(flashSaveAddr, uTempData); + flashSaveAddr += 2; + STMFLASH_WriteHalfWord(flashSaveAddr, setIpPort); + flashSaveAddr += 2; + + //־ + uTempData = 0x0A0B; + STMFLASH_WriteHalfWord(FLASH_SAVE_ADDR, uTempData); + FLASH_Lock(); // + + printf("\r\nTime4 = %d\r\n", time_value); + printf("\r\nɹ\r\n"); +} + +/* +*********************************************************************** +* : GetDeviceConfig +* ˵: ȡ豸ò +* Σ +* ֵ: +*********************************************************************** +*/ +uint8_t GetDeviceConfig(void) +{ + uint8_t i = 0; + uint16_t uTempData = 0; + uint32_t flashSaveAddr = 0; + + flashSaveAddr = FLASH_SAVE_ADDR; + + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + + if(uTempData == 0x0A0B) + { + //豸 + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setPassword = uTempData; + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setPassword = (setPassword << 16) | uTempData; + + //豸ͻ + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setCustomerID = uTempData; + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setCustomerID = (setCustomerID << 16) | uTempData; + + //豸 + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setDeviceType = uTempData >> 8; + setDevChannelNumbers = (uint8_t)uTempData; + + //1·Ͷز + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setDevChannel1Type = uTempData >> 8; + setDevChannel1DisDepthVal = (uint8_t)uTempData; + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setDevChannel1DisMaxVal = uTempData >> 8; + setDevChannel1DisAlarmPercent = (uint8_t)uTempData; + + //2·Ͷز + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setDevChannel2Type = uTempData >> 8; + setDevChannel2DisDepthVal = (uint8_t)uTempData; + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setDevChannel2DisMaxVal = uTempData >> 8; + setDevChannel2DisAlarmPercent = (uint8_t)uTempData; + + //3·Ͷز + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setDevChannel3Type = uTempData >> 8; + setDevChannel3DisDepthVal = (uint8_t)uTempData; + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setDevChannel3DisMaxVal = uTempData >> 8; + setDevChannel3DisAlarmPercent = (uint8_t)uTempData; + + //4·Ͷز + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setDevChannel4Type = uTempData >> 8; + setDevChannel4DisDepthVal = (uint8_t)uTempData; + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setDevChannel4DisMaxVal = uTempData >> 8; + setDevChannel4DisAlarmPercent = (uint8_t)uTempData; + + flashSaveAddr += 24; + + //ICûܺICά빦ܱ־λ + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setDisableICCardFunStatus = uTempData >> 8; + setEnableCleanQRCodeStatus = (uint8_t)uTempData; + + //豸ų + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setDeviceIdLength = uTempData; + + //豸 + for(i = 0; i < 32; i+=2) + { + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setDeviceIdBuf[i] = uTempData >> 8; + setDeviceIdBuf[i+1] = (uint8_t)uTempData; + } + + //IPַ˿ں + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setIpAddr0 = uTempData >> 8; + setIpAddr1 = (uint8_t)uTempData; + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setIpAddr2 = uTempData >> 8; + setIpAddr3 = (uint8_t)uTempData; + uTempData = STMFLASH_ReadHalfWord(flashSaveAddr); + flashSaveAddr += 2; + setIpPort = uTempData; + + printf("\r\nȡɹ\r\n"); + + printf("\r\nSet P=%d; ID=%d; Type=%d; Cnt=%d; T1=%d, h1=%d, H1=%d, A1=%d; T2=%d, h2=%d, H2=%d, A2=%d, ICE=%d; ICQR=%d; "\ + "devLen=%d; devID=%s; IP=%d.%d.%d.%d:%d\r\n", + setPassword, + setCustomerID, + setDeviceType, + setDevChannelNumbers, + setDevChannel1Type, setDevChannel1DisDepthVal, setDevChannel1DisMaxVal, setDevChannel1DisAlarmPercent, + setDevChannel2Type, setDevChannel2DisDepthVal, setDevChannel2DisMaxVal, setDevChannel2DisAlarmPercent, + setDisableICCardFunStatus, + setEnableCleanQRCodeStatus, + setDeviceIdLength, + setDeviceIdBuf, + setIpAddr0,setIpAddr1,setIpAddr2,setIpAddr3,setIpPort + ); + + return 0; + }else{ + printf("\r\nûб豸\r\n"); + return 1; + } +} + +/* +*********************************************************************** +* : ResetDeviceConfig +* ˵: ָ豸ò +* Σ +* ֵ: +*********************************************************************** +*/ +void ResetDeviceConfig(void) +{ + FLASH_Unlock(); // + DeviceConfigErase(FLASH_SAVE_ADDR); + FLASH_Lock(); // + printf("\r\n豸òѻָɳã\r\n"); +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/STMFLASH/stmflash.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/STMFLASH/stmflash.h new file mode 100755 index 0000000..e8bf6fe --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/STMFLASH/stmflash.h @@ -0,0 +1,32 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ stmflash.c + * STM32-FLASH + * V1.0 + * XuZhongPing + * 2017/07/23 +*********************************************************************************/ +#ifndef __STMFLASH_H__ +#define __STMFLASH_H__ +#include "stm32f10x.h" + +#define STM32_FLASH_SIZE 512 //ѡSTM32FLASHС(λΪK) +#define STM32_FLASH_WREN 1 //ʹFLASHд(0;1ʹ) + +//FLASHַ +#define STM32_FLASH_BASE 0x08000000 //STM32 FLASHʼַ +#define FLASH_SAVE_ADDR 0X0807F800 //FLASH ַ(Ϊż) + + +uint16_t STMFLASH_ReadHalfWord(uint32_t faddr); // +uint32_t STMFLASH_ReadLenByte(uint32_t ReadAddr, uint16_t Len); //ַָʼȡָ +void STMFLASH_Write(uint32_t WriteAddr, uint16_t *pBuffer, uint16_t NumToWrite); //ַָʼдָȵ +void STMFLASH_Read(uint32_t ReadAddr, uint16_t *pBuffer, uint16_t NumToRead); //ַָʼָȵ +void STMFLASH_WriteHalfWord(uint32_t WriteAddr, uint16_t WriteData); //ַָдһ֣16λ + +void SaveDeviceConfig(void); +uint8_t GetDeviceConfig(void); +void ResetDeviceConfig(void); + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/TIMER/timer.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/TIMER/timer.c new file mode 100755 index 0000000..0b96b26 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/TIMER/timer.c @@ -0,0 +1,353 @@ +/*************************** (C) COPYRIGHT 2018 Ping **************************** + * ļ timer.c + * ʱ + * V1.0 + * XuZhongPing + * 2017/02/07 +*********************************************************************************/ +#include "timer.h" +#include "usart1.h" +#include "device.h" +#include "data_typedef.h" + +uint32_t time_value = 0;//uip ʱÿ10ms1. + +/* +*********************************************************************** +* : clock_time +* ˵: ȡõǰʱֵ +* : +* ֵ: ǰʱֵ +*********************************************************************** +*/ +clock_time_t clock_time(void) +{ + return time_value; /* 10ms λ */ +} + +/* +*********************************************************************** +* : timer_set +* ˵: һʱ +* : +* t:ʱ +* intervalʱֵ +* ֵ: +*********************************************************************** +*/ +void timer_set(timer *t, clock_time_t interval) +{ + t->interval = interval; + t->start = clock_time(); +} + +/* +*********************************************************************** +* : timer_reset +* ˵: Զʱиλ +* : +* t:ʱ +* ֵ: +*********************************************************************** +*/ +void timer_reset(timer *t) +{ + t->start += t->interval; +} + +/* +*********************************************************************** +* : timer_reset_interval +* ˵: öʱʱ +* : +* t:ʱ +* ֵ: +*********************************************************************** +*/ +void timer_reset_interval(timer *t, clock_time_t interval) +{ + t->interval = interval; +} + +/* +*********************************************************************** +* : timer_restart +* ˵: ӵǰʱʱ +* : +* t:ʱ +* ֵ: +*********************************************************************** +*/ +void timer_restart(timer *t) +{ + t->start = clock_time(); +} + +/* +*********************************************************************** +* : timer_expired +* ˵: жһʱǷﵽʱʱ +* : +* t:ʱ +* ֵ: Ѿ˶ʱʱ䣬ʱδ +*********************************************************************** +*/ +int timer_expired(timer *t) +{ + return (clock_time_t)(clock_time() - t->start) >= (clock_time_t)t->interval; +} + +/* +*********************************************************************** +* : timer_remaining +* ˵: жһʱʣ¶ʱﵽʱʱ +* : +* t:ʱ +* ֵ: ضʱʣʱ +*********************************************************************** +*/ +uint32_t timer_remaining(timer *t) +{ + uint32_t res = 0; + + if(clock_time() < (t->start + (clock_time_t)t->interval)) + { + res = (t->start + (clock_time_t)t->interval) - clock_time(); + return res; + }else{ + return 0; + } +} + +//ʱʱ2ڿʼһʱⲿʹ +//λΪ100ms(0.1S) +/* +*********************************************************************** +* : TIM2_Int_Init +* ˵: ʱ2ʼ +* ΣarrԶװֵ +* pscʱԤƵ +* ֵ: +*********************************************************************** +*/ +void TIM2_Int_Init(uint16_t arr,uint16_t psc) +{ + TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; + NVIC_InitTypeDef NVIC_InitStructure; + + RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); //ʱʹ + + TIM_TimeBaseStructure.TIM_Period = arr; //һ¼װԶװؼĴڵֵ 5000Ϊ500ms + TIM_TimeBaseStructure.TIM_Prescaler = psc; //ΪTIMxʱƵʳԤƵֵ 10KhzļƵʣ0.1msڣ + TIM_TimeBaseStructure.TIM_ClockDivision = 0; //ʱӷָ:TDTS = Tck_tim + TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //TIMϼģʽ + TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure); //TIM_TimeBaseInitStructָIJʼTIMxʱλ + + TIM_ITConfig( TIM2, TIM_IT_Update|TIM_IT_Trigger, ENABLE); //ʹܶʱ2´ж + TIM_Cmd(TIM2, ENABLE); //ʹTIMx + + NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn; //TIM3ж + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //ռȼ0 + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //ȼ3 + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨʹ + NVIC_Init(&NVIC_InitStructure); //NVIC_InitStructָIJʼNVICĴ +} + +/* +*********************************************************************** +* : TIM2_IRQHandler +* ˵: ʱ2жϷӳ +* Σ +* ֵ: +*********************************************************************** +*/ +void TIM2_IRQHandler(void) //TIM2ж +{ + if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET) //ָTIMжϷ:TIM жԴ + { + time_value++; //ʱ1 + } + TIM_ClearITPendingBit(TIM2, TIM_IT_Update); //TIMxжϴλ:TIM жԴ +} + +///////////////////////////////////////////////////////////////////////////////////////////////// +//ʱ3֣ڰɨ裩ÿ10msжһ +/* +*********************************************************************** +* : TIM3_Int_Init +* ˵: ʱ3ʼ +* ΣarrԶװֵ +* pscʱԤƵ +* ֵ: +*********************************************************************** +*/ +void TIM3_Int_Init(uint16_t arr,uint16_t psc) +{ + TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; + NVIC_InitTypeDef NVIC_InitStructure; + + RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); //ʱʹ + + TIM_TimeBaseStructure.TIM_Period = arr; //һ¼װԶװؼĴڵֵ + TIM_TimeBaseStructure.TIM_Prescaler = psc; //ΪTIMxʱƵʳԤƵֵ 10KhzļƵʣ0.1msڣ + TIM_TimeBaseStructure.TIM_ClockDivision = 0; //ʱӷָ:TDTS = Tck_tim + TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //TIMϼģʽ + TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); //TIM_TimeBaseInitStructָIJʼTIMxʱλ + + TIM_ITConfig( TIM3, TIM_IT_Update|TIM_IT_Trigger, ENABLE); //ʹܶʱ2´ж + TIM_Cmd(TIM3, ENABLE); //ʹTIMx + + NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; //TIM3ж + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; //ռȼ0 + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; //ȼ3 + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨʹ + NVIC_Init(&NVIC_InitStructure); //NVIC_InitStructָIJʼNVICĴ +} + +/* +*********************************************************************** +* : TIM3_IRQHandler +* ˵: ʱ2жϷӳ +* Σ +* ֵ: +*********************************************************************** +*/ +void TIM3_IRQHandler(void) //TIM3ж +{ + uint8_t keyTemp = 0; + static uint8_t timerCut = 0; + + if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) //ָTIMжϷ:TIM жԴ + { + if(deviceInitFlag == 1) + { +// OptoKeyScanning(); +// BottleScanning(); //ƿɨ⺯ + + if(keyType == 0) + { + keyTemp = KeyScanning(); + }else if(keyType == 1){ + keyTemp = TouchKeyScanning(); + } + + if(keyTemp != 0) + { + keyValue = keyTemp; //ֵⲿȡ + } + } + } + TIM_ClearITPendingBit(TIM3, TIM_IT_Update); //TIMxжϴλ:TIM жԴ +} + +///////////////////////////////////////////////////////////////////////////////////////////////// +//ʱ4֣ڳࣩ +/* +*********************************************************************** +* : TIM4_Int_Init +* ˵: ʱ4ʼ +* ΣarrԶװֵ +* pscʱԤƵ +* ֵ: +*********************************************************************** +*/ +void TIM4_Int_Init(u16 arr,u16 psc) +{ + TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; + NVIC_InitTypeDef NVIC_InitStructure; + + RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE); //ʱʹ + + //ʱTIM4ʼ + TIM_TimeBaseStructure.TIM_Period = arr; //һ¼װԶװؼĴڵֵ + TIM_TimeBaseStructure.TIM_Prescaler =psc; //ΪTIMxʱƵʳԤƵֵ + TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //ʱӷָ:TDTS = Tck_tim + TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //TIMϼģʽ + TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure); //ָIJʼTIMxʱλ + + TIM_ITConfig(TIM4, TIM_IT_Update | TIM_IT_Trigger, ENABLE); //ʹָTIM4ж,ж + + //жȼNVIC + NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); + + TIM_Cmd(TIM4, DISABLE); +// TIM_Cmd(TIM4, ENABLE); +} + +/* +*********************************************************************** +* : TIM4_IRQHandler +* ˵: ʱ4жϷӳ +* Σ +* ֵ: +*********************************************************************** +*/ +void TIM4_IRQHandler(void) //TIM4ж +{ + if (TIM_GetITStatus(TIM4, TIM_IT_Update) != RESET) //TIM4жϷ + { + TIM_ClearITPendingBit(TIM4, TIM_IT_Update); //TIMxжϱ־ + } +} + +///////////////////////////////////////////////////////////////////////////////////////////////// +//ʱ4֣ڶάͷݽɱã +/* +*********************************************************************** +* : TIM5_Int_Init +* ˵: ʱ5ʼ +* ΣarrԶװֵ +* pscʱԤƵ +* ֵ: +*********************************************************************** +*/ +void TIM5_Int_Init(uint16_t arr, uint16_t psc) +{ + TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; + NVIC_InitTypeDef NVIC_InitStructure; + + RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE); + + //ʱTIM5ʼ + TIM_TimeBaseStructure.TIM_Period = arr; //һ¼װԶװؼĴڵֵ + TIM_TimeBaseStructure.TIM_Prescaler =psc; //ΪTIMxʱƵʳԤƵֵ + TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //ʱӷָ:TDTS = Tck_tim + TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //TIMϼģʽ + TIM_TimeBaseInit(TIM5, &TIM_TimeBaseStructure); //ָIJʼTIMxʱλ + + TIM_ITConfig(TIM5,TIM_IT_Update,ENABLE ); //ʹָTIM4ж,ж + + //жȼNVIC + NVIC_InitStructure.NVIC_IRQChannel = TIM5_IRQn; //TIM5ж + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; //ռȼ3 + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; //ȼ2 + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨʹ + NVIC_Init(&NVIC_InitStructure); //ʼNVICĴ + + TIM_Cmd(TIM5, DISABLE); //ʧTIMx +} + +/* +*********************************************************************** +* : TIM5_IRQHandler +* ˵: ʱ4жϷӳ +* Σ +* ֵ: +*********************************************************************** +*/ +void TIM5_IRQHandler(void) +{ + if(TIM_GetITStatus(TIM5, TIM_IT_Update) != RESET) //TIM5жϷ + { + USART1_RX_STA |= 1<<15; //ǽ + TIM_ClearITPendingBit(TIM5, TIM_IT_Update); //TIMxжϱ־ + TIM_Cmd(TIM5, DISABLE); //رTIMx + } +} + +/******************** (C) COPYRIGHT 2018 Ping *****END OF FILE*******************/ + diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/TIMER/timer.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/TIMER/timer.h new file mode 100755 index 0000000..02ac6cf --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/TIMER/timer.h @@ -0,0 +1,35 @@ +#ifndef __TIMER_H +#define __TIMER_H + +#include "stm32f10x.h" + +typedef uint32_t clock_time_t; +#define CLOCK_CONF_SECOND 10 +#define CLOCK_SECOND CLOCK_CONF_SECOND +extern uint32_t time_value; //ʱֵ + + +typedef struct _timer { + clock_time_t start; + clock_time_t interval; +}timer; + +void timer_set(timer *t, clock_time_t interval); +void timer_reset(timer *t); +void timer_reset_interval(timer *t, clock_time_t interval); +void timer_restart(timer *t); +int timer_expired(timer *t); +uint32_t timer_remaining(timer *t); + +void TIM2_Int_Init(u16 arr,u16 psc); + +// void TIM2_Int_Init(u16 arr,u16 psc); +void TIM3_Int_Init(u16 arr,u16 psc); +void TIM3_Period_Reset(u16 arr); + +void TIM4_Int_Init(u16 arr,u16 psc); +void TIM5_Int_Init(u16 arr,u16 psc); + +void TIM6_Int_Init(u16 arr,u16 psc); + +#endif diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/RS485.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/RS485.c new file mode 100755 index 0000000..dc3f642 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/RS485.c @@ -0,0 +1,453 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ RS485.c + * RS485ͨŴ3֣֡򡢷ִ֡ + * V1.0 + * XuZhongPing + * 2017/02/10 +*********************************************************************************/ +#include "delay.h" +#include "sys.h" +#include "RS485.h" +#include "usart.h" +#include "timer.h" +#include "DataProcessing.h" +#include "message.h" + +/*ͨѶ*/ +#define BaudRate 19200 //1200bps + +uint8_t Address = 0x00; //豸ַ +uint8_t RS485_RX_BUF[128]; //ջ,64ֽ +uint8_t RS485_TX_BUF[64]; //ͻ,64ֽ + +// +uint8_t RS485_RX_STA = 0x00; //RS485״̬ +uint8_t RS485_communicationStatus; //RS485ͨѶɹ־ +uint16_t RS485_serialNumber; //RS485ͨˮ +uint16_t RS485_RX_serialNumber; //RS485ͨˮ +uint8_t rxCmd; //ӻصָ + +/* +*********************************************************************** +* : RS485_Init +* ˵: ʼRS485ӿ +* : +* ֵ: +*********************************************************************** +*/ +void RS485_Init(void) +{ + //GPIO˿ + GPIO_InitTypeDef GPIO_InitStructure; + USART_InitTypeDef USART_InitStructure; + NVIC_InitTypeDef NVIC_InitStructure; + + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //ʹGPIOAʱ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); //ʹUSART2ʱ + + //RS485_TX_EN PA.0 RS485ͽտƽ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; //PA0˿ + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(GPIOA, &GPIO_InitStructure); + GPIO_ResetBits(GPIOA, GPIO_Pin_0); //0ĬϽ״̬ + + //USART2_TX PA.2 + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; //PA.2 + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; // + GPIO_Init(GPIOA, &GPIO_InitStructure); //ʼPA2 + + //USART2_RX PA.3 + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; // + GPIO_Init(GPIOA, &GPIO_InitStructure); //ʼPA3 + + //USART ʼ + + USART_InitStructure.USART_BaudRate = BaudRate; //һΪ9600; + USART_InitStructure.USART_WordLength = USART_WordLength_8b; //ֳΪ8λݸʽ + USART_InitStructure.USART_StopBits = USART_StopBits_1; //һֹͣλ + USART_InitStructure.USART_Parity = USART_Parity_No; //żУλ + USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; //Ӳ + USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //շģʽ + USART_Init(USART2, &USART_InitStructure); //ʼ + + //Usart2 NVIC + NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0 ; //ռȼ0 + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; //ȼ0 + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨʹ + NVIC_Init(&NVIC_InitStructure); //ָIJʼVICĴ + + USART_ITConfig(USART2, USART_IT_RXNE, ENABLE); //ж + USART_Cmd(USART2, ENABLE); //ʹܴ +} + +/* +*********************************************************************** +* : USART2_IRQHandler +* ˵: 2жϷӺRS485 +* : +* ֵ: +*********************************************************************** +*/ +void USART2_IRQHandler(void) +{ + uint8_t res; + static uint8_t RX_State = 0; //״̬ + static uint8_t CS = 0; //պ + static uint8_t RX_Size = 0; //ͨѶݳ + static uint8_t Byte_Count = 0; //ֽڼ + + if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) + { + res = USART_ReceiveData(USART2); //ȡյ +// printf("RX_DATA = %x\r\n", res); + switch(RX_State) + { + case 0: //һǰֽ + if(res == 0xfe){ + RX_State = 1; + }else{ + RX_State = 0; + } + break; + case 1: //ڶǰֽ + if(res == 0xfe){ + RX_State = 1; //ת֡ͷ + }else{ + if(res == 0x68) + { + RX_State = 3; //ת豸ͨѶַ + CS = 0x68; + }else{ + RX_State = 0; + } + } + break; +// case 2: //֡ͷ +// if(res == 0x68){ +// RX_State = 3; //ת豸ͨѶַ +// CS = 0x68; +// }else{ +// RX_State = 0; +// } +// break; + case 3: //豸ͨѶַ + RS485_RX_BUF[0] = res; + CS += res; + RX_State = 4; + break; + case 4: //֡ͷ + if(res == 0x68){ + RX_State = 5; //תͨѶ + CS += 0x68; + }else{ + RX_State = 0; + } + break; + case 5: //ͨѶ + RS485_RX_BUF[1] = res; + CS += res; + RX_State = 6; //תݳ + break; + case 6: //ͨѶݳ + RS485_RX_BUF[2] = res; + CS += res; + RX_Size = res; //յݳ + if(RX_Size == 0x00){ //ݳΪ0ֱתУ + RX_State = 8; + }else{ + RX_State = 7; //ת + } + break; + case 7: //Nֽ + if(Byte_Count < RX_Size-1){ + RS485_RX_BUF[Byte_Count + 3] = res; + CS += res; + Byte_Count++; + }else{ + RS485_RX_BUF[Byte_Count + 3] = res; + CS += res; + Byte_Count = 0; //Nֽڵݽռ0 + RX_State = 8; //תպ + } + break; + case 8: //У + if(CS != res){ + RX_State = 0; + }else{ + RX_State = 9; //ת֡β0x16 + } + break; + case 9: //֡β + if(res == 0x16){ //֡β + RS485_RX_STA = 0xfd; //һ֡ճɹUSART_RX_STA=0xfd֪ͨͨѶ +// printf("\r\n<--\r\n"); + } + RX_State = 0; + break; + default: // + break; + } + } +} + +/* +*********************************************************************** +* : Send_Data +* ˵: һֽ +* : +* ֵ: +*********************************************************************** +*/ +void Send_Data(uint8_t Serial_data) +{ +// CTRL485 = 1; //Ϊģʽ + USART_SendData(USART2, Serial_data); //򴮿ڷ + while(USART_GetFlagStatus(USART2, USART_FLAG_TC) != SET);//ȴͽ +// CTRL485 = 0; //ָΪģʽ +} + +/* +*********************************************************************** +* : Send_One +* ˵: һ֡ +* : ַָ֡ +* ֵ: +*********************************************************************** +*/ +void Send_One(uint8_t *s) +{ + uint8_t i; + uint8_t CS = 0x68; //պ + uint8_t TX_Size = 0; //ͨѶݳ + printf("\r\n----->RS485--> %x\r\n", *(s+1)); + CTRL485 = 1; //RS-485 ͨѶлΪ״̬ + + delay_ms(1); + Send_Data(0xfe); //2ǰֽ + Send_Data(0xfe); + Send_Data(0xfe); + Send_Data(0x68); //֡ͷ + Send_Data(*s); //͵ַ + CS += *s; + Send_Data(0x68); //֡ͷ + CS += 0x68; + Send_Data(*(s+1)); //֡ + CS += *(s+1); + TX_Size = *(s+2); //ȡͨѶݳ + Send_Data(TX_Size); //ݳ + CS += *(s+2); + for(i=0; iޣ0x01->IC0x02->ά룩 +// receiveDataLength = *(s+6); //ȡϢݳ +// memcpy(receiveDataBuf, (s+7), 33); //ȡϢ +// } + break; + + case 0x22: //Ҫӻϴεû״̬Ϣ +// if(*(s+3)) +// { +// clearPutInInfoMark = 1; +// } + break; + + case 0x23: //ȡࡢ +// getPutInInfoMark = *(s+3); //ȡӻ̴״̬ +// if(getPutInInfoMark) //ӻѾɹ̴ +// { +// receiveDistance_a = *(s+4); //ȡ +// receiveDistance_b = *(s+5); //ȡ + +// receiveWeight_a = (uint16_t)(*(s+6)) << 8; //ȡ8λ +// receiveWeight_a |= *(s+7); //ȡ8λ +// +// receiveWeight_b = (uint16_t)(*(s+8)) << 8; //ȡ8λ +// receiveWeight_b |= *(s+9); //ȡ8λ +// +// printf("\r\n<- = %2.2f Kg; %2.2f Kg\r\n", (float)receiveWeight_a/100, (float)receiveWeight_b/100); +// printf("\r\n<- 1 = %3.1f cm\r\n", (float)receiveDistance_a); +// printf("\r\n<- 2 = %3.1f cm\r\n", (float)receiveDistance_b); +// +// } + break; + + case 0x24: //յMCU2ϴ̨ݣûͶϢ + memset(receiveDataBuf, 0x00, 33); //ǰȰ֮ǰĻ + + //ȡûϢ + receivePutInType = *(s+3); //ȡͣ0x00->ޣ0x01->IC0x02->ά룩 + receiveDataLength = *(s+4); //ȡϢݳ + memcpy(receiveDataBuf, (s+5), 33); //ȡϢ + + //ȡһغͲ + weight_paper = (uint16_t)(*(s+38)) << 8; //ȡ8λ + weight_paper |= *(s+39); //ȡ8λ + distance_paper = *(s+40); //ȡ + + //ȡڶغͲ + weight_plastic = (uint16_t)(*(s+41)) << 8; //ȡ8λ + weight_plastic |= *(s+42); //ȡ8λ + distance_plastic = *(s+43); //ȡ + + //ȡغͲ + weight_metal = (uint16_t)(*(s+44)) << 8; //ȡ8λ + weight_metal |= *(s+45); //ȡ8λ + distance_metal = *(s+46); //ȡ + + //ȡغͲ + weight_glass = (uint16_t)(*(s+47)) << 8; //ȡ8λ + weight_glass |= *(s+48); //ȡ8λ + distance_glass = *(s+49); //ȡ + + receiveDataStatus = 1; //յMCU2͵ͶϢñ־λ1ⲿȡ + + break; + + case 0x25: //յMCU2͹豸Ϣࡢ¶ȣ + temperature = *(s+3); //ȡ¶ + + distance_paper = *(s+4); //ȡֽͰ + distance_plastic = *(s+5); //ȡͰ + distance_metal = *(s+6); //ȡͰ + distance_glass = *(s+7); //ȡͰ + + recDeviceStatus = 1; //յMCU2͵豸Ϣñ־λ1ⲿȡ + + break; + + default: // + break; + } + + break; + + case 0x00: //ַ + return 0; + break; + } + return 1; //ִ֡ȷ +} + + +/* +*********************************************************************** +* : RS485_Task +* ˵: RS485ͨѶ +* : +* ֵ: +*********************************************************************** +*/ +void RS485_Task(void) +{ +} + +/* +*********************************************************************** +* : Receive_One +* ˵: RS485һͨѶ +* : +* ֵ: +*********************************************************************** +*/ +void RS485_ReceiveTask(void) +{ + if(RS485_RX_STA == 0xfd) //нյӻصݣҪ֤ + { + Serial_Command_Run(RS485_RX_BUF); //ͷص + RS485_RX_STA = 0; + } +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/UsarInterface.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/UsarInterface.c new file mode 100755 index 0000000..49bf36a --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/UsarInterface.c @@ -0,0 +1,17 @@ +/*************************** (C) COPYRIGHT 2014 GLHF **************************** + * ļ USART5.c + * 5(ش2) + * V1.0 + * XuZhongPing + * 2017/03/15 +*********************************************************************************/ +#include "usart.h" +#include "UsarInterface.h" +#include "rs485.h" + + +void USART5_ReceiveDataHandler(uint8_t res) +{ +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/UsarInterface.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/UsarInterface.h new file mode 100755 index 0000000..739a6e2 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/UsarInterface.h @@ -0,0 +1,19 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ usart5.h + * 5ͷļ + * V1.0 + * XuZhongPing + * 2017/03/15 +*********************************************************************************/ +#ifndef __USART_InterFace_H +#define __USART_InterFace_H + +#include "stm32f10x.h" +#include "stdio.h" + +void USART5_ReceiveDataHandler(uint8_t res); + +#endif + + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/crc16.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/crc16.c new file mode 100755 index 0000000..4f1952c --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/crc16.c @@ -0,0 +1,77 @@ +#include +#include +#include "stdio.h" +#include "crc16.h" + +const unsigned char auchCRCLo[]={ +0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5, 0xC4, +0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, +0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, +0x1D, 0x1C, 0xDC, 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3, +0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32, 0x36, 0xF6, 0xF7, +0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, +0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, +0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26, +0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1, 0x63, 0xA3, 0xA2, +0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, +0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB, +0x7B, 0x7A, 0xBA, 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5, +0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, 0x50, 0x90, 0x91, +0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C, +0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98, 0x88, +0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C, +0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83, 0x41, 0x81, 0x80, +0x40 +}; + +/* Table of CRC values for highCorder byte */ +const unsigned char auchCRCHi[]={ +0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, +0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, +0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, +0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, +0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, +0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, +0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, +0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, +0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, +0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, +0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, +0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, +0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, +0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, +0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, +0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, +0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, +0x40 +}; + +/*--------------------------------------------------------- + *ƣunsigned int getCRC16(unsigned char array[],unsigned int length) + *ܣCRC16У + *УݡУ鳤 + * + *زУֵ + *-------------------------------------------------------*/ +unsigned int GetCRC16(unsigned char *array,unsigned int length) +{ + unsigned char uchCRCHi = 0xFF ; /* ʼֽ*/ + unsigned char uchCRCLo = 0xFF ; /* ʼֽ*/ + unsigned char uIndex ; /*CRC*/ + unsigned char *p = array; + while(length--) + { + uIndex = uchCRCHi^*(p++); + uchCRCHi = uchCRCLo^auchCRCHi[uIndex]; + uchCRCLo = auchCRCLo[uIndex]; + } + return ((uchCRCHi<<8)|uchCRCLo); + + //ijЩУֵָ8λ8λΪ0x00 + //Ӷ³ûʱ0x00滻һ0x00ֵ + //return ((((uchCRCHi<<8) == 0)?(0xAA<<8):(uchCRCHi<<8)) | ((uchCRCLo == 0)?0xAA:uchCRCLo)); +} + + + + diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/crc16.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/crc16.h new file mode 100755 index 0000000..b24e28f --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/crc16.h @@ -0,0 +1,9 @@ +#ifndef __CRC16_H +#define __CRC16_H + +unsigned int GetCRC16(unsigned char *array,unsigned int length); + +#endif + + + diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/printf.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/printf.c new file mode 100755 index 0000000..20cac30 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/printf.c @@ -0,0 +1,65 @@ +/* +******************************************************************************* +* +* ģ : printfģ +* ļ : printf.c +* ˵ : ʵprintfscanfض򵽴1֧printfϢUSART1 +* ʵضֻҪ2: +* int fputc(int ch, FILE *f); +* int fgetc(FILE *f); +* KEIL MDKѡҪMicorLibǰ򹳣򲻻ݴӡUSART1 +* +* cģ޶Ӧhļ +* +******************************************************************************* +*/ + +/* Includes ------------------------------------------------------------------*/ +#include +#include "sys.h" + +#if 1 + +struct __FILE +{ + int handle; +}; + +FILE __stdout; +//_sys_exit()Աʹðģʽ +_sys_exit(int x) +{ + x = x; +} + +/********************************************************* + * @function fputc + * @role ضputcʹprintfӴ1ӡ + * @input None + * @output None + * @return None + ********************************************************/ +int fputc(int ch, FILE *f) +{ + while((USART1->SR&0X40)==0);//ѭ,ֱ + USART1->DR = (u8) ch; + return ch; +} + +///********************************************************* +// * @function fgetc +// * @role ضgetcʹscanffӴ1 +// * @input None +// * @output None +// * @return None +// ********************************************************/ +//int fgetc(FILE *f) +//{ +// /* ȴ1 */ +// while (USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET); +// return (int)USART_ReceiveData(USART1); +//} + + +#endif + diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/rs485.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/rs485.h new file mode 100755 index 0000000..81a340b --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/rs485.h @@ -0,0 +1,37 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ RS485.h + * RS485ͨŴͷļ + * V1.0 + * XuZhongPing + * 2017/02/10 +*********************************************************************************/ +#ifndef __RS485_H +#define __RS485_H +#include "stdio.h" +#include "stdint.h" + +#define CTRL485 PAout(0) //485ģʽ +extern uint8_t Address; + +extern uint8_t RS485_RX_BUF[128]; //ջ +extern uint8_t RS485_TX_BUF[64]; //ͻ + +extern uint8_t RS485_RX_STA; //RS485״̬ +extern uint8_t RS485_communicationStatus; //RS485ͨѶɹ־ +extern uint16_t RS485_serialNumber; //RS485ͨˮ +extern uint16_t RS485_RX_serialNumber; //RS485ͨˮ +extern uint8_t rxCmd; //ӻصָ + +void RS485_Init(void); +uint8_t Receive_One(uint8_t *s); +void Send_Data(uint8_t Serial_data); +void Send_One(uint8_t *s); +uint8_t Serial_Command_Run(uint8_t *s); +void Serial_Command(void); +void RS485_Task(void); +void RS485_ReceiveTask(void); + +#endif + + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart1.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart1.c new file mode 100755 index 0000000..0fe6b13 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart1.c @@ -0,0 +1,125 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ usart.c + * 1 + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#include "usart1.h" + +uint8_t USART1_RX_BUF[USART1_RECV_LEN]; //ջ,USART_REC_LENֽ. +uint16_t USART1_RX_STA = 0; //״̬ + +/* +*********************************************************************** +* : USART1_Init +* ˵: 1ʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void USART1_Init(uint32_t bound) +{ + //GPIO˿ + GPIO_InitTypeDef GPIO_InitStructure; + USART_InitTypeDef USART_InitStructure; + NVIC_InitTypeDef NVIC_InitStructure; + + RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE); //ʹUSART1GPIOAʱ + USART_DeInit(USART1); //λ1 + + //USART1_TX PA.9 + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; // + GPIO_Init(GPIOA, &GPIO_InitStructure); + + //USART1_RX PA.10 + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; // + GPIO_Init(GPIOA, &GPIO_InitStructure); + + //USART ʼ + USART_InitStructure.USART_BaudRate = bound; //ò + USART_InitStructure.USART_WordLength = USART_WordLength_8b; //ֳΪ8λݸʽ + USART_InitStructure.USART_StopBits = USART_StopBits_1; //һֹͣλ + USART_InitStructure.USART_Parity = USART_Parity_No; //żУλ + USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;//Ӳ + USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //շģʽ + USART_Init(USART1, &USART_InitStructure); //ʼ + + //Usart1 NVIC + NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1 ; //ռȼ + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; //ȼ + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨʹ + NVIC_Init(&NVIC_InitStructure); + + USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); //ж + USART_Cmd(USART1, ENABLE); + USART1_RX_STA = 0; +} + +/* +*********************************************************************** +* : USART1_IRQHandler +* ˵: жϷ +* Σ +* ֵ: +*********************************************************************** +*/ +void USART1_IRQHandler(void) +{ + uint8_t res = 0; + + if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) //ж(յݱ0x0d 0x0aβ) + { + res = USART_ReceiveData(USART1); //ȡյ + if(USART1_RX_STA < USART1_RECV_LEN) //Խ + { + TIM_SetCounter(TIM5, 0); // + if(USART1_RX_STA == 0) + { + TIM_Cmd(TIM5, ENABLE); //ʹܶʱ5ж + } + USART1_RX_BUF[USART1_RX_STA++] = res; //¼յֵ + }else{ + USART1_RX_STA |= 1<<15; //ǿƱǽ + } + } +} + +/* +*********************************************************************** +* : USART1_SendByteData +* ˵: һֽ +* : +* ֵ: +*********************************************************************** +*/ +void USART1_SendByteData(uint8_t bData) +{ + USART_SendData(USART1, bData); + while(USART_GetFlagStatus(USART1, USART_FLAG_TC) != SET); //ȴͽ +} + +/* +*********************************************************************** +* : USART1_SendFrameData +* ˵: һ֡ +* : pData -> ݵ׵ַlen -> ݵij +* ֵ: +*********************************************************************** +*/ +void USART1_SendFrameData(uint8_t pDataBuf[], uint16_t len) +{ + uint16_t i = 0; + + USART_ClearFlag(USART1, USART_FLAG_TC); + for(i = 0; i < len; i++) + { + USART1_SendByteData(pDataBuf[i]); + } +} + +/******************** (C) COPYRIGHT 2017 ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart1.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart1.h new file mode 100755 index 0000000..a37b15a --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart1.h @@ -0,0 +1,25 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ usart.h + * 1 + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#ifndef __USART_H +#define __USART_H +#include "stm32f10x.h" + +#define USART1_RECV_LEN 128 //ջֽ +#define USART1_SEND_LEN 128 //ͻֽ + +extern uint8_t USART1_RX_BUF[USART1_RECV_LEN]; //ջ,USART_REC_LENֽ +extern uint16_t USART1_RX_STA; //״̬ + +void USART1_Init(uint32_t bound); +void USART1_SendByteData(uint8_t bData); +void USART1_SendFrameData(uint8_t pDataBuf[], uint16_t len); + +#endif + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ + diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart2.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart2.c new file mode 100755 index 0000000..a96ba42 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart2.c @@ -0,0 +1,220 @@ +/*************************** (C) COPYRIGHT 2017 Ping **************************** + * ļ usart2.c + * 2 + * V1.0 + * XuZhongPing + * 2017/09/04 +*********************************************************************************/ +#include "usart2.h" + +uint8_t USART2_RX_BUF[USART2_RECV_LEN]; //ջ +uint8_t USART2_TX_BUF[USART2_SEND_LEN]; //ջ +uint8_t USART2_RX_STA = 0; //״̬ + +void USART2_ReceiveHandler(uint8_t res); + +/* +*********************************************************************** +* : USART2_Init +* ˵: 2ʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void USART2_Init(uint32_t bound) +{ + //GPIO˿ + GPIO_InitTypeDef GPIO_InitStructure; + USART_InitTypeDef USART_InitStructure; + NVIC_InitTypeDef NVIC_InitStructure; + + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //ʹGPIOAʱ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); //ʹUSART2ʱ + + //USART2_TX PA.2 + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; //PA.2 + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; // + GPIO_Init(GPIOA, &GPIO_InitStructure); //ʼPA2 + + //USART2_RX PA.3 + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; // + GPIO_Init(GPIOA, &GPIO_InitStructure); //ʼPA3 + + //USART ʼ + USART_InitStructure.USART_BaudRate = bound; //һΪ9600; + USART_InitStructure.USART_WordLength = USART_WordLength_8b; //ֳΪ8λݸʽ + USART_InitStructure.USART_StopBits = USART_StopBits_1; //һֹͣλ + USART_InitStructure.USART_Parity = USART_Parity_No; //żУλ + USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; //Ӳ + USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //շģʽ + USART_Init(USART2, &USART_InitStructure); //ʼ + + //Usart1 NVIC + NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0 ; //ռȼ0 + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //ȼ0 + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨʹ + NVIC_Init(&NVIC_InitStructure); //ָIJʼVICĴ + + USART_ITConfig(USART2, USART_IT_RXNE, ENABLE); //ж + USART_Cmd(USART2, ENABLE); //ʹܴ +} + +/* +*********************************************************************** +* : USART2_IRQHandler +* ˵: 2жϷ +* Σ +* ֵ: +*********************************************************************** +*/ +void USART2_IRQHandler(void) +{ + uint8_t res = 0; + + if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) //յ + { + res = USART_ReceiveData(USART2); //ȡյ + USART2_ReceiveHandler(res); + } +} + +/* +*********************************************************************** +* : USART2_SendByteData +* ˵: һֽ +* : +* ֵ: +*********************************************************************** +*/ +void USART2_SendByteData(uint8_t bData) +{ + USART_SendData(USART2, bData); + while(USART_GetFlagStatus(USART2, USART_FLAG_TC) != SET); //ȴͽ +} + +/* +*********************************************************************** +* : USART2_SendFrameData +* ˵: һ֡ +* : pData -> ݵ׵ַlen -> ݵij +* ֵ: +*********************************************************************** +*/ +void USART2_SendFrameData(uint8_t pDataBuf[], uint16_t len) +{ + uint16_t i = 0; + + USART_ClearFlag(USART2, USART_FLAG_TC); + for(i = 0; i < len; i++) + { + USART2_SendByteData(pDataBuf[i]); + } +} + +/* +*********************************************************************** +* : USART2_ReceiveHandler +* ˵: ݽմ +* : 봮ڽյ +* ֵ: ޣӰ촮ڽ״̬USART2_RX_STA +*********************************************************************** +*/ +void USART2_ReceiveHandler(uint8_t res) +{ + static uint8_t RX_Status = 0; //״̬ + static uint8_t CS = 0; //պ + static uint8_t RX_Size = 0; //ͨѶݳ + static uint8_t RX_ByteCount = 0; //ֽڼ + +// printf("U2 = %02X\r\n", res); + + switch(RX_Status) + { + case 0: //һǰֽ + if(res == 0xfe){ + RX_Status = 1; + }else{ + RX_Status = 0; + } + break; + + case 1: //ڶǰֽ + if(res == 0xfe){ + RX_Status = 1; //ǰֽ + }else if(res == 0x68){ + RX_Status = 3; //ת豸ͨѶַ + CS = 0x68; + }else{ + RX_Status = 0; + } + break; + + case 3: //豸ͨѶַ + USART2_RX_BUF[0] = res; + CS += res; + RX_Status = 4; + break; + + case 4: //֡ͷ + if(res == 0x68){ + RX_Status = 5; //תͨѶ + CS += 0x68; + }else{ + RX_Status = 0; + } + break; + case 5: //ͨѶ + USART2_RX_BUF[1] = res; + CS += res; + RX_Status = 6; //תݳ + break; + + case 6: //ͨѶݳ + USART2_RX_BUF[2] = res; + CS += res; + RX_Size = res; //յݳ + if(RX_Size == 0x00){ //ݳΪ0ֱתУ + RX_Status = 8; + }else{ + RX_Status = 7; //ת + } + break; + + case 7: //Nֽ + if(RX_ByteCount < RX_Size-1){ + USART2_RX_BUF[RX_ByteCount + 3] = res; + CS += res; + RX_ByteCount++; + }else{ + USART2_RX_BUF[RX_ByteCount + 3] = res; + CS += res; + RX_ByteCount = 0; //Nֽڵݽռ0 + RX_Status = 8; //תպ + } + break; + + case 8: //У + if(CS != res){ + RX_Status = 0; + }else{ + RX_Status = 9; //ת֡β0x16 + } + break; + + case 9: //֡β + if(res == 0x16){ //֡β + USART2_RX_STA = 0xfd; //һ֡ճɹǽյһ֪֡ͨͨѶ + } + RX_Status = 0; + break; + + default: // + RX_Status = 0; + break; + } +} + +/******************** (C) COPYRIGHT 2017 Ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart2.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart2.h new file mode 100755 index 0000000..8123468 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart2.h @@ -0,0 +1,26 @@ +/*************************** (C) COPYRIGHT 2017 Ping **************************** + * ļ usart2.h + * 2ͷļ + * V1.0 + * XuZhongPing + * 2017/09/04 +*********************************************************************************/ +#ifndef __USART2_H +#define __USART2_H +#include "stm32f10x.h" +#include "stdio.h" + +#define USART2_RECV_LEN 128 //ջֽ +#define USART2_SEND_LEN 128 //ͻֽ + +extern uint8_t USART2_RX_BUF[USART2_RECV_LEN]; +extern uint8_t USART2_TX_BUF[USART2_SEND_LEN]; +extern uint8_t USART2_RX_STA; + +void USART2_Init(uint32_t bound); +void USART2_SendByteData(uint8_t bData); +void USART2_SendFrameData(uint8_t pDataBuf[], uint16_t len); + +#endif + +/******************** (C) COPYRIGHT 2017 Ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart3.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart3.c new file mode 100755 index 0000000..1aac56d --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart3.c @@ -0,0 +1,156 @@ +/*************************** (C) COPYRIGHT 2014 GLHF **************************** + * ļ usart3.c + * 3(GPRS) + * V1.0 + * XuZhongPing + * 2013/11/21 +*********************************************************************************/ +#include "stm32f10x.h" +#include "delay.h" +#include "usart3.h" +#include "stdarg.h" +#include "stdio.h" +#include "string.h" +#include "gsm_uart.h" +#include "gsm_uart_conf.h" + +static void UART3_DMA_Config(void); + +/* +*********************************************************************** +* : USART3_Init +* ˵: 3ʼ +* : +* ֵ: +*********************************************************************** +*/ +void USART3_Init(u32 bound) +{ + //GPIO˿ + GPIO_InitTypeDef GPIO_InitStructure; + USART_InitTypeDef USART_InitStructure; + NVIC_InitTypeDef NVIC_InitStructure; + + //ʹõʱ + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); //ʹGPIOBʱ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); //ʹUSART3ʱ + + USART_DeInit(USART3); //λ3 + + //USART3_TX PB.10 + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; // + GPIO_Init(GPIOB, &GPIO_InitStructure); //ʼPB10 + + //USART3_RX PB.11 + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; // + GPIO_Init(GPIOB, &GPIO_InitStructure); //ʼPB11 + + + //USART ʼ + USART_InitStructure.USART_BaudRate = bound; //ò; + USART_InitStructure.USART_WordLength = USART_WordLength_8b; //ֳΪ8λݸʽ + USART_InitStructure.USART_StopBits = USART_StopBits_1; //һֹͣλ + USART_InitStructure.USART_Parity = USART_Parity_No; //żУλ + USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; //Ӳ + USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //շģʽ + + USART_Init(USART3, &USART_InitStructure); //ʼ + + UART3_DMA_Config(); //DMA1ͨ2,Ϊ3,洢ΪUSART3_TX_BUF + + //Usart3 NVIC + NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0 ; //ռȼ0 + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //ȼ1 + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨʹ + NVIC_Init(&NVIC_InitStructure); //ָIJʼVICĴ + + USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); //ж + + USART_Cmd(USART3, ENABLE); //ʹܴ + GPRS_RX_STA = 0; //״̬ + TIM_Cmd(TIM4, DISABLE); //رTIMx +} + +/* +*********************************************************************** +* : USART3_IRQHandler +* ˵: 3жϣڽGSM_GPRSݣ +* ͨжϽ2ַ֮ʱ10msDzһ. +* 2ַռ10ms,Ϊ1.Ҳdz10msûнյ +* κ,ʾ˴ν. +* : +* ֵ: ӰȫֱGPRS_RX_STA: +* [15]:0,ûнյ;1,յһ. +* [14:0]:յݳ +*********************************************************************** +*/ +void USART3_IRQHandler(void) +{ + uint8_t res; + if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) //յ + { + res = USART_ReceiveData(USART3); //ȡյ + GSM_GPRS_ReceiveData(res); + } +} + +///////////////////////////////////////USART3 DMAò////////////////////////////////// +//DMA1ĸͨ +//Ĵʽǹ̶,Ҫݲͬ޸ +//Ӵ洢->ģʽ/8λݿ/洢ģʽ +//DMA_CHx:DMAͨCHx +//cpar:ַ +//cmar:洢ַ + +/* +*********************************************************************** +* : UART3_DMA_Config +* ˵: GSM +* : +* ֵ: +*********************************************************************** +*/ +static void UART3_DMA_Config(void) +{ + DMA_InitTypeDef DMA_InitStructure; + RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); //ʹDMA + + delay_us(5); + DMA_DeInit(DMA1_Channel2); //DMAͨ2ĴΪȱʡֵ +// DMA1_MEM_LEN=cndtr; + DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&USART3->DR; //DMAADCַ + DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)GPRS_TX_BUF; //DMAڴַ + DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; //ݴ䷽򣬴ڴȡ͵ +// DMA_InitStructure.DMA_BufferSize = cndtr; //DMAͨDMAĴС + DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //ַĴ + DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //ڴַĴ + DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; //ݿΪ8λ + DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; //ݿΪ8λ + DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; //ģʽ + DMA_InitStructure.DMA_Priority = DMA_Priority_Medium; //DMAͨ xӵȼ + DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; //DMAͨxûΪڴ浽ڴ洫 + DMA_Init(DMA1_Channel2, &DMA_InitStructure); //DMA_InitStructָIJʼDMAͨUSART1_Tx_DMA_ChannelʶļĴ + + USART_DMACmd(USART3, USART_DMAReq_Tx, ENABLE); //ʹܴ3DMA +} + +/* +*********************************************************************** +* : UART3_Send_One +* ˵: ͨDMA򴮿3һ +* : +* ֵ: +*********************************************************************** +*/ +void UART3_Send_One(uint16_t len) +{ + DMA_Cmd(DMA1_Channel2, DISABLE); //رUSART3 TX DMA1 ָʾͨ + DMA_SetCurrDataCounter(DMA1_Channel2, len); //DMAͨDMAĴС + DMA_Cmd(DMA1_Channel2, ENABLE); //ʹUSART3 TX DMA1 ָʾͨ +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart3.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart3.h new file mode 100755 index 0000000..94e84f4 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart3.h @@ -0,0 +1,19 @@ +/*************************** (C) COPYRIGHT 2014 GLHF **************************** + * ļ usart3.h + * 3ͷļ + * V1.0 + * XuZhongPing + * 2013/11/21 +*********************************************************************************/ +#ifndef __USART3_H +#define __USART3_H + +#include "stm32f10x.h" + +void USART3_Init(u32 bound); //3ʼ +void UART3_Send_One(u16 len); +#endif + +/******************** (C) COPYRIGHT 2014 GLHF *****END OF FILE*******************/ + + diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart4.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart4.c new file mode 100755 index 0000000..6c760fe --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart4.c @@ -0,0 +1,227 @@ +/*************************** (C) COPYRIGHT 2014 GLHF **************************** + * ļ USART4.c + * 4 + * V1.0 + * XuZhongPing + * 2017/09/03 +*********************************************************************************/ +#include "usart4.h" + +uint8_t USART4_RX_BUF[USART4_RECV_LEN]; //ջ +uint8_t USART4_TX_BUF[USART4_SEND_LEN]; //ջ +uint8_t USART4_RX_STA = 0; //״̬ + +void USART4_ReceiveHandler(uint8_t rxBuf[], uint8_t bData); +/* +*********************************************************************** +* : USART4_Init +* ˵: ʼIO 4 +* Σbound: +* ֵ: +*********************************************************************** +*/ +void USART4_Init(u32 bound) +{ + //GPIO˿ + GPIO_InitTypeDef GPIO_InitStructure; + USART_InitTypeDef USART_InitStructure; + NVIC_InitTypeDef NVIC_InitStructure; + + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); //ʹGPIOAʱ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE); //ʹUSART4ʱ + + //USART4_TX PC.10 + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //PC.10 + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; // + GPIO_Init(GPIOC, &GPIO_InitStructure); //ʼPC.10 + + //USART4_RX PC.11 + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; // + GPIO_Init(GPIOC, &GPIO_InitStructure); //ʼPC.11 + + //USART ʼ + USART_InitStructure.USART_BaudRate = bound; //ò; + USART_InitStructure.USART_WordLength = USART_WordLength_8b; //ֳΪ8λݸʽ + USART_InitStructure.USART_StopBits = USART_StopBits_1; //һֹͣλ + USART_InitStructure.USART_Parity = USART_Parity_No; //żУλ + USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; //Ӳ + USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //շģʽ + USART_Init(UART4, &USART_InitStructure); //ʼ + + //Usart4 NVIC + NVIC_InitStructure.NVIC_IRQChannel = UART4_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1 ; //ռȼ0 + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; //ȼ1 + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨʹ + NVIC_Init(&NVIC_InitStructure); //ָIJʼVICĴ + + USART_ITConfig(UART4, USART_IT_RXNE, ENABLE); //ж + USART_Cmd(UART4, ENABLE); //ʹܴ +} + +/* +*********************************************************************** +* : USART4_IRQHandler +* ˵: 4жϷ +* Σ +* ֵ: +*********************************************************************** +*/ +void UART4_IRQHandler(void) +{ + uint8_t res = 0; + + if(USART_GetITStatus(UART4, USART_IT_RXNE) != RESET) + { + res = USART_ReceiveData(UART4); //ȡյ + USART4_ReceiveHandler(USART4_RX_BUF, res); + } +} + +/* +*********************************************************************** +* : USART4_SendByteData +* ˵: һֽ +* : +* ֵ: +*********************************************************************** +*/ +void USART4_SendByteData(uint8_t bData) +{ + USART_SendData(UART4, bData); + while(USART_GetFlagStatus(UART4, USART_FLAG_TC) != SET); //ȴͽ +} + +/* +*********************************************************************** +* : USART4_SendFrameData +* ˵: һ֡ +* : pData -> ݵ׵ַlen -> ݵij +* ֵ: +*********************************************************************** +*/ +void USART4_SendFrameData(uint8_t pDataBuf[], uint16_t len) +{ + uint16_t i = 0; + + USART_ClearFlag(UART4, USART_FLAG_TC); + for(i = 0; i < len; i++) + { + USART4_SendByteData(pDataBuf[i]); + } +} + +/* +*********************************************************************** +* : USART4_ReceiveHandler +* ˵: ݽմ +* : 봮ڽյ +* ֵ: ޣӰ촮ڽ״̬USART4_RX_STA +*********************************************************************** +*/ +void USART4_ReceiveHandler(uint8_t rxBuf[], uint8_t bData) +{ + static uint8_t RX_Status = 0; //״̬ + static uint8_t CS = 0; //պ + static uint16_t RX_Size = 0; //ͨѶݳ + static uint16_t RX_ByteCount = 0; //ֽڼ + +// printf("U3 = %02X\r\n", bData); + + switch(RX_Status) + { + case 0: //һǰֽ + if(bData == 0xfe){ + RX_Status = 1; + }else{ + RX_Status = 0; + } + break; + + case 1: //ڶǰֽ + if(bData == 0xfe){ + RX_Status = 1; //ǰֽ + }else if(bData == 0x68){ + RX_Status = 3; //ת豸ͨѶַ + CS = 0x68; + }else{ + RX_Status = 0; + } + break; + + case 3: //豸ͨѶַ + rxBuf[0] = bData; + CS += bData; + RX_Status = 4; + break; + + case 4: //֡ͷ + if(bData == 0x68){ + RX_Status = 5; //תͨѶ + CS += 0x68; + }else{ + RX_Status = 0; + } + break; + case 5: //ͨѶ + rxBuf[1] = bData; + CS += bData; + RX_Status = 6; //תݳ + break; + + case 6: //ͨѶݳȣ8λ + rxBuf[2] = bData; + CS += bData; + RX_Status = 62; //ת + break; + + case 62: //ͨѶݳȣ8λ + rxBuf[3] = bData; + CS += bData; + RX_Size = (rxBuf[2] << 8) | rxBuf[3]; //յݳ + if(RX_Size == 0x00){ //ݳΪ0ֱתУ + RX_Status = 8; + }else{ + RX_ByteCount = 0; + RX_Status = 7; //ת + } + break; + + case 7: //Nֽ + if(RX_ByteCount < RX_Size-1){ + rxBuf[RX_ByteCount + 4] = bData; + CS += bData; + RX_ByteCount++; + }else{ + rxBuf[RX_ByteCount + 4] = bData; + CS += bData; + RX_ByteCount = 0; //Nֽڵݽռ0 + RX_Status = 8; //תպ + } + break; + + case 8: //У + if(CS != bData){ + RX_Status = 0; + }else{ + RX_Status = 9; //ת֡β0x16 + } + break; + + case 9: //֡β + if(bData == 0x16) //֡β + { + USART4_RX_STA = 0xfd; //һ֡ճɹǽյһ֪֡ͨͨѶ + } + RX_Status = 0; + break; + + default: // + RX_Status = 0; + break; + } +} + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart4.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart4.h new file mode 100755 index 0000000..f59a46f --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart4.h @@ -0,0 +1,26 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ usart4.h + * 4ͷļ + * V1.0 + * XuZhongPing + * 2017/02/05 +*********************************************************************************/ +#ifndef __USART4_H +#define __USART4_H +#include "stm32f10x.h" +#include "stdio.h" + +#define USART4_RECV_LEN 256 //ջֽ +#define USART4_SEND_LEN 256 //ͻֽ + +extern uint8_t USART4_RX_BUF[USART4_RECV_LEN]; +extern uint8_t USART4_TX_BUF[USART4_SEND_LEN]; +extern uint8_t USART4_RX_STA; + +void USART4_Init(uint32_t bound); +void USART4_SendByteData(uint8_t bData); +void USART4_SendFrameData(uint8_t pDataBuf[], uint16_t len); + +#endif + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart5.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart5.c new file mode 100755 index 0000000..a8daf62 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart5.c @@ -0,0 +1,141 @@ +/*************************** (C) COPYRIGHT 2014 GLHF **************************** + * ļ USART5.c + * 5 + * V1.0 + * XuZhongPing + * 2017/09/03 +*********************************************************************************/ +#include "usart5.h" + +uint8_t USART5_RX_BUF[USART5_RECV_LEN]; //ջ +uint8_t USART5_TX_BUF[USART5_SEND_LEN]; //ջ +uint8_t USART5_RX_STA = 0; //״̬ + +void USART5_ReceiveHandler(uint8_t res); + +/* +*********************************************************************** +* : USART5_Init +* ˵: ʼIO 5 +* Σbound: +* ֵ: +*********************************************************************** +*/ +void USART5_Init(uint32_t bound) +{ + //GPIO˿ + GPIO_InitTypeDef GPIO_InitStructure; + USART_InitTypeDef USART_InitStructure; + NVIC_InitTypeDef NVIC_InitStructure; + + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD, ENABLE); + RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART5, ENABLE); + + //USART5_TX PC.12 + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + GPIO_Init(GPIOC, &GPIO_InitStructure); + + //USART5_RX PD.2 + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; // + GPIO_Init(GPIOD, &GPIO_InitStructure); //ʼPD.2 + + //USART ʼ + USART_InitStructure.USART_BaudRate = bound; //ò; + USART_InitStructure.USART_WordLength = USART_WordLength_8b; //ֳΪ8λݸʽ + USART_InitStructure.USART_StopBits = USART_StopBits_1; //һֹͣλ + USART_InitStructure.USART_Parity = USART_Parity_No; //żУλ + USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; //Ӳ + USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //շģʽ + USART_Init(UART5, &USART_InitStructure); //ʼ + + //Usart5 NVIC + NVIC_InitStructure.NVIC_IRQChannel = UART5_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=2 ; //ռȼ0 + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; //ȼ1 + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨʹ + NVIC_Init(&NVIC_InitStructure); //ָIJʼVICĴ + + USART_ITConfig(UART5, USART_IT_RXNE, ENABLE); //ж + USART_Cmd(UART5, ENABLE); //ʹܴ +} + +/* +*********************************************************************** +* : UART5_IRQHandler +* ˵: 5жϷӳ +* Σ +* ֵ: +*********************************************************************** +*/ +void UART5_IRQHandler(void) +{ + uint8_t res = 0; + + if(USART_GetITStatus(UART5, USART_IT_RXNE) != RESET) //ж(յݱ0x0d 0x0aβ) + { + res = USART_ReceiveData(UART5); + USART5_ReceiveHandler(res); + } +} + +/* +*********************************************************************** +* : UART5_Send_Data +* ˵: һֽ +* : +* ֵ: +*********************************************************************** +*/ +void USART5_SendByteData(uint8_t Serial_data) +{ + USART_SendData(UART5, Serial_data); //򴮿ڷ + while(USART_GetFlagStatus(UART5, USART_FLAG_TC) != SET); //ȴͽ +} + +/* +*********************************************************************** +* : USART5_SendFrameData +* ˵: һ֡ +* : pData -> ݵ׵ַlen -> ݵij +* ֵ: +*********************************************************************** +*/ +void USART5_SendFrameData(uint8_t pDataBuf[], uint16_t len) +{ + uint16_t i = 0; + + USART_ClearFlag(UART5, USART_FLAG_TC); + for(i = 0; i < len; i++) + { + USART5_SendByteData(pDataBuf[i]); + } +} + +/* +*********************************************************************** +* : USART5_ReceiveHandler +* ˵: ݽմ +* : 봮ڽյ +* ֵ: ޣӰ촮ڽ״̬USART5_RX_STA +*********************************************************************** +*/ +void USART5_ReceiveHandler(uint8_t res) +{ + static uint8_t Byte_count = 0; //ֽڼ + static uint8_t receiveState = 0; //״̬ + + switch(receiveState) + { + case 0: //һʼ + + break; + + default: // + break; + } +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart5.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart5.h new file mode 100755 index 0000000..b261659 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/USART/usart5.h @@ -0,0 +1,27 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ usart5.h + * 5ͷļ + * V1.0 + * XuZhongPing + * 2017/03/15 +*********************************************************************************/ +#ifndef __USART5_H +#define __USART5_H +#include "stm32f10x.h" +#include "stdio.h" + +#define USART5_RECV_LEN 128 //ջֽ +#define USART5_SEND_LEN 128 //ͻֽ + +extern uint8_t USART5_RX_BUF[USART5_RECV_LEN]; +extern uint8_t USART5_TX_BUF[USART5_SEND_LEN]; +extern uint8_t USART5_RX_STA; + +void USART5_Init(uint32_t bound); +void USART5_SendByteData(uint8_t bData); +void USART5_SendFrameData(uint8_t pDataBuf[], uint16_t len); + +#endif + + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/UltrasonicWave/UltrasonicWave.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/UltrasonicWave/UltrasonicWave.c new file mode 100755 index 0000000..fcfa744 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/UltrasonicWave/UltrasonicWave.c @@ -0,0 +1,518 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ UltrasonicWave.c + * HC-SR04 + * V1.0 + * XuZhongPing + * 2017/08/04 +*********************************************************************************/ +#include "UltrasonicWave.h" +#include "timer.h" +#include "delay.h" +#include "my_math.h" +#include "data_typedef.h" + + +#define TRIG1_PORT GPIOA //TRIGڵIO +#define ECHO1_PORT GPIOC //ECHOڵIO +#define TRIG1_PIN GPIO_Pin_11 //TRIG +#define ECHO1_PIN GPIO_Pin_1 //ECHO +#define ECHO1_PortSource GPIO_PortSourceGPIOC //жԴIO +#define ECHO1_PinSource GPIO_PinSource1 //ж +#define ECHO1_EXTI_Line EXTI_Line1 //ж + +#define TRIG2_PORT GPIOA //TRIGڵIO +#define ECHO2_PORT GPIOC //ECHOڵIO +#define TRIG2_PIN GPIO_Pin_12 //TRIG +#define ECHO2_PIN GPIO_Pin_0 //ECHO +#define ECHO2_PortSource GPIO_PortSourceGPIOC //жԴIO +#define ECHO2_PinSource GPIO_PinSource0 //ж +#define ECHO2_EXTI_Line EXTI_Line0 //ж + +#define TRIG3_PORT GPIOA //TRIGڵIO +#define ECHO3_PORT GPIOD //ECHOڵIO +#define TRIG3_PIN GPIO_Pin_15 //TRIG +#define ECHO3_PIN GPIO_Pin_0 //ECHO +#define ECHO3_PortSource GPIO_PortSourceGPIOD //жԴIO +#define ECHO3_PinSource GPIO_PinSource0 //ж +#define ECHO3_EXTI_Line EXTI_Line0 //ж + +#define TRIG4_PORT GPIOD //TRIGڵIO +#define ECHO4_PORT GPIOD //ECHOڵIO +#define TRIG4_PIN GPIO_Pin_1 //TRIG +#define ECHO4_PIN GPIO_Pin_3 //ECHO +#define ECHO4_PortSource GPIO_PortSourceGPIOD //жԴIO +#define ECHO4_PinSource GPIO_PinSource3 //ж +#define ECHO4_EXTI_Line EXTI_Line3 //ж + +#define ULT_Data_Size 5 + +uint8_t distance1 = 255; //óõľ +uint8_t distance2 = 255; //óõľ +uint8_t distance3 = 255; //óõľ +uint8_t distance4 = 255; //óõľ + +uint8_t dataOutState = 0; //ǷѾ״̬1Ѵɿ״̬0δ +uint8_t dataOutState1 = 0; +uint8_t dataOutState2 = 0; + +uint8_t succeedFlag; //ճɹ־ +uint16_t counterValue; //زʱ +// uint8_t ULT_Data[ULT_Data_Size]; + +static void EXTI_Cmd(uint16_t EXTI_Line, uint8_t NewState); + +/* +*********************************************************************** +* : UltrasonicWave_Configuration +* ˵: ģijʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void UltrasonicWaveInit(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + EXTI_InitTypeDef EXTI_InitStructure; + NVIC_InitTypeDef NVIC_InitStructure; + + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO, ENABLE); + + GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE); + + //NO.1 + GPIO_InitStructure.GPIO_Pin = TRIG1_PIN; //TRIG + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //Ϊģʽ + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(TRIG1_PORT, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = ECHO1_PIN; //ECHO + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //Ϊ + GPIO_Init(ECHO1_PORT, &GPIO_InitStructure); + + //NO.2 + GPIO_InitStructure.GPIO_Pin = TRIG2_PIN; //TRIG + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //Ϊģʽ + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_Init(TRIG2_PORT, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = ECHO2_PIN; //ECHO + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //Ϊ + GPIO_Init(ECHO2_PORT, &GPIO_InitStructure); + + //NO.1ж߳ʼ + GPIO_EXTILineConfig(ECHO1_PortSource, ECHO1_PinSource); + EXTI_InitStructure.EXTI_Line = ECHO1_EXTI_Line; + EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; + EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //½ش + EXTI_InitStructure.EXTI_LineCmd = ENABLE; + EXTI_Init(&EXTI_InitStructure); + EXTI_Cmd(ECHO1_EXTI_Line, DISABLE); + + //NO.2ж߳ʼ + GPIO_EXTILineConfig(ECHO2_PortSource, ECHO2_PinSource); + EXTI_InitStructure.EXTI_Line = ECHO2_EXTI_Line; + EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; + EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //½ش + EXTI_InitStructure.EXTI_LineCmd = ENABLE; + EXTI_Init(&EXTI_InitStructure); + EXTI_Cmd(ECHO2_EXTI_Line, DISABLE); + + //ж + NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; //ʹܼڵⲿжͨ + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; //ռȼ2 + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; //ȼ2 + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //ʹⲿжͨ + NVIC_Init(&NVIC_InitStructure); + + NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn; //ʹܼڵⲿжͨ + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; //ռȼ2 + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; //ȼ2 + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //ʹⲿжͨ + NVIC_Init(&NVIC_InitStructure); +} + +/* +*********************************************************************** +* : EXTI15_10_IRQHandler +* ˵: ⲿжϷӳ +* Σ +* ֵ: +*********************************************************************** +*/ +void EXTI0_IRQHandler(void) +{ + counterValue = TIM_GetCounter(TIM4); //ȡزĶʱʱ +// printf("ʱΪ:%d\r\n", counterValue); + succeedFlag = 1; //ýճɹ־ + EXTI_ClearITPendingBit(ECHO2_EXTI_Line); //NO.1EXTI·λ +} + +/* +*********************************************************************** +* : EXTI9_5_IRQHandler +* ˵: ⲿжϷӳ +* Σ +* ֵ: +*********************************************************************** +*/ +void EXTI1_IRQHandler(void) +{ + counterValue = TIM_GetCounter(TIM4); //ȡزĶʱʱ +// printf("ʱΪ:%d\r\n", counterValue); + succeedFlag = 1; //ýճɹ־ + EXTI_ClearITPendingBit(ECHO1_EXTI_Line); //NO.3EXTI·λ +} + +/* +*********************************************************************** +* : EXTI_Cmd +* ˵: ⲿжʹ/ܲ +* Σ +* EXTI_Line:ⲿжź +* NewState :ʹENABLEDISABLE +* ֵ: +*********************************************************************** +*/ +static void EXTI_Cmd(uint16_t EXTI_Line, uint8_t NewState) +{ + EXTI->PR = EXTI_Line; //EXTI_Lineϵжϱ־λ + if(NewState){ + EXTI->IMR |= EXTI_Line; //EXTI_Lineϵж + }else{ + EXTI->IMR &= ~EXTI_Line; //EXTI_Lineϵж + } +} + +/* +*********************************************************************** +* : GetDistance +* ˵: ȡһγ +* Σ +* ֵ: õ +*********************************************************************** +*/ +uint8_t GetDistance(uint8_t whichOne) +{ + uint8_t value = 255; + uint16_t TIM_Count = 0; + + GPIO_TypeDef *TRIG_PORTx; + GPIO_TypeDef *ECHO_PORTx; + uint16_t TRIG_PINx; + uint16_t ECHO_PINx; + uint16_t ECHO_EXTI_LineX; + + switch(whichOne) + { + case 1: + TRIG_PORTx = TRIG1_PORT; + ECHO_PORTx = ECHO1_PORT; + TRIG_PINx = TRIG1_PIN; + ECHO_PINx = ECHO1_PIN; + ECHO_EXTI_LineX = ECHO1_EXTI_Line; + break; + + case 2: + TRIG_PORTx = TRIG2_PORT; + ECHO_PORTx = ECHO2_PORT; + TRIG_PINx = TRIG2_PIN; + ECHO_PINx = ECHO2_PIN; + ECHO_EXTI_LineX = ECHO2_EXTI_Line; + break; + + case 3: + TRIG_PORTx = TRIG3_PORT; + ECHO_PORTx = ECHO3_PORT; + TRIG_PINx = TRIG3_PIN; + ECHO_PINx = ECHO3_PIN; + ECHO_EXTI_LineX = ECHO3_EXTI_Line; + break; + + case 4: + TRIG_PORTx = TRIG4_PORT; + ECHO_PORTx = ECHO4_PORT; + TRIG_PINx = TRIG4_PIN; + ECHO_PINx = ECHO4_PIN; + ECHO_EXTI_LineX = ECHO4_EXTI_Line; + break; + + default: + break; + } + + //TRIGŲһ10usϵĸߵƽ崥ź + GPIO_SetBits(TRIG_PORTx, TRIG_PINx); + delay_us(20); + GPIO_ResetBits(TRIG_PORTx, TRIG_PINx); + while((GPIO_ReadInputDataBit(ECHO_PORTx, ECHO_PINx) == 0) && (TIM_Count<4000)) //ȴEchoزűɸߵƽ + { + TIM_Count++; + } + if(TIM_Count >= 4000) + { + return 255; + } + TIM_Count = 0; + succeedFlag = 0; + EXTI_Cmd(ECHO_EXTI_LineX, ENABLE); //ECHO_EXTI_Lineⲿжϣصĵ + + TIM_SetCounter(TIM4, 0); //ʱֵ0 + TIM_Cmd(TIM4, ENABLE); //򿪶ʱʼʱ + + while(TIM_Count < 120 && succeedFlag == 0) //޶ȴʱ䣨12msΪ2׾룩ʱ仹ûдⲿж˵Ч + { + TIM_Count = TIM_GetCounter(TIM4); + } + + TIM_Cmd(TIM4, DISABLE); //رնʱ + EXTI_Cmd(ECHO_EXTI_LineX, DISABLE); //رECHO_EXTI_Lineⲿж + +// printf("TIM_count:%d\r\n", TIM_Count); + if(succeedFlag == 1) //жϲǷɹ + { +// printf("\r\nsucceedFlag\r\n"); + value = (float)(counterValue*100)/58; + } + counterValue = 0; + return value; +} + +/* +*********************************************************************** +* : ULT_DataProcessing +* ˵: Բɼݴƽ +* Σ +* *p: Ҫָ +* n: ij +* ֵ: մĽ +*********************************************************************** +*/ +uint8_t ULT_DataProcessing(uint8_t *p, uint16_t n, uint8_t discardVal) +{ + uint8_t retData; + sort_8(p, n); //ԴڻеIJɼݽ + retData = average_8(p, n, discardVal); //ȥͷβƽ +// printf("\r\nValue = %d\r\n", retData); + return retData; +} + +/* +*********************************************************************** +* : GetDistanceData +* ˵: ȡ +* Σ +* ֵ: ز +*********************************************************************** +*/ +uint8_t GetDistanceData(uint8_t num) +{ + uint8_t retData = 0; + retData = GetDistance(num); + return retData; +} + +/* +*********************************************************************** +* : GetDistanceTask +* ˵: ȡ +* Σ +* ֵ: ݴ״̬ 1Ѵɿ0δ +*********************************************************************** +*/ +void GetDistanceTask_01(void) +{ + static uint8_t ULT_status = 0x00; + static uint8_t getDataCnt = 0x00; + + static uint8_t newValue = 0x00; + static uint8_t oleValue = 0x00; + static uint8_t ULT_Data[ULT_Data_Size]; + + static timer waitingTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&waitingTimer, 3); + } + + switch(ULT_status) + { + case 0x00: + if(timer_expired(&waitingTimer)) + { + newValue = GetDistanceData(1); +// printf("\r\nValue = %3.1f cm\r\n",(float)newValue); + ULT_status = 0x01; + timer_restart(&waitingTimer); + } + break; + case 0x01: + if(DifferenceCompare(newValue, oleValue, 5)) //Ƚ¾ֵIJֵǰֵ - ֮ǰֵ> 趨ֵʱ²ɼ + { + getDataCnt = 0; + } +// printf("\r\nCnt = %d, newValue = %d, oleValue = %d\r\n", getDataCnt, newValue, oleValue); + oleValue = newValue; + + ULT_Data[getDataCnt] = newValue; + getDataCnt++; + if(ULT_Data_Size == getDataCnt) //10ݶΪѾȶ + { + getDataCnt = 0; + ULT_status = 0x02; //תݴ + }else{ + ULT_status = 0x00; + } + break; + + case 0x02: + distance1 = ULT_DataProcessing(ULT_Data, ULT_Data_Size, 0); +// printf("\r\nNo1 ---> %3.1f cm\r\n",(float)distance_01); + dataOutState1 = 1; + ULT_status = 0x00; + break; + + default: + ULT_status = 0x00; + break; + } +} + +/* +*********************************************************************** +* : GetDistanceTask_02 +* ˵: ȡ +* Σ +* ֵ: ݴ״̬ 1Ѵɿ0δ +*********************************************************************** +*/ +void GetDistanceTask_02(void) +{ + static uint8_t ULT_status = 0x00; + static uint8_t getDataCnt = 0x00; + + static uint8_t newValue = 0x00; + static uint8_t oleValue = 0x00; + static uint8_t ULT_Data[ULT_Data_Size]; + + static timer waitingTimer; + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&waitingTimer, 3); + } + + switch(ULT_status) + { + case 0x00: + if(timer_expired(&waitingTimer)) + { + newValue = GetDistanceData(2); +// printf("\r\nValue = %3.1f cm\r\n",(float)newValue); + ULT_status = 0x01; + timer_restart(&waitingTimer); + } + break; + case 0x01: + if(DifferenceCompare(newValue, oleValue, 5)) //Ƚ¾ֵIJֵǰֵ - ֮ǰֵ> 趨ֵʱ²ɼ + { + getDataCnt = 0; + } +// printf("\r\nCnt = %d, newValue = %d, oleValue = %d\r\n", getDataCnt, newValue, oleValue); + oleValue = newValue; + + ULT_Data[getDataCnt] = newValue; + getDataCnt++; + if(ULT_Data_Size == getDataCnt) //10ݶΪѾȶ + { + getDataCnt = 0; + ULT_status = 0x02; //תݴ + }else{ + ULT_status = 0x00; + } + break; + + case 0x02: + distance2 = ULT_DataProcessing(ULT_Data, ULT_Data_Size, 0); +// printf("\r\nNo2 ---> %3.1f cm\r\n",(float)distance_02); + dataOutState2 = 1; //Ѿ׼ݣˣ˱־ⲿ + ULT_status = 0x00; + break; + + default: + ULT_status = 0x00; + break; + } +} + +// /* +// *********************************************************************** +// * : GetDistanceTask +// * ˵: ȡ +// * Σ +// * ֵ: +// *********************************************************************** +// */ +// void GetDistanceTask(void) +// { +// static uint8_t ULT_getDataStatus = 0x00; +// +// static timer waitingTimer; +// static timer responsTimer; +// static uint8_t timer_ok = 0; +// +// if(timer_ok == 0) +// { +// timer_ok = 1; +// timer_set(&waitingTimer, CLOCK_SECOND*2); +// timer_set(&responsTimer, 3); +// } +// +// switch(ULT_getDataStatus) +// { +// case 0x00: +// if(timer_expired(&waitingTimer)) +// { +// ULT_getDataStatus = 0x01; +// } +// break; +// +// case 0x01: +// GetDistanceTask_01(); +// if(dataOutState1 == 1) //һ·ݲɼɹ +// { +// dataOutState1 = 0; +// ULT_getDataStatus = 0x02; +// // printf("\r\n1·ɼOK\r\n"); +// } +// break; +// +// case 0x02: +// GetDistanceTask_02(); +// if(dataOutState2 == 1) //һ·ݲɼɹ +// { +// dataOutState2 = 0; +// ULT_getDataStatus = 0x03; +// // printf("\r\n2·ɼOK\r\n"); +// } +// break; +// +// case 0x03: +// getDistance1 = distance1; +// getDistance2 = distance2; +// printf("\r\nࣺNo1 = %3.1f cm, ", (float)distance1); +// printf("No2 = %3.1f cm\r\n", (float)distance2); +// // printf("No3 = %3.1f cm, ", (float)distance3); +// // printf("No4 = %3.1f cm\r\n", (float)distance4); +// ULT_getDataStatus = 0x00; +// timer_restart(&waitingTimer); +// break; +// } +// } + + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/UltrasonicWave/UltrasonicWave.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/UltrasonicWave/UltrasonicWave.h new file mode 100755 index 0000000..a9d083c --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/UltrasonicWave/UltrasonicWave.h @@ -0,0 +1,28 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ UltrasonicWave.h + * HC-SR04 + * V1.0 + * XuZhongPing + * 2017/08/04 +*********************************************************************************/ +#ifndef __UltrasonicWave_H +#define __UltrasonicWave_H +#include "stm32f10x.h" + +extern uint8_t distance1; //óõľ +extern uint8_t distance2; //óõľ +extern uint8_t distance3; //óõľ +extern uint8_t distance4; //óõľ + +extern uint8_t dataOutState; //״̬־Ϊ1 +extern uint8_t dataOutState1; +extern uint8_t dataOutState2; + +void UltrasonicWaveInit(void); //Գģʼ +void GetDistanceTask_01(void); +void GetDistanceTask_02(void); +// void GetDistanceTask(void); + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/WDG/wdg.c b/STM32_4路称重_Git提交精简工程/src/HARDWARE/WDG/wdg.c new file mode 100755 index 0000000..f4cf6d8 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/WDG/wdg.c @@ -0,0 +1,75 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ 2code.c + * ά봦 + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#include "wdg.h" +#include "timer.h" + +/* +*********************************************************************** +* : IWDG_Init +* ˵: ʼŹ +* : prer -> Ƶ:0~7(ֻе3λЧ!) +* Ƶ=4*2^prer.ֵֻ256! +* rlr -> װؼĴֵ:11λЧ. +* ʱ():Tout=((4*2^prer)*rlr)/40 (ms). +* ֵ: +*********************************************************************** +*/ +void IWDG_Init(uint8_t prer, uint16_t rlr) +{ + IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable); //ʹܶԼĴIWDG_PRIWDG_RLRд + + IWDG_SetPrescaler(prer); //IWDGԤƵֵ:IWDGԤƵֵΪ64 + + IWDG_SetReload(rlr); //IWDGװֵ + + IWDG_ReloadCounter(); //IWDGװؼĴֵװIWDG + + IWDG_Enable(); //ʹIWDG +} + +/* +*********************************************************************** +* : IWDG_Feed +* ˵: ιŹ +* : +* ֵ: +*********************************************************************** +*/ +void IWDG_Feed(void) +{ + IWDG_ReloadCounter(); //reload +} + +/* +*********************************************************************** +* : IWDG_FeedTask +* ˵: Źι +* Σ +* ֵ: +*********************************************************************** +*/ +void IWDG_FeedTask(void) +{ + static timer WDG_feedTimer; //Źιʱ + + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&WDG_feedTimer, 5); + } + + if(timer_expired(&WDG_feedTimer)) + { + timer_restart(&WDG_feedTimer); + IWDG_Feed(); //ι +// printf("\r\nι\r\n"); + } +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/HARDWARE/WDG/wdg.h b/STM32_4路称重_Git提交精简工程/src/HARDWARE/WDG/wdg.h new file mode 100755 index 0000000..93e59be --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/HARDWARE/WDG/wdg.h @@ -0,0 +1,18 @@ +/*************************** (C) COPYRIGHT 2017 ping **************************** + * ļ wdg.h + * Źͷļ + * V1.0 + * XuZhongPing + * 2017/02/05 +*********************************************************************************/ +#ifndef __WDG_H +#define __WDG_H +#include "stm32f10x.h" + +void IWDG_Init(uint8_t prer, uint16_t rlr); +void IWDG_Feed(void); +void IWDG_FeedTask(void); + +#endif + +/******************** (C) COPYRIGHT 2017 ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/Project/Project.uvprojx b/STM32_4路称重_Git提交精简工程/src/Project/Project.uvprojx new file mode 100755 index 0000000..b941a5a --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/Project/Project.uvprojx @@ -0,0 +1,751 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + Target 1 + 0x4 + ARM-ADS + 5060750::V5.06 update 6 (build 750)::ARMCC + 0 + + + STM32F103RC + STMicroelectronics + Keil.STM32F1xx_DFP.2.3.0 + http://www.keil.com/pack/ + IRAM(0x20000000,0x0000C000) IROM(0x08000000,0x00040000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_512 -FS08000000 -FL080000 -FP0($$Device:STM32F103RC$Flash\STM32F10x_512.FLM)) + 0 + $$Device:STM32F103RC$Device\Include\stm32f10x.h + + + + + + + + + + $$Device:STM32F103RC$SVD\STM32F103xx.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + ..\Output\ + HEX_Output + 1 + 0 + 1 + 1 + 1 + ..\Listing\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + -REMAP + DCM.DLL + -pCM3 + SARMCM3.DLL + + TCM.DLL + -pCM3 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M3" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 8 + 0 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0xc000 + + + 1 + 0x8000000 + 0x40000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x8000000 + 0x40000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0xc000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 4 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + STM32F10X_HD,USE_STDPERIPH_DRIVER + + ..\USER;..\CORE;..\SYSTEM\delay;..\SYSTEM\debug;..\SYSTEM\usart;..\STM32F10x_FWLib\inc;..\HARDWARE\LED;..\HARDWARE\KEY;..\HARDWARE\LCD;..\HARDWARE\24CXX;..\HARDWARE\FLASH;..\HARDWARE\IIC;..\HARDWARE\SPI;..\HARDWARE\BUZZER;..\HARDWARE\RFID;..\HARDWARE\EXTI;..\HARDWARE\TIMER;..\HARDWARE\UltrasonicWave;..\HARDWARE\USART;..\HARDWARE\GPS;..\HARDWARE\GSM;..\HARDWARE\QR_Code;..\HARDWARE\DEVICE;..\HARDWARE\LCD;..\HARDWARE\NTC_ADC;..\HARDWARE\WDG;..\HARDWARE\SCALE;..\HARDWARE\ElectronicLock;..\HARDWARE\MOTOR;..\HARDWARE\AUDIO;..\HARDWARE\FLASH;..\HARDWARE\OPTO_SWITCH;..\HARDWARE\IR_Distancer;..\HARDWARE\RS485;..\HARDWARE\STMFLASH;..\HARDWARE\Disinfection + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x08000000 + 0x20000000 + + + + + + + + + + + + + USER + + + main.c + 1 + ..\USER\main.c + + + stm32f10x_it.c + 1 + ..\USER\stm32f10x_it.c + + + system_stm32f10x.c + 1 + ..\CMSIS\system_stm32f10x.c + + + data_typedef.c + 1 + ..\USER\data_typedef.c + + + message.c + 1 + ..\USER\message.c + + + my_math.c + 1 + ..\USER\my_math.c + + + date_time.c + 1 + ..\USER\date_time.c + + + tcp_protocol.c + 1 + ..\USER\tcp_protocol.c + + + pc_protocol.c + 1 + ..\USER\pc_protocol.c + + + user_app.c + 1 + ..\USER\user_app.c + + + user_manag.c + 1 + ..\USER\user_manag.c + + + + + HARDWARE + + + wdg.c + 1 + ..\HARDWARE\WDG\wdg.c + + + timer.c + 1 + ..\HARDWARE\TIMER\timer.c + + + usart1.c + 1 + ..\HARDWARE\USART\usart1.c + + + usart2.c + 1 + ..\HARDWARE\USART\usart2.c + + + usart3.c + 1 + ..\HARDWARE\USART\usart3.c + + + usart4.c + 1 + ..\HARDWARE\USART\usart4.c + + + usart5.c + 1 + ..\HARDWARE\USART\usart5.c + + + led.c + 1 + ..\HARDWARE\LED\led.c + + + key.c + 1 + ..\HARDWARE\KEY\key.c + + + buzzer.c + 1 + ..\HARDWARE\BUZZER\buzzer.c + + + scale.c + 1 + ..\HARDWARE\SCALE\scale.c + + + gps.c + 1 + ..\HARDWARE\GPS\gps.c + + + gsm_uart.c + 1 + ..\HARDWARE\GSM\gsm_uart.c + + + ec200x.c + 1 + ..\HARDWARE\GSM\ec200x.c + + + at_proc.c + 1 + ..\HARDWARE\GSM\at_proc.c + + + netwer_appcall.c + 1 + ..\HARDWARE\GSM\netwer_appcall.c + + + rfid_decode_yn.c + 1 + ..\HARDWARE\RFID\rfid_decode_yn.c + + + rfid_decode_yhk.c + 1 + ..\HARDWARE\RFID\rfid_decode_yhk.c + + + rfid_decode_zl.c + 1 + ..\HARDWARE\RFID\rfid_decode_zl.c + + + RFID_IC.c + 1 + ..\HARDWARE\RFID\RFID_IC.c + + + qr_code.c + 1 + ..\HARDWARE\QR_Code\qr_code.c + + + adc.c + 1 + ..\HARDWARE\NTC_ADC\adc.c + + + ntc.c + 1 + ..\HARDWARE\NTC_ADC\ntc.c + + + display.c + 1 + ..\HARDWARE\LCD\display.c + + + lcd.c + 1 + ..\HARDWARE\LCD\lcd.c + + + lcd12864.c + 1 + ..\HARDWARE\LCD\lcd12864.c + + + ElectronicLock.c + 1 + ..\HARDWARE\ElectronicLock\ElectronicLock.c + + + motor.c + 1 + ..\HARDWARE\MOTOR\motor.c + + + door_ctrl.c + 1 + ..\HARDWARE\MOTOR\door_ctrl.c + + + device.c + 1 + ..\HARDWARE\DEVICE\device.c + + + deviceSet.c + 1 + ..\HARDWARE\DEVICE\deviceSet.c + + + IR_Distancer.c + 1 + ..\HARDWARE\IR_Distancer\IR_Distancer.c + + + distancer.c + 1 + ..\HARDWARE\DEVICE\distancer.c + + + sound.c + 1 + ..\HARDWARE\AUDIO\sound.c + + + spi.c + 1 + ..\HARDWARE\SPI\spi.c + + + stmflash.c + 1 + ..\HARDWARE\STMFLASH\stmflash.c + + + m_s_comm.c + 1 + ..\HARDWARE\DEVICE\m_s_comm.c + + + disinfection.c + 1 + ..\HARDWARE\Disinfection\disinfection.c + + + + + SYSTEM + + + delay.c + 1 + ..\SYSTEM\delay\delay.c + + + debug_conf.c + 1 + ..\SYSTEM\debug\debug_conf.c + + + + + CORE + + + core_cm3.c + 1 + ..\CMSIS\core_cm3.c + + + startup_stm32f10x_hd.s + 2 + ..\CMSIS\Startup\startup_stm32f10x_hd.s + + + + + FWLib + + + misc.c + 1 + ..\STM32F10x_FWLib\src\misc.c + + + stm32f10x_fsmc.c + 1 + ..\STM32F10x_FWLib\src\stm32f10x_fsmc.c + + + stm32f10x_gpio.c + 1 + ..\STM32F10x_FWLib\src\stm32f10x_gpio.c + + + stm32f10x_rcc.c + 1 + ..\STM32F10x_FWLib\src\stm32f10x_rcc.c + + + stm32f10x_usart.c + 1 + ..\STM32F10x_FWLib\src\stm32f10x_usart.c + + + stm32f10x_spi.c + 1 + ..\STM32F10x_FWLib\src\stm32f10x_spi.c + + + stm32f10x_exti.c + 1 + ..\STM32F10x_FWLib\src\stm32f10x_exti.c + + + stm32f10x_tim.c + 1 + ..\STM32F10x_FWLib\src\stm32f10x_tim.c + + + stm32f10x_dma.c + 1 + ..\STM32F10x_FWLib\src\stm32f10x_dma.c + + + stm32f10x_adc.c + 1 + ..\STM32F10x_FWLib\src\stm32f10x_adc.c + + + stm32f10x_iwdg.c + 1 + ..\STM32F10x_FWLib\src\stm32f10x_iwdg.c + + + stm32f10x_flash.c + 1 + ..\STM32F10x_FWLib\src\stm32f10x_flash.c + + + + + ::CMSIS + + + + + + + + + + + + + + + + + + +
diff --git a/STM32_4路称重_Git提交精简工程/src/Project/stm32f10x_conf.h b/STM32_4路称重_Git提交精简工程/src/Project/stm32f10x_conf.h new file mode 100755 index 0000000..fd1c485 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/Project/stm32f10x_conf.h @@ -0,0 +1,77 @@ +/** + ****************************************************************************** + * @file GPIO/IOToggle/stm32f10x_conf.h + * @author MCD Application Team + * @version V3.5.0 + * @date 08-April-2011 + * @brief Library configuration file. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_CONF_H +#define __STM32F10x_CONF_H + +/* Includes ------------------------------------------------------------------*/ +/* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */ +//#include "stm32f10x_adc.h" +//#include "stm32f10x_bkp.h" +//#include "stm32f10x_can.h" +//#include "stm32f10x_cec.h" +//#include "stm32f10x_crc.h" +//#include "stm32f10x_dac.h" +#include "stm32f10x_dbgmcu.h" +#include "stm32f10x_dma.h" +#include "stm32f10x_exti.h" +#include "stm32f10x_flash.h" +#include "stm32f10x_fsmc.h" +#include "stm32f10x_gpio.h" +//#include "stm32f10x_i2c.h" +//#include "stm32f10x_iwdg.h" +//#include "stm32f10x_pwr.h" +#include "stm32f10x_rcc.h" +#include "stm32f10x_rtc.h" +//#include "stm32f10x_sdio.h" +#include "stm32f10x_spi.h" +#include "stm32f10x_tim.h" +#include "stm32f10x_usart.h" +//#include "stm32f10x_wwdg.h" +#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Uncomment the line below to expanse the "assert_param" macro in the + Standard Peripheral Library drivers code */ +/* #define USE_FULL_ASSERT 1 */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT + +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function which reports + * the name of the source file and the source line number of the call + * that failed. If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0) +#endif /* USE_FULL_ASSERT */ + +#endif /* __STM32F10x_CONF_H */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/misc.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/misc.h new file mode 100755 index 0000000..7d401ca --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/misc.h @@ -0,0 +1,220 @@ +/** + ****************************************************************************** + * @file misc.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the miscellaneous + * firmware library functions (add-on to CMSIS functions). + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MISC_H +#define __MISC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup MISC + * @{ + */ + +/** @defgroup MISC_Exported_Types + * @{ + */ + +/** + * @brief NVIC Init Structure definition + */ + +typedef struct +{ + uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled. + This parameter can be a value of @ref IRQn_Type + (For the complete STM32 Devices IRQ Channels list, please + refer to stm32f10x.h file) */ + + uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel + specified in NVIC_IRQChannel. This parameter can be a value + between 0 and 15 as described in the table @ref NVIC_Priority_Table */ + + uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified + in NVIC_IRQChannel. This parameter can be a value + between 0 and 15 as described in the table @ref NVIC_Priority_Table */ + + FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel + will be enabled or disabled. + This parameter can be set either to ENABLE or DISABLE */ +} NVIC_InitTypeDef; + +/** + * @} + */ + +/** @defgroup NVIC_Priority_Table + * @{ + */ + +/** +@code + The table below gives the allowed values of the pre-emption priority and subpriority according + to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function + ============================================================================================================================ + NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description + ============================================================================================================================ + NVIC_PriorityGroup_0 | 0 | 0-15 | 0 bits for pre-emption priority + | | | 4 bits for subpriority + ---------------------------------------------------------------------------------------------------------------------------- + NVIC_PriorityGroup_1 | 0-1 | 0-7 | 1 bits for pre-emption priority + | | | 3 bits for subpriority + ---------------------------------------------------------------------------------------------------------------------------- + NVIC_PriorityGroup_2 | 0-3 | 0-3 | 2 bits for pre-emption priority + | | | 2 bits for subpriority + ---------------------------------------------------------------------------------------------------------------------------- + NVIC_PriorityGroup_3 | 0-7 | 0-1 | 3 bits for pre-emption priority + | | | 1 bits for subpriority + ---------------------------------------------------------------------------------------------------------------------------- + NVIC_PriorityGroup_4 | 0-15 | 0 | 4 bits for pre-emption priority + | | | 0 bits for subpriority + ============================================================================================================================ +@endcode +*/ + +/** + * @} + */ + +/** @defgroup MISC_Exported_Constants + * @{ + */ + +/** @defgroup Vector_Table_Base + * @{ + */ + +#define NVIC_VectTab_RAM ((uint32_t)0x20000000) +#define NVIC_VectTab_FLASH ((uint32_t)0x08000000) +#define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \ + ((VECTTAB) == NVIC_VectTab_FLASH)) +/** + * @} + */ + +/** @defgroup System_Low_Power + * @{ + */ + +#define NVIC_LP_SEVONPEND ((uint8_t)0x10) +#define NVIC_LP_SLEEPDEEP ((uint8_t)0x04) +#define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02) +#define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \ + ((LP) == NVIC_LP_SLEEPDEEP) || \ + ((LP) == NVIC_LP_SLEEPONEXIT)) +/** + * @} + */ + +/** @defgroup Preemption_Priority_Group + * @{ + */ + +#define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority + 4 bits for subpriority */ +#define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority + 3 bits for subpriority */ +#define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority + 2 bits for subpriority */ +#define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority + 1 bits for subpriority */ +#define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority + 0 bits for subpriority */ + +#define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \ + ((GROUP) == NVIC_PriorityGroup_1) || \ + ((GROUP) == NVIC_PriorityGroup_2) || \ + ((GROUP) == NVIC_PriorityGroup_3) || \ + ((GROUP) == NVIC_PriorityGroup_4)) + +#define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) + +#define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) + +#define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF) + +/** + * @} + */ + +/** @defgroup SysTick_clock_source + * @{ + */ + +#define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB) +#define SysTick_CLKSource_HCLK ((uint32_t)0x00000004) +#define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \ + ((SOURCE) == SysTick_CLKSource_HCLK_Div8)) +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup MISC_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup MISC_Exported_Functions + * @{ + */ + +void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); +void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); +void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset); +void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState); +void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource); + +#ifdef __cplusplus +} +#endif + +#endif /* __MISC_H */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_adc.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_adc.h new file mode 100755 index 0000000..d1b2653 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_adc.h @@ -0,0 +1,483 @@ +/** + ****************************************************************************** + * @file stm32f10x_adc.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the ADC firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_ADC_H +#define __STM32F10x_ADC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup ADC + * @{ + */ + +/** @defgroup ADC_Exported_Types + * @{ + */ + +/** + * @brief ADC Init structure definition + */ + +typedef struct +{ + uint32_t ADC_Mode; /*!< Configures the ADC to operate in independent or + dual mode. + This parameter can be a value of @ref ADC_mode */ + + FunctionalState ADC_ScanConvMode; /*!< Specifies whether the conversion is performed in + Scan (multichannels) or Single (one channel) mode. + This parameter can be set to ENABLE or DISABLE */ + + FunctionalState ADC_ContinuousConvMode; /*!< Specifies whether the conversion is performed in + Continuous or Single mode. + This parameter can be set to ENABLE or DISABLE. */ + + uint32_t ADC_ExternalTrigConv; /*!< Defines the external trigger used to start the analog + to digital conversion of regular channels. This parameter + can be a value of @ref ADC_external_trigger_sources_for_regular_channels_conversion */ + + uint32_t ADC_DataAlign; /*!< Specifies whether the ADC data alignment is left or right. + This parameter can be a value of @ref ADC_data_align */ + + uint8_t ADC_NbrOfChannel; /*!< Specifies the number of ADC channels that will be converted + using the sequencer for regular channel group. + This parameter must range from 1 to 16. */ +}ADC_InitTypeDef; +/** + * @} + */ + +/** @defgroup ADC_Exported_Constants + * @{ + */ + +#define IS_ADC_ALL_PERIPH(PERIPH) (((PERIPH) == ADC1) || \ + ((PERIPH) == ADC2) || \ + ((PERIPH) == ADC3)) + +#define IS_ADC_DMA_PERIPH(PERIPH) (((PERIPH) == ADC1) || \ + ((PERIPH) == ADC3)) + +/** @defgroup ADC_mode + * @{ + */ + +#define ADC_Mode_Independent ((uint32_t)0x00000000) +#define ADC_Mode_RegInjecSimult ((uint32_t)0x00010000) +#define ADC_Mode_RegSimult_AlterTrig ((uint32_t)0x00020000) +#define ADC_Mode_InjecSimult_FastInterl ((uint32_t)0x00030000) +#define ADC_Mode_InjecSimult_SlowInterl ((uint32_t)0x00040000) +#define ADC_Mode_InjecSimult ((uint32_t)0x00050000) +#define ADC_Mode_RegSimult ((uint32_t)0x00060000) +#define ADC_Mode_FastInterl ((uint32_t)0x00070000) +#define ADC_Mode_SlowInterl ((uint32_t)0x00080000) +#define ADC_Mode_AlterTrig ((uint32_t)0x00090000) + +#define IS_ADC_MODE(MODE) (((MODE) == ADC_Mode_Independent) || \ + ((MODE) == ADC_Mode_RegInjecSimult) || \ + ((MODE) == ADC_Mode_RegSimult_AlterTrig) || \ + ((MODE) == ADC_Mode_InjecSimult_FastInterl) || \ + ((MODE) == ADC_Mode_InjecSimult_SlowInterl) || \ + ((MODE) == ADC_Mode_InjecSimult) || \ + ((MODE) == ADC_Mode_RegSimult) || \ + ((MODE) == ADC_Mode_FastInterl) || \ + ((MODE) == ADC_Mode_SlowInterl) || \ + ((MODE) == ADC_Mode_AlterTrig)) +/** + * @} + */ + +/** @defgroup ADC_external_trigger_sources_for_regular_channels_conversion + * @{ + */ + +#define ADC_ExternalTrigConv_T1_CC1 ((uint32_t)0x00000000) /*!< For ADC1 and ADC2 */ +#define ADC_ExternalTrigConv_T1_CC2 ((uint32_t)0x00020000) /*!< For ADC1 and ADC2 */ +#define ADC_ExternalTrigConv_T2_CC2 ((uint32_t)0x00060000) /*!< For ADC1 and ADC2 */ +#define ADC_ExternalTrigConv_T3_TRGO ((uint32_t)0x00080000) /*!< For ADC1 and ADC2 */ +#define ADC_ExternalTrigConv_T4_CC4 ((uint32_t)0x000A0000) /*!< For ADC1 and ADC2 */ +#define ADC_ExternalTrigConv_Ext_IT11_TIM8_TRGO ((uint32_t)0x000C0000) /*!< For ADC1 and ADC2 */ + +#define ADC_ExternalTrigConv_T1_CC3 ((uint32_t)0x00040000) /*!< For ADC1, ADC2 and ADC3 */ +#define ADC_ExternalTrigConv_None ((uint32_t)0x000E0000) /*!< For ADC1, ADC2 and ADC3 */ + +#define ADC_ExternalTrigConv_T3_CC1 ((uint32_t)0x00000000) /*!< For ADC3 only */ +#define ADC_ExternalTrigConv_T2_CC3 ((uint32_t)0x00020000) /*!< For ADC3 only */ +#define ADC_ExternalTrigConv_T8_CC1 ((uint32_t)0x00060000) /*!< For ADC3 only */ +#define ADC_ExternalTrigConv_T8_TRGO ((uint32_t)0x00080000) /*!< For ADC3 only */ +#define ADC_ExternalTrigConv_T5_CC1 ((uint32_t)0x000A0000) /*!< For ADC3 only */ +#define ADC_ExternalTrigConv_T5_CC3 ((uint32_t)0x000C0000) /*!< For ADC3 only */ + +#define IS_ADC_EXT_TRIG(REGTRIG) (((REGTRIG) == ADC_ExternalTrigConv_T1_CC1) || \ + ((REGTRIG) == ADC_ExternalTrigConv_T1_CC2) || \ + ((REGTRIG) == ADC_ExternalTrigConv_T1_CC3) || \ + ((REGTRIG) == ADC_ExternalTrigConv_T2_CC2) || \ + ((REGTRIG) == ADC_ExternalTrigConv_T3_TRGO) || \ + ((REGTRIG) == ADC_ExternalTrigConv_T4_CC4) || \ + ((REGTRIG) == ADC_ExternalTrigConv_Ext_IT11_TIM8_TRGO) || \ + ((REGTRIG) == ADC_ExternalTrigConv_None) || \ + ((REGTRIG) == ADC_ExternalTrigConv_T3_CC1) || \ + ((REGTRIG) == ADC_ExternalTrigConv_T2_CC3) || \ + ((REGTRIG) == ADC_ExternalTrigConv_T8_CC1) || \ + ((REGTRIG) == ADC_ExternalTrigConv_T8_TRGO) || \ + ((REGTRIG) == ADC_ExternalTrigConv_T5_CC1) || \ + ((REGTRIG) == ADC_ExternalTrigConv_T5_CC3)) +/** + * @} + */ + +/** @defgroup ADC_data_align + * @{ + */ + +#define ADC_DataAlign_Right ((uint32_t)0x00000000) +#define ADC_DataAlign_Left ((uint32_t)0x00000800) +#define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DataAlign_Right) || \ + ((ALIGN) == ADC_DataAlign_Left)) +/** + * @} + */ + +/** @defgroup ADC_channels + * @{ + */ + +#define ADC_Channel_0 ((uint8_t)0x00) +#define ADC_Channel_1 ((uint8_t)0x01) +#define ADC_Channel_2 ((uint8_t)0x02) +#define ADC_Channel_3 ((uint8_t)0x03) +#define ADC_Channel_4 ((uint8_t)0x04) +#define ADC_Channel_5 ((uint8_t)0x05) +#define ADC_Channel_6 ((uint8_t)0x06) +#define ADC_Channel_7 ((uint8_t)0x07) +#define ADC_Channel_8 ((uint8_t)0x08) +#define ADC_Channel_9 ((uint8_t)0x09) +#define ADC_Channel_10 ((uint8_t)0x0A) +#define ADC_Channel_11 ((uint8_t)0x0B) +#define ADC_Channel_12 ((uint8_t)0x0C) +#define ADC_Channel_13 ((uint8_t)0x0D) +#define ADC_Channel_14 ((uint8_t)0x0E) +#define ADC_Channel_15 ((uint8_t)0x0F) +#define ADC_Channel_16 ((uint8_t)0x10) +#define ADC_Channel_17 ((uint8_t)0x11) + +#define ADC_Channel_TempSensor ((uint8_t)ADC_Channel_16) +#define ADC_Channel_Vrefint ((uint8_t)ADC_Channel_17) + +#define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) == ADC_Channel_0) || ((CHANNEL) == ADC_Channel_1) || \ + ((CHANNEL) == ADC_Channel_2) || ((CHANNEL) == ADC_Channel_3) || \ + ((CHANNEL) == ADC_Channel_4) || ((CHANNEL) == ADC_Channel_5) || \ + ((CHANNEL) == ADC_Channel_6) || ((CHANNEL) == ADC_Channel_7) || \ + ((CHANNEL) == ADC_Channel_8) || ((CHANNEL) == ADC_Channel_9) || \ + ((CHANNEL) == ADC_Channel_10) || ((CHANNEL) == ADC_Channel_11) || \ + ((CHANNEL) == ADC_Channel_12) || ((CHANNEL) == ADC_Channel_13) || \ + ((CHANNEL) == ADC_Channel_14) || ((CHANNEL) == ADC_Channel_15) || \ + ((CHANNEL) == ADC_Channel_16) || ((CHANNEL) == ADC_Channel_17)) +/** + * @} + */ + +/** @defgroup ADC_sampling_time + * @{ + */ + +#define ADC_SampleTime_1Cycles5 ((uint8_t)0x00) +#define ADC_SampleTime_7Cycles5 ((uint8_t)0x01) +#define ADC_SampleTime_13Cycles5 ((uint8_t)0x02) +#define ADC_SampleTime_28Cycles5 ((uint8_t)0x03) +#define ADC_SampleTime_41Cycles5 ((uint8_t)0x04) +#define ADC_SampleTime_55Cycles5 ((uint8_t)0x05) +#define ADC_SampleTime_71Cycles5 ((uint8_t)0x06) +#define ADC_SampleTime_239Cycles5 ((uint8_t)0x07) +#define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SampleTime_1Cycles5) || \ + ((TIME) == ADC_SampleTime_7Cycles5) || \ + ((TIME) == ADC_SampleTime_13Cycles5) || \ + ((TIME) == ADC_SampleTime_28Cycles5) || \ + ((TIME) == ADC_SampleTime_41Cycles5) || \ + ((TIME) == ADC_SampleTime_55Cycles5) || \ + ((TIME) == ADC_SampleTime_71Cycles5) || \ + ((TIME) == ADC_SampleTime_239Cycles5)) +/** + * @} + */ + +/** @defgroup ADC_external_trigger_sources_for_injected_channels_conversion + * @{ + */ + +#define ADC_ExternalTrigInjecConv_T2_TRGO ((uint32_t)0x00002000) /*!< For ADC1 and ADC2 */ +#define ADC_ExternalTrigInjecConv_T2_CC1 ((uint32_t)0x00003000) /*!< For ADC1 and ADC2 */ +#define ADC_ExternalTrigInjecConv_T3_CC4 ((uint32_t)0x00004000) /*!< For ADC1 and ADC2 */ +#define ADC_ExternalTrigInjecConv_T4_TRGO ((uint32_t)0x00005000) /*!< For ADC1 and ADC2 */ +#define ADC_ExternalTrigInjecConv_Ext_IT15_TIM8_CC4 ((uint32_t)0x00006000) /*!< For ADC1 and ADC2 */ + +#define ADC_ExternalTrigInjecConv_T1_TRGO ((uint32_t)0x00000000) /*!< For ADC1, ADC2 and ADC3 */ +#define ADC_ExternalTrigInjecConv_T1_CC4 ((uint32_t)0x00001000) /*!< For ADC1, ADC2 and ADC3 */ +#define ADC_ExternalTrigInjecConv_None ((uint32_t)0x00007000) /*!< For ADC1, ADC2 and ADC3 */ + +#define ADC_ExternalTrigInjecConv_T4_CC3 ((uint32_t)0x00002000) /*!< For ADC3 only */ +#define ADC_ExternalTrigInjecConv_T8_CC2 ((uint32_t)0x00003000) /*!< For ADC3 only */ +#define ADC_ExternalTrigInjecConv_T8_CC4 ((uint32_t)0x00004000) /*!< For ADC3 only */ +#define ADC_ExternalTrigInjecConv_T5_TRGO ((uint32_t)0x00005000) /*!< For ADC3 only */ +#define ADC_ExternalTrigInjecConv_T5_CC4 ((uint32_t)0x00006000) /*!< For ADC3 only */ + +#define IS_ADC_EXT_INJEC_TRIG(INJTRIG) (((INJTRIG) == ADC_ExternalTrigInjecConv_T1_TRGO) || \ + ((INJTRIG) == ADC_ExternalTrigInjecConv_T1_CC4) || \ + ((INJTRIG) == ADC_ExternalTrigInjecConv_T2_TRGO) || \ + ((INJTRIG) == ADC_ExternalTrigInjecConv_T2_CC1) || \ + ((INJTRIG) == ADC_ExternalTrigInjecConv_T3_CC4) || \ + ((INJTRIG) == ADC_ExternalTrigInjecConv_T4_TRGO) || \ + ((INJTRIG) == ADC_ExternalTrigInjecConv_Ext_IT15_TIM8_CC4) || \ + ((INJTRIG) == ADC_ExternalTrigInjecConv_None) || \ + ((INJTRIG) == ADC_ExternalTrigInjecConv_T4_CC3) || \ + ((INJTRIG) == ADC_ExternalTrigInjecConv_T8_CC2) || \ + ((INJTRIG) == ADC_ExternalTrigInjecConv_T8_CC4) || \ + ((INJTRIG) == ADC_ExternalTrigInjecConv_T5_TRGO) || \ + ((INJTRIG) == ADC_ExternalTrigInjecConv_T5_CC4)) +/** + * @} + */ + +/** @defgroup ADC_injected_channel_selection + * @{ + */ + +#define ADC_InjectedChannel_1 ((uint8_t)0x14) +#define ADC_InjectedChannel_2 ((uint8_t)0x18) +#define ADC_InjectedChannel_3 ((uint8_t)0x1C) +#define ADC_InjectedChannel_4 ((uint8_t)0x20) +#define IS_ADC_INJECTED_CHANNEL(CHANNEL) (((CHANNEL) == ADC_InjectedChannel_1) || \ + ((CHANNEL) == ADC_InjectedChannel_2) || \ + ((CHANNEL) == ADC_InjectedChannel_3) || \ + ((CHANNEL) == ADC_InjectedChannel_4)) +/** + * @} + */ + +/** @defgroup ADC_analog_watchdog_selection + * @{ + */ + +#define ADC_AnalogWatchdog_SingleRegEnable ((uint32_t)0x00800200) +#define ADC_AnalogWatchdog_SingleInjecEnable ((uint32_t)0x00400200) +#define ADC_AnalogWatchdog_SingleRegOrInjecEnable ((uint32_t)0x00C00200) +#define ADC_AnalogWatchdog_AllRegEnable ((uint32_t)0x00800000) +#define ADC_AnalogWatchdog_AllInjecEnable ((uint32_t)0x00400000) +#define ADC_AnalogWatchdog_AllRegAllInjecEnable ((uint32_t)0x00C00000) +#define ADC_AnalogWatchdog_None ((uint32_t)0x00000000) + +#define IS_ADC_ANALOG_WATCHDOG(WATCHDOG) (((WATCHDOG) == ADC_AnalogWatchdog_SingleRegEnable) || \ + ((WATCHDOG) == ADC_AnalogWatchdog_SingleInjecEnable) || \ + ((WATCHDOG) == ADC_AnalogWatchdog_SingleRegOrInjecEnable) || \ + ((WATCHDOG) == ADC_AnalogWatchdog_AllRegEnable) || \ + ((WATCHDOG) == ADC_AnalogWatchdog_AllInjecEnable) || \ + ((WATCHDOG) == ADC_AnalogWatchdog_AllRegAllInjecEnable) || \ + ((WATCHDOG) == ADC_AnalogWatchdog_None)) +/** + * @} + */ + +/** @defgroup ADC_interrupts_definition + * @{ + */ + +#define ADC_IT_EOC ((uint16_t)0x0220) +#define ADC_IT_AWD ((uint16_t)0x0140) +#define ADC_IT_JEOC ((uint16_t)0x0480) + +#define IS_ADC_IT(IT) ((((IT) & (uint16_t)0xF81F) == 0x00) && ((IT) != 0x00)) + +#define IS_ADC_GET_IT(IT) (((IT) == ADC_IT_EOC) || ((IT) == ADC_IT_AWD) || \ + ((IT) == ADC_IT_JEOC)) +/** + * @} + */ + +/** @defgroup ADC_flags_definition + * @{ + */ + +#define ADC_FLAG_AWD ((uint8_t)0x01) +#define ADC_FLAG_EOC ((uint8_t)0x02) +#define ADC_FLAG_JEOC ((uint8_t)0x04) +#define ADC_FLAG_JSTRT ((uint8_t)0x08) +#define ADC_FLAG_STRT ((uint8_t)0x10) +#define IS_ADC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint8_t)0xE0) == 0x00) && ((FLAG) != 0x00)) +#define IS_ADC_GET_FLAG(FLAG) (((FLAG) == ADC_FLAG_AWD) || ((FLAG) == ADC_FLAG_EOC) || \ + ((FLAG) == ADC_FLAG_JEOC) || ((FLAG)== ADC_FLAG_JSTRT) || \ + ((FLAG) == ADC_FLAG_STRT)) +/** + * @} + */ + +/** @defgroup ADC_thresholds + * @{ + */ + +#define IS_ADC_THRESHOLD(THRESHOLD) ((THRESHOLD) <= 0xFFF) + +/** + * @} + */ + +/** @defgroup ADC_injected_offset + * @{ + */ + +#define IS_ADC_OFFSET(OFFSET) ((OFFSET) <= 0xFFF) + +/** + * @} + */ + +/** @defgroup ADC_injected_length + * @{ + */ + +#define IS_ADC_INJECTED_LENGTH(LENGTH) (((LENGTH) >= 0x1) && ((LENGTH) <= 0x4)) + +/** + * @} + */ + +/** @defgroup ADC_injected_rank + * @{ + */ + +#define IS_ADC_INJECTED_RANK(RANK) (((RANK) >= 0x1) && ((RANK) <= 0x4)) + +/** + * @} + */ + + +/** @defgroup ADC_regular_length + * @{ + */ + +#define IS_ADC_REGULAR_LENGTH(LENGTH) (((LENGTH) >= 0x1) && ((LENGTH) <= 0x10)) +/** + * @} + */ + +/** @defgroup ADC_regular_rank + * @{ + */ + +#define IS_ADC_REGULAR_RANK(RANK) (((RANK) >= 0x1) && ((RANK) <= 0x10)) + +/** + * @} + */ + +/** @defgroup ADC_regular_discontinuous_mode_number + * @{ + */ + +#define IS_ADC_REGULAR_DISC_NUMBER(NUMBER) (((NUMBER) >= 0x1) && ((NUMBER) <= 0x8)) + +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup ADC_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup ADC_Exported_Functions + * @{ + */ + +void ADC_DeInit(ADC_TypeDef* ADCx); +void ADC_Init(ADC_TypeDef* ADCx, ADC_InitTypeDef* ADC_InitStruct); +void ADC_StructInit(ADC_InitTypeDef* ADC_InitStruct); +void ADC_Cmd(ADC_TypeDef* ADCx, FunctionalState NewState); +void ADC_DMACmd(ADC_TypeDef* ADCx, FunctionalState NewState); +void ADC_ITConfig(ADC_TypeDef* ADCx, uint16_t ADC_IT, FunctionalState NewState); +void ADC_ResetCalibration(ADC_TypeDef* ADCx); +FlagStatus ADC_GetResetCalibrationStatus(ADC_TypeDef* ADCx); +void ADC_StartCalibration(ADC_TypeDef* ADCx); +FlagStatus ADC_GetCalibrationStatus(ADC_TypeDef* ADCx); +void ADC_SoftwareStartConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState); +FlagStatus ADC_GetSoftwareStartConvStatus(ADC_TypeDef* ADCx); +void ADC_DiscModeChannelCountConfig(ADC_TypeDef* ADCx, uint8_t Number); +void ADC_DiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState); +void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime); +void ADC_ExternalTrigConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState); +uint16_t ADC_GetConversionValue(ADC_TypeDef* ADCx); +uint32_t ADC_GetDualModeConversionValue(void); +void ADC_AutoInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState); +void ADC_InjectedDiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState); +void ADC_ExternalTrigInjectedConvConfig(ADC_TypeDef* ADCx, uint32_t ADC_ExternalTrigInjecConv); +void ADC_ExternalTrigInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState); +void ADC_SoftwareStartInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState); +FlagStatus ADC_GetSoftwareStartInjectedConvCmdStatus(ADC_TypeDef* ADCx); +void ADC_InjectedChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime); +void ADC_InjectedSequencerLengthConfig(ADC_TypeDef* ADCx, uint8_t Length); +void ADC_SetInjectedOffset(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel, uint16_t Offset); +uint16_t ADC_GetInjectedConversionValue(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel); +void ADC_AnalogWatchdogCmd(ADC_TypeDef* ADCx, uint32_t ADC_AnalogWatchdog); +void ADC_AnalogWatchdogThresholdsConfig(ADC_TypeDef* ADCx, uint16_t HighThreshold, uint16_t LowThreshold); +void ADC_AnalogWatchdogSingleChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel); +void ADC_TempSensorVrefintCmd(FunctionalState NewState); +FlagStatus ADC_GetFlagStatus(ADC_TypeDef* ADCx, uint8_t ADC_FLAG); +void ADC_ClearFlag(ADC_TypeDef* ADCx, uint8_t ADC_FLAG); +ITStatus ADC_GetITStatus(ADC_TypeDef* ADCx, uint16_t ADC_IT); +void ADC_ClearITPendingBit(ADC_TypeDef* ADCx, uint16_t ADC_IT); + +#ifdef __cplusplus +} +#endif + +#endif /*__STM32F10x_ADC_H */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_bkp.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_bkp.h new file mode 100755 index 0000000..b620753 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_bkp.h @@ -0,0 +1,195 @@ +/** + ****************************************************************************** + * @file stm32f10x_bkp.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the BKP firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_BKP_H +#define __STM32F10x_BKP_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup BKP + * @{ + */ + +/** @defgroup BKP_Exported_Types + * @{ + */ + +/** + * @} + */ + +/** @defgroup BKP_Exported_Constants + * @{ + */ + +/** @defgroup Tamper_Pin_active_level + * @{ + */ + +#define BKP_TamperPinLevel_High ((uint16_t)0x0000) +#define BKP_TamperPinLevel_Low ((uint16_t)0x0001) +#define IS_BKP_TAMPER_PIN_LEVEL(LEVEL) (((LEVEL) == BKP_TamperPinLevel_High) || \ + ((LEVEL) == BKP_TamperPinLevel_Low)) +/** + * @} + */ + +/** @defgroup RTC_output_source_to_output_on_the_Tamper_pin + * @{ + */ + +#define BKP_RTCOutputSource_None ((uint16_t)0x0000) +#define BKP_RTCOutputSource_CalibClock ((uint16_t)0x0080) +#define BKP_RTCOutputSource_Alarm ((uint16_t)0x0100) +#define BKP_RTCOutputSource_Second ((uint16_t)0x0300) +#define IS_BKP_RTC_OUTPUT_SOURCE(SOURCE) (((SOURCE) == BKP_RTCOutputSource_None) || \ + ((SOURCE) == BKP_RTCOutputSource_CalibClock) || \ + ((SOURCE) == BKP_RTCOutputSource_Alarm) || \ + ((SOURCE) == BKP_RTCOutputSource_Second)) +/** + * @} + */ + +/** @defgroup Data_Backup_Register + * @{ + */ + +#define BKP_DR1 ((uint16_t)0x0004) +#define BKP_DR2 ((uint16_t)0x0008) +#define BKP_DR3 ((uint16_t)0x000C) +#define BKP_DR4 ((uint16_t)0x0010) +#define BKP_DR5 ((uint16_t)0x0014) +#define BKP_DR6 ((uint16_t)0x0018) +#define BKP_DR7 ((uint16_t)0x001C) +#define BKP_DR8 ((uint16_t)0x0020) +#define BKP_DR9 ((uint16_t)0x0024) +#define BKP_DR10 ((uint16_t)0x0028) +#define BKP_DR11 ((uint16_t)0x0040) +#define BKP_DR12 ((uint16_t)0x0044) +#define BKP_DR13 ((uint16_t)0x0048) +#define BKP_DR14 ((uint16_t)0x004C) +#define BKP_DR15 ((uint16_t)0x0050) +#define BKP_DR16 ((uint16_t)0x0054) +#define BKP_DR17 ((uint16_t)0x0058) +#define BKP_DR18 ((uint16_t)0x005C) +#define BKP_DR19 ((uint16_t)0x0060) +#define BKP_DR20 ((uint16_t)0x0064) +#define BKP_DR21 ((uint16_t)0x0068) +#define BKP_DR22 ((uint16_t)0x006C) +#define BKP_DR23 ((uint16_t)0x0070) +#define BKP_DR24 ((uint16_t)0x0074) +#define BKP_DR25 ((uint16_t)0x0078) +#define BKP_DR26 ((uint16_t)0x007C) +#define BKP_DR27 ((uint16_t)0x0080) +#define BKP_DR28 ((uint16_t)0x0084) +#define BKP_DR29 ((uint16_t)0x0088) +#define BKP_DR30 ((uint16_t)0x008C) +#define BKP_DR31 ((uint16_t)0x0090) +#define BKP_DR32 ((uint16_t)0x0094) +#define BKP_DR33 ((uint16_t)0x0098) +#define BKP_DR34 ((uint16_t)0x009C) +#define BKP_DR35 ((uint16_t)0x00A0) +#define BKP_DR36 ((uint16_t)0x00A4) +#define BKP_DR37 ((uint16_t)0x00A8) +#define BKP_DR38 ((uint16_t)0x00AC) +#define BKP_DR39 ((uint16_t)0x00B0) +#define BKP_DR40 ((uint16_t)0x00B4) +#define BKP_DR41 ((uint16_t)0x00B8) +#define BKP_DR42 ((uint16_t)0x00BC) + +#define IS_BKP_DR(DR) (((DR) == BKP_DR1) || ((DR) == BKP_DR2) || ((DR) == BKP_DR3) || \ + ((DR) == BKP_DR4) || ((DR) == BKP_DR5) || ((DR) == BKP_DR6) || \ + ((DR) == BKP_DR7) || ((DR) == BKP_DR8) || ((DR) == BKP_DR9) || \ + ((DR) == BKP_DR10) || ((DR) == BKP_DR11) || ((DR) == BKP_DR12) || \ + ((DR) == BKP_DR13) || ((DR) == BKP_DR14) || ((DR) == BKP_DR15) || \ + ((DR) == BKP_DR16) || ((DR) == BKP_DR17) || ((DR) == BKP_DR18) || \ + ((DR) == BKP_DR19) || ((DR) == BKP_DR20) || ((DR) == BKP_DR21) || \ + ((DR) == BKP_DR22) || ((DR) == BKP_DR23) || ((DR) == BKP_DR24) || \ + ((DR) == BKP_DR25) || ((DR) == BKP_DR26) || ((DR) == BKP_DR27) || \ + ((DR) == BKP_DR28) || ((DR) == BKP_DR29) || ((DR) == BKP_DR30) || \ + ((DR) == BKP_DR31) || ((DR) == BKP_DR32) || ((DR) == BKP_DR33) || \ + ((DR) == BKP_DR34) || ((DR) == BKP_DR35) || ((DR) == BKP_DR36) || \ + ((DR) == BKP_DR37) || ((DR) == BKP_DR38) || ((DR) == BKP_DR39) || \ + ((DR) == BKP_DR40) || ((DR) == BKP_DR41) || ((DR) == BKP_DR42)) + +#define IS_BKP_CALIBRATION_VALUE(VALUE) ((VALUE) <= 0x7F) +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup BKP_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup BKP_Exported_Functions + * @{ + */ + +void BKP_DeInit(void); +void BKP_TamperPinLevelConfig(uint16_t BKP_TamperPinLevel); +void BKP_TamperPinCmd(FunctionalState NewState); +void BKP_ITConfig(FunctionalState NewState); +void BKP_RTCOutputConfig(uint16_t BKP_RTCOutputSource); +void BKP_SetRTCCalibrationValue(uint8_t CalibrationValue); +void BKP_WriteBackupRegister(uint16_t BKP_DR, uint16_t Data); +uint16_t BKP_ReadBackupRegister(uint16_t BKP_DR); +FlagStatus BKP_GetFlagStatus(void); +void BKP_ClearFlag(void); +ITStatus BKP_GetITStatus(void); +void BKP_ClearITPendingBit(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_BKP_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_can.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_can.h new file mode 100755 index 0000000..648f747 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_can.h @@ -0,0 +1,697 @@ +/** + ****************************************************************************** + * @file stm32f10x_can.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the CAN firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_CAN_H +#define __STM32F10x_CAN_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup CAN + * @{ + */ + +/** @defgroup CAN_Exported_Types + * @{ + */ + +#define IS_CAN_ALL_PERIPH(PERIPH) (((PERIPH) == CAN1) || \ + ((PERIPH) == CAN2)) + +/** + * @brief CAN init structure definition + */ + +typedef struct +{ + uint16_t CAN_Prescaler; /*!< Specifies the length of a time quantum. + It ranges from 1 to 1024. */ + + uint8_t CAN_Mode; /*!< Specifies the CAN operating mode. + This parameter can be a value of + @ref CAN_operating_mode */ + + uint8_t CAN_SJW; /*!< Specifies the maximum number of time quanta + the CAN hardware is allowed to lengthen or + shorten a bit to perform resynchronization. + This parameter can be a value of + @ref CAN_synchronisation_jump_width */ + + uint8_t CAN_BS1; /*!< Specifies the number of time quanta in Bit + Segment 1. This parameter can be a value of + @ref CAN_time_quantum_in_bit_segment_1 */ + + uint8_t CAN_BS2; /*!< Specifies the number of time quanta in Bit + Segment 2. + This parameter can be a value of + @ref CAN_time_quantum_in_bit_segment_2 */ + + FunctionalState CAN_TTCM; /*!< Enable or disable the time triggered + communication mode. This parameter can be set + either to ENABLE or DISABLE. */ + + FunctionalState CAN_ABOM; /*!< Enable or disable the automatic bus-off + management. This parameter can be set either + to ENABLE or DISABLE. */ + + FunctionalState CAN_AWUM; /*!< Enable or disable the automatic wake-up mode. + This parameter can be set either to ENABLE or + DISABLE. */ + + FunctionalState CAN_NART; /*!< Enable or disable the no-automatic + retransmission mode. This parameter can be + set either to ENABLE or DISABLE. */ + + FunctionalState CAN_RFLM; /*!< Enable or disable the Receive FIFO Locked mode. + This parameter can be set either to ENABLE + or DISABLE. */ + + FunctionalState CAN_TXFP; /*!< Enable or disable the transmit FIFO priority. + This parameter can be set either to ENABLE + or DISABLE. */ +} CAN_InitTypeDef; + +/** + * @brief CAN filter init structure definition + */ + +typedef struct +{ + uint16_t CAN_FilterIdHigh; /*!< Specifies the filter identification number (MSBs for a 32-bit + configuration, first one for a 16-bit configuration). + This parameter can be a value between 0x0000 and 0xFFFF */ + + uint16_t CAN_FilterIdLow; /*!< Specifies the filter identification number (LSBs for a 32-bit + configuration, second one for a 16-bit configuration). + This parameter can be a value between 0x0000 and 0xFFFF */ + + uint16_t CAN_FilterMaskIdHigh; /*!< Specifies the filter mask number or identification number, + according to the mode (MSBs for a 32-bit configuration, + first one for a 16-bit configuration). + This parameter can be a value between 0x0000 and 0xFFFF */ + + uint16_t CAN_FilterMaskIdLow; /*!< Specifies the filter mask number or identification number, + according to the mode (LSBs for a 32-bit configuration, + second one for a 16-bit configuration). + This parameter can be a value between 0x0000 and 0xFFFF */ + + uint16_t CAN_FilterFIFOAssignment; /*!< Specifies the FIFO (0 or 1) which will be assigned to the filter. + This parameter can be a value of @ref CAN_filter_FIFO */ + + uint8_t CAN_FilterNumber; /*!< Specifies the filter which will be initialized. It ranges from 0 to 13. */ + + uint8_t CAN_FilterMode; /*!< Specifies the filter mode to be initialized. + This parameter can be a value of @ref CAN_filter_mode */ + + uint8_t CAN_FilterScale; /*!< Specifies the filter scale. + This parameter can be a value of @ref CAN_filter_scale */ + + FunctionalState CAN_FilterActivation; /*!< Enable or disable the filter. + This parameter can be set either to ENABLE or DISABLE. */ +} CAN_FilterInitTypeDef; + +/** + * @brief CAN Tx message structure definition + */ + +typedef struct +{ + uint32_t StdId; /*!< Specifies the standard identifier. + This parameter can be a value between 0 to 0x7FF. */ + + uint32_t ExtId; /*!< Specifies the extended identifier. + This parameter can be a value between 0 to 0x1FFFFFFF. */ + + uint8_t IDE; /*!< Specifies the type of identifier for the message that + will be transmitted. This parameter can be a value + of @ref CAN_identifier_type */ + + uint8_t RTR; /*!< Specifies the type of frame for the message that will + be transmitted. This parameter can be a value of + @ref CAN_remote_transmission_request */ + + uint8_t DLC; /*!< Specifies the length of the frame that will be + transmitted. This parameter can be a value between + 0 to 8 */ + + uint8_t Data[8]; /*!< Contains the data to be transmitted. It ranges from 0 + to 0xFF. */ +} CanTxMsg; + +/** + * @brief CAN Rx message structure definition + */ + +typedef struct +{ + uint32_t StdId; /*!< Specifies the standard identifier. + This parameter can be a value between 0 to 0x7FF. */ + + uint32_t ExtId; /*!< Specifies the extended identifier. + This parameter can be a value between 0 to 0x1FFFFFFF. */ + + uint8_t IDE; /*!< Specifies the type of identifier for the message that + will be received. This parameter can be a value of + @ref CAN_identifier_type */ + + uint8_t RTR; /*!< Specifies the type of frame for the received message. + This parameter can be a value of + @ref CAN_remote_transmission_request */ + + uint8_t DLC; /*!< Specifies the length of the frame that will be received. + This parameter can be a value between 0 to 8 */ + + uint8_t Data[8]; /*!< Contains the data to be received. It ranges from 0 to + 0xFF. */ + + uint8_t FMI; /*!< Specifies the index of the filter the message stored in + the mailbox passes through. This parameter can be a + value between 0 to 0xFF */ +} CanRxMsg; + +/** + * @} + */ + +/** @defgroup CAN_Exported_Constants + * @{ + */ + +/** @defgroup CAN_sleep_constants + * @{ + */ + +#define CAN_InitStatus_Failed ((uint8_t)0x00) /*!< CAN initialization failed */ +#define CAN_InitStatus_Success ((uint8_t)0x01) /*!< CAN initialization OK */ + +/** + * @} + */ + +/** @defgroup CAN_Mode + * @{ + */ + +#define CAN_Mode_Normal ((uint8_t)0x00) /*!< normal mode */ +#define CAN_Mode_LoopBack ((uint8_t)0x01) /*!< loopback mode */ +#define CAN_Mode_Silent ((uint8_t)0x02) /*!< silent mode */ +#define CAN_Mode_Silent_LoopBack ((uint8_t)0x03) /*!< loopback combined with silent mode */ + +#define IS_CAN_MODE(MODE) (((MODE) == CAN_Mode_Normal) || \ + ((MODE) == CAN_Mode_LoopBack)|| \ + ((MODE) == CAN_Mode_Silent) || \ + ((MODE) == CAN_Mode_Silent_LoopBack)) +/** + * @} + */ + + +/** + * @defgroup CAN_Operating_Mode + * @{ + */ +#define CAN_OperatingMode_Initialization ((uint8_t)0x00) /*!< Initialization mode */ +#define CAN_OperatingMode_Normal ((uint8_t)0x01) /*!< Normal mode */ +#define CAN_OperatingMode_Sleep ((uint8_t)0x02) /*!< sleep mode */ + + +#define IS_CAN_OPERATING_MODE(MODE) (((MODE) == CAN_OperatingMode_Initialization) ||\ + ((MODE) == CAN_OperatingMode_Normal)|| \ + ((MODE) == CAN_OperatingMode_Sleep)) +/** + * @} + */ + +/** + * @defgroup CAN_Mode_Status + * @{ + */ + +#define CAN_ModeStatus_Failed ((uint8_t)0x00) /*!< CAN entering the specific mode failed */ +#define CAN_ModeStatus_Success ((uint8_t)!CAN_ModeStatus_Failed) /*!< CAN entering the specific mode Succeed */ + + +/** + * @} + */ + +/** @defgroup CAN_synchronisation_jump_width + * @{ + */ + +#define CAN_SJW_1tq ((uint8_t)0x00) /*!< 1 time quantum */ +#define CAN_SJW_2tq ((uint8_t)0x01) /*!< 2 time quantum */ +#define CAN_SJW_3tq ((uint8_t)0x02) /*!< 3 time quantum */ +#define CAN_SJW_4tq ((uint8_t)0x03) /*!< 4 time quantum */ + +#define IS_CAN_SJW(SJW) (((SJW) == CAN_SJW_1tq) || ((SJW) == CAN_SJW_2tq)|| \ + ((SJW) == CAN_SJW_3tq) || ((SJW) == CAN_SJW_4tq)) +/** + * @} + */ + +/** @defgroup CAN_time_quantum_in_bit_segment_1 + * @{ + */ + +#define CAN_BS1_1tq ((uint8_t)0x00) /*!< 1 time quantum */ +#define CAN_BS1_2tq ((uint8_t)0x01) /*!< 2 time quantum */ +#define CAN_BS1_3tq ((uint8_t)0x02) /*!< 3 time quantum */ +#define CAN_BS1_4tq ((uint8_t)0x03) /*!< 4 time quantum */ +#define CAN_BS1_5tq ((uint8_t)0x04) /*!< 5 time quantum */ +#define CAN_BS1_6tq ((uint8_t)0x05) /*!< 6 time quantum */ +#define CAN_BS1_7tq ((uint8_t)0x06) /*!< 7 time quantum */ +#define CAN_BS1_8tq ((uint8_t)0x07) /*!< 8 time quantum */ +#define CAN_BS1_9tq ((uint8_t)0x08) /*!< 9 time quantum */ +#define CAN_BS1_10tq ((uint8_t)0x09) /*!< 10 time quantum */ +#define CAN_BS1_11tq ((uint8_t)0x0A) /*!< 11 time quantum */ +#define CAN_BS1_12tq ((uint8_t)0x0B) /*!< 12 time quantum */ +#define CAN_BS1_13tq ((uint8_t)0x0C) /*!< 13 time quantum */ +#define CAN_BS1_14tq ((uint8_t)0x0D) /*!< 14 time quantum */ +#define CAN_BS1_15tq ((uint8_t)0x0E) /*!< 15 time quantum */ +#define CAN_BS1_16tq ((uint8_t)0x0F) /*!< 16 time quantum */ + +#define IS_CAN_BS1(BS1) ((BS1) <= CAN_BS1_16tq) +/** + * @} + */ + +/** @defgroup CAN_time_quantum_in_bit_segment_2 + * @{ + */ + +#define CAN_BS2_1tq ((uint8_t)0x00) /*!< 1 time quantum */ +#define CAN_BS2_2tq ((uint8_t)0x01) /*!< 2 time quantum */ +#define CAN_BS2_3tq ((uint8_t)0x02) /*!< 3 time quantum */ +#define CAN_BS2_4tq ((uint8_t)0x03) /*!< 4 time quantum */ +#define CAN_BS2_5tq ((uint8_t)0x04) /*!< 5 time quantum */ +#define CAN_BS2_6tq ((uint8_t)0x05) /*!< 6 time quantum */ +#define CAN_BS2_7tq ((uint8_t)0x06) /*!< 7 time quantum */ +#define CAN_BS2_8tq ((uint8_t)0x07) /*!< 8 time quantum */ + +#define IS_CAN_BS2(BS2) ((BS2) <= CAN_BS2_8tq) + +/** + * @} + */ + +/** @defgroup CAN_clock_prescaler + * @{ + */ + +#define IS_CAN_PRESCALER(PRESCALER) (((PRESCALER) >= 1) && ((PRESCALER) <= 1024)) + +/** + * @} + */ + +/** @defgroup CAN_filter_number + * @{ + */ +#ifndef STM32F10X_CL + #define IS_CAN_FILTER_NUMBER(NUMBER) ((NUMBER) <= 13) +#else + #define IS_CAN_FILTER_NUMBER(NUMBER) ((NUMBER) <= 27) +#endif /* STM32F10X_CL */ +/** + * @} + */ + +/** @defgroup CAN_filter_mode + * @{ + */ + +#define CAN_FilterMode_IdMask ((uint8_t)0x00) /*!< identifier/mask mode */ +#define CAN_FilterMode_IdList ((uint8_t)0x01) /*!< identifier list mode */ + +#define IS_CAN_FILTER_MODE(MODE) (((MODE) == CAN_FilterMode_IdMask) || \ + ((MODE) == CAN_FilterMode_IdList)) +/** + * @} + */ + +/** @defgroup CAN_filter_scale + * @{ + */ + +#define CAN_FilterScale_16bit ((uint8_t)0x00) /*!< Two 16-bit filters */ +#define CAN_FilterScale_32bit ((uint8_t)0x01) /*!< One 32-bit filter */ + +#define IS_CAN_FILTER_SCALE(SCALE) (((SCALE) == CAN_FilterScale_16bit) || \ + ((SCALE) == CAN_FilterScale_32bit)) + +/** + * @} + */ + +/** @defgroup CAN_filter_FIFO + * @{ + */ + +#define CAN_Filter_FIFO0 ((uint8_t)0x00) /*!< Filter FIFO 0 assignment for filter x */ +#define CAN_Filter_FIFO1 ((uint8_t)0x01) /*!< Filter FIFO 1 assignment for filter x */ +#define IS_CAN_FILTER_FIFO(FIFO) (((FIFO) == CAN_FilterFIFO0) || \ + ((FIFO) == CAN_FilterFIFO1)) +/** + * @} + */ + +/** @defgroup Start_bank_filter_for_slave_CAN + * @{ + */ +#define IS_CAN_BANKNUMBER(BANKNUMBER) (((BANKNUMBER) >= 1) && ((BANKNUMBER) <= 27)) +/** + * @} + */ + +/** @defgroup CAN_Tx + * @{ + */ + +#define IS_CAN_TRANSMITMAILBOX(TRANSMITMAILBOX) ((TRANSMITMAILBOX) <= ((uint8_t)0x02)) +#define IS_CAN_STDID(STDID) ((STDID) <= ((uint32_t)0x7FF)) +#define IS_CAN_EXTID(EXTID) ((EXTID) <= ((uint32_t)0x1FFFFFFF)) +#define IS_CAN_DLC(DLC) ((DLC) <= ((uint8_t)0x08)) + +/** + * @} + */ + +/** @defgroup CAN_identifier_type + * @{ + */ + +#define CAN_Id_Standard ((uint32_t)0x00000000) /*!< Standard Id */ +#define CAN_Id_Extended ((uint32_t)0x00000004) /*!< Extended Id */ +#define IS_CAN_IDTYPE(IDTYPE) (((IDTYPE) == CAN_Id_Standard) || \ + ((IDTYPE) == CAN_Id_Extended)) +/** + * @} + */ + +/** @defgroup CAN_remote_transmission_request + * @{ + */ + +#define CAN_RTR_Data ((uint32_t)0x00000000) /*!< Data frame */ +#define CAN_RTR_Remote ((uint32_t)0x00000002) /*!< Remote frame */ +#define IS_CAN_RTR(RTR) (((RTR) == CAN_RTR_Data) || ((RTR) == CAN_RTR_Remote)) + +/** + * @} + */ + +/** @defgroup CAN_transmit_constants + * @{ + */ + +#define CAN_TxStatus_Failed ((uint8_t)0x00)/*!< CAN transmission failed */ +#define CAN_TxStatus_Ok ((uint8_t)0x01) /*!< CAN transmission succeeded */ +#define CAN_TxStatus_Pending ((uint8_t)0x02) /*!< CAN transmission pending */ +#define CAN_TxStatus_NoMailBox ((uint8_t)0x04) /*!< CAN cell did not provide an empty mailbox */ + +/** + * @} + */ + +/** @defgroup CAN_receive_FIFO_number_constants + * @{ + */ + +#define CAN_FIFO0 ((uint8_t)0x00) /*!< CAN FIFO 0 used to receive */ +#define CAN_FIFO1 ((uint8_t)0x01) /*!< CAN FIFO 1 used to receive */ + +#define IS_CAN_FIFO(FIFO) (((FIFO) == CAN_FIFO0) || ((FIFO) == CAN_FIFO1)) + +/** + * @} + */ + +/** @defgroup CAN_sleep_constants + * @{ + */ + +#define CAN_Sleep_Failed ((uint8_t)0x00) /*!< CAN did not enter the sleep mode */ +#define CAN_Sleep_Ok ((uint8_t)0x01) /*!< CAN entered the sleep mode */ + +/** + * @} + */ + +/** @defgroup CAN_wake_up_constants + * @{ + */ + +#define CAN_WakeUp_Failed ((uint8_t)0x00) /*!< CAN did not leave the sleep mode */ +#define CAN_WakeUp_Ok ((uint8_t)0x01) /*!< CAN leaved the sleep mode */ + +/** + * @} + */ + +/** + * @defgroup CAN_Error_Code_constants + * @{ + */ + +#define CAN_ErrorCode_NoErr ((uint8_t)0x00) /*!< No Error */ +#define CAN_ErrorCode_StuffErr ((uint8_t)0x10) /*!< Stuff Error */ +#define CAN_ErrorCode_FormErr ((uint8_t)0x20) /*!< Form Error */ +#define CAN_ErrorCode_ACKErr ((uint8_t)0x30) /*!< Acknowledgment Error */ +#define CAN_ErrorCode_BitRecessiveErr ((uint8_t)0x40) /*!< Bit Recessive Error */ +#define CAN_ErrorCode_BitDominantErr ((uint8_t)0x50) /*!< Bit Dominant Error */ +#define CAN_ErrorCode_CRCErr ((uint8_t)0x60) /*!< CRC Error */ +#define CAN_ErrorCode_SoftwareSetErr ((uint8_t)0x70) /*!< Software Set Error */ + + +/** + * @} + */ + +/** @defgroup CAN_flags + * @{ + */ +/* If the flag is 0x3XXXXXXX, it means that it can be used with CAN_GetFlagStatus() + and CAN_ClearFlag() functions. */ +/* If the flag is 0x1XXXXXXX, it means that it can only be used with CAN_GetFlagStatus() function. */ + +/* Transmit Flags */ +#define CAN_FLAG_RQCP0 ((uint32_t)0x38000001) /*!< Request MailBox0 Flag */ +#define CAN_FLAG_RQCP1 ((uint32_t)0x38000100) /*!< Request MailBox1 Flag */ +#define CAN_FLAG_RQCP2 ((uint32_t)0x38010000) /*!< Request MailBox2 Flag */ + +/* Receive Flags */ +#define CAN_FLAG_FMP0 ((uint32_t)0x12000003) /*!< FIFO 0 Message Pending Flag */ +#define CAN_FLAG_FF0 ((uint32_t)0x32000008) /*!< FIFO 0 Full Flag */ +#define CAN_FLAG_FOV0 ((uint32_t)0x32000010) /*!< FIFO 0 Overrun Flag */ +#define CAN_FLAG_FMP1 ((uint32_t)0x14000003) /*!< FIFO 1 Message Pending Flag */ +#define CAN_FLAG_FF1 ((uint32_t)0x34000008) /*!< FIFO 1 Full Flag */ +#define CAN_FLAG_FOV1 ((uint32_t)0x34000010) /*!< FIFO 1 Overrun Flag */ + +/* Operating Mode Flags */ +#define CAN_FLAG_WKU ((uint32_t)0x31000008) /*!< Wake up Flag */ +#define CAN_FLAG_SLAK ((uint32_t)0x31000012) /*!< Sleep acknowledge Flag */ +/* Note: When SLAK intterupt is disabled (SLKIE=0), no polling on SLAKI is possible. + In this case the SLAK bit can be polled.*/ + +/* Error Flags */ +#define CAN_FLAG_EWG ((uint32_t)0x10F00001) /*!< Error Warning Flag */ +#define CAN_FLAG_EPV ((uint32_t)0x10F00002) /*!< Error Passive Flag */ +#define CAN_FLAG_BOF ((uint32_t)0x10F00004) /*!< Bus-Off Flag */ +#define CAN_FLAG_LEC ((uint32_t)0x30F00070) /*!< Last error code Flag */ + +#define IS_CAN_GET_FLAG(FLAG) (((FLAG) == CAN_FLAG_LEC) || ((FLAG) == CAN_FLAG_BOF) || \ + ((FLAG) == CAN_FLAG_EPV) || ((FLAG) == CAN_FLAG_EWG) || \ + ((FLAG) == CAN_FLAG_WKU) || ((FLAG) == CAN_FLAG_FOV0) || \ + ((FLAG) == CAN_FLAG_FF0) || ((FLAG) == CAN_FLAG_FMP0) || \ + ((FLAG) == CAN_FLAG_FOV1) || ((FLAG) == CAN_FLAG_FF1) || \ + ((FLAG) == CAN_FLAG_FMP1) || ((FLAG) == CAN_FLAG_RQCP2) || \ + ((FLAG) == CAN_FLAG_RQCP1)|| ((FLAG) == CAN_FLAG_RQCP0) || \ + ((FLAG) == CAN_FLAG_SLAK )) + +#define IS_CAN_CLEAR_FLAG(FLAG)(((FLAG) == CAN_FLAG_LEC) || ((FLAG) == CAN_FLAG_RQCP2) || \ + ((FLAG) == CAN_FLAG_RQCP1) || ((FLAG) == CAN_FLAG_RQCP0) || \ + ((FLAG) == CAN_FLAG_FF0) || ((FLAG) == CAN_FLAG_FOV0) ||\ + ((FLAG) == CAN_FLAG_FF1) || ((FLAG) == CAN_FLAG_FOV1) || \ + ((FLAG) == CAN_FLAG_WKU) || ((FLAG) == CAN_FLAG_SLAK)) +/** + * @} + */ + + +/** @defgroup CAN_interrupts + * @{ + */ + + + +#define CAN_IT_TME ((uint32_t)0x00000001) /*!< Transmit mailbox empty Interrupt*/ + +/* Receive Interrupts */ +#define CAN_IT_FMP0 ((uint32_t)0x00000002) /*!< FIFO 0 message pending Interrupt*/ +#define CAN_IT_FF0 ((uint32_t)0x00000004) /*!< FIFO 0 full Interrupt*/ +#define CAN_IT_FOV0 ((uint32_t)0x00000008) /*!< FIFO 0 overrun Interrupt*/ +#define CAN_IT_FMP1 ((uint32_t)0x00000010) /*!< FIFO 1 message pending Interrupt*/ +#define CAN_IT_FF1 ((uint32_t)0x00000020) /*!< FIFO 1 full Interrupt*/ +#define CAN_IT_FOV1 ((uint32_t)0x00000040) /*!< FIFO 1 overrun Interrupt*/ + +/* Operating Mode Interrupts */ +#define CAN_IT_WKU ((uint32_t)0x00010000) /*!< Wake-up Interrupt*/ +#define CAN_IT_SLK ((uint32_t)0x00020000) /*!< Sleep acknowledge Interrupt*/ + +/* Error Interrupts */ +#define CAN_IT_EWG ((uint32_t)0x00000100) /*!< Error warning Interrupt*/ +#define CAN_IT_EPV ((uint32_t)0x00000200) /*!< Error passive Interrupt*/ +#define CAN_IT_BOF ((uint32_t)0x00000400) /*!< Bus-off Interrupt*/ +#define CAN_IT_LEC ((uint32_t)0x00000800) /*!< Last error code Interrupt*/ +#define CAN_IT_ERR ((uint32_t)0x00008000) /*!< Error Interrupt*/ + +/* Flags named as Interrupts : kept only for FW compatibility */ +#define CAN_IT_RQCP0 CAN_IT_TME +#define CAN_IT_RQCP1 CAN_IT_TME +#define CAN_IT_RQCP2 CAN_IT_TME + + +#define IS_CAN_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FMP0) ||\ + ((IT) == CAN_IT_FF0) || ((IT) == CAN_IT_FOV0) ||\ + ((IT) == CAN_IT_FMP1) || ((IT) == CAN_IT_FF1) ||\ + ((IT) == CAN_IT_FOV1) || ((IT) == CAN_IT_EWG) ||\ + ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\ + ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\ + ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK)) + +#define IS_CAN_CLEAR_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FF0) ||\ + ((IT) == CAN_IT_FOV0)|| ((IT) == CAN_IT_FF1) ||\ + ((IT) == CAN_IT_FOV1)|| ((IT) == CAN_IT_EWG) ||\ + ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\ + ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\ + ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK)) + +/** + * @} + */ + +/** @defgroup CAN_Legacy + * @{ + */ +#define CANINITFAILED CAN_InitStatus_Failed +#define CANINITOK CAN_InitStatus_Success +#define CAN_FilterFIFO0 CAN_Filter_FIFO0 +#define CAN_FilterFIFO1 CAN_Filter_FIFO1 +#define CAN_ID_STD CAN_Id_Standard +#define CAN_ID_EXT CAN_Id_Extended +#define CAN_RTR_DATA CAN_RTR_Data +#define CAN_RTR_REMOTE CAN_RTR_Remote +#define CANTXFAILE CAN_TxStatus_Failed +#define CANTXOK CAN_TxStatus_Ok +#define CANTXPENDING CAN_TxStatus_Pending +#define CAN_NO_MB CAN_TxStatus_NoMailBox +#define CANSLEEPFAILED CAN_Sleep_Failed +#define CANSLEEPOK CAN_Sleep_Ok +#define CANWAKEUPFAILED CAN_WakeUp_Failed +#define CANWAKEUPOK CAN_WakeUp_Ok + +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup CAN_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup CAN_Exported_Functions + * @{ + */ +/* Function used to set the CAN configuration to the default reset state *****/ +void CAN_DeInit(CAN_TypeDef* CANx); + +/* Initialization and Configuration functions *********************************/ +uint8_t CAN_Init(CAN_TypeDef* CANx, CAN_InitTypeDef* CAN_InitStruct); +void CAN_FilterInit(CAN_FilterInitTypeDef* CAN_FilterInitStruct); +void CAN_StructInit(CAN_InitTypeDef* CAN_InitStruct); +void CAN_SlaveStartBank(uint8_t CAN_BankNumber); +void CAN_DBGFreeze(CAN_TypeDef* CANx, FunctionalState NewState); +void CAN_TTComModeCmd(CAN_TypeDef* CANx, FunctionalState NewState); + +/* Transmit functions *********************************************************/ +uint8_t CAN_Transmit(CAN_TypeDef* CANx, CanTxMsg* TxMessage); +uint8_t CAN_TransmitStatus(CAN_TypeDef* CANx, uint8_t TransmitMailbox); +void CAN_CancelTransmit(CAN_TypeDef* CANx, uint8_t Mailbox); + +/* Receive functions **********************************************************/ +void CAN_Receive(CAN_TypeDef* CANx, uint8_t FIFONumber, CanRxMsg* RxMessage); +void CAN_FIFORelease(CAN_TypeDef* CANx, uint8_t FIFONumber); +uint8_t CAN_MessagePending(CAN_TypeDef* CANx, uint8_t FIFONumber); + + +/* Operation modes functions **************************************************/ +uint8_t CAN_OperatingModeRequest(CAN_TypeDef* CANx, uint8_t CAN_OperatingMode); +uint8_t CAN_Sleep(CAN_TypeDef* CANx); +uint8_t CAN_WakeUp(CAN_TypeDef* CANx); + +/* Error management functions *************************************************/ +uint8_t CAN_GetLastErrorCode(CAN_TypeDef* CANx); +uint8_t CAN_GetReceiveErrorCounter(CAN_TypeDef* CANx); +uint8_t CAN_GetLSBTransmitErrorCounter(CAN_TypeDef* CANx); + +/* Interrupts and flags management functions **********************************/ +void CAN_ITConfig(CAN_TypeDef* CANx, uint32_t CAN_IT, FunctionalState NewState); +FlagStatus CAN_GetFlagStatus(CAN_TypeDef* CANx, uint32_t CAN_FLAG); +void CAN_ClearFlag(CAN_TypeDef* CANx, uint32_t CAN_FLAG); +ITStatus CAN_GetITStatus(CAN_TypeDef* CANx, uint32_t CAN_IT); +void CAN_ClearITPendingBit(CAN_TypeDef* CANx, uint32_t CAN_IT); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_CAN_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_cec.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_cec.h new file mode 100755 index 0000000..a3f8fc7 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_cec.h @@ -0,0 +1,210 @@ +/** + ****************************************************************************** + * @file stm32f10x_cec.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the CEC firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_CEC_H +#define __STM32F10x_CEC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup CEC + * @{ + */ + + +/** @defgroup CEC_Exported_Types + * @{ + */ + +/** + * @brief CEC Init structure definition + */ +typedef struct +{ + uint16_t CEC_BitTimingMode; /*!< Configures the CEC Bit Timing Error Mode. + This parameter can be a value of @ref CEC_BitTiming_Mode */ + uint16_t CEC_BitPeriodMode; /*!< Configures the CEC Bit Period Error Mode. + This parameter can be a value of @ref CEC_BitPeriod_Mode */ +}CEC_InitTypeDef; + +/** + * @} + */ + +/** @defgroup CEC_Exported_Constants + * @{ + */ + +/** @defgroup CEC_BitTiming_Mode + * @{ + */ +#define CEC_BitTimingStdMode ((uint16_t)0x00) /*!< Bit timing error Standard Mode */ +#define CEC_BitTimingErrFreeMode CEC_CFGR_BTEM /*!< Bit timing error Free Mode */ + +#define IS_CEC_BIT_TIMING_ERROR_MODE(MODE) (((MODE) == CEC_BitTimingStdMode) || \ + ((MODE) == CEC_BitTimingErrFreeMode)) +/** + * @} + */ + +/** @defgroup CEC_BitPeriod_Mode + * @{ + */ +#define CEC_BitPeriodStdMode ((uint16_t)0x00) /*!< Bit period error Standard Mode */ +#define CEC_BitPeriodFlexibleMode CEC_CFGR_BPEM /*!< Bit period error Flexible Mode */ + +#define IS_CEC_BIT_PERIOD_ERROR_MODE(MODE) (((MODE) == CEC_BitPeriodStdMode) || \ + ((MODE) == CEC_BitPeriodFlexibleMode)) +/** + * @} + */ + + +/** @defgroup CEC_interrupts_definition + * @{ + */ +#define CEC_IT_TERR CEC_CSR_TERR +#define CEC_IT_TBTRF CEC_CSR_TBTRF +#define CEC_IT_RERR CEC_CSR_RERR +#define CEC_IT_RBTF CEC_CSR_RBTF +#define IS_CEC_GET_IT(IT) (((IT) == CEC_IT_TERR) || ((IT) == CEC_IT_TBTRF) || \ + ((IT) == CEC_IT_RERR) || ((IT) == CEC_IT_RBTF)) +/** + * @} + */ + + +/** @defgroup CEC_Own_Address + * @{ + */ +#define IS_CEC_ADDRESS(ADDRESS) ((ADDRESS) < 0x10) +/** + * @} + */ + +/** @defgroup CEC_Prescaler + * @{ + */ +#define IS_CEC_PRESCALER(PRESCALER) ((PRESCALER) <= 0x3FFF) + +/** + * @} + */ + +/** @defgroup CEC_flags_definition + * @{ + */ + +/** + * @brief ESR register flags + */ +#define CEC_FLAG_BTE ((uint32_t)0x10010000) +#define CEC_FLAG_BPE ((uint32_t)0x10020000) +#define CEC_FLAG_RBTFE ((uint32_t)0x10040000) +#define CEC_FLAG_SBE ((uint32_t)0x10080000) +#define CEC_FLAG_ACKE ((uint32_t)0x10100000) +#define CEC_FLAG_LINE ((uint32_t)0x10200000) +#define CEC_FLAG_TBTFE ((uint32_t)0x10400000) + +/** + * @brief CSR register flags + */ +#define CEC_FLAG_TEOM ((uint32_t)0x00000002) +#define CEC_FLAG_TERR ((uint32_t)0x00000004) +#define CEC_FLAG_TBTRF ((uint32_t)0x00000008) +#define CEC_FLAG_RSOM ((uint32_t)0x00000010) +#define CEC_FLAG_REOM ((uint32_t)0x00000020) +#define CEC_FLAG_RERR ((uint32_t)0x00000040) +#define CEC_FLAG_RBTF ((uint32_t)0x00000080) + +#define IS_CEC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFF03) == 0x00) && ((FLAG) != 0x00)) + +#define IS_CEC_GET_FLAG(FLAG) (((FLAG) == CEC_FLAG_BTE) || ((FLAG) == CEC_FLAG_BPE) || \ + ((FLAG) == CEC_FLAG_RBTFE) || ((FLAG)== CEC_FLAG_SBE) || \ + ((FLAG) == CEC_FLAG_ACKE) || ((FLAG) == CEC_FLAG_LINE) || \ + ((FLAG) == CEC_FLAG_TBTFE) || ((FLAG) == CEC_FLAG_TEOM) || \ + ((FLAG) == CEC_FLAG_TERR) || ((FLAG) == CEC_FLAG_TBTRF) || \ + ((FLAG) == CEC_FLAG_RSOM) || ((FLAG) == CEC_FLAG_REOM) || \ + ((FLAG) == CEC_FLAG_RERR) || ((FLAG) == CEC_FLAG_RBTF)) + +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup CEC_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup CEC_Exported_Functions + * @{ + */ +void CEC_DeInit(void); +void CEC_Init(CEC_InitTypeDef* CEC_InitStruct); +void CEC_Cmd(FunctionalState NewState); +void CEC_ITConfig(FunctionalState NewState); +void CEC_OwnAddressConfig(uint8_t CEC_OwnAddress); +void CEC_SetPrescaler(uint16_t CEC_Prescaler); +void CEC_SendDataByte(uint8_t Data); +uint8_t CEC_ReceiveDataByte(void); +void CEC_StartOfMessage(void); +void CEC_EndOfMessageCmd(FunctionalState NewState); +FlagStatus CEC_GetFlagStatus(uint32_t CEC_FLAG); +void CEC_ClearFlag(uint32_t CEC_FLAG); +ITStatus CEC_GetITStatus(uint8_t CEC_IT); +void CEC_ClearITPendingBit(uint16_t CEC_IT); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_CEC_H */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_crc.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_crc.h new file mode 100755 index 0000000..658a51c --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_crc.h @@ -0,0 +1,94 @@ +/** + ****************************************************************************** + * @file stm32f10x_crc.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the CRC firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_CRC_H +#define __STM32F10x_CRC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup CRC + * @{ + */ + +/** @defgroup CRC_Exported_Types + * @{ + */ + +/** + * @} + */ + +/** @defgroup CRC_Exported_Constants + * @{ + */ + +/** + * @} + */ + +/** @defgroup CRC_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup CRC_Exported_Functions + * @{ + */ + +void CRC_ResetDR(void); +uint32_t CRC_CalcCRC(uint32_t Data); +uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); +uint32_t CRC_GetCRC(void); +void CRC_SetIDRegister(uint8_t IDValue); +uint8_t CRC_GetIDRegister(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_CRC_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_dac.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_dac.h new file mode 100755 index 0000000..7106164 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_dac.h @@ -0,0 +1,317 @@ +/** + ****************************************************************************** + * @file stm32f10x_dac.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the DAC firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_DAC_H +#define __STM32F10x_DAC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup DAC + * @{ + */ + +/** @defgroup DAC_Exported_Types + * @{ + */ + +/** + * @brief DAC Init structure definition + */ + +typedef struct +{ + uint32_t DAC_Trigger; /*!< Specifies the external trigger for the selected DAC channel. + This parameter can be a value of @ref DAC_trigger_selection */ + + uint32_t DAC_WaveGeneration; /*!< Specifies whether DAC channel noise waves or triangle waves + are generated, or whether no wave is generated. + This parameter can be a value of @ref DAC_wave_generation */ + + uint32_t DAC_LFSRUnmask_TriangleAmplitude; /*!< Specifies the LFSR mask for noise wave generation or + the maximum amplitude triangle generation for the DAC channel. + This parameter can be a value of @ref DAC_lfsrunmask_triangleamplitude */ + + uint32_t DAC_OutputBuffer; /*!< Specifies whether the DAC channel output buffer is enabled or disabled. + This parameter can be a value of @ref DAC_output_buffer */ +}DAC_InitTypeDef; + +/** + * @} + */ + +/** @defgroup DAC_Exported_Constants + * @{ + */ + +/** @defgroup DAC_trigger_selection + * @{ + */ + +#define DAC_Trigger_None ((uint32_t)0x00000000) /*!< Conversion is automatic once the DAC1_DHRxxxx register + has been loaded, and not by external trigger */ +#define DAC_Trigger_T6_TRGO ((uint32_t)0x00000004) /*!< TIM6 TRGO selected as external conversion trigger for DAC channel */ +#define DAC_Trigger_T8_TRGO ((uint32_t)0x0000000C) /*!< TIM8 TRGO selected as external conversion trigger for DAC channel + only in High-density devices*/ +#define DAC_Trigger_T3_TRGO ((uint32_t)0x0000000C) /*!< TIM8 TRGO selected as external conversion trigger for DAC channel + only in Connectivity line, Medium-density and Low-density Value Line devices */ +#define DAC_Trigger_T7_TRGO ((uint32_t)0x00000014) /*!< TIM7 TRGO selected as external conversion trigger for DAC channel */ +#define DAC_Trigger_T5_TRGO ((uint32_t)0x0000001C) /*!< TIM5 TRGO selected as external conversion trigger for DAC channel */ +#define DAC_Trigger_T15_TRGO ((uint32_t)0x0000001C) /*!< TIM15 TRGO selected as external conversion trigger for DAC channel + only in Medium-density and Low-density Value Line devices*/ +#define DAC_Trigger_T2_TRGO ((uint32_t)0x00000024) /*!< TIM2 TRGO selected as external conversion trigger for DAC channel */ +#define DAC_Trigger_T4_TRGO ((uint32_t)0x0000002C) /*!< TIM4 TRGO selected as external conversion trigger for DAC channel */ +#define DAC_Trigger_Ext_IT9 ((uint32_t)0x00000034) /*!< EXTI Line9 event selected as external conversion trigger for DAC channel */ +#define DAC_Trigger_Software ((uint32_t)0x0000003C) /*!< Conversion started by software trigger for DAC channel */ + +#define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_Trigger_None) || \ + ((TRIGGER) == DAC_Trigger_T6_TRGO) || \ + ((TRIGGER) == DAC_Trigger_T8_TRGO) || \ + ((TRIGGER) == DAC_Trigger_T7_TRGO) || \ + ((TRIGGER) == DAC_Trigger_T5_TRGO) || \ + ((TRIGGER) == DAC_Trigger_T2_TRGO) || \ + ((TRIGGER) == DAC_Trigger_T4_TRGO) || \ + ((TRIGGER) == DAC_Trigger_Ext_IT9) || \ + ((TRIGGER) == DAC_Trigger_Software)) + +/** + * @} + */ + +/** @defgroup DAC_wave_generation + * @{ + */ + +#define DAC_WaveGeneration_None ((uint32_t)0x00000000) +#define DAC_WaveGeneration_Noise ((uint32_t)0x00000040) +#define DAC_WaveGeneration_Triangle ((uint32_t)0x00000080) +#define IS_DAC_GENERATE_WAVE(WAVE) (((WAVE) == DAC_WaveGeneration_None) || \ + ((WAVE) == DAC_WaveGeneration_Noise) || \ + ((WAVE) == DAC_WaveGeneration_Triangle)) +/** + * @} + */ + +/** @defgroup DAC_lfsrunmask_triangleamplitude + * @{ + */ + +#define DAC_LFSRUnmask_Bit0 ((uint32_t)0x00000000) /*!< Unmask DAC channel LFSR bit0 for noise wave generation */ +#define DAC_LFSRUnmask_Bits1_0 ((uint32_t)0x00000100) /*!< Unmask DAC channel LFSR bit[1:0] for noise wave generation */ +#define DAC_LFSRUnmask_Bits2_0 ((uint32_t)0x00000200) /*!< Unmask DAC channel LFSR bit[2:0] for noise wave generation */ +#define DAC_LFSRUnmask_Bits3_0 ((uint32_t)0x00000300) /*!< Unmask DAC channel LFSR bit[3:0] for noise wave generation */ +#define DAC_LFSRUnmask_Bits4_0 ((uint32_t)0x00000400) /*!< Unmask DAC channel LFSR bit[4:0] for noise wave generation */ +#define DAC_LFSRUnmask_Bits5_0 ((uint32_t)0x00000500) /*!< Unmask DAC channel LFSR bit[5:0] for noise wave generation */ +#define DAC_LFSRUnmask_Bits6_0 ((uint32_t)0x00000600) /*!< Unmask DAC channel LFSR bit[6:0] for noise wave generation */ +#define DAC_LFSRUnmask_Bits7_0 ((uint32_t)0x00000700) /*!< Unmask DAC channel LFSR bit[7:0] for noise wave generation */ +#define DAC_LFSRUnmask_Bits8_0 ((uint32_t)0x00000800) /*!< Unmask DAC channel LFSR bit[8:0] for noise wave generation */ +#define DAC_LFSRUnmask_Bits9_0 ((uint32_t)0x00000900) /*!< Unmask DAC channel LFSR bit[9:0] for noise wave generation */ +#define DAC_LFSRUnmask_Bits10_0 ((uint32_t)0x00000A00) /*!< Unmask DAC channel LFSR bit[10:0] for noise wave generation */ +#define DAC_LFSRUnmask_Bits11_0 ((uint32_t)0x00000B00) /*!< Unmask DAC channel LFSR bit[11:0] for noise wave generation */ +#define DAC_TriangleAmplitude_1 ((uint32_t)0x00000000) /*!< Select max triangle amplitude of 1 */ +#define DAC_TriangleAmplitude_3 ((uint32_t)0x00000100) /*!< Select max triangle amplitude of 3 */ +#define DAC_TriangleAmplitude_7 ((uint32_t)0x00000200) /*!< Select max triangle amplitude of 7 */ +#define DAC_TriangleAmplitude_15 ((uint32_t)0x00000300) /*!< Select max triangle amplitude of 15 */ +#define DAC_TriangleAmplitude_31 ((uint32_t)0x00000400) /*!< Select max triangle amplitude of 31 */ +#define DAC_TriangleAmplitude_63 ((uint32_t)0x00000500) /*!< Select max triangle amplitude of 63 */ +#define DAC_TriangleAmplitude_127 ((uint32_t)0x00000600) /*!< Select max triangle amplitude of 127 */ +#define DAC_TriangleAmplitude_255 ((uint32_t)0x00000700) /*!< Select max triangle amplitude of 255 */ +#define DAC_TriangleAmplitude_511 ((uint32_t)0x00000800) /*!< Select max triangle amplitude of 511 */ +#define DAC_TriangleAmplitude_1023 ((uint32_t)0x00000900) /*!< Select max triangle amplitude of 1023 */ +#define DAC_TriangleAmplitude_2047 ((uint32_t)0x00000A00) /*!< Select max triangle amplitude of 2047 */ +#define DAC_TriangleAmplitude_4095 ((uint32_t)0x00000B00) /*!< Select max triangle amplitude of 4095 */ + +#define IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(VALUE) (((VALUE) == DAC_LFSRUnmask_Bit0) || \ + ((VALUE) == DAC_LFSRUnmask_Bits1_0) || \ + ((VALUE) == DAC_LFSRUnmask_Bits2_0) || \ + ((VALUE) == DAC_LFSRUnmask_Bits3_0) || \ + ((VALUE) == DAC_LFSRUnmask_Bits4_0) || \ + ((VALUE) == DAC_LFSRUnmask_Bits5_0) || \ + ((VALUE) == DAC_LFSRUnmask_Bits6_0) || \ + ((VALUE) == DAC_LFSRUnmask_Bits7_0) || \ + ((VALUE) == DAC_LFSRUnmask_Bits8_0) || \ + ((VALUE) == DAC_LFSRUnmask_Bits9_0) || \ + ((VALUE) == DAC_LFSRUnmask_Bits10_0) || \ + ((VALUE) == DAC_LFSRUnmask_Bits11_0) || \ + ((VALUE) == DAC_TriangleAmplitude_1) || \ + ((VALUE) == DAC_TriangleAmplitude_3) || \ + ((VALUE) == DAC_TriangleAmplitude_7) || \ + ((VALUE) == DAC_TriangleAmplitude_15) || \ + ((VALUE) == DAC_TriangleAmplitude_31) || \ + ((VALUE) == DAC_TriangleAmplitude_63) || \ + ((VALUE) == DAC_TriangleAmplitude_127) || \ + ((VALUE) == DAC_TriangleAmplitude_255) || \ + ((VALUE) == DAC_TriangleAmplitude_511) || \ + ((VALUE) == DAC_TriangleAmplitude_1023) || \ + ((VALUE) == DAC_TriangleAmplitude_2047) || \ + ((VALUE) == DAC_TriangleAmplitude_4095)) +/** + * @} + */ + +/** @defgroup DAC_output_buffer + * @{ + */ + +#define DAC_OutputBuffer_Enable ((uint32_t)0x00000000) +#define DAC_OutputBuffer_Disable ((uint32_t)0x00000002) +#define IS_DAC_OUTPUT_BUFFER_STATE(STATE) (((STATE) == DAC_OutputBuffer_Enable) || \ + ((STATE) == DAC_OutputBuffer_Disable)) +/** + * @} + */ + +/** @defgroup DAC_Channel_selection + * @{ + */ + +#define DAC_Channel_1 ((uint32_t)0x00000000) +#define DAC_Channel_2 ((uint32_t)0x00000010) +#define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_Channel_1) || \ + ((CHANNEL) == DAC_Channel_2)) +/** + * @} + */ + +/** @defgroup DAC_data_alignment + * @{ + */ + +#define DAC_Align_12b_R ((uint32_t)0x00000000) +#define DAC_Align_12b_L ((uint32_t)0x00000004) +#define DAC_Align_8b_R ((uint32_t)0x00000008) +#define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_Align_12b_R) || \ + ((ALIGN) == DAC_Align_12b_L) || \ + ((ALIGN) == DAC_Align_8b_R)) +/** + * @} + */ + +/** @defgroup DAC_wave_generation + * @{ + */ + +#define DAC_Wave_Noise ((uint32_t)0x00000040) +#define DAC_Wave_Triangle ((uint32_t)0x00000080) +#define IS_DAC_WAVE(WAVE) (((WAVE) == DAC_Wave_Noise) || \ + ((WAVE) == DAC_Wave_Triangle)) +/** + * @} + */ + +/** @defgroup DAC_data + * @{ + */ + +#define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0) +/** + * @} + */ +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) +/** @defgroup DAC_interrupts_definition + * @{ + */ + +#define DAC_IT_DMAUDR ((uint32_t)0x00002000) +#define IS_DAC_IT(IT) (((IT) == DAC_IT_DMAUDR)) + +/** + * @} + */ + +/** @defgroup DAC_flags_definition + * @{ + */ + +#define DAC_FLAG_DMAUDR ((uint32_t)0x00002000) +#define IS_DAC_FLAG(FLAG) (((FLAG) == DAC_FLAG_DMAUDR)) + +/** + * @} + */ +#endif + +/** + * @} + */ + +/** @defgroup DAC_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup DAC_Exported_Functions + * @{ + */ + +void DAC_DeInit(void); +void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct); +void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct); +void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState); +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) +void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState); +#endif +void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState); +void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState); +void DAC_DualSoftwareTriggerCmd(FunctionalState NewState); +void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState); +void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data); +void DAC_SetChannel2Data(uint32_t DAC_Align, uint16_t Data); +void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1); +uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel); +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) +FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG); +void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG); +ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT); +void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*__STM32F10x_DAC_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_dbgmcu.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_dbgmcu.h new file mode 100755 index 0000000..1e6a68a --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_dbgmcu.h @@ -0,0 +1,119 @@ +/** + ****************************************************************************** + * @file stm32f10x_dbgmcu.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the DBGMCU + * firmware library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_DBGMCU_H +#define __STM32F10x_DBGMCU_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup DBGMCU + * @{ + */ + +/** @defgroup DBGMCU_Exported_Types + * @{ + */ + +/** + * @} + */ + +/** @defgroup DBGMCU_Exported_Constants + * @{ + */ + +#define DBGMCU_SLEEP ((uint32_t)0x00000001) +#define DBGMCU_STOP ((uint32_t)0x00000002) +#define DBGMCU_STANDBY ((uint32_t)0x00000004) +#define DBGMCU_IWDG_STOP ((uint32_t)0x00000100) +#define DBGMCU_WWDG_STOP ((uint32_t)0x00000200) +#define DBGMCU_TIM1_STOP ((uint32_t)0x00000400) +#define DBGMCU_TIM2_STOP ((uint32_t)0x00000800) +#define DBGMCU_TIM3_STOP ((uint32_t)0x00001000) +#define DBGMCU_TIM4_STOP ((uint32_t)0x00002000) +#define DBGMCU_CAN1_STOP ((uint32_t)0x00004000) +#define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00008000) +#define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00010000) +#define DBGMCU_TIM8_STOP ((uint32_t)0x00020000) +#define DBGMCU_TIM5_STOP ((uint32_t)0x00040000) +#define DBGMCU_TIM6_STOP ((uint32_t)0x00080000) +#define DBGMCU_TIM7_STOP ((uint32_t)0x00100000) +#define DBGMCU_CAN2_STOP ((uint32_t)0x00200000) +#define DBGMCU_TIM15_STOP ((uint32_t)0x00400000) +#define DBGMCU_TIM16_STOP ((uint32_t)0x00800000) +#define DBGMCU_TIM17_STOP ((uint32_t)0x01000000) +#define DBGMCU_TIM12_STOP ((uint32_t)0x02000000) +#define DBGMCU_TIM13_STOP ((uint32_t)0x04000000) +#define DBGMCU_TIM14_STOP ((uint32_t)0x08000000) +#define DBGMCU_TIM9_STOP ((uint32_t)0x10000000) +#define DBGMCU_TIM10_STOP ((uint32_t)0x20000000) +#define DBGMCU_TIM11_STOP ((uint32_t)0x40000000) + +#define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0x800000F8) == 0x00) && ((PERIPH) != 0x00)) +/** + * @} + */ + +/** @defgroup DBGMCU_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup DBGMCU_Exported_Functions + * @{ + */ + +uint32_t DBGMCU_GetREVID(void); +uint32_t DBGMCU_GetDEVID(void); +void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_DBGMCU_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_dma.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_dma.h new file mode 100755 index 0000000..b5dc6a8 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_dma.h @@ -0,0 +1,439 @@ +/** + ****************************************************************************** + * @file stm32f10x_dma.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the DMA firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_DMA_H +#define __STM32F10x_DMA_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup DMA + * @{ + */ + +/** @defgroup DMA_Exported_Types + * @{ + */ + +/** + * @brief DMA Init structure definition + */ + +typedef struct +{ + uint32_t DMA_PeripheralBaseAddr; /*!< Specifies the peripheral base address for DMAy Channelx. */ + + uint32_t DMA_MemoryBaseAddr; /*!< Specifies the memory base address for DMAy Channelx. */ + + uint32_t DMA_DIR; /*!< Specifies if the peripheral is the source or destination. + This parameter can be a value of @ref DMA_data_transfer_direction */ + + uint32_t DMA_BufferSize; /*!< Specifies the buffer size, in data unit, of the specified Channel. + The data unit is equal to the configuration set in DMA_PeripheralDataSize + or DMA_MemoryDataSize members depending in the transfer direction. */ + + uint32_t DMA_PeripheralInc; /*!< Specifies whether the Peripheral address register is incremented or not. + This parameter can be a value of @ref DMA_peripheral_incremented_mode */ + + uint32_t DMA_MemoryInc; /*!< Specifies whether the memory address register is incremented or not. + This parameter can be a value of @ref DMA_memory_incremented_mode */ + + uint32_t DMA_PeripheralDataSize; /*!< Specifies the Peripheral data width. + This parameter can be a value of @ref DMA_peripheral_data_size */ + + uint32_t DMA_MemoryDataSize; /*!< Specifies the Memory data width. + This parameter can be a value of @ref DMA_memory_data_size */ + + uint32_t DMA_Mode; /*!< Specifies the operation mode of the DMAy Channelx. + This parameter can be a value of @ref DMA_circular_normal_mode. + @note: The circular buffer mode cannot be used if the memory-to-memory + data transfer is configured on the selected Channel */ + + uint32_t DMA_Priority; /*!< Specifies the software priority for the DMAy Channelx. + This parameter can be a value of @ref DMA_priority_level */ + + uint32_t DMA_M2M; /*!< Specifies if the DMAy Channelx will be used in memory-to-memory transfer. + This parameter can be a value of @ref DMA_memory_to_memory */ +}DMA_InitTypeDef; + +/** + * @} + */ + +/** @defgroup DMA_Exported_Constants + * @{ + */ + +#define IS_DMA_ALL_PERIPH(PERIPH) (((PERIPH) == DMA1_Channel1) || \ + ((PERIPH) == DMA1_Channel2) || \ + ((PERIPH) == DMA1_Channel3) || \ + ((PERIPH) == DMA1_Channel4) || \ + ((PERIPH) == DMA1_Channel5) || \ + ((PERIPH) == DMA1_Channel6) || \ + ((PERIPH) == DMA1_Channel7) || \ + ((PERIPH) == DMA2_Channel1) || \ + ((PERIPH) == DMA2_Channel2) || \ + ((PERIPH) == DMA2_Channel3) || \ + ((PERIPH) == DMA2_Channel4) || \ + ((PERIPH) == DMA2_Channel5)) + +/** @defgroup DMA_data_transfer_direction + * @{ + */ + +#define DMA_DIR_PeripheralDST ((uint32_t)0x00000010) +#define DMA_DIR_PeripheralSRC ((uint32_t)0x00000000) +#define IS_DMA_DIR(DIR) (((DIR) == DMA_DIR_PeripheralDST) || \ + ((DIR) == DMA_DIR_PeripheralSRC)) +/** + * @} + */ + +/** @defgroup DMA_peripheral_incremented_mode + * @{ + */ + +#define DMA_PeripheralInc_Enable ((uint32_t)0x00000040) +#define DMA_PeripheralInc_Disable ((uint32_t)0x00000000) +#define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PeripheralInc_Enable) || \ + ((STATE) == DMA_PeripheralInc_Disable)) +/** + * @} + */ + +/** @defgroup DMA_memory_incremented_mode + * @{ + */ + +#define DMA_MemoryInc_Enable ((uint32_t)0x00000080) +#define DMA_MemoryInc_Disable ((uint32_t)0x00000000) +#define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MemoryInc_Enable) || \ + ((STATE) == DMA_MemoryInc_Disable)) +/** + * @} + */ + +/** @defgroup DMA_peripheral_data_size + * @{ + */ + +#define DMA_PeripheralDataSize_Byte ((uint32_t)0x00000000) +#define DMA_PeripheralDataSize_HalfWord ((uint32_t)0x00000100) +#define DMA_PeripheralDataSize_Word ((uint32_t)0x00000200) +#define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PeripheralDataSize_Byte) || \ + ((SIZE) == DMA_PeripheralDataSize_HalfWord) || \ + ((SIZE) == DMA_PeripheralDataSize_Word)) +/** + * @} + */ + +/** @defgroup DMA_memory_data_size + * @{ + */ + +#define DMA_MemoryDataSize_Byte ((uint32_t)0x00000000) +#define DMA_MemoryDataSize_HalfWord ((uint32_t)0x00000400) +#define DMA_MemoryDataSize_Word ((uint32_t)0x00000800) +#define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MemoryDataSize_Byte) || \ + ((SIZE) == DMA_MemoryDataSize_HalfWord) || \ + ((SIZE) == DMA_MemoryDataSize_Word)) +/** + * @} + */ + +/** @defgroup DMA_circular_normal_mode + * @{ + */ + +#define DMA_Mode_Circular ((uint32_t)0x00000020) +#define DMA_Mode_Normal ((uint32_t)0x00000000) +#define IS_DMA_MODE(MODE) (((MODE) == DMA_Mode_Circular) || ((MODE) == DMA_Mode_Normal)) +/** + * @} + */ + +/** @defgroup DMA_priority_level + * @{ + */ + +#define DMA_Priority_VeryHigh ((uint32_t)0x00003000) +#define DMA_Priority_High ((uint32_t)0x00002000) +#define DMA_Priority_Medium ((uint32_t)0x00001000) +#define DMA_Priority_Low ((uint32_t)0x00000000) +#define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_Priority_VeryHigh) || \ + ((PRIORITY) == DMA_Priority_High) || \ + ((PRIORITY) == DMA_Priority_Medium) || \ + ((PRIORITY) == DMA_Priority_Low)) +/** + * @} + */ + +/** @defgroup DMA_memory_to_memory + * @{ + */ + +#define DMA_M2M_Enable ((uint32_t)0x00004000) +#define DMA_M2M_Disable ((uint32_t)0x00000000) +#define IS_DMA_M2M_STATE(STATE) (((STATE) == DMA_M2M_Enable) || ((STATE) == DMA_M2M_Disable)) + +/** + * @} + */ + +/** @defgroup DMA_interrupts_definition + * @{ + */ + +#define DMA_IT_TC ((uint32_t)0x00000002) +#define DMA_IT_HT ((uint32_t)0x00000004) +#define DMA_IT_TE ((uint32_t)0x00000008) +#define IS_DMA_CONFIG_IT(IT) ((((IT) & 0xFFFFFFF1) == 0x00) && ((IT) != 0x00)) + +#define DMA1_IT_GL1 ((uint32_t)0x00000001) +#define DMA1_IT_TC1 ((uint32_t)0x00000002) +#define DMA1_IT_HT1 ((uint32_t)0x00000004) +#define DMA1_IT_TE1 ((uint32_t)0x00000008) +#define DMA1_IT_GL2 ((uint32_t)0x00000010) +#define DMA1_IT_TC2 ((uint32_t)0x00000020) +#define DMA1_IT_HT2 ((uint32_t)0x00000040) +#define DMA1_IT_TE2 ((uint32_t)0x00000080) +#define DMA1_IT_GL3 ((uint32_t)0x00000100) +#define DMA1_IT_TC3 ((uint32_t)0x00000200) +#define DMA1_IT_HT3 ((uint32_t)0x00000400) +#define DMA1_IT_TE3 ((uint32_t)0x00000800) +#define DMA1_IT_GL4 ((uint32_t)0x00001000) +#define DMA1_IT_TC4 ((uint32_t)0x00002000) +#define DMA1_IT_HT4 ((uint32_t)0x00004000) +#define DMA1_IT_TE4 ((uint32_t)0x00008000) +#define DMA1_IT_GL5 ((uint32_t)0x00010000) +#define DMA1_IT_TC5 ((uint32_t)0x00020000) +#define DMA1_IT_HT5 ((uint32_t)0x00040000) +#define DMA1_IT_TE5 ((uint32_t)0x00080000) +#define DMA1_IT_GL6 ((uint32_t)0x00100000) +#define DMA1_IT_TC6 ((uint32_t)0x00200000) +#define DMA1_IT_HT6 ((uint32_t)0x00400000) +#define DMA1_IT_TE6 ((uint32_t)0x00800000) +#define DMA1_IT_GL7 ((uint32_t)0x01000000) +#define DMA1_IT_TC7 ((uint32_t)0x02000000) +#define DMA1_IT_HT7 ((uint32_t)0x04000000) +#define DMA1_IT_TE7 ((uint32_t)0x08000000) + +#define DMA2_IT_GL1 ((uint32_t)0x10000001) +#define DMA2_IT_TC1 ((uint32_t)0x10000002) +#define DMA2_IT_HT1 ((uint32_t)0x10000004) +#define DMA2_IT_TE1 ((uint32_t)0x10000008) +#define DMA2_IT_GL2 ((uint32_t)0x10000010) +#define DMA2_IT_TC2 ((uint32_t)0x10000020) +#define DMA2_IT_HT2 ((uint32_t)0x10000040) +#define DMA2_IT_TE2 ((uint32_t)0x10000080) +#define DMA2_IT_GL3 ((uint32_t)0x10000100) +#define DMA2_IT_TC3 ((uint32_t)0x10000200) +#define DMA2_IT_HT3 ((uint32_t)0x10000400) +#define DMA2_IT_TE3 ((uint32_t)0x10000800) +#define DMA2_IT_GL4 ((uint32_t)0x10001000) +#define DMA2_IT_TC4 ((uint32_t)0x10002000) +#define DMA2_IT_HT4 ((uint32_t)0x10004000) +#define DMA2_IT_TE4 ((uint32_t)0x10008000) +#define DMA2_IT_GL5 ((uint32_t)0x10010000) +#define DMA2_IT_TC5 ((uint32_t)0x10020000) +#define DMA2_IT_HT5 ((uint32_t)0x10040000) +#define DMA2_IT_TE5 ((uint32_t)0x10080000) + +#define IS_DMA_CLEAR_IT(IT) (((((IT) & 0xF0000000) == 0x00) || (((IT) & 0xEFF00000) == 0x00)) && ((IT) != 0x00)) + +#define IS_DMA_GET_IT(IT) (((IT) == DMA1_IT_GL1) || ((IT) == DMA1_IT_TC1) || \ + ((IT) == DMA1_IT_HT1) || ((IT) == DMA1_IT_TE1) || \ + ((IT) == DMA1_IT_GL2) || ((IT) == DMA1_IT_TC2) || \ + ((IT) == DMA1_IT_HT2) || ((IT) == DMA1_IT_TE2) || \ + ((IT) == DMA1_IT_GL3) || ((IT) == DMA1_IT_TC3) || \ + ((IT) == DMA1_IT_HT3) || ((IT) == DMA1_IT_TE3) || \ + ((IT) == DMA1_IT_GL4) || ((IT) == DMA1_IT_TC4) || \ + ((IT) == DMA1_IT_HT4) || ((IT) == DMA1_IT_TE4) || \ + ((IT) == DMA1_IT_GL5) || ((IT) == DMA1_IT_TC5) || \ + ((IT) == DMA1_IT_HT5) || ((IT) == DMA1_IT_TE5) || \ + ((IT) == DMA1_IT_GL6) || ((IT) == DMA1_IT_TC6) || \ + ((IT) == DMA1_IT_HT6) || ((IT) == DMA1_IT_TE6) || \ + ((IT) == DMA1_IT_GL7) || ((IT) == DMA1_IT_TC7) || \ + ((IT) == DMA1_IT_HT7) || ((IT) == DMA1_IT_TE7) || \ + ((IT) == DMA2_IT_GL1) || ((IT) == DMA2_IT_TC1) || \ + ((IT) == DMA2_IT_HT1) || ((IT) == DMA2_IT_TE1) || \ + ((IT) == DMA2_IT_GL2) || ((IT) == DMA2_IT_TC2) || \ + ((IT) == DMA2_IT_HT2) || ((IT) == DMA2_IT_TE2) || \ + ((IT) == DMA2_IT_GL3) || ((IT) == DMA2_IT_TC3) || \ + ((IT) == DMA2_IT_HT3) || ((IT) == DMA2_IT_TE3) || \ + ((IT) == DMA2_IT_GL4) || ((IT) == DMA2_IT_TC4) || \ + ((IT) == DMA2_IT_HT4) || ((IT) == DMA2_IT_TE4) || \ + ((IT) == DMA2_IT_GL5) || ((IT) == DMA2_IT_TC5) || \ + ((IT) == DMA2_IT_HT5) || ((IT) == DMA2_IT_TE5)) + +/** + * @} + */ + +/** @defgroup DMA_flags_definition + * @{ + */ +#define DMA1_FLAG_GL1 ((uint32_t)0x00000001) +#define DMA1_FLAG_TC1 ((uint32_t)0x00000002) +#define DMA1_FLAG_HT1 ((uint32_t)0x00000004) +#define DMA1_FLAG_TE1 ((uint32_t)0x00000008) +#define DMA1_FLAG_GL2 ((uint32_t)0x00000010) +#define DMA1_FLAG_TC2 ((uint32_t)0x00000020) +#define DMA1_FLAG_HT2 ((uint32_t)0x00000040) +#define DMA1_FLAG_TE2 ((uint32_t)0x00000080) +#define DMA1_FLAG_GL3 ((uint32_t)0x00000100) +#define DMA1_FLAG_TC3 ((uint32_t)0x00000200) +#define DMA1_FLAG_HT3 ((uint32_t)0x00000400) +#define DMA1_FLAG_TE3 ((uint32_t)0x00000800) +#define DMA1_FLAG_GL4 ((uint32_t)0x00001000) +#define DMA1_FLAG_TC4 ((uint32_t)0x00002000) +#define DMA1_FLAG_HT4 ((uint32_t)0x00004000) +#define DMA1_FLAG_TE4 ((uint32_t)0x00008000) +#define DMA1_FLAG_GL5 ((uint32_t)0x00010000) +#define DMA1_FLAG_TC5 ((uint32_t)0x00020000) +#define DMA1_FLAG_HT5 ((uint32_t)0x00040000) +#define DMA1_FLAG_TE5 ((uint32_t)0x00080000) +#define DMA1_FLAG_GL6 ((uint32_t)0x00100000) +#define DMA1_FLAG_TC6 ((uint32_t)0x00200000) +#define DMA1_FLAG_HT6 ((uint32_t)0x00400000) +#define DMA1_FLAG_TE6 ((uint32_t)0x00800000) +#define DMA1_FLAG_GL7 ((uint32_t)0x01000000) +#define DMA1_FLAG_TC7 ((uint32_t)0x02000000) +#define DMA1_FLAG_HT7 ((uint32_t)0x04000000) +#define DMA1_FLAG_TE7 ((uint32_t)0x08000000) + +#define DMA2_FLAG_GL1 ((uint32_t)0x10000001) +#define DMA2_FLAG_TC1 ((uint32_t)0x10000002) +#define DMA2_FLAG_HT1 ((uint32_t)0x10000004) +#define DMA2_FLAG_TE1 ((uint32_t)0x10000008) +#define DMA2_FLAG_GL2 ((uint32_t)0x10000010) +#define DMA2_FLAG_TC2 ((uint32_t)0x10000020) +#define DMA2_FLAG_HT2 ((uint32_t)0x10000040) +#define DMA2_FLAG_TE2 ((uint32_t)0x10000080) +#define DMA2_FLAG_GL3 ((uint32_t)0x10000100) +#define DMA2_FLAG_TC3 ((uint32_t)0x10000200) +#define DMA2_FLAG_HT3 ((uint32_t)0x10000400) +#define DMA2_FLAG_TE3 ((uint32_t)0x10000800) +#define DMA2_FLAG_GL4 ((uint32_t)0x10001000) +#define DMA2_FLAG_TC4 ((uint32_t)0x10002000) +#define DMA2_FLAG_HT4 ((uint32_t)0x10004000) +#define DMA2_FLAG_TE4 ((uint32_t)0x10008000) +#define DMA2_FLAG_GL5 ((uint32_t)0x10010000) +#define DMA2_FLAG_TC5 ((uint32_t)0x10020000) +#define DMA2_FLAG_HT5 ((uint32_t)0x10040000) +#define DMA2_FLAG_TE5 ((uint32_t)0x10080000) + +#define IS_DMA_CLEAR_FLAG(FLAG) (((((FLAG) & 0xF0000000) == 0x00) || (((FLAG) & 0xEFF00000) == 0x00)) && ((FLAG) != 0x00)) + +#define IS_DMA_GET_FLAG(FLAG) (((FLAG) == DMA1_FLAG_GL1) || ((FLAG) == DMA1_FLAG_TC1) || \ + ((FLAG) == DMA1_FLAG_HT1) || ((FLAG) == DMA1_FLAG_TE1) || \ + ((FLAG) == DMA1_FLAG_GL2) || ((FLAG) == DMA1_FLAG_TC2) || \ + ((FLAG) == DMA1_FLAG_HT2) || ((FLAG) == DMA1_FLAG_TE2) || \ + ((FLAG) == DMA1_FLAG_GL3) || ((FLAG) == DMA1_FLAG_TC3) || \ + ((FLAG) == DMA1_FLAG_HT3) || ((FLAG) == DMA1_FLAG_TE3) || \ + ((FLAG) == DMA1_FLAG_GL4) || ((FLAG) == DMA1_FLAG_TC4) || \ + ((FLAG) == DMA1_FLAG_HT4) || ((FLAG) == DMA1_FLAG_TE4) || \ + ((FLAG) == DMA1_FLAG_GL5) || ((FLAG) == DMA1_FLAG_TC5) || \ + ((FLAG) == DMA1_FLAG_HT5) || ((FLAG) == DMA1_FLAG_TE5) || \ + ((FLAG) == DMA1_FLAG_GL6) || ((FLAG) == DMA1_FLAG_TC6) || \ + ((FLAG) == DMA1_FLAG_HT6) || ((FLAG) == DMA1_FLAG_TE6) || \ + ((FLAG) == DMA1_FLAG_GL7) || ((FLAG) == DMA1_FLAG_TC7) || \ + ((FLAG) == DMA1_FLAG_HT7) || ((FLAG) == DMA1_FLAG_TE7) || \ + ((FLAG) == DMA2_FLAG_GL1) || ((FLAG) == DMA2_FLAG_TC1) || \ + ((FLAG) == DMA2_FLAG_HT1) || ((FLAG) == DMA2_FLAG_TE1) || \ + ((FLAG) == DMA2_FLAG_GL2) || ((FLAG) == DMA2_FLAG_TC2) || \ + ((FLAG) == DMA2_FLAG_HT2) || ((FLAG) == DMA2_FLAG_TE2) || \ + ((FLAG) == DMA2_FLAG_GL3) || ((FLAG) == DMA2_FLAG_TC3) || \ + ((FLAG) == DMA2_FLAG_HT3) || ((FLAG) == DMA2_FLAG_TE3) || \ + ((FLAG) == DMA2_FLAG_GL4) || ((FLAG) == DMA2_FLAG_TC4) || \ + ((FLAG) == DMA2_FLAG_HT4) || ((FLAG) == DMA2_FLAG_TE4) || \ + ((FLAG) == DMA2_FLAG_GL5) || ((FLAG) == DMA2_FLAG_TC5) || \ + ((FLAG) == DMA2_FLAG_HT5) || ((FLAG) == DMA2_FLAG_TE5)) +/** + * @} + */ + +/** @defgroup DMA_Buffer_Size + * @{ + */ + +#define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x1) && ((SIZE) < 0x10000)) + +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup DMA_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup DMA_Exported_Functions + * @{ + */ + +void DMA_DeInit(DMA_Channel_TypeDef* DMAy_Channelx); +void DMA_Init(DMA_Channel_TypeDef* DMAy_Channelx, DMA_InitTypeDef* DMA_InitStruct); +void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct); +void DMA_Cmd(DMA_Channel_TypeDef* DMAy_Channelx, FunctionalState NewState); +void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState); +void DMA_SetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx, uint16_t DataNumber); +uint16_t DMA_GetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx); +FlagStatus DMA_GetFlagStatus(uint32_t DMAy_FLAG); +void DMA_ClearFlag(uint32_t DMAy_FLAG); +ITStatus DMA_GetITStatus(uint32_t DMAy_IT); +void DMA_ClearITPendingBit(uint32_t DMAy_IT); + +#ifdef __cplusplus +} +#endif + +#endif /*__STM32F10x_DMA_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_exti.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_exti.h new file mode 100755 index 0000000..a1ab7d0 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_exti.h @@ -0,0 +1,184 @@ +/** + ****************************************************************************** + * @file stm32f10x_exti.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the EXTI firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_EXTI_H +#define __STM32F10x_EXTI_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup EXTI + * @{ + */ + +/** @defgroup EXTI_Exported_Types + * @{ + */ + +/** + * @brief EXTI mode enumeration + */ + +typedef enum +{ + EXTI_Mode_Interrupt = 0x00, + EXTI_Mode_Event = 0x04 +}EXTIMode_TypeDef; + +#define IS_EXTI_MODE(MODE) (((MODE) == EXTI_Mode_Interrupt) || ((MODE) == EXTI_Mode_Event)) + +/** + * @brief EXTI Trigger enumeration + */ + +typedef enum +{ + EXTI_Trigger_Rising = 0x08, + EXTI_Trigger_Falling = 0x0C, + EXTI_Trigger_Rising_Falling = 0x10 +}EXTITrigger_TypeDef; + +#define IS_EXTI_TRIGGER(TRIGGER) (((TRIGGER) == EXTI_Trigger_Rising) || \ + ((TRIGGER) == EXTI_Trigger_Falling) || \ + ((TRIGGER) == EXTI_Trigger_Rising_Falling)) +/** + * @brief EXTI Init Structure definition + */ + +typedef struct +{ + uint32_t EXTI_Line; /*!< Specifies the EXTI lines to be enabled or disabled. + This parameter can be any combination of @ref EXTI_Lines */ + + EXTIMode_TypeDef EXTI_Mode; /*!< Specifies the mode for the EXTI lines. + This parameter can be a value of @ref EXTIMode_TypeDef */ + + EXTITrigger_TypeDef EXTI_Trigger; /*!< Specifies the trigger signal active edge for the EXTI lines. + This parameter can be a value of @ref EXTIMode_TypeDef */ + + FunctionalState EXTI_LineCmd; /*!< Specifies the new state of the selected EXTI lines. + This parameter can be set either to ENABLE or DISABLE */ +}EXTI_InitTypeDef; + +/** + * @} + */ + +/** @defgroup EXTI_Exported_Constants + * @{ + */ + +/** @defgroup EXTI_Lines + * @{ + */ + +#define EXTI_Line0 ((uint32_t)0x00001) /*!< External interrupt line 0 */ +#define EXTI_Line1 ((uint32_t)0x00002) /*!< External interrupt line 1 */ +#define EXTI_Line2 ((uint32_t)0x00004) /*!< External interrupt line 2 */ +#define EXTI_Line3 ((uint32_t)0x00008) /*!< External interrupt line 3 */ +#define EXTI_Line4 ((uint32_t)0x00010) /*!< External interrupt line 4 */ +#define EXTI_Line5 ((uint32_t)0x00020) /*!< External interrupt line 5 */ +#define EXTI_Line6 ((uint32_t)0x00040) /*!< External interrupt line 6 */ +#define EXTI_Line7 ((uint32_t)0x00080) /*!< External interrupt line 7 */ +#define EXTI_Line8 ((uint32_t)0x00100) /*!< External interrupt line 8 */ +#define EXTI_Line9 ((uint32_t)0x00200) /*!< External interrupt line 9 */ +#define EXTI_Line10 ((uint32_t)0x00400) /*!< External interrupt line 10 */ +#define EXTI_Line11 ((uint32_t)0x00800) /*!< External interrupt line 11 */ +#define EXTI_Line12 ((uint32_t)0x01000) /*!< External interrupt line 12 */ +#define EXTI_Line13 ((uint32_t)0x02000) /*!< External interrupt line 13 */ +#define EXTI_Line14 ((uint32_t)0x04000) /*!< External interrupt line 14 */ +#define EXTI_Line15 ((uint32_t)0x08000) /*!< External interrupt line 15 */ +#define EXTI_Line16 ((uint32_t)0x10000) /*!< External interrupt line 16 Connected to the PVD Output */ +#define EXTI_Line17 ((uint32_t)0x20000) /*!< External interrupt line 17 Connected to the RTC Alarm event */ +#define EXTI_Line18 ((uint32_t)0x40000) /*!< External interrupt line 18 Connected to the USB Device/USB OTG FS + Wakeup from suspend event */ +#define EXTI_Line19 ((uint32_t)0x80000) /*!< External interrupt line 19 Connected to the Ethernet Wakeup event */ + +#define IS_EXTI_LINE(LINE) ((((LINE) & (uint32_t)0xFFF00000) == 0x00) && ((LINE) != (uint16_t)0x00)) +#define IS_GET_EXTI_LINE(LINE) (((LINE) == EXTI_Line0) || ((LINE) == EXTI_Line1) || \ + ((LINE) == EXTI_Line2) || ((LINE) == EXTI_Line3) || \ + ((LINE) == EXTI_Line4) || ((LINE) == EXTI_Line5) || \ + ((LINE) == EXTI_Line6) || ((LINE) == EXTI_Line7) || \ + ((LINE) == EXTI_Line8) || ((LINE) == EXTI_Line9) || \ + ((LINE) == EXTI_Line10) || ((LINE) == EXTI_Line11) || \ + ((LINE) == EXTI_Line12) || ((LINE) == EXTI_Line13) || \ + ((LINE) == EXTI_Line14) || ((LINE) == EXTI_Line15) || \ + ((LINE) == EXTI_Line16) || ((LINE) == EXTI_Line17) || \ + ((LINE) == EXTI_Line18) || ((LINE) == EXTI_Line19)) + + +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup EXTI_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup EXTI_Exported_Functions + * @{ + */ + +void EXTI_DeInit(void); +void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct); +void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct); +void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line); +FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line); +void EXTI_ClearFlag(uint32_t EXTI_Line); +ITStatus EXTI_GetITStatus(uint32_t EXTI_Line); +void EXTI_ClearITPendingBit(uint32_t EXTI_Line); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_EXTI_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_flash.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_flash.h new file mode 100755 index 0000000..f46d4e8 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_flash.h @@ -0,0 +1,426 @@ +/** + ****************************************************************************** + * @file stm32f10x_flash.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the FLASH + * firmware library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_FLASH_H +#define __STM32F10x_FLASH_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup FLASH + * @{ + */ + +/** @defgroup FLASH_Exported_Types + * @{ + */ + +/** + * @brief FLASH Status + */ + +typedef enum +{ + FLASH_BUSY = 1, + FLASH_ERROR_PG, + FLASH_ERROR_WRP, + FLASH_COMPLETE, + FLASH_TIMEOUT +}FLASH_Status; + +/** + * @} + */ + +/** @defgroup FLASH_Exported_Constants + * @{ + */ + +/** @defgroup Flash_Latency + * @{ + */ + +#define FLASH_Latency_0 ((uint32_t)0x00000000) /*!< FLASH Zero Latency cycle */ +#define FLASH_Latency_1 ((uint32_t)0x00000001) /*!< FLASH One Latency cycle */ +#define FLASH_Latency_2 ((uint32_t)0x00000002) /*!< FLASH Two Latency cycles */ +#define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_Latency_0) || \ + ((LATENCY) == FLASH_Latency_1) || \ + ((LATENCY) == FLASH_Latency_2)) +/** + * @} + */ + +/** @defgroup Half_Cycle_Enable_Disable + * @{ + */ + +#define FLASH_HalfCycleAccess_Enable ((uint32_t)0x00000008) /*!< FLASH Half Cycle Enable */ +#define FLASH_HalfCycleAccess_Disable ((uint32_t)0x00000000) /*!< FLASH Half Cycle Disable */ +#define IS_FLASH_HALFCYCLEACCESS_STATE(STATE) (((STATE) == FLASH_HalfCycleAccess_Enable) || \ + ((STATE) == FLASH_HalfCycleAccess_Disable)) +/** + * @} + */ + +/** @defgroup Prefetch_Buffer_Enable_Disable + * @{ + */ + +#define FLASH_PrefetchBuffer_Enable ((uint32_t)0x00000010) /*!< FLASH Prefetch Buffer Enable */ +#define FLASH_PrefetchBuffer_Disable ((uint32_t)0x00000000) /*!< FLASH Prefetch Buffer Disable */ +#define IS_FLASH_PREFETCHBUFFER_STATE(STATE) (((STATE) == FLASH_PrefetchBuffer_Enable) || \ + ((STATE) == FLASH_PrefetchBuffer_Disable)) +/** + * @} + */ + +/** @defgroup Option_Bytes_Write_Protection + * @{ + */ + +/* Values to be used with STM32 Low and Medium density devices */ +#define FLASH_WRProt_Pages0to3 ((uint32_t)0x00000001) /*!< STM32 Low and Medium density devices: Write protection of page 0 to 3 */ +#define FLASH_WRProt_Pages4to7 ((uint32_t)0x00000002) /*!< STM32 Low and Medium density devices: Write protection of page 4 to 7 */ +#define FLASH_WRProt_Pages8to11 ((uint32_t)0x00000004) /*!< STM32 Low and Medium density devices: Write protection of page 8 to 11 */ +#define FLASH_WRProt_Pages12to15 ((uint32_t)0x00000008) /*!< STM32 Low and Medium density devices: Write protection of page 12 to 15 */ +#define FLASH_WRProt_Pages16to19 ((uint32_t)0x00000010) /*!< STM32 Low and Medium density devices: Write protection of page 16 to 19 */ +#define FLASH_WRProt_Pages20to23 ((uint32_t)0x00000020) /*!< STM32 Low and Medium density devices: Write protection of page 20 to 23 */ +#define FLASH_WRProt_Pages24to27 ((uint32_t)0x00000040) /*!< STM32 Low and Medium density devices: Write protection of page 24 to 27 */ +#define FLASH_WRProt_Pages28to31 ((uint32_t)0x00000080) /*!< STM32 Low and Medium density devices: Write protection of page 28 to 31 */ + +/* Values to be used with STM32 Medium-density devices */ +#define FLASH_WRProt_Pages32to35 ((uint32_t)0x00000100) /*!< STM32 Medium-density devices: Write protection of page 32 to 35 */ +#define FLASH_WRProt_Pages36to39 ((uint32_t)0x00000200) /*!< STM32 Medium-density devices: Write protection of page 36 to 39 */ +#define FLASH_WRProt_Pages40to43 ((uint32_t)0x00000400) /*!< STM32 Medium-density devices: Write protection of page 40 to 43 */ +#define FLASH_WRProt_Pages44to47 ((uint32_t)0x00000800) /*!< STM32 Medium-density devices: Write protection of page 44 to 47 */ +#define FLASH_WRProt_Pages48to51 ((uint32_t)0x00001000) /*!< STM32 Medium-density devices: Write protection of page 48 to 51 */ +#define FLASH_WRProt_Pages52to55 ((uint32_t)0x00002000) /*!< STM32 Medium-density devices: Write protection of page 52 to 55 */ +#define FLASH_WRProt_Pages56to59 ((uint32_t)0x00004000) /*!< STM32 Medium-density devices: Write protection of page 56 to 59 */ +#define FLASH_WRProt_Pages60to63 ((uint32_t)0x00008000) /*!< STM32 Medium-density devices: Write protection of page 60 to 63 */ +#define FLASH_WRProt_Pages64to67 ((uint32_t)0x00010000) /*!< STM32 Medium-density devices: Write protection of page 64 to 67 */ +#define FLASH_WRProt_Pages68to71 ((uint32_t)0x00020000) /*!< STM32 Medium-density devices: Write protection of page 68 to 71 */ +#define FLASH_WRProt_Pages72to75 ((uint32_t)0x00040000) /*!< STM32 Medium-density devices: Write protection of page 72 to 75 */ +#define FLASH_WRProt_Pages76to79 ((uint32_t)0x00080000) /*!< STM32 Medium-density devices: Write protection of page 76 to 79 */ +#define FLASH_WRProt_Pages80to83 ((uint32_t)0x00100000) /*!< STM32 Medium-density devices: Write protection of page 80 to 83 */ +#define FLASH_WRProt_Pages84to87 ((uint32_t)0x00200000) /*!< STM32 Medium-density devices: Write protection of page 84 to 87 */ +#define FLASH_WRProt_Pages88to91 ((uint32_t)0x00400000) /*!< STM32 Medium-density devices: Write protection of page 88 to 91 */ +#define FLASH_WRProt_Pages92to95 ((uint32_t)0x00800000) /*!< STM32 Medium-density devices: Write protection of page 92 to 95 */ +#define FLASH_WRProt_Pages96to99 ((uint32_t)0x01000000) /*!< STM32 Medium-density devices: Write protection of page 96 to 99 */ +#define FLASH_WRProt_Pages100to103 ((uint32_t)0x02000000) /*!< STM32 Medium-density devices: Write protection of page 100 to 103 */ +#define FLASH_WRProt_Pages104to107 ((uint32_t)0x04000000) /*!< STM32 Medium-density devices: Write protection of page 104 to 107 */ +#define FLASH_WRProt_Pages108to111 ((uint32_t)0x08000000) /*!< STM32 Medium-density devices: Write protection of page 108 to 111 */ +#define FLASH_WRProt_Pages112to115 ((uint32_t)0x10000000) /*!< STM32 Medium-density devices: Write protection of page 112 to 115 */ +#define FLASH_WRProt_Pages116to119 ((uint32_t)0x20000000) /*!< STM32 Medium-density devices: Write protection of page 115 to 119 */ +#define FLASH_WRProt_Pages120to123 ((uint32_t)0x40000000) /*!< STM32 Medium-density devices: Write protection of page 120 to 123 */ +#define FLASH_WRProt_Pages124to127 ((uint32_t)0x80000000) /*!< STM32 Medium-density devices: Write protection of page 124 to 127 */ + +/* Values to be used with STM32 High-density and STM32F10X Connectivity line devices */ +#define FLASH_WRProt_Pages0to1 ((uint32_t)0x00000001) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 0 to 1 */ +#define FLASH_WRProt_Pages2to3 ((uint32_t)0x00000002) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 2 to 3 */ +#define FLASH_WRProt_Pages4to5 ((uint32_t)0x00000004) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 4 to 5 */ +#define FLASH_WRProt_Pages6to7 ((uint32_t)0x00000008) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 6 to 7 */ +#define FLASH_WRProt_Pages8to9 ((uint32_t)0x00000010) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 8 to 9 */ +#define FLASH_WRProt_Pages10to11 ((uint32_t)0x00000020) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 10 to 11 */ +#define FLASH_WRProt_Pages12to13 ((uint32_t)0x00000040) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 12 to 13 */ +#define FLASH_WRProt_Pages14to15 ((uint32_t)0x00000080) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 14 to 15 */ +#define FLASH_WRProt_Pages16to17 ((uint32_t)0x00000100) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 16 to 17 */ +#define FLASH_WRProt_Pages18to19 ((uint32_t)0x00000200) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 18 to 19 */ +#define FLASH_WRProt_Pages20to21 ((uint32_t)0x00000400) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 20 to 21 */ +#define FLASH_WRProt_Pages22to23 ((uint32_t)0x00000800) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 22 to 23 */ +#define FLASH_WRProt_Pages24to25 ((uint32_t)0x00001000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 24 to 25 */ +#define FLASH_WRProt_Pages26to27 ((uint32_t)0x00002000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 26 to 27 */ +#define FLASH_WRProt_Pages28to29 ((uint32_t)0x00004000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 28 to 29 */ +#define FLASH_WRProt_Pages30to31 ((uint32_t)0x00008000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 30 to 31 */ +#define FLASH_WRProt_Pages32to33 ((uint32_t)0x00010000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 32 to 33 */ +#define FLASH_WRProt_Pages34to35 ((uint32_t)0x00020000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 34 to 35 */ +#define FLASH_WRProt_Pages36to37 ((uint32_t)0x00040000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 36 to 37 */ +#define FLASH_WRProt_Pages38to39 ((uint32_t)0x00080000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 38 to 39 */ +#define FLASH_WRProt_Pages40to41 ((uint32_t)0x00100000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 40 to 41 */ +#define FLASH_WRProt_Pages42to43 ((uint32_t)0x00200000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 42 to 43 */ +#define FLASH_WRProt_Pages44to45 ((uint32_t)0x00400000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 44 to 45 */ +#define FLASH_WRProt_Pages46to47 ((uint32_t)0x00800000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 46 to 47 */ +#define FLASH_WRProt_Pages48to49 ((uint32_t)0x01000000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 48 to 49 */ +#define FLASH_WRProt_Pages50to51 ((uint32_t)0x02000000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 50 to 51 */ +#define FLASH_WRProt_Pages52to53 ((uint32_t)0x04000000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 52 to 53 */ +#define FLASH_WRProt_Pages54to55 ((uint32_t)0x08000000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 54 to 55 */ +#define FLASH_WRProt_Pages56to57 ((uint32_t)0x10000000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 56 to 57 */ +#define FLASH_WRProt_Pages58to59 ((uint32_t)0x20000000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 58 to 59 */ +#define FLASH_WRProt_Pages60to61 ((uint32_t)0x40000000) /*!< STM32 High-density, XL-density and Connectivity line devices: + Write protection of page 60 to 61 */ +#define FLASH_WRProt_Pages62to127 ((uint32_t)0x80000000) /*!< STM32 Connectivity line devices: Write protection of page 62 to 127 */ +#define FLASH_WRProt_Pages62to255 ((uint32_t)0x80000000) /*!< STM32 Medium-density devices: Write protection of page 62 to 255 */ +#define FLASH_WRProt_Pages62to511 ((uint32_t)0x80000000) /*!< STM32 XL-density devices: Write protection of page 62 to 511 */ + +#define FLASH_WRProt_AllPages ((uint32_t)0xFFFFFFFF) /*!< Write protection of all Pages */ + +#define IS_FLASH_WRPROT_PAGE(PAGE) (((PAGE) != 0x00000000)) + +#define IS_FLASH_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) < 0x080FFFFF)) + +#define IS_OB_DATA_ADDRESS(ADDRESS) (((ADDRESS) == 0x1FFFF804) || ((ADDRESS) == 0x1FFFF806)) + +/** + * @} + */ + +/** @defgroup Option_Bytes_IWatchdog + * @{ + */ + +#define OB_IWDG_SW ((uint16_t)0x0001) /*!< Software IWDG selected */ +#define OB_IWDG_HW ((uint16_t)0x0000) /*!< Hardware IWDG selected */ +#define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW)) + +/** + * @} + */ + +/** @defgroup Option_Bytes_nRST_STOP + * @{ + */ + +#define OB_STOP_NoRST ((uint16_t)0x0002) /*!< No reset generated when entering in STOP */ +#define OB_STOP_RST ((uint16_t)0x0000) /*!< Reset generated when entering in STOP */ +#define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NoRST) || ((SOURCE) == OB_STOP_RST)) + +/** + * @} + */ + +/** @defgroup Option_Bytes_nRST_STDBY + * @{ + */ + +#define OB_STDBY_NoRST ((uint16_t)0x0004) /*!< No reset generated when entering in STANDBY */ +#define OB_STDBY_RST ((uint16_t)0x0000) /*!< Reset generated when entering in STANDBY */ +#define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST)) + +#ifdef STM32F10X_XL +/** + * @} + */ +/** @defgroup FLASH_Boot + * @{ + */ +#define FLASH_BOOT_Bank1 ((uint16_t)0x0000) /*!< At startup, if boot pins are set in boot from user Flash position + and this parameter is selected the device will boot from Bank1(Default) */ +#define FLASH_BOOT_Bank2 ((uint16_t)0x0001) /*!< At startup, if boot pins are set in boot from user Flash position + and this parameter is selected the device will boot from Bank 2 or Bank 1, + depending on the activation of the bank */ +#define IS_FLASH_BOOT(BOOT) (((BOOT) == FLASH_BOOT_Bank1) || ((BOOT) == FLASH_BOOT_Bank2)) +#endif +/** + * @} + */ +/** @defgroup FLASH_Interrupts + * @{ + */ +#ifdef STM32F10X_XL +#define FLASH_IT_BANK2_ERROR ((uint32_t)0x80000400) /*!< FPEC BANK2 error interrupt source */ +#define FLASH_IT_BANK2_EOP ((uint32_t)0x80001000) /*!< End of FLASH BANK2 Operation Interrupt source */ + +#define FLASH_IT_BANK1_ERROR FLASH_IT_ERROR /*!< FPEC BANK1 error interrupt source */ +#define FLASH_IT_BANK1_EOP FLASH_IT_EOP /*!< End of FLASH BANK1 Operation Interrupt source */ + +#define FLASH_IT_ERROR ((uint32_t)0x00000400) /*!< FPEC BANK1 error interrupt source */ +#define FLASH_IT_EOP ((uint32_t)0x00001000) /*!< End of FLASH BANK1 Operation Interrupt source */ +#define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0x7FFFEBFF) == 0x00000000) && (((IT) != 0x00000000))) +#else +#define FLASH_IT_ERROR ((uint32_t)0x00000400) /*!< FPEC error interrupt source */ +#define FLASH_IT_EOP ((uint32_t)0x00001000) /*!< End of FLASH Operation Interrupt source */ +#define FLASH_IT_BANK1_ERROR FLASH_IT_ERROR /*!< FPEC BANK1 error interrupt source */ +#define FLASH_IT_BANK1_EOP FLASH_IT_EOP /*!< End of FLASH BANK1 Operation Interrupt source */ + +#define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0xFFFFEBFF) == 0x00000000) && (((IT) != 0x00000000))) +#endif + +/** + * @} + */ + +/** @defgroup FLASH_Flags + * @{ + */ +#ifdef STM32F10X_XL +#define FLASH_FLAG_BANK2_BSY ((uint32_t)0x80000001) /*!< FLASH BANK2 Busy flag */ +#define FLASH_FLAG_BANK2_EOP ((uint32_t)0x80000020) /*!< FLASH BANK2 End of Operation flag */ +#define FLASH_FLAG_BANK2_PGERR ((uint32_t)0x80000004) /*!< FLASH BANK2 Program error flag */ +#define FLASH_FLAG_BANK2_WRPRTERR ((uint32_t)0x80000010) /*!< FLASH BANK2 Write protected error flag */ + +#define FLASH_FLAG_BANK1_BSY FLASH_FLAG_BSY /*!< FLASH BANK1 Busy flag*/ +#define FLASH_FLAG_BANK1_EOP FLASH_FLAG_EOP /*!< FLASH BANK1 End of Operation flag */ +#define FLASH_FLAG_BANK1_PGERR FLASH_FLAG_PGERR /*!< FLASH BANK1 Program error flag */ +#define FLASH_FLAG_BANK1_WRPRTERR FLASH_FLAG_WRPRTERR /*!< FLASH BANK1 Write protected error flag */ + +#define FLASH_FLAG_BSY ((uint32_t)0x00000001) /*!< FLASH Busy flag */ +#define FLASH_FLAG_EOP ((uint32_t)0x00000020) /*!< FLASH End of Operation flag */ +#define FLASH_FLAG_PGERR ((uint32_t)0x00000004) /*!< FLASH Program error flag */ +#define FLASH_FLAG_WRPRTERR ((uint32_t)0x00000010) /*!< FLASH Write protected error flag */ +#define FLASH_FLAG_OPTERR ((uint32_t)0x00000001) /*!< FLASH Option Byte error flag */ + +#define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0x7FFFFFCA) == 0x00000000) && ((FLAG) != 0x00000000)) +#define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \ + ((FLAG) == FLASH_FLAG_PGERR) || ((FLAG) == FLASH_FLAG_WRPRTERR) || \ + ((FLAG) == FLASH_FLAG_OPTERR)|| \ + ((FLAG) == FLASH_FLAG_BANK1_BSY) || ((FLAG) == FLASH_FLAG_BANK1_EOP) || \ + ((FLAG) == FLASH_FLAG_BANK1_PGERR) || ((FLAG) == FLASH_FLAG_BANK1_WRPRTERR) || \ + ((FLAG) == FLASH_FLAG_BANK2_BSY) || ((FLAG) == FLASH_FLAG_BANK2_EOP) || \ + ((FLAG) == FLASH_FLAG_BANK2_PGERR) || ((FLAG) == FLASH_FLAG_BANK2_WRPRTERR)) +#else +#define FLASH_FLAG_BSY ((uint32_t)0x00000001) /*!< FLASH Busy flag */ +#define FLASH_FLAG_EOP ((uint32_t)0x00000020) /*!< FLASH End of Operation flag */ +#define FLASH_FLAG_PGERR ((uint32_t)0x00000004) /*!< FLASH Program error flag */ +#define FLASH_FLAG_WRPRTERR ((uint32_t)0x00000010) /*!< FLASH Write protected error flag */ +#define FLASH_FLAG_OPTERR ((uint32_t)0x00000001) /*!< FLASH Option Byte error flag */ + +#define FLASH_FLAG_BANK1_BSY FLASH_FLAG_BSY /*!< FLASH BANK1 Busy flag*/ +#define FLASH_FLAG_BANK1_EOP FLASH_FLAG_EOP /*!< FLASH BANK1 End of Operation flag */ +#define FLASH_FLAG_BANK1_PGERR FLASH_FLAG_PGERR /*!< FLASH BANK1 Program error flag */ +#define FLASH_FLAG_BANK1_WRPRTERR FLASH_FLAG_WRPRTERR /*!< FLASH BANK1 Write protected error flag */ + +#define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFFCA) == 0x00000000) && ((FLAG) != 0x00000000)) +#define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \ + ((FLAG) == FLASH_FLAG_PGERR) || ((FLAG) == FLASH_FLAG_WRPRTERR) || \ + ((FLAG) == FLASH_FLAG_BANK1_BSY) || ((FLAG) == FLASH_FLAG_BANK1_EOP) || \ + ((FLAG) == FLASH_FLAG_BANK1_PGERR) || ((FLAG) == FLASH_FLAG_BANK1_WRPRTERR) || \ + ((FLAG) == FLASH_FLAG_OPTERR)) +#endif + +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup FLASH_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup FLASH_Exported_Functions + * @{ + */ + +/*------------ Functions used for all STM32F10x devices -----*/ +void FLASH_SetLatency(uint32_t FLASH_Latency); +void FLASH_HalfCycleAccessCmd(uint32_t FLASH_HalfCycleAccess); +void FLASH_PrefetchBufferCmd(uint32_t FLASH_PrefetchBuffer); +void FLASH_Unlock(void); +void FLASH_Lock(void); +FLASH_Status FLASH_ErasePage(uint32_t Page_Address); +FLASH_Status FLASH_EraseAllPages(void); +FLASH_Status FLASH_EraseOptionBytes(void); +FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data); +FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data); +FLASH_Status FLASH_ProgramOptionByteData(uint32_t Address, uint8_t Data); +FLASH_Status FLASH_EnableWriteProtection(uint32_t FLASH_Pages); +FLASH_Status FLASH_ReadOutProtection(FunctionalState NewState); +FLASH_Status FLASH_UserOptionByteConfig(uint16_t OB_IWDG, uint16_t OB_STOP, uint16_t OB_STDBY); +uint32_t FLASH_GetUserOptionByte(void); +uint32_t FLASH_GetWriteProtectionOptionByte(void); +FlagStatus FLASH_GetReadOutProtectionStatus(void); +FlagStatus FLASH_GetPrefetchBufferStatus(void); +void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState); +FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG); +void FLASH_ClearFlag(uint32_t FLASH_FLAG); +FLASH_Status FLASH_GetStatus(void); +FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout); + +/*------------ New function used for all STM32F10x devices -----*/ +void FLASH_UnlockBank1(void); +void FLASH_LockBank1(void); +FLASH_Status FLASH_EraseAllBank1Pages(void); +FLASH_Status FLASH_GetBank1Status(void); +FLASH_Status FLASH_WaitForLastBank1Operation(uint32_t Timeout); + +#ifdef STM32F10X_XL +/*---- New Functions used only with STM32F10x_XL density devices -----*/ +void FLASH_UnlockBank2(void); +void FLASH_LockBank2(void); +FLASH_Status FLASH_EraseAllBank2Pages(void); +FLASH_Status FLASH_GetBank2Status(void); +FLASH_Status FLASH_WaitForLastBank2Operation(uint32_t Timeout); +FLASH_Status FLASH_BootConfig(uint16_t FLASH_BOOT); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_FLASH_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_fsmc.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_fsmc.h new file mode 100755 index 0000000..ee707e7 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_fsmc.h @@ -0,0 +1,733 @@ +/** + ****************************************************************************** + * @file stm32f10x_fsmc.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the FSMC firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_FSMC_H +#define __STM32F10x_FSMC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup FSMC + * @{ + */ + +/** @defgroup FSMC_Exported_Types + * @{ + */ + +/** + * @brief Timing parameters For NOR/SRAM Banks + */ + +typedef struct +{ + uint32_t FSMC_AddressSetupTime; /*!< Defines the number of HCLK cycles to configure + the duration of the address setup time. + This parameter can be a value between 0 and 0xF. + @note: It is not used with synchronous NOR Flash memories. */ + + uint32_t FSMC_AddressHoldTime; /*!< Defines the number of HCLK cycles to configure + the duration of the address hold time. + This parameter can be a value between 0 and 0xF. + @note: It is not used with synchronous NOR Flash memories.*/ + + uint32_t FSMC_DataSetupTime; /*!< Defines the number of HCLK cycles to configure + the duration of the data setup time. + This parameter can be a value between 0 and 0xFF. + @note: It is used for SRAMs, ROMs and asynchronous multiplexed NOR Flash memories. */ + + uint32_t FSMC_BusTurnAroundDuration; /*!< Defines the number of HCLK cycles to configure + the duration of the bus turnaround. + This parameter can be a value between 0 and 0xF. + @note: It is only used for multiplexed NOR Flash memories. */ + + uint32_t FSMC_CLKDivision; /*!< Defines the period of CLK clock output signal, expressed in number of HCLK cycles. + This parameter can be a value between 1 and 0xF. + @note: This parameter is not used for asynchronous NOR Flash, SRAM or ROM accesses. */ + + uint32_t FSMC_DataLatency; /*!< Defines the number of memory clock cycles to issue + to the memory before getting the first data. + The value of this parameter depends on the memory type as shown below: + - It must be set to 0 in case of a CRAM + - It is don't care in asynchronous NOR, SRAM or ROM accesses + - It may assume a value between 0 and 0xF in NOR Flash memories + with synchronous burst mode enable */ + + uint32_t FSMC_AccessMode; /*!< Specifies the asynchronous access mode. + This parameter can be a value of @ref FSMC_Access_Mode */ +}FSMC_NORSRAMTimingInitTypeDef; + +/** + * @brief FSMC NOR/SRAM Init structure definition + */ + +typedef struct +{ + uint32_t FSMC_Bank; /*!< Specifies the NOR/SRAM memory bank that will be used. + This parameter can be a value of @ref FSMC_NORSRAM_Bank */ + + uint32_t FSMC_DataAddressMux; /*!< Specifies whether the address and data values are + multiplexed on the databus or not. + This parameter can be a value of @ref FSMC_Data_Address_Bus_Multiplexing */ + + uint32_t FSMC_MemoryType; /*!< Specifies the type of external memory attached to + the corresponding memory bank. + This parameter can be a value of @ref FSMC_Memory_Type */ + + uint32_t FSMC_MemoryDataWidth; /*!< Specifies the external memory device width. + This parameter can be a value of @ref FSMC_Data_Width */ + + uint32_t FSMC_BurstAccessMode; /*!< Enables or disables the burst access mode for Flash memory, + valid only with synchronous burst Flash memories. + This parameter can be a value of @ref FSMC_Burst_Access_Mode */ + + uint32_t FSMC_AsynchronousWait; /*!< Enables or disables wait signal during asynchronous transfers, + valid only with asynchronous Flash memories. + This parameter can be a value of @ref FSMC_AsynchronousWait */ + + uint32_t FSMC_WaitSignalPolarity; /*!< Specifies the wait signal polarity, valid only when accessing + the Flash memory in burst mode. + This parameter can be a value of @ref FSMC_Wait_Signal_Polarity */ + + uint32_t FSMC_WrapMode; /*!< Enables or disables the Wrapped burst access mode for Flash + memory, valid only when accessing Flash memories in burst mode. + This parameter can be a value of @ref FSMC_Wrap_Mode */ + + uint32_t FSMC_WaitSignalActive; /*!< Specifies if the wait signal is asserted by the memory one + clock cycle before the wait state or during the wait state, + valid only when accessing memories in burst mode. + This parameter can be a value of @ref FSMC_Wait_Timing */ + + uint32_t FSMC_WriteOperation; /*!< Enables or disables the write operation in the selected bank by the FSMC. + This parameter can be a value of @ref FSMC_Write_Operation */ + + uint32_t FSMC_WaitSignal; /*!< Enables or disables the wait-state insertion via wait + signal, valid for Flash memory access in burst mode. + This parameter can be a value of @ref FSMC_Wait_Signal */ + + uint32_t FSMC_ExtendedMode; /*!< Enables or disables the extended mode. + This parameter can be a value of @ref FSMC_Extended_Mode */ + + uint32_t FSMC_WriteBurst; /*!< Enables or disables the write burst operation. + This parameter can be a value of @ref FSMC_Write_Burst */ + + FSMC_NORSRAMTimingInitTypeDef* FSMC_ReadWriteTimingStruct; /*!< Timing Parameters for write and read access if the ExtendedMode is not used*/ + + FSMC_NORSRAMTimingInitTypeDef* FSMC_WriteTimingStruct; /*!< Timing Parameters for write access if the ExtendedMode is used*/ +}FSMC_NORSRAMInitTypeDef; + +/** + * @brief Timing parameters For FSMC NAND and PCCARD Banks + */ + +typedef struct +{ + uint32_t FSMC_SetupTime; /*!< Defines the number of HCLK cycles to setup address before + the command assertion for NAND-Flash read or write access + to common/Attribute or I/O memory space (depending on + the memory space timing to be configured). + This parameter can be a value between 0 and 0xFF.*/ + + uint32_t FSMC_WaitSetupTime; /*!< Defines the minimum number of HCLK cycles to assert the + command for NAND-Flash read or write access to + common/Attribute or I/O memory space (depending on the + memory space timing to be configured). + This parameter can be a number between 0x00 and 0xFF */ + + uint32_t FSMC_HoldSetupTime; /*!< Defines the number of HCLK clock cycles to hold address + (and data for write access) after the command deassertion + for NAND-Flash read or write access to common/Attribute + or I/O memory space (depending on the memory space timing + to be configured). + This parameter can be a number between 0x00 and 0xFF */ + + uint32_t FSMC_HiZSetupTime; /*!< Defines the number of HCLK clock cycles during which the + databus is kept in HiZ after the start of a NAND-Flash + write access to common/Attribute or I/O memory space (depending + on the memory space timing to be configured). + This parameter can be a number between 0x00 and 0xFF */ +}FSMC_NAND_PCCARDTimingInitTypeDef; + +/** + * @brief FSMC NAND Init structure definition + */ + +typedef struct +{ + uint32_t FSMC_Bank; /*!< Specifies the NAND memory bank that will be used. + This parameter can be a value of @ref FSMC_NAND_Bank */ + + uint32_t FSMC_Waitfeature; /*!< Enables or disables the Wait feature for the NAND Memory Bank. + This parameter can be any value of @ref FSMC_Wait_feature */ + + uint32_t FSMC_MemoryDataWidth; /*!< Specifies the external memory device width. + This parameter can be any value of @ref FSMC_Data_Width */ + + uint32_t FSMC_ECC; /*!< Enables or disables the ECC computation. + This parameter can be any value of @ref FSMC_ECC */ + + uint32_t FSMC_ECCPageSize; /*!< Defines the page size for the extended ECC. + This parameter can be any value of @ref FSMC_ECC_Page_Size */ + + uint32_t FSMC_TCLRSetupTime; /*!< Defines the number of HCLK cycles to configure the + delay between CLE low and RE low. + This parameter can be a value between 0 and 0xFF. */ + + uint32_t FSMC_TARSetupTime; /*!< Defines the number of HCLK cycles to configure the + delay between ALE low and RE low. + This parameter can be a number between 0x0 and 0xFF */ + + FSMC_NAND_PCCARDTimingInitTypeDef* FSMC_CommonSpaceTimingStruct; /*!< FSMC Common Space Timing */ + + FSMC_NAND_PCCARDTimingInitTypeDef* FSMC_AttributeSpaceTimingStruct; /*!< FSMC Attribute Space Timing */ +}FSMC_NANDInitTypeDef; + +/** + * @brief FSMC PCCARD Init structure definition + */ + +typedef struct +{ + uint32_t FSMC_Waitfeature; /*!< Enables or disables the Wait feature for the Memory Bank. + This parameter can be any value of @ref FSMC_Wait_feature */ + + uint32_t FSMC_TCLRSetupTime; /*!< Defines the number of HCLK cycles to configure the + delay between CLE low and RE low. + This parameter can be a value between 0 and 0xFF. */ + + uint32_t FSMC_TARSetupTime; /*!< Defines the number of HCLK cycles to configure the + delay between ALE low and RE low. + This parameter can be a number between 0x0 and 0xFF */ + + + FSMC_NAND_PCCARDTimingInitTypeDef* FSMC_CommonSpaceTimingStruct; /*!< FSMC Common Space Timing */ + + FSMC_NAND_PCCARDTimingInitTypeDef* FSMC_AttributeSpaceTimingStruct; /*!< FSMC Attribute Space Timing */ + + FSMC_NAND_PCCARDTimingInitTypeDef* FSMC_IOSpaceTimingStruct; /*!< FSMC IO Space Timing */ +}FSMC_PCCARDInitTypeDef; + +/** + * @} + */ + +/** @defgroup FSMC_Exported_Constants + * @{ + */ + +/** @defgroup FSMC_NORSRAM_Bank + * @{ + */ +#define FSMC_Bank1_NORSRAM1 ((uint32_t)0x00000000) +#define FSMC_Bank1_NORSRAM2 ((uint32_t)0x00000002) +#define FSMC_Bank1_NORSRAM3 ((uint32_t)0x00000004) +#define FSMC_Bank1_NORSRAM4 ((uint32_t)0x00000006) +/** + * @} + */ + +/** @defgroup FSMC_NAND_Bank + * @{ + */ +#define FSMC_Bank2_NAND ((uint32_t)0x00000010) +#define FSMC_Bank3_NAND ((uint32_t)0x00000100) +/** + * @} + */ + +/** @defgroup FSMC_PCCARD_Bank + * @{ + */ +#define FSMC_Bank4_PCCARD ((uint32_t)0x00001000) +/** + * @} + */ + +#define IS_FSMC_NORSRAM_BANK(BANK) (((BANK) == FSMC_Bank1_NORSRAM1) || \ + ((BANK) == FSMC_Bank1_NORSRAM2) || \ + ((BANK) == FSMC_Bank1_NORSRAM3) || \ + ((BANK) == FSMC_Bank1_NORSRAM4)) + +#define IS_FSMC_NAND_BANK(BANK) (((BANK) == FSMC_Bank2_NAND) || \ + ((BANK) == FSMC_Bank3_NAND)) + +#define IS_FSMC_GETFLAG_BANK(BANK) (((BANK) == FSMC_Bank2_NAND) || \ + ((BANK) == FSMC_Bank3_NAND) || \ + ((BANK) == FSMC_Bank4_PCCARD)) + +#define IS_FSMC_IT_BANK(BANK) (((BANK) == FSMC_Bank2_NAND) || \ + ((BANK) == FSMC_Bank3_NAND) || \ + ((BANK) == FSMC_Bank4_PCCARD)) + +/** @defgroup NOR_SRAM_Controller + * @{ + */ + +/** @defgroup FSMC_Data_Address_Bus_Multiplexing + * @{ + */ + +#define FSMC_DataAddressMux_Disable ((uint32_t)0x00000000) +#define FSMC_DataAddressMux_Enable ((uint32_t)0x00000002) +#define IS_FSMC_MUX(MUX) (((MUX) == FSMC_DataAddressMux_Disable) || \ + ((MUX) == FSMC_DataAddressMux_Enable)) + +/** + * @} + */ + +/** @defgroup FSMC_Memory_Type + * @{ + */ + +#define FSMC_MemoryType_SRAM ((uint32_t)0x00000000) +#define FSMC_MemoryType_PSRAM ((uint32_t)0x00000004) +#define FSMC_MemoryType_NOR ((uint32_t)0x00000008) +#define IS_FSMC_MEMORY(MEMORY) (((MEMORY) == FSMC_MemoryType_SRAM) || \ + ((MEMORY) == FSMC_MemoryType_PSRAM)|| \ + ((MEMORY) == FSMC_MemoryType_NOR)) + +/** + * @} + */ + +/** @defgroup FSMC_Data_Width + * @{ + */ + +#define FSMC_MemoryDataWidth_8b ((uint32_t)0x00000000) +#define FSMC_MemoryDataWidth_16b ((uint32_t)0x00000010) +#define IS_FSMC_MEMORY_WIDTH(WIDTH) (((WIDTH) == FSMC_MemoryDataWidth_8b) || \ + ((WIDTH) == FSMC_MemoryDataWidth_16b)) + +/** + * @} + */ + +/** @defgroup FSMC_Burst_Access_Mode + * @{ + */ + +#define FSMC_BurstAccessMode_Disable ((uint32_t)0x00000000) +#define FSMC_BurstAccessMode_Enable ((uint32_t)0x00000100) +#define IS_FSMC_BURSTMODE(STATE) (((STATE) == FSMC_BurstAccessMode_Disable) || \ + ((STATE) == FSMC_BurstAccessMode_Enable)) +/** + * @} + */ + +/** @defgroup FSMC_AsynchronousWait + * @{ + */ +#define FSMC_AsynchronousWait_Disable ((uint32_t)0x00000000) +#define FSMC_AsynchronousWait_Enable ((uint32_t)0x00008000) +#define IS_FSMC_ASYNWAIT(STATE) (((STATE) == FSMC_AsynchronousWait_Disable) || \ + ((STATE) == FSMC_AsynchronousWait_Enable)) + +/** + * @} + */ + +/** @defgroup FSMC_Wait_Signal_Polarity + * @{ + */ + +#define FSMC_WaitSignalPolarity_Low ((uint32_t)0x00000000) +#define FSMC_WaitSignalPolarity_High ((uint32_t)0x00000200) +#define IS_FSMC_WAIT_POLARITY(POLARITY) (((POLARITY) == FSMC_WaitSignalPolarity_Low) || \ + ((POLARITY) == FSMC_WaitSignalPolarity_High)) + +/** + * @} + */ + +/** @defgroup FSMC_Wrap_Mode + * @{ + */ + +#define FSMC_WrapMode_Disable ((uint32_t)0x00000000) +#define FSMC_WrapMode_Enable ((uint32_t)0x00000400) +#define IS_FSMC_WRAP_MODE(MODE) (((MODE) == FSMC_WrapMode_Disable) || \ + ((MODE) == FSMC_WrapMode_Enable)) + +/** + * @} + */ + +/** @defgroup FSMC_Wait_Timing + * @{ + */ + +#define FSMC_WaitSignalActive_BeforeWaitState ((uint32_t)0x00000000) +#define FSMC_WaitSignalActive_DuringWaitState ((uint32_t)0x00000800) +#define IS_FSMC_WAIT_SIGNAL_ACTIVE(ACTIVE) (((ACTIVE) == FSMC_WaitSignalActive_BeforeWaitState) || \ + ((ACTIVE) == FSMC_WaitSignalActive_DuringWaitState)) + +/** + * @} + */ + +/** @defgroup FSMC_Write_Operation + * @{ + */ + +#define FSMC_WriteOperation_Disable ((uint32_t)0x00000000) +#define FSMC_WriteOperation_Enable ((uint32_t)0x00001000) +#define IS_FSMC_WRITE_OPERATION(OPERATION) (((OPERATION) == FSMC_WriteOperation_Disable) || \ + ((OPERATION) == FSMC_WriteOperation_Enable)) + +/** + * @} + */ + +/** @defgroup FSMC_Wait_Signal + * @{ + */ + +#define FSMC_WaitSignal_Disable ((uint32_t)0x00000000) +#define FSMC_WaitSignal_Enable ((uint32_t)0x00002000) +#define IS_FSMC_WAITE_SIGNAL(SIGNAL) (((SIGNAL) == FSMC_WaitSignal_Disable) || \ + ((SIGNAL) == FSMC_WaitSignal_Enable)) +/** + * @} + */ + +/** @defgroup FSMC_Extended_Mode + * @{ + */ + +#define FSMC_ExtendedMode_Disable ((uint32_t)0x00000000) +#define FSMC_ExtendedMode_Enable ((uint32_t)0x00004000) + +#define IS_FSMC_EXTENDED_MODE(MODE) (((MODE) == FSMC_ExtendedMode_Disable) || \ + ((MODE) == FSMC_ExtendedMode_Enable)) + +/** + * @} + */ + +/** @defgroup FSMC_Write_Burst + * @{ + */ + +#define FSMC_WriteBurst_Disable ((uint32_t)0x00000000) +#define FSMC_WriteBurst_Enable ((uint32_t)0x00080000) +#define IS_FSMC_WRITE_BURST(BURST) (((BURST) == FSMC_WriteBurst_Disable) || \ + ((BURST) == FSMC_WriteBurst_Enable)) +/** + * @} + */ + +/** @defgroup FSMC_Address_Setup_Time + * @{ + */ + +#define IS_FSMC_ADDRESS_SETUP_TIME(TIME) ((TIME) <= 0xF) + +/** + * @} + */ + +/** @defgroup FSMC_Address_Hold_Time + * @{ + */ + +#define IS_FSMC_ADDRESS_HOLD_TIME(TIME) ((TIME) <= 0xF) + +/** + * @} + */ + +/** @defgroup FSMC_Data_Setup_Time + * @{ + */ + +#define IS_FSMC_DATASETUP_TIME(TIME) (((TIME) > 0) && ((TIME) <= 0xFF)) + +/** + * @} + */ + +/** @defgroup FSMC_Bus_Turn_around_Duration + * @{ + */ + +#define IS_FSMC_TURNAROUND_TIME(TIME) ((TIME) <= 0xF) + +/** + * @} + */ + +/** @defgroup FSMC_CLK_Division + * @{ + */ + +#define IS_FSMC_CLK_DIV(DIV) ((DIV) <= 0xF) + +/** + * @} + */ + +/** @defgroup FSMC_Data_Latency + * @{ + */ + +#define IS_FSMC_DATA_LATENCY(LATENCY) ((LATENCY) <= 0xF) + +/** + * @} + */ + +/** @defgroup FSMC_Access_Mode + * @{ + */ + +#define FSMC_AccessMode_A ((uint32_t)0x00000000) +#define FSMC_AccessMode_B ((uint32_t)0x10000000) +#define FSMC_AccessMode_C ((uint32_t)0x20000000) +#define FSMC_AccessMode_D ((uint32_t)0x30000000) +#define IS_FSMC_ACCESS_MODE(MODE) (((MODE) == FSMC_AccessMode_A) || \ + ((MODE) == FSMC_AccessMode_B) || \ + ((MODE) == FSMC_AccessMode_C) || \ + ((MODE) == FSMC_AccessMode_D)) + +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup NAND_PCCARD_Controller + * @{ + */ + +/** @defgroup FSMC_Wait_feature + * @{ + */ + +#define FSMC_Waitfeature_Disable ((uint32_t)0x00000000) +#define FSMC_Waitfeature_Enable ((uint32_t)0x00000002) +#define IS_FSMC_WAIT_FEATURE(FEATURE) (((FEATURE) == FSMC_Waitfeature_Disable) || \ + ((FEATURE) == FSMC_Waitfeature_Enable)) + +/** + * @} + */ + + +/** @defgroup FSMC_ECC + * @{ + */ + +#define FSMC_ECC_Disable ((uint32_t)0x00000000) +#define FSMC_ECC_Enable ((uint32_t)0x00000040) +#define IS_FSMC_ECC_STATE(STATE) (((STATE) == FSMC_ECC_Disable) || \ + ((STATE) == FSMC_ECC_Enable)) + +/** + * @} + */ + +/** @defgroup FSMC_ECC_Page_Size + * @{ + */ + +#define FSMC_ECCPageSize_256Bytes ((uint32_t)0x00000000) +#define FSMC_ECCPageSize_512Bytes ((uint32_t)0x00020000) +#define FSMC_ECCPageSize_1024Bytes ((uint32_t)0x00040000) +#define FSMC_ECCPageSize_2048Bytes ((uint32_t)0x00060000) +#define FSMC_ECCPageSize_4096Bytes ((uint32_t)0x00080000) +#define FSMC_ECCPageSize_8192Bytes ((uint32_t)0x000A0000) +#define IS_FSMC_ECCPAGE_SIZE(SIZE) (((SIZE) == FSMC_ECCPageSize_256Bytes) || \ + ((SIZE) == FSMC_ECCPageSize_512Bytes) || \ + ((SIZE) == FSMC_ECCPageSize_1024Bytes) || \ + ((SIZE) == FSMC_ECCPageSize_2048Bytes) || \ + ((SIZE) == FSMC_ECCPageSize_4096Bytes) || \ + ((SIZE) == FSMC_ECCPageSize_8192Bytes)) + +/** + * @} + */ + +/** @defgroup FSMC_TCLR_Setup_Time + * @{ + */ + +#define IS_FSMC_TCLR_TIME(TIME) ((TIME) <= 0xFF) + +/** + * @} + */ + +/** @defgroup FSMC_TAR_Setup_Time + * @{ + */ + +#define IS_FSMC_TAR_TIME(TIME) ((TIME) <= 0xFF) + +/** + * @} + */ + +/** @defgroup FSMC_Setup_Time + * @{ + */ + +#define IS_FSMC_SETUP_TIME(TIME) ((TIME) <= 0xFF) + +/** + * @} + */ + +/** @defgroup FSMC_Wait_Setup_Time + * @{ + */ + +#define IS_FSMC_WAIT_TIME(TIME) ((TIME) <= 0xFF) + +/** + * @} + */ + +/** @defgroup FSMC_Hold_Setup_Time + * @{ + */ + +#define IS_FSMC_HOLD_TIME(TIME) ((TIME) <= 0xFF) + +/** + * @} + */ + +/** @defgroup FSMC_HiZ_Setup_Time + * @{ + */ + +#define IS_FSMC_HIZ_TIME(TIME) ((TIME) <= 0xFF) + +/** + * @} + */ + +/** @defgroup FSMC_Interrupt_sources + * @{ + */ + +#define FSMC_IT_RisingEdge ((uint32_t)0x00000008) +#define FSMC_IT_Level ((uint32_t)0x00000010) +#define FSMC_IT_FallingEdge ((uint32_t)0x00000020) +#define IS_FSMC_IT(IT) ((((IT) & (uint32_t)0xFFFFFFC7) == 0x00000000) && ((IT) != 0x00000000)) +#define IS_FSMC_GET_IT(IT) (((IT) == FSMC_IT_RisingEdge) || \ + ((IT) == FSMC_IT_Level) || \ + ((IT) == FSMC_IT_FallingEdge)) +/** + * @} + */ + +/** @defgroup FSMC_Flags + * @{ + */ + +#define FSMC_FLAG_RisingEdge ((uint32_t)0x00000001) +#define FSMC_FLAG_Level ((uint32_t)0x00000002) +#define FSMC_FLAG_FallingEdge ((uint32_t)0x00000004) +#define FSMC_FLAG_FEMPT ((uint32_t)0x00000040) +#define IS_FSMC_GET_FLAG(FLAG) (((FLAG) == FSMC_FLAG_RisingEdge) || \ + ((FLAG) == FSMC_FLAG_Level) || \ + ((FLAG) == FSMC_FLAG_FallingEdge) || \ + ((FLAG) == FSMC_FLAG_FEMPT)) + +#define IS_FSMC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFFF8) == 0x00000000) && ((FLAG) != 0x00000000)) + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup FSMC_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup FSMC_Exported_Functions + * @{ + */ + +void FSMC_NORSRAMDeInit(uint32_t FSMC_Bank); +void FSMC_NANDDeInit(uint32_t FSMC_Bank); +void FSMC_PCCARDDeInit(void); +void FSMC_NORSRAMInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct); +void FSMC_NANDInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct); +void FSMC_PCCARDInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct); +void FSMC_NORSRAMStructInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct); +void FSMC_NANDStructInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct); +void FSMC_PCCARDStructInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct); +void FSMC_NORSRAMCmd(uint32_t FSMC_Bank, FunctionalState NewState); +void FSMC_NANDCmd(uint32_t FSMC_Bank, FunctionalState NewState); +void FSMC_PCCARDCmd(FunctionalState NewState); +void FSMC_NANDECCCmd(uint32_t FSMC_Bank, FunctionalState NewState); +uint32_t FSMC_GetECC(uint32_t FSMC_Bank); +void FSMC_ITConfig(uint32_t FSMC_Bank, uint32_t FSMC_IT, FunctionalState NewState); +FlagStatus FSMC_GetFlagStatus(uint32_t FSMC_Bank, uint32_t FSMC_FLAG); +void FSMC_ClearFlag(uint32_t FSMC_Bank, uint32_t FSMC_FLAG); +ITStatus FSMC_GetITStatus(uint32_t FSMC_Bank, uint32_t FSMC_IT); +void FSMC_ClearITPendingBit(uint32_t FSMC_Bank, uint32_t FSMC_IT); + +#ifdef __cplusplus +} +#endif + +#endif /*__STM32F10x_FSMC_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_gpio.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_gpio.h new file mode 100755 index 0000000..b8aa49a --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_gpio.h @@ -0,0 +1,385 @@ +/** + ****************************************************************************** + * @file stm32f10x_gpio.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the GPIO + * firmware library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_GPIO_H +#define __STM32F10x_GPIO_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup GPIO + * @{ + */ + +/** @defgroup GPIO_Exported_Types + * @{ + */ + +#define IS_GPIO_ALL_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \ + ((PERIPH) == GPIOB) || \ + ((PERIPH) == GPIOC) || \ + ((PERIPH) == GPIOD) || \ + ((PERIPH) == GPIOE) || \ + ((PERIPH) == GPIOF) || \ + ((PERIPH) == GPIOG)) + +/** + * @brief Output Maximum frequency selection + */ + +typedef enum +{ + GPIO_Speed_10MHz = 1, + GPIO_Speed_2MHz, + GPIO_Speed_50MHz +}GPIOSpeed_TypeDef; +#define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_Speed_10MHz) || ((SPEED) == GPIO_Speed_2MHz) || \ + ((SPEED) == GPIO_Speed_50MHz)) + +/** + * @brief Configuration Mode enumeration + */ + +typedef enum +{ GPIO_Mode_AIN = 0x0, + GPIO_Mode_IN_FLOATING = 0x04, + GPIO_Mode_IPD = 0x28, + GPIO_Mode_IPU = 0x48, + GPIO_Mode_Out_OD = 0x14, + GPIO_Mode_Out_PP = 0x10, + GPIO_Mode_AF_OD = 0x1C, + GPIO_Mode_AF_PP = 0x18 +}GPIOMode_TypeDef; + +#define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_AIN) || ((MODE) == GPIO_Mode_IN_FLOATING) || \ + ((MODE) == GPIO_Mode_IPD) || ((MODE) == GPIO_Mode_IPU) || \ + ((MODE) == GPIO_Mode_Out_OD) || ((MODE) == GPIO_Mode_Out_PP) || \ + ((MODE) == GPIO_Mode_AF_OD) || ((MODE) == GPIO_Mode_AF_PP)) + +/** + * @brief GPIO Init structure definition + */ + +typedef struct +{ + uint16_t GPIO_Pin; /*!< Specifies the GPIO pins to be configured. + This parameter can be any value of @ref GPIO_pins_define */ + + GPIOSpeed_TypeDef GPIO_Speed; /*!< Specifies the speed for the selected pins. + This parameter can be a value of @ref GPIOSpeed_TypeDef */ + + GPIOMode_TypeDef GPIO_Mode; /*!< Specifies the operating mode for the selected pins. + This parameter can be a value of @ref GPIOMode_TypeDef */ +}GPIO_InitTypeDef; + + +/** + * @brief Bit_SET and Bit_RESET enumeration + */ + +typedef enum +{ Bit_RESET = 0, + Bit_SET +}BitAction; + +#define IS_GPIO_BIT_ACTION(ACTION) (((ACTION) == Bit_RESET) || ((ACTION) == Bit_SET)) + +/** + * @} + */ + +/** @defgroup GPIO_Exported_Constants + * @{ + */ + +/** @defgroup GPIO_pins_define + * @{ + */ + +#define GPIO_Pin_0 ((uint16_t)0x0001) /*!< Pin 0 selected */ +#define GPIO_Pin_1 ((uint16_t)0x0002) /*!< Pin 1 selected */ +#define GPIO_Pin_2 ((uint16_t)0x0004) /*!< Pin 2 selected */ +#define GPIO_Pin_3 ((uint16_t)0x0008) /*!< Pin 3 selected */ +#define GPIO_Pin_4 ((uint16_t)0x0010) /*!< Pin 4 selected */ +#define GPIO_Pin_5 ((uint16_t)0x0020) /*!< Pin 5 selected */ +#define GPIO_Pin_6 ((uint16_t)0x0040) /*!< Pin 6 selected */ +#define GPIO_Pin_7 ((uint16_t)0x0080) /*!< Pin 7 selected */ +#define GPIO_Pin_8 ((uint16_t)0x0100) /*!< Pin 8 selected */ +#define GPIO_Pin_9 ((uint16_t)0x0200) /*!< Pin 9 selected */ +#define GPIO_Pin_10 ((uint16_t)0x0400) /*!< Pin 10 selected */ +#define GPIO_Pin_11 ((uint16_t)0x0800) /*!< Pin 11 selected */ +#define GPIO_Pin_12 ((uint16_t)0x1000) /*!< Pin 12 selected */ +#define GPIO_Pin_13 ((uint16_t)0x2000) /*!< Pin 13 selected */ +#define GPIO_Pin_14 ((uint16_t)0x4000) /*!< Pin 14 selected */ +#define GPIO_Pin_15 ((uint16_t)0x8000) /*!< Pin 15 selected */ +#define GPIO_Pin_All ((uint16_t)0xFFFF) /*!< All pins selected */ + +#define IS_GPIO_PIN(PIN) ((((PIN) & (uint16_t)0x00) == 0x00) && ((PIN) != (uint16_t)0x00)) + +#define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || \ + ((PIN) == GPIO_Pin_1) || \ + ((PIN) == GPIO_Pin_2) || \ + ((PIN) == GPIO_Pin_3) || \ + ((PIN) == GPIO_Pin_4) || \ + ((PIN) == GPIO_Pin_5) || \ + ((PIN) == GPIO_Pin_6) || \ + ((PIN) == GPIO_Pin_7) || \ + ((PIN) == GPIO_Pin_8) || \ + ((PIN) == GPIO_Pin_9) || \ + ((PIN) == GPIO_Pin_10) || \ + ((PIN) == GPIO_Pin_11) || \ + ((PIN) == GPIO_Pin_12) || \ + ((PIN) == GPIO_Pin_13) || \ + ((PIN) == GPIO_Pin_14) || \ + ((PIN) == GPIO_Pin_15)) + +/** + * @} + */ + +/** @defgroup GPIO_Remap_define + * @{ + */ + +#define GPIO_Remap_SPI1 ((uint32_t)0x00000001) /*!< SPI1 Alternate Function mapping */ +#define GPIO_Remap_I2C1 ((uint32_t)0x00000002) /*!< I2C1 Alternate Function mapping */ +#define GPIO_Remap_USART1 ((uint32_t)0x00000004) /*!< USART1 Alternate Function mapping */ +#define GPIO_Remap_USART2 ((uint32_t)0x00000008) /*!< USART2 Alternate Function mapping */ +#define GPIO_PartialRemap_USART3 ((uint32_t)0x00140010) /*!< USART3 Partial Alternate Function mapping */ +#define GPIO_FullRemap_USART3 ((uint32_t)0x00140030) /*!< USART3 Full Alternate Function mapping */ +#define GPIO_PartialRemap_TIM1 ((uint32_t)0x00160040) /*!< TIM1 Partial Alternate Function mapping */ +#define GPIO_FullRemap_TIM1 ((uint32_t)0x001600C0) /*!< TIM1 Full Alternate Function mapping */ +#define GPIO_PartialRemap1_TIM2 ((uint32_t)0x00180100) /*!< TIM2 Partial1 Alternate Function mapping */ +#define GPIO_PartialRemap2_TIM2 ((uint32_t)0x00180200) /*!< TIM2 Partial2 Alternate Function mapping */ +#define GPIO_FullRemap_TIM2 ((uint32_t)0x00180300) /*!< TIM2 Full Alternate Function mapping */ +#define GPIO_PartialRemap_TIM3 ((uint32_t)0x001A0800) /*!< TIM3 Partial Alternate Function mapping */ +#define GPIO_FullRemap_TIM3 ((uint32_t)0x001A0C00) /*!< TIM3 Full Alternate Function mapping */ +#define GPIO_Remap_TIM4 ((uint32_t)0x00001000) /*!< TIM4 Alternate Function mapping */ +#define GPIO_Remap1_CAN1 ((uint32_t)0x001D4000) /*!< CAN1 Alternate Function mapping */ +#define GPIO_Remap2_CAN1 ((uint32_t)0x001D6000) /*!< CAN1 Alternate Function mapping */ +#define GPIO_Remap_PD01 ((uint32_t)0x00008000) /*!< PD01 Alternate Function mapping */ +#define GPIO_Remap_TIM5CH4_LSI ((uint32_t)0x00200001) /*!< LSI connected to TIM5 Channel4 input capture for calibration */ +#define GPIO_Remap_ADC1_ETRGINJ ((uint32_t)0x00200002) /*!< ADC1 External Trigger Injected Conversion remapping */ +#define GPIO_Remap_ADC1_ETRGREG ((uint32_t)0x00200004) /*!< ADC1 External Trigger Regular Conversion remapping */ +#define GPIO_Remap_ADC2_ETRGINJ ((uint32_t)0x00200008) /*!< ADC2 External Trigger Injected Conversion remapping */ +#define GPIO_Remap_ADC2_ETRGREG ((uint32_t)0x00200010) /*!< ADC2 External Trigger Regular Conversion remapping */ +#define GPIO_Remap_ETH ((uint32_t)0x00200020) /*!< Ethernet remapping (only for Connectivity line devices) */ +#define GPIO_Remap_CAN2 ((uint32_t)0x00200040) /*!< CAN2 remapping (only for Connectivity line devices) */ +#define GPIO_Remap_SWJ_NoJTRST ((uint32_t)0x00300100) /*!< Full SWJ Enabled (JTAG-DP + SW-DP) but without JTRST */ +#define GPIO_Remap_SWJ_JTAGDisable ((uint32_t)0x00300200) /*!< JTAG-DP Disabled and SW-DP Enabled */ +#define GPIO_Remap_SWJ_Disable ((uint32_t)0x00300400) /*!< Full SWJ Disabled (JTAG-DP + SW-DP) */ +#define GPIO_Remap_SPI3 ((uint32_t)0x00201100) /*!< SPI3/I2S3 Alternate Function mapping (only for Connectivity line devices) */ +#define GPIO_Remap_TIM2ITR1_PTP_SOF ((uint32_t)0x00202000) /*!< Ethernet PTP output or USB OTG SOF (Start of Frame) connected + to TIM2 Internal Trigger 1 for calibration + (only for Connectivity line devices) */ +#define GPIO_Remap_PTP_PPS ((uint32_t)0x00204000) /*!< Ethernet MAC PPS_PTS output on PB05 (only for Connectivity line devices) */ + +#define GPIO_Remap_TIM15 ((uint32_t)0x80000001) /*!< TIM15 Alternate Function mapping (only for Value line devices) */ +#define GPIO_Remap_TIM16 ((uint32_t)0x80000002) /*!< TIM16 Alternate Function mapping (only for Value line devices) */ +#define GPIO_Remap_TIM17 ((uint32_t)0x80000004) /*!< TIM17 Alternate Function mapping (only for Value line devices) */ +#define GPIO_Remap_CEC ((uint32_t)0x80000008) /*!< CEC Alternate Function mapping (only for Value line devices) */ +#define GPIO_Remap_TIM1_DMA ((uint32_t)0x80000010) /*!< TIM1 DMA requests mapping (only for Value line devices) */ + +#define GPIO_Remap_TIM9 ((uint32_t)0x80000020) /*!< TIM9 Alternate Function mapping (only for XL-density devices) */ +#define GPIO_Remap_TIM10 ((uint32_t)0x80000040) /*!< TIM10 Alternate Function mapping (only for XL-density devices) */ +#define GPIO_Remap_TIM11 ((uint32_t)0x80000080) /*!< TIM11 Alternate Function mapping (only for XL-density devices) */ +#define GPIO_Remap_TIM13 ((uint32_t)0x80000100) /*!< TIM13 Alternate Function mapping (only for High density Value line and XL-density devices) */ +#define GPIO_Remap_TIM14 ((uint32_t)0x80000200) /*!< TIM14 Alternate Function mapping (only for High density Value line and XL-density devices) */ +#define GPIO_Remap_FSMC_NADV ((uint32_t)0x80000400) /*!< FSMC_NADV Alternate Function mapping (only for High density Value line and XL-density devices) */ + +#define GPIO_Remap_TIM67_DAC_DMA ((uint32_t)0x80000800) /*!< TIM6/TIM7 and DAC DMA requests remapping (only for High density Value line devices) */ +#define GPIO_Remap_TIM12 ((uint32_t)0x80001000) /*!< TIM12 Alternate Function mapping (only for High density Value line devices) */ +#define GPIO_Remap_MISC ((uint32_t)0x80002000) /*!< Miscellaneous Remap (DMA2 Channel5 Position and DAC Trigger remapping, + only for High density Value line devices) */ + +#define IS_GPIO_REMAP(REMAP) (((REMAP) == GPIO_Remap_SPI1) || ((REMAP) == GPIO_Remap_I2C1) || \ + ((REMAP) == GPIO_Remap_USART1) || ((REMAP) == GPIO_Remap_USART2) || \ + ((REMAP) == GPIO_PartialRemap_USART3) || ((REMAP) == GPIO_FullRemap_USART3) || \ + ((REMAP) == GPIO_PartialRemap_TIM1) || ((REMAP) == GPIO_FullRemap_TIM1) || \ + ((REMAP) == GPIO_PartialRemap1_TIM2) || ((REMAP) == GPIO_PartialRemap2_TIM2) || \ + ((REMAP) == GPIO_FullRemap_TIM2) || ((REMAP) == GPIO_PartialRemap_TIM3) || \ + ((REMAP) == GPIO_FullRemap_TIM3) || ((REMAP) == GPIO_Remap_TIM4) || \ + ((REMAP) == GPIO_Remap1_CAN1) || ((REMAP) == GPIO_Remap2_CAN1) || \ + ((REMAP) == GPIO_Remap_PD01) || ((REMAP) == GPIO_Remap_TIM5CH4_LSI) || \ + ((REMAP) == GPIO_Remap_ADC1_ETRGINJ) ||((REMAP) == GPIO_Remap_ADC1_ETRGREG) || \ + ((REMAP) == GPIO_Remap_ADC2_ETRGINJ) ||((REMAP) == GPIO_Remap_ADC2_ETRGREG) || \ + ((REMAP) == GPIO_Remap_ETH) ||((REMAP) == GPIO_Remap_CAN2) || \ + ((REMAP) == GPIO_Remap_SWJ_NoJTRST) || ((REMAP) == GPIO_Remap_SWJ_JTAGDisable) || \ + ((REMAP) == GPIO_Remap_SWJ_Disable)|| ((REMAP) == GPIO_Remap_SPI3) || \ + ((REMAP) == GPIO_Remap_TIM2ITR1_PTP_SOF) || ((REMAP) == GPIO_Remap_PTP_PPS) || \ + ((REMAP) == GPIO_Remap_TIM15) || ((REMAP) == GPIO_Remap_TIM16) || \ + ((REMAP) == GPIO_Remap_TIM17) || ((REMAP) == GPIO_Remap_CEC) || \ + ((REMAP) == GPIO_Remap_TIM1_DMA) || ((REMAP) == GPIO_Remap_TIM9) || \ + ((REMAP) == GPIO_Remap_TIM10) || ((REMAP) == GPIO_Remap_TIM11) || \ + ((REMAP) == GPIO_Remap_TIM13) || ((REMAP) == GPIO_Remap_TIM14) || \ + ((REMAP) == GPIO_Remap_FSMC_NADV) || ((REMAP) == GPIO_Remap_TIM67_DAC_DMA) || \ + ((REMAP) == GPIO_Remap_TIM12) || ((REMAP) == GPIO_Remap_MISC)) + +/** + * @} + */ + +/** @defgroup GPIO_Port_Sources + * @{ + */ + +#define GPIO_PortSourceGPIOA ((uint8_t)0x00) +#define GPIO_PortSourceGPIOB ((uint8_t)0x01) +#define GPIO_PortSourceGPIOC ((uint8_t)0x02) +#define GPIO_PortSourceGPIOD ((uint8_t)0x03) +#define GPIO_PortSourceGPIOE ((uint8_t)0x04) +#define GPIO_PortSourceGPIOF ((uint8_t)0x05) +#define GPIO_PortSourceGPIOG ((uint8_t)0x06) +#define IS_GPIO_EVENTOUT_PORT_SOURCE(PORTSOURCE) (((PORTSOURCE) == GPIO_PortSourceGPIOA) || \ + ((PORTSOURCE) == GPIO_PortSourceGPIOB) || \ + ((PORTSOURCE) == GPIO_PortSourceGPIOC) || \ + ((PORTSOURCE) == GPIO_PortSourceGPIOD) || \ + ((PORTSOURCE) == GPIO_PortSourceGPIOE)) + +#define IS_GPIO_EXTI_PORT_SOURCE(PORTSOURCE) (((PORTSOURCE) == GPIO_PortSourceGPIOA) || \ + ((PORTSOURCE) == GPIO_PortSourceGPIOB) || \ + ((PORTSOURCE) == GPIO_PortSourceGPIOC) || \ + ((PORTSOURCE) == GPIO_PortSourceGPIOD) || \ + ((PORTSOURCE) == GPIO_PortSourceGPIOE) || \ + ((PORTSOURCE) == GPIO_PortSourceGPIOF) || \ + ((PORTSOURCE) == GPIO_PortSourceGPIOG)) + +/** + * @} + */ + +/** @defgroup GPIO_Pin_sources + * @{ + */ + +#define GPIO_PinSource0 ((uint8_t)0x00) +#define GPIO_PinSource1 ((uint8_t)0x01) +#define GPIO_PinSource2 ((uint8_t)0x02) +#define GPIO_PinSource3 ((uint8_t)0x03) +#define GPIO_PinSource4 ((uint8_t)0x04) +#define GPIO_PinSource5 ((uint8_t)0x05) +#define GPIO_PinSource6 ((uint8_t)0x06) +#define GPIO_PinSource7 ((uint8_t)0x07) +#define GPIO_PinSource8 ((uint8_t)0x08) +#define GPIO_PinSource9 ((uint8_t)0x09) +#define GPIO_PinSource10 ((uint8_t)0x0A) +#define GPIO_PinSource11 ((uint8_t)0x0B) +#define GPIO_PinSource12 ((uint8_t)0x0C) +#define GPIO_PinSource13 ((uint8_t)0x0D) +#define GPIO_PinSource14 ((uint8_t)0x0E) +#define GPIO_PinSource15 ((uint8_t)0x0F) + +#define IS_GPIO_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == GPIO_PinSource0) || \ + ((PINSOURCE) == GPIO_PinSource1) || \ + ((PINSOURCE) == GPIO_PinSource2) || \ + ((PINSOURCE) == GPIO_PinSource3) || \ + ((PINSOURCE) == GPIO_PinSource4) || \ + ((PINSOURCE) == GPIO_PinSource5) || \ + ((PINSOURCE) == GPIO_PinSource6) || \ + ((PINSOURCE) == GPIO_PinSource7) || \ + ((PINSOURCE) == GPIO_PinSource8) || \ + ((PINSOURCE) == GPIO_PinSource9) || \ + ((PINSOURCE) == GPIO_PinSource10) || \ + ((PINSOURCE) == GPIO_PinSource11) || \ + ((PINSOURCE) == GPIO_PinSource12) || \ + ((PINSOURCE) == GPIO_PinSource13) || \ + ((PINSOURCE) == GPIO_PinSource14) || \ + ((PINSOURCE) == GPIO_PinSource15)) + +/** + * @} + */ + +/** @defgroup Ethernet_Media_Interface + * @{ + */ +#define GPIO_ETH_MediaInterface_MII ((u32)0x00000000) +#define GPIO_ETH_MediaInterface_RMII ((u32)0x00000001) + +#define IS_GPIO_ETH_MEDIA_INTERFACE(INTERFACE) (((INTERFACE) == GPIO_ETH_MediaInterface_MII) || \ + ((INTERFACE) == GPIO_ETH_MediaInterface_RMII)) + +/** + * @} + */ +/** + * @} + */ + +/** @defgroup GPIO_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup GPIO_Exported_Functions + * @{ + */ + +void GPIO_DeInit(GPIO_TypeDef* GPIOx); +void GPIO_AFIODeInit(void); +void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct); +void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct); +uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); +uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx); +uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); +uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx); +void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); +void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); +void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal); +void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal); +void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); +void GPIO_EventOutputConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource); +void GPIO_EventOutputCmd(FunctionalState NewState); +void GPIO_PinRemapConfig(uint32_t GPIO_Remap, FunctionalState NewState); +void GPIO_EXTILineConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource); +void GPIO_ETH_MediaInterfaceConfig(uint32_t GPIO_ETH_MediaInterface); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_GPIO_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_i2c.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_i2c.h new file mode 100755 index 0000000..2d42e5c --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_i2c.h @@ -0,0 +1,684 @@ +/** + ****************************************************************************** + * @file stm32f10x_i2c.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the I2C firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_I2C_H +#define __STM32F10x_I2C_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup I2C + * @{ + */ + +/** @defgroup I2C_Exported_Types + * @{ + */ + +/** + * @brief I2C Init structure definition + */ + +typedef struct +{ + uint32_t I2C_ClockSpeed; /*!< Specifies the clock frequency. + This parameter must be set to a value lower than 400kHz */ + + uint16_t I2C_Mode; /*!< Specifies the I2C mode. + This parameter can be a value of @ref I2C_mode */ + + uint16_t I2C_DutyCycle; /*!< Specifies the I2C fast mode duty cycle. + This parameter can be a value of @ref I2C_duty_cycle_in_fast_mode */ + + uint16_t I2C_OwnAddress1; /*!< Specifies the first device own address. + This parameter can be a 7-bit or 10-bit address. */ + + uint16_t I2C_Ack; /*!< Enables or disables the acknowledgement. + This parameter can be a value of @ref I2C_acknowledgement */ + + uint16_t I2C_AcknowledgedAddress; /*!< Specifies if 7-bit or 10-bit address is acknowledged. + This parameter can be a value of @ref I2C_acknowledged_address */ +}I2C_InitTypeDef; + +/** + * @} + */ + + +/** @defgroup I2C_Exported_Constants + * @{ + */ + +#define IS_I2C_ALL_PERIPH(PERIPH) (((PERIPH) == I2C1) || \ + ((PERIPH) == I2C2)) +/** @defgroup I2C_mode + * @{ + */ + +#define I2C_Mode_I2C ((uint16_t)0x0000) +#define I2C_Mode_SMBusDevice ((uint16_t)0x0002) +#define I2C_Mode_SMBusHost ((uint16_t)0x000A) +#define IS_I2C_MODE(MODE) (((MODE) == I2C_Mode_I2C) || \ + ((MODE) == I2C_Mode_SMBusDevice) || \ + ((MODE) == I2C_Mode_SMBusHost)) +/** + * @} + */ + +/** @defgroup I2C_duty_cycle_in_fast_mode + * @{ + */ + +#define I2C_DutyCycle_16_9 ((uint16_t)0x4000) /*!< I2C fast mode Tlow/Thigh = 16/9 */ +#define I2C_DutyCycle_2 ((uint16_t)0xBFFF) /*!< I2C fast mode Tlow/Thigh = 2 */ +#define IS_I2C_DUTY_CYCLE(CYCLE) (((CYCLE) == I2C_DutyCycle_16_9) || \ + ((CYCLE) == I2C_DutyCycle_2)) +/** + * @} + */ + +/** @defgroup I2C_acknowledgement + * @{ + */ + +#define I2C_Ack_Enable ((uint16_t)0x0400) +#define I2C_Ack_Disable ((uint16_t)0x0000) +#define IS_I2C_ACK_STATE(STATE) (((STATE) == I2C_Ack_Enable) || \ + ((STATE) == I2C_Ack_Disable)) +/** + * @} + */ + +/** @defgroup I2C_transfer_direction + * @{ + */ + +#define I2C_Direction_Transmitter ((uint8_t)0x00) +#define I2C_Direction_Receiver ((uint8_t)0x01) +#define IS_I2C_DIRECTION(DIRECTION) (((DIRECTION) == I2C_Direction_Transmitter) || \ + ((DIRECTION) == I2C_Direction_Receiver)) +/** + * @} + */ + +/** @defgroup I2C_acknowledged_address + * @{ + */ + +#define I2C_AcknowledgedAddress_7bit ((uint16_t)0x4000) +#define I2C_AcknowledgedAddress_10bit ((uint16_t)0xC000) +#define IS_I2C_ACKNOWLEDGE_ADDRESS(ADDRESS) (((ADDRESS) == I2C_AcknowledgedAddress_7bit) || \ + ((ADDRESS) == I2C_AcknowledgedAddress_10bit)) +/** + * @} + */ + +/** @defgroup I2C_registers + * @{ + */ + +#define I2C_Register_CR1 ((uint8_t)0x00) +#define I2C_Register_CR2 ((uint8_t)0x04) +#define I2C_Register_OAR1 ((uint8_t)0x08) +#define I2C_Register_OAR2 ((uint8_t)0x0C) +#define I2C_Register_DR ((uint8_t)0x10) +#define I2C_Register_SR1 ((uint8_t)0x14) +#define I2C_Register_SR2 ((uint8_t)0x18) +#define I2C_Register_CCR ((uint8_t)0x1C) +#define I2C_Register_TRISE ((uint8_t)0x20) +#define IS_I2C_REGISTER(REGISTER) (((REGISTER) == I2C_Register_CR1) || \ + ((REGISTER) == I2C_Register_CR2) || \ + ((REGISTER) == I2C_Register_OAR1) || \ + ((REGISTER) == I2C_Register_OAR2) || \ + ((REGISTER) == I2C_Register_DR) || \ + ((REGISTER) == I2C_Register_SR1) || \ + ((REGISTER) == I2C_Register_SR2) || \ + ((REGISTER) == I2C_Register_CCR) || \ + ((REGISTER) == I2C_Register_TRISE)) +/** + * @} + */ + +/** @defgroup I2C_SMBus_alert_pin_level + * @{ + */ + +#define I2C_SMBusAlert_Low ((uint16_t)0x2000) +#define I2C_SMBusAlert_High ((uint16_t)0xDFFF) +#define IS_I2C_SMBUS_ALERT(ALERT) (((ALERT) == I2C_SMBusAlert_Low) || \ + ((ALERT) == I2C_SMBusAlert_High)) +/** + * @} + */ + +/** @defgroup I2C_PEC_position + * @{ + */ + +#define I2C_PECPosition_Next ((uint16_t)0x0800) +#define I2C_PECPosition_Current ((uint16_t)0xF7FF) +#define IS_I2C_PEC_POSITION(POSITION) (((POSITION) == I2C_PECPosition_Next) || \ + ((POSITION) == I2C_PECPosition_Current)) +/** + * @} + */ + +/** @defgroup I2C_NCAK_position + * @{ + */ + +#define I2C_NACKPosition_Next ((uint16_t)0x0800) +#define I2C_NACKPosition_Current ((uint16_t)0xF7FF) +#define IS_I2C_NACK_POSITION(POSITION) (((POSITION) == I2C_NACKPosition_Next) || \ + ((POSITION) == I2C_NACKPosition_Current)) +/** + * @} + */ + +/** @defgroup I2C_interrupts_definition + * @{ + */ + +#define I2C_IT_BUF ((uint16_t)0x0400) +#define I2C_IT_EVT ((uint16_t)0x0200) +#define I2C_IT_ERR ((uint16_t)0x0100) +#define IS_I2C_CONFIG_IT(IT) ((((IT) & (uint16_t)0xF8FF) == 0x00) && ((IT) != 0x00)) +/** + * @} + */ + +/** @defgroup I2C_interrupts_definition + * @{ + */ + +#define I2C_IT_SMBALERT ((uint32_t)0x01008000) +#define I2C_IT_TIMEOUT ((uint32_t)0x01004000) +#define I2C_IT_PECERR ((uint32_t)0x01001000) +#define I2C_IT_OVR ((uint32_t)0x01000800) +#define I2C_IT_AF ((uint32_t)0x01000400) +#define I2C_IT_ARLO ((uint32_t)0x01000200) +#define I2C_IT_BERR ((uint32_t)0x01000100) +#define I2C_IT_TXE ((uint32_t)0x06000080) +#define I2C_IT_RXNE ((uint32_t)0x06000040) +#define I2C_IT_STOPF ((uint32_t)0x02000010) +#define I2C_IT_ADD10 ((uint32_t)0x02000008) +#define I2C_IT_BTF ((uint32_t)0x02000004) +#define I2C_IT_ADDR ((uint32_t)0x02000002) +#define I2C_IT_SB ((uint32_t)0x02000001) + +#define IS_I2C_CLEAR_IT(IT) ((((IT) & (uint16_t)0x20FF) == 0x00) && ((IT) != (uint16_t)0x00)) + +#define IS_I2C_GET_IT(IT) (((IT) == I2C_IT_SMBALERT) || ((IT) == I2C_IT_TIMEOUT) || \ + ((IT) == I2C_IT_PECERR) || ((IT) == I2C_IT_OVR) || \ + ((IT) == I2C_IT_AF) || ((IT) == I2C_IT_ARLO) || \ + ((IT) == I2C_IT_BERR) || ((IT) == I2C_IT_TXE) || \ + ((IT) == I2C_IT_RXNE) || ((IT) == I2C_IT_STOPF) || \ + ((IT) == I2C_IT_ADD10) || ((IT) == I2C_IT_BTF) || \ + ((IT) == I2C_IT_ADDR) || ((IT) == I2C_IT_SB)) +/** + * @} + */ + +/** @defgroup I2C_flags_definition + * @{ + */ + +/** + * @brief SR2 register flags + */ + +#define I2C_FLAG_DUALF ((uint32_t)0x00800000) +#define I2C_FLAG_SMBHOST ((uint32_t)0x00400000) +#define I2C_FLAG_SMBDEFAULT ((uint32_t)0x00200000) +#define I2C_FLAG_GENCALL ((uint32_t)0x00100000) +#define I2C_FLAG_TRA ((uint32_t)0x00040000) +#define I2C_FLAG_BUSY ((uint32_t)0x00020000) +#define I2C_FLAG_MSL ((uint32_t)0x00010000) + +/** + * @brief SR1 register flags + */ + +#define I2C_FLAG_SMBALERT ((uint32_t)0x10008000) +#define I2C_FLAG_TIMEOUT ((uint32_t)0x10004000) +#define I2C_FLAG_PECERR ((uint32_t)0x10001000) +#define I2C_FLAG_OVR ((uint32_t)0x10000800) +#define I2C_FLAG_AF ((uint32_t)0x10000400) +#define I2C_FLAG_ARLO ((uint32_t)0x10000200) +#define I2C_FLAG_BERR ((uint32_t)0x10000100) +#define I2C_FLAG_TXE ((uint32_t)0x10000080) +#define I2C_FLAG_RXNE ((uint32_t)0x10000040) +#define I2C_FLAG_STOPF ((uint32_t)0x10000010) +#define I2C_FLAG_ADD10 ((uint32_t)0x10000008) +#define I2C_FLAG_BTF ((uint32_t)0x10000004) +#define I2C_FLAG_ADDR ((uint32_t)0x10000002) +#define I2C_FLAG_SB ((uint32_t)0x10000001) + +#define IS_I2C_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0x20FF) == 0x00) && ((FLAG) != (uint16_t)0x00)) + +#define IS_I2C_GET_FLAG(FLAG) (((FLAG) == I2C_FLAG_DUALF) || ((FLAG) == I2C_FLAG_SMBHOST) || \ + ((FLAG) == I2C_FLAG_SMBDEFAULT) || ((FLAG) == I2C_FLAG_GENCALL) || \ + ((FLAG) == I2C_FLAG_TRA) || ((FLAG) == I2C_FLAG_BUSY) || \ + ((FLAG) == I2C_FLAG_MSL) || ((FLAG) == I2C_FLAG_SMBALERT) || \ + ((FLAG) == I2C_FLAG_TIMEOUT) || ((FLAG) == I2C_FLAG_PECERR) || \ + ((FLAG) == I2C_FLAG_OVR) || ((FLAG) == I2C_FLAG_AF) || \ + ((FLAG) == I2C_FLAG_ARLO) || ((FLAG) == I2C_FLAG_BERR) || \ + ((FLAG) == I2C_FLAG_TXE) || ((FLAG) == I2C_FLAG_RXNE) || \ + ((FLAG) == I2C_FLAG_STOPF) || ((FLAG) == I2C_FLAG_ADD10) || \ + ((FLAG) == I2C_FLAG_BTF) || ((FLAG) == I2C_FLAG_ADDR) || \ + ((FLAG) == I2C_FLAG_SB)) +/** + * @} + */ + +/** @defgroup I2C_Events + * @{ + */ + +/*======================================== + + I2C Master Events (Events grouped in order of communication) + ==========================================*/ +/** + * @brief Communication start + * + * After sending the START condition (I2C_GenerateSTART() function) the master + * has to wait for this event. It means that the Start condition has been correctly + * released on the I2C bus (the bus is free, no other devices is communicating). + * + */ +/* --EV5 */ +#define I2C_EVENT_MASTER_MODE_SELECT ((uint32_t)0x00030001) /* BUSY, MSL and SB flag */ + +/** + * @brief Address Acknowledge + * + * After checking on EV5 (start condition correctly released on the bus), the + * master sends the address of the slave(s) with which it will communicate + * (I2C_Send7bitAddress() function, it also determines the direction of the communication: + * Master transmitter or Receiver). Then the master has to wait that a slave acknowledges + * his address. If an acknowledge is sent on the bus, one of the following events will + * be set: + * + * 1) In case of Master Receiver (7-bit addressing): the I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED + * event is set. + * + * 2) In case of Master Transmitter (7-bit addressing): the I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED + * is set + * + * 3) In case of 10-Bit addressing mode, the master (just after generating the START + * and checking on EV5) has to send the header of 10-bit addressing mode (I2C_SendData() + * function). Then master should wait on EV9. It means that the 10-bit addressing + * header has been correctly sent on the bus. Then master should send the second part of + * the 10-bit address (LSB) using the function I2C_Send7bitAddress(). Then master + * should wait for event EV6. + * + */ + +/* --EV6 */ +#define I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED ((uint32_t)0x00070082) /* BUSY, MSL, ADDR, TXE and TRA flags */ +#define I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED ((uint32_t)0x00030002) /* BUSY, MSL and ADDR flags */ +/* --EV9 */ +#define I2C_EVENT_MASTER_MODE_ADDRESS10 ((uint32_t)0x00030008) /* BUSY, MSL and ADD10 flags */ + +/** + * @brief Communication events + * + * If a communication is established (START condition generated and slave address + * acknowledged) then the master has to check on one of the following events for + * communication procedures: + * + * 1) Master Receiver mode: The master has to wait on the event EV7 then to read + * the data received from the slave (I2C_ReceiveData() function). + * + * 2) Master Transmitter mode: The master has to send data (I2C_SendData() + * function) then to wait on event EV8 or EV8_2. + * These two events are similar: + * - EV8 means that the data has been written in the data register and is + * being shifted out. + * - EV8_2 means that the data has been physically shifted out and output + * on the bus. + * In most cases, using EV8 is sufficient for the application. + * Using EV8_2 leads to a slower communication but ensure more reliable test. + * EV8_2 is also more suitable than EV8 for testing on the last data transmission + * (before Stop condition generation). + * + * @note In case the user software does not guarantee that this event EV7 is + * managed before the current byte end of transfer, then user may check on EV7 + * and BTF flag at the same time (ie. (I2C_EVENT_MASTER_BYTE_RECEIVED | I2C_FLAG_BTF)). + * In this case the communication may be slower. + * + */ + +/* Master RECEIVER mode -----------------------------*/ +/* --EV7 */ +#define I2C_EVENT_MASTER_BYTE_RECEIVED ((uint32_t)0x00030040) /* BUSY, MSL and RXNE flags */ + +/* Master TRANSMITTER mode --------------------------*/ +/* --EV8 */ +#define I2C_EVENT_MASTER_BYTE_TRANSMITTING ((uint32_t)0x00070080) /* TRA, BUSY, MSL, TXE flags */ +/* --EV8_2 */ +#define I2C_EVENT_MASTER_BYTE_TRANSMITTED ((uint32_t)0x00070084) /* TRA, BUSY, MSL, TXE and BTF flags */ + + +/*======================================== + + I2C Slave Events (Events grouped in order of communication) + ==========================================*/ + +/** + * @brief Communication start events + * + * Wait on one of these events at the start of the communication. It means that + * the I2C peripheral detected a Start condition on the bus (generated by master + * device) followed by the peripheral address. The peripheral generates an ACK + * condition on the bus (if the acknowledge feature is enabled through function + * I2C_AcknowledgeConfig()) and the events listed above are set : + * + * 1) In normal case (only one address managed by the slave), when the address + * sent by the master matches the own address of the peripheral (configured by + * I2C_OwnAddress1 field) the I2C_EVENT_SLAVE_XXX_ADDRESS_MATCHED event is set + * (where XXX could be TRANSMITTER or RECEIVER). + * + * 2) In case the address sent by the master matches the second address of the + * peripheral (configured by the function I2C_OwnAddress2Config() and enabled + * by the function I2C_DualAddressCmd()) the events I2C_EVENT_SLAVE_XXX_SECONDADDRESS_MATCHED + * (where XXX could be TRANSMITTER or RECEIVER) are set. + * + * 3) In case the address sent by the master is General Call (address 0x00) and + * if the General Call is enabled for the peripheral (using function I2C_GeneralCallCmd()) + * the following event is set I2C_EVENT_SLAVE_GENERALCALLADDRESS_MATCHED. + * + */ + +/* --EV1 (all the events below are variants of EV1) */ +/* 1) Case of One Single Address managed by the slave */ +#define I2C_EVENT_SLAVE_RECEIVER_ADDRESS_MATCHED ((uint32_t)0x00020002) /* BUSY and ADDR flags */ +#define I2C_EVENT_SLAVE_TRANSMITTER_ADDRESS_MATCHED ((uint32_t)0x00060082) /* TRA, BUSY, TXE and ADDR flags */ + +/* 2) Case of Dual address managed by the slave */ +#define I2C_EVENT_SLAVE_RECEIVER_SECONDADDRESS_MATCHED ((uint32_t)0x00820000) /* DUALF and BUSY flags */ +#define I2C_EVENT_SLAVE_TRANSMITTER_SECONDADDRESS_MATCHED ((uint32_t)0x00860080) /* DUALF, TRA, BUSY and TXE flags */ + +/* 3) Case of General Call enabled for the slave */ +#define I2C_EVENT_SLAVE_GENERALCALLADDRESS_MATCHED ((uint32_t)0x00120000) /* GENCALL and BUSY flags */ + +/** + * @brief Communication events + * + * Wait on one of these events when EV1 has already been checked and: + * + * - Slave RECEIVER mode: + * - EV2: When the application is expecting a data byte to be received. + * - EV4: When the application is expecting the end of the communication: master + * sends a stop condition and data transmission is stopped. + * + * - Slave Transmitter mode: + * - EV3: When a byte has been transmitted by the slave and the application is expecting + * the end of the byte transmission. The two events I2C_EVENT_SLAVE_BYTE_TRANSMITTED and + * I2C_EVENT_SLAVE_BYTE_TRANSMITTING are similar. The second one can optionally be + * used when the user software doesn't guarantee the EV3 is managed before the + * current byte end of transfer. + * - EV3_2: When the master sends a NACK in order to tell slave that data transmission + * shall end (before sending the STOP condition). In this case slave has to stop sending + * data bytes and expect a Stop condition on the bus. + * + * @note In case the user software does not guarantee that the event EV2 is + * managed before the current byte end of transfer, then user may check on EV2 + * and BTF flag at the same time (ie. (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_BTF)). + * In this case the communication may be slower. + * + */ + +/* Slave RECEIVER mode --------------------------*/ +/* --EV2 */ +#define I2C_EVENT_SLAVE_BYTE_RECEIVED ((uint32_t)0x00020040) /* BUSY and RXNE flags */ +/* --EV4 */ +#define I2C_EVENT_SLAVE_STOP_DETECTED ((uint32_t)0x00000010) /* STOPF flag */ + +/* Slave TRANSMITTER mode -----------------------*/ +/* --EV3 */ +#define I2C_EVENT_SLAVE_BYTE_TRANSMITTED ((uint32_t)0x00060084) /* TRA, BUSY, TXE and BTF flags */ +#define I2C_EVENT_SLAVE_BYTE_TRANSMITTING ((uint32_t)0x00060080) /* TRA, BUSY and TXE flags */ +/* --EV3_2 */ +#define I2C_EVENT_SLAVE_ACK_FAILURE ((uint32_t)0x00000400) /* AF flag */ + +/*=========================== End of Events Description ==========================================*/ + +#define IS_I2C_EVENT(EVENT) (((EVENT) == I2C_EVENT_SLAVE_TRANSMITTER_ADDRESS_MATCHED) || \ + ((EVENT) == I2C_EVENT_SLAVE_RECEIVER_ADDRESS_MATCHED) || \ + ((EVENT) == I2C_EVENT_SLAVE_TRANSMITTER_SECONDADDRESS_MATCHED) || \ + ((EVENT) == I2C_EVENT_SLAVE_RECEIVER_SECONDADDRESS_MATCHED) || \ + ((EVENT) == I2C_EVENT_SLAVE_GENERALCALLADDRESS_MATCHED) || \ + ((EVENT) == I2C_EVENT_SLAVE_BYTE_RECEIVED) || \ + ((EVENT) == (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_DUALF)) || \ + ((EVENT) == (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_GENCALL)) || \ + ((EVENT) == I2C_EVENT_SLAVE_BYTE_TRANSMITTED) || \ + ((EVENT) == (I2C_EVENT_SLAVE_BYTE_TRANSMITTED | I2C_FLAG_DUALF)) || \ + ((EVENT) == (I2C_EVENT_SLAVE_BYTE_TRANSMITTED | I2C_FLAG_GENCALL)) || \ + ((EVENT) == I2C_EVENT_SLAVE_STOP_DETECTED) || \ + ((EVENT) == I2C_EVENT_MASTER_MODE_SELECT) || \ + ((EVENT) == I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED) || \ + ((EVENT) == I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED) || \ + ((EVENT) == I2C_EVENT_MASTER_BYTE_RECEIVED) || \ + ((EVENT) == I2C_EVENT_MASTER_BYTE_TRANSMITTED) || \ + ((EVENT) == I2C_EVENT_MASTER_BYTE_TRANSMITTING) || \ + ((EVENT) == I2C_EVENT_MASTER_MODE_ADDRESS10) || \ + ((EVENT) == I2C_EVENT_SLAVE_ACK_FAILURE)) +/** + * @} + */ + +/** @defgroup I2C_own_address1 + * @{ + */ + +#define IS_I2C_OWN_ADDRESS1(ADDRESS1) ((ADDRESS1) <= 0x3FF) +/** + * @} + */ + +/** @defgroup I2C_clock_speed + * @{ + */ + +#define IS_I2C_CLOCK_SPEED(SPEED) (((SPEED) >= 0x1) && ((SPEED) <= 400000)) +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup I2C_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup I2C_Exported_Functions + * @{ + */ + +void I2C_DeInit(I2C_TypeDef* I2Cx); +void I2C_Init(I2C_TypeDef* I2Cx, I2C_InitTypeDef* I2C_InitStruct); +void I2C_StructInit(I2C_InitTypeDef* I2C_InitStruct); +void I2C_Cmd(I2C_TypeDef* I2Cx, FunctionalState NewState); +void I2C_DMACmd(I2C_TypeDef* I2Cx, FunctionalState NewState); +void I2C_DMALastTransferCmd(I2C_TypeDef* I2Cx, FunctionalState NewState); +void I2C_GenerateSTART(I2C_TypeDef* I2Cx, FunctionalState NewState); +void I2C_GenerateSTOP(I2C_TypeDef* I2Cx, FunctionalState NewState); +void I2C_AcknowledgeConfig(I2C_TypeDef* I2Cx, FunctionalState NewState); +void I2C_OwnAddress2Config(I2C_TypeDef* I2Cx, uint8_t Address); +void I2C_DualAddressCmd(I2C_TypeDef* I2Cx, FunctionalState NewState); +void I2C_GeneralCallCmd(I2C_TypeDef* I2Cx, FunctionalState NewState); +void I2C_ITConfig(I2C_TypeDef* I2Cx, uint16_t I2C_IT, FunctionalState NewState); +void I2C_SendData(I2C_TypeDef* I2Cx, uint8_t Data); +uint8_t I2C_ReceiveData(I2C_TypeDef* I2Cx); +void I2C_Send7bitAddress(I2C_TypeDef* I2Cx, uint8_t Address, uint8_t I2C_Direction); +uint16_t I2C_ReadRegister(I2C_TypeDef* I2Cx, uint8_t I2C_Register); +void I2C_SoftwareResetCmd(I2C_TypeDef* I2Cx, FunctionalState NewState); +void I2C_NACKPositionConfig(I2C_TypeDef* I2Cx, uint16_t I2C_NACKPosition); +void I2C_SMBusAlertConfig(I2C_TypeDef* I2Cx, uint16_t I2C_SMBusAlert); +void I2C_TransmitPEC(I2C_TypeDef* I2Cx, FunctionalState NewState); +void I2C_PECPositionConfig(I2C_TypeDef* I2Cx, uint16_t I2C_PECPosition); +void I2C_CalculatePEC(I2C_TypeDef* I2Cx, FunctionalState NewState); +uint8_t I2C_GetPEC(I2C_TypeDef* I2Cx); +void I2C_ARPCmd(I2C_TypeDef* I2Cx, FunctionalState NewState); +void I2C_StretchClockCmd(I2C_TypeDef* I2Cx, FunctionalState NewState); +void I2C_FastModeDutyCycleConfig(I2C_TypeDef* I2Cx, uint16_t I2C_DutyCycle); + +/** + * @brief + **************************************************************************************** + * + * I2C State Monitoring Functions + * + **************************************************************************************** + * This I2C driver provides three different ways for I2C state monitoring + * depending on the application requirements and constraints: + * + * + * 1) Basic state monitoring: + * Using I2C_CheckEvent() function: + * It compares the status registers (SR1 and SR2) content to a given event + * (can be the combination of one or more flags). + * It returns SUCCESS if the current status includes the given flags + * and returns ERROR if one or more flags are missing in the current status. + * - When to use: + * - This function is suitable for most applications as well as for startup + * activity since the events are fully described in the product reference manual + * (RM0008). + * - It is also suitable for users who need to define their own events. + * - Limitations: + * - If an error occurs (ie. error flags are set besides to the monitored flags), + * the I2C_CheckEvent() function may return SUCCESS despite the communication + * hold or corrupted real state. + * In this case, it is advised to use error interrupts to monitor the error + * events and handle them in the interrupt IRQ handler. + * + * @note + * For error management, it is advised to use the following functions: + * - I2C_ITConfig() to configure and enable the error interrupts (I2C_IT_ERR). + * - I2Cx_ER_IRQHandler() which is called when the error interrupt occurs. + * Where x is the peripheral instance (I2C1, I2C2 ...) + * - I2C_GetFlagStatus() or I2C_GetITStatus() to be called into I2Cx_ER_IRQHandler() + * in order to determine which error occurred. + * - I2C_ClearFlag() or I2C_ClearITPendingBit() and/or I2C_SoftwareResetCmd() + * and/or I2C_GenerateStop() in order to clear the error flag and source, + * and return to correct communication status. + * + * + * 2) Advanced state monitoring: + * Using the function I2C_GetLastEvent() which returns the image of both status + * registers in a single word (uint32_t) (Status Register 2 value is shifted left + * by 16 bits and concatenated to Status Register 1). + * - When to use: + * - This function is suitable for the same applications above but it allows to + * overcome the limitations of I2C_GetFlagStatus() function (see below). + * The returned value could be compared to events already defined in the + * library (stm32f10x_i2c.h) or to custom values defined by user. + * - This function is suitable when multiple flags are monitored at the same time. + * - At the opposite of I2C_CheckEvent() function, this function allows user to + * choose when an event is accepted (when all events flags are set and no + * other flags are set or just when the needed flags are set like + * I2C_CheckEvent() function). + * - Limitations: + * - User may need to define his own events. + * - Same remark concerning the error management is applicable for this + * function if user decides to check only regular communication flags (and + * ignores error flags). + * + * + * 3) Flag-based state monitoring: + * Using the function I2C_GetFlagStatus() which simply returns the status of + * one single flag (ie. I2C_FLAG_RXNE ...). + * - When to use: + * - This function could be used for specific applications or in debug phase. + * - It is suitable when only one flag checking is needed (most I2C events + * are monitored through multiple flags). + * - Limitations: + * - When calling this function, the Status register is accessed. Some flags are + * cleared when the status register is accessed. So checking the status + * of one Flag, may clear other ones. + * - Function may need to be called twice or more in order to monitor one + * single event. + * + */ + +/** + * + * 1) Basic state monitoring + ******************************************************************************* + */ +ErrorStatus I2C_CheckEvent(I2C_TypeDef* I2Cx, uint32_t I2C_EVENT); +/** + * + * 2) Advanced state monitoring + ******************************************************************************* + */ +uint32_t I2C_GetLastEvent(I2C_TypeDef* I2Cx); +/** + * + * 3) Flag-based state monitoring + ******************************************************************************* + */ +FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG); +/** + * + ******************************************************************************* + */ + +void I2C_ClearFlag(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG); +ITStatus I2C_GetITStatus(I2C_TypeDef* I2Cx, uint32_t I2C_IT); +void I2C_ClearITPendingBit(I2C_TypeDef* I2Cx, uint32_t I2C_IT); + +#ifdef __cplusplus +} +#endif + +#endif /*__STM32F10x_I2C_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_iwdg.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_iwdg.h new file mode 100755 index 0000000..7f5ab76 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_iwdg.h @@ -0,0 +1,140 @@ +/** + ****************************************************************************** + * @file stm32f10x_iwdg.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the IWDG + * firmware library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_IWDG_H +#define __STM32F10x_IWDG_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup IWDG + * @{ + */ + +/** @defgroup IWDG_Exported_Types + * @{ + */ + +/** + * @} + */ + +/** @defgroup IWDG_Exported_Constants + * @{ + */ + +/** @defgroup IWDG_WriteAccess + * @{ + */ + +#define IWDG_WriteAccess_Enable ((uint16_t)0x5555) +#define IWDG_WriteAccess_Disable ((uint16_t)0x0000) +#define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \ + ((ACCESS) == IWDG_WriteAccess_Disable)) +/** + * @} + */ + +/** @defgroup IWDG_prescaler + * @{ + */ + +#define IWDG_Prescaler_4 ((uint8_t)0x00) +#define IWDG_Prescaler_8 ((uint8_t)0x01) +#define IWDG_Prescaler_16 ((uint8_t)0x02) +#define IWDG_Prescaler_32 ((uint8_t)0x03) +#define IWDG_Prescaler_64 ((uint8_t)0x04) +#define IWDG_Prescaler_128 ((uint8_t)0x05) +#define IWDG_Prescaler_256 ((uint8_t)0x06) +#define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \ + ((PRESCALER) == IWDG_Prescaler_8) || \ + ((PRESCALER) == IWDG_Prescaler_16) || \ + ((PRESCALER) == IWDG_Prescaler_32) || \ + ((PRESCALER) == IWDG_Prescaler_64) || \ + ((PRESCALER) == IWDG_Prescaler_128)|| \ + ((PRESCALER) == IWDG_Prescaler_256)) +/** + * @} + */ + +/** @defgroup IWDG_Flag + * @{ + */ + +#define IWDG_FLAG_PVU ((uint16_t)0x0001) +#define IWDG_FLAG_RVU ((uint16_t)0x0002) +#define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU)) +#define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup IWDG_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup IWDG_Exported_Functions + * @{ + */ + +void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess); +void IWDG_SetPrescaler(uint8_t IWDG_Prescaler); +void IWDG_SetReload(uint16_t Reload); +void IWDG_ReloadCounter(void); +void IWDG_Enable(void); +FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_IWDG_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_pwr.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_pwr.h new file mode 100755 index 0000000..76e6ce9 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_pwr.h @@ -0,0 +1,156 @@ +/** + ****************************************************************************** + * @file stm32f10x_pwr.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the PWR firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_PWR_H +#define __STM32F10x_PWR_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup PWR + * @{ + */ + +/** @defgroup PWR_Exported_Types + * @{ + */ + +/** + * @} + */ + +/** @defgroup PWR_Exported_Constants + * @{ + */ + +/** @defgroup PVD_detection_level + * @{ + */ + +#define PWR_PVDLevel_2V2 ((uint32_t)0x00000000) +#define PWR_PVDLevel_2V3 ((uint32_t)0x00000020) +#define PWR_PVDLevel_2V4 ((uint32_t)0x00000040) +#define PWR_PVDLevel_2V5 ((uint32_t)0x00000060) +#define PWR_PVDLevel_2V6 ((uint32_t)0x00000080) +#define PWR_PVDLevel_2V7 ((uint32_t)0x000000A0) +#define PWR_PVDLevel_2V8 ((uint32_t)0x000000C0) +#define PWR_PVDLevel_2V9 ((uint32_t)0x000000E0) +#define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_2V2) || ((LEVEL) == PWR_PVDLevel_2V3)|| \ + ((LEVEL) == PWR_PVDLevel_2V4) || ((LEVEL) == PWR_PVDLevel_2V5)|| \ + ((LEVEL) == PWR_PVDLevel_2V6) || ((LEVEL) == PWR_PVDLevel_2V7)|| \ + ((LEVEL) == PWR_PVDLevel_2V8) || ((LEVEL) == PWR_PVDLevel_2V9)) +/** + * @} + */ + +/** @defgroup Regulator_state_is_STOP_mode + * @{ + */ + +#define PWR_Regulator_ON ((uint32_t)0x00000000) +#define PWR_Regulator_LowPower ((uint32_t)0x00000001) +#define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \ + ((REGULATOR) == PWR_Regulator_LowPower)) +/** + * @} + */ + +/** @defgroup STOP_mode_entry + * @{ + */ + +#define PWR_STOPEntry_WFI ((uint8_t)0x01) +#define PWR_STOPEntry_WFE ((uint8_t)0x02) +#define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE)) + +/** + * @} + */ + +/** @defgroup PWR_Flag + * @{ + */ + +#define PWR_FLAG_WU ((uint32_t)0x00000001) +#define PWR_FLAG_SB ((uint32_t)0x00000002) +#define PWR_FLAG_PVDO ((uint32_t)0x00000004) +#define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \ + ((FLAG) == PWR_FLAG_PVDO)) + +#define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB)) +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup PWR_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup PWR_Exported_Functions + * @{ + */ + +void PWR_DeInit(void); +void PWR_BackupAccessCmd(FunctionalState NewState); +void PWR_PVDCmd(FunctionalState NewState); +void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel); +void PWR_WakeUpPinCmd(FunctionalState NewState); +void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry); +void PWR_EnterSTANDBYMode(void); +FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG); +void PWR_ClearFlag(uint32_t PWR_FLAG); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_PWR_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_rcc.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_rcc.h new file mode 100755 index 0000000..b3b7d82 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_rcc.h @@ -0,0 +1,727 @@ +/** + ****************************************************************************** + * @file stm32f10x_rcc.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the RCC firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_RCC_H +#define __STM32F10x_RCC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup RCC + * @{ + */ + +/** @defgroup RCC_Exported_Types + * @{ + */ + +typedef struct +{ + uint32_t SYSCLK_Frequency; /*!< returns SYSCLK clock frequency expressed in Hz */ + uint32_t HCLK_Frequency; /*!< returns HCLK clock frequency expressed in Hz */ + uint32_t PCLK1_Frequency; /*!< returns PCLK1 clock frequency expressed in Hz */ + uint32_t PCLK2_Frequency; /*!< returns PCLK2 clock frequency expressed in Hz */ + uint32_t ADCCLK_Frequency; /*!< returns ADCCLK clock frequency expressed in Hz */ +}RCC_ClocksTypeDef; + +/** + * @} + */ + +/** @defgroup RCC_Exported_Constants + * @{ + */ + +/** @defgroup HSE_configuration + * @{ + */ + +#define RCC_HSE_OFF ((uint32_t)0x00000000) +#define RCC_HSE_ON ((uint32_t)0x00010000) +#define RCC_HSE_Bypass ((uint32_t)0x00040000) +#define IS_RCC_HSE(HSE) (((HSE) == RCC_HSE_OFF) || ((HSE) == RCC_HSE_ON) || \ + ((HSE) == RCC_HSE_Bypass)) + +/** + * @} + */ + +/** @defgroup PLL_entry_clock_source + * @{ + */ + +#define RCC_PLLSource_HSI_Div2 ((uint32_t)0x00000000) + +#if !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_CL) + #define RCC_PLLSource_HSE_Div1 ((uint32_t)0x00010000) + #define RCC_PLLSource_HSE_Div2 ((uint32_t)0x00030000) + #define IS_RCC_PLL_SOURCE(SOURCE) (((SOURCE) == RCC_PLLSource_HSI_Div2) || \ + ((SOURCE) == RCC_PLLSource_HSE_Div1) || \ + ((SOURCE) == RCC_PLLSource_HSE_Div2)) +#else + #define RCC_PLLSource_PREDIV1 ((uint32_t)0x00010000) + #define IS_RCC_PLL_SOURCE(SOURCE) (((SOURCE) == RCC_PLLSource_HSI_Div2) || \ + ((SOURCE) == RCC_PLLSource_PREDIV1)) +#endif /* STM32F10X_CL */ + +/** + * @} + */ + +/** @defgroup PLL_multiplication_factor + * @{ + */ +#ifndef STM32F10X_CL + #define RCC_PLLMul_2 ((uint32_t)0x00000000) + #define RCC_PLLMul_3 ((uint32_t)0x00040000) + #define RCC_PLLMul_4 ((uint32_t)0x00080000) + #define RCC_PLLMul_5 ((uint32_t)0x000C0000) + #define RCC_PLLMul_6 ((uint32_t)0x00100000) + #define RCC_PLLMul_7 ((uint32_t)0x00140000) + #define RCC_PLLMul_8 ((uint32_t)0x00180000) + #define RCC_PLLMul_9 ((uint32_t)0x001C0000) + #define RCC_PLLMul_10 ((uint32_t)0x00200000) + #define RCC_PLLMul_11 ((uint32_t)0x00240000) + #define RCC_PLLMul_12 ((uint32_t)0x00280000) + #define RCC_PLLMul_13 ((uint32_t)0x002C0000) + #define RCC_PLLMul_14 ((uint32_t)0x00300000) + #define RCC_PLLMul_15 ((uint32_t)0x00340000) + #define RCC_PLLMul_16 ((uint32_t)0x00380000) + #define IS_RCC_PLL_MUL(MUL) (((MUL) == RCC_PLLMul_2) || ((MUL) == RCC_PLLMul_3) || \ + ((MUL) == RCC_PLLMul_4) || ((MUL) == RCC_PLLMul_5) || \ + ((MUL) == RCC_PLLMul_6) || ((MUL) == RCC_PLLMul_7) || \ + ((MUL) == RCC_PLLMul_8) || ((MUL) == RCC_PLLMul_9) || \ + ((MUL) == RCC_PLLMul_10) || ((MUL) == RCC_PLLMul_11) || \ + ((MUL) == RCC_PLLMul_12) || ((MUL) == RCC_PLLMul_13) || \ + ((MUL) == RCC_PLLMul_14) || ((MUL) == RCC_PLLMul_15) || \ + ((MUL) == RCC_PLLMul_16)) + +#else + #define RCC_PLLMul_4 ((uint32_t)0x00080000) + #define RCC_PLLMul_5 ((uint32_t)0x000C0000) + #define RCC_PLLMul_6 ((uint32_t)0x00100000) + #define RCC_PLLMul_7 ((uint32_t)0x00140000) + #define RCC_PLLMul_8 ((uint32_t)0x00180000) + #define RCC_PLLMul_9 ((uint32_t)0x001C0000) + #define RCC_PLLMul_6_5 ((uint32_t)0x00340000) + + #define IS_RCC_PLL_MUL(MUL) (((MUL) == RCC_PLLMul_4) || ((MUL) == RCC_PLLMul_5) || \ + ((MUL) == RCC_PLLMul_6) || ((MUL) == RCC_PLLMul_7) || \ + ((MUL) == RCC_PLLMul_8) || ((MUL) == RCC_PLLMul_9) || \ + ((MUL) == RCC_PLLMul_6_5)) +#endif /* STM32F10X_CL */ +/** + * @} + */ + +/** @defgroup PREDIV1_division_factor + * @{ + */ +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) || defined (STM32F10X_CL) + #define RCC_PREDIV1_Div1 ((uint32_t)0x00000000) + #define RCC_PREDIV1_Div2 ((uint32_t)0x00000001) + #define RCC_PREDIV1_Div3 ((uint32_t)0x00000002) + #define RCC_PREDIV1_Div4 ((uint32_t)0x00000003) + #define RCC_PREDIV1_Div5 ((uint32_t)0x00000004) + #define RCC_PREDIV1_Div6 ((uint32_t)0x00000005) + #define RCC_PREDIV1_Div7 ((uint32_t)0x00000006) + #define RCC_PREDIV1_Div8 ((uint32_t)0x00000007) + #define RCC_PREDIV1_Div9 ((uint32_t)0x00000008) + #define RCC_PREDIV1_Div10 ((uint32_t)0x00000009) + #define RCC_PREDIV1_Div11 ((uint32_t)0x0000000A) + #define RCC_PREDIV1_Div12 ((uint32_t)0x0000000B) + #define RCC_PREDIV1_Div13 ((uint32_t)0x0000000C) + #define RCC_PREDIV1_Div14 ((uint32_t)0x0000000D) + #define RCC_PREDIV1_Div15 ((uint32_t)0x0000000E) + #define RCC_PREDIV1_Div16 ((uint32_t)0x0000000F) + + #define IS_RCC_PREDIV1(PREDIV1) (((PREDIV1) == RCC_PREDIV1_Div1) || ((PREDIV1) == RCC_PREDIV1_Div2) || \ + ((PREDIV1) == RCC_PREDIV1_Div3) || ((PREDIV1) == RCC_PREDIV1_Div4) || \ + ((PREDIV1) == RCC_PREDIV1_Div5) || ((PREDIV1) == RCC_PREDIV1_Div6) || \ + ((PREDIV1) == RCC_PREDIV1_Div7) || ((PREDIV1) == RCC_PREDIV1_Div8) || \ + ((PREDIV1) == RCC_PREDIV1_Div9) || ((PREDIV1) == RCC_PREDIV1_Div10) || \ + ((PREDIV1) == RCC_PREDIV1_Div11) || ((PREDIV1) == RCC_PREDIV1_Div12) || \ + ((PREDIV1) == RCC_PREDIV1_Div13) || ((PREDIV1) == RCC_PREDIV1_Div14) || \ + ((PREDIV1) == RCC_PREDIV1_Div15) || ((PREDIV1) == RCC_PREDIV1_Div16)) +#endif +/** + * @} + */ + + +/** @defgroup PREDIV1_clock_source + * @{ + */ +#ifdef STM32F10X_CL +/* PREDIV1 clock source (for STM32 connectivity line devices) */ + #define RCC_PREDIV1_Source_HSE ((uint32_t)0x00000000) + #define RCC_PREDIV1_Source_PLL2 ((uint32_t)0x00010000) + + #define IS_RCC_PREDIV1_SOURCE(SOURCE) (((SOURCE) == RCC_PREDIV1_Source_HSE) || \ + ((SOURCE) == RCC_PREDIV1_Source_PLL2)) +#elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) +/* PREDIV1 clock source (for STM32 Value line devices) */ + #define RCC_PREDIV1_Source_HSE ((uint32_t)0x00000000) + + #define IS_RCC_PREDIV1_SOURCE(SOURCE) (((SOURCE) == RCC_PREDIV1_Source_HSE)) +#endif +/** + * @} + */ + +#ifdef STM32F10X_CL +/** @defgroup PREDIV2_division_factor + * @{ + */ + + #define RCC_PREDIV2_Div1 ((uint32_t)0x00000000) + #define RCC_PREDIV2_Div2 ((uint32_t)0x00000010) + #define RCC_PREDIV2_Div3 ((uint32_t)0x00000020) + #define RCC_PREDIV2_Div4 ((uint32_t)0x00000030) + #define RCC_PREDIV2_Div5 ((uint32_t)0x00000040) + #define RCC_PREDIV2_Div6 ((uint32_t)0x00000050) + #define RCC_PREDIV2_Div7 ((uint32_t)0x00000060) + #define RCC_PREDIV2_Div8 ((uint32_t)0x00000070) + #define RCC_PREDIV2_Div9 ((uint32_t)0x00000080) + #define RCC_PREDIV2_Div10 ((uint32_t)0x00000090) + #define RCC_PREDIV2_Div11 ((uint32_t)0x000000A0) + #define RCC_PREDIV2_Div12 ((uint32_t)0x000000B0) + #define RCC_PREDIV2_Div13 ((uint32_t)0x000000C0) + #define RCC_PREDIV2_Div14 ((uint32_t)0x000000D0) + #define RCC_PREDIV2_Div15 ((uint32_t)0x000000E0) + #define RCC_PREDIV2_Div16 ((uint32_t)0x000000F0) + + #define IS_RCC_PREDIV2(PREDIV2) (((PREDIV2) == RCC_PREDIV2_Div1) || ((PREDIV2) == RCC_PREDIV2_Div2) || \ + ((PREDIV2) == RCC_PREDIV2_Div3) || ((PREDIV2) == RCC_PREDIV2_Div4) || \ + ((PREDIV2) == RCC_PREDIV2_Div5) || ((PREDIV2) == RCC_PREDIV2_Div6) || \ + ((PREDIV2) == RCC_PREDIV2_Div7) || ((PREDIV2) == RCC_PREDIV2_Div8) || \ + ((PREDIV2) == RCC_PREDIV2_Div9) || ((PREDIV2) == RCC_PREDIV2_Div10) || \ + ((PREDIV2) == RCC_PREDIV2_Div11) || ((PREDIV2) == RCC_PREDIV2_Div12) || \ + ((PREDIV2) == RCC_PREDIV2_Div13) || ((PREDIV2) == RCC_PREDIV2_Div14) || \ + ((PREDIV2) == RCC_PREDIV2_Div15) || ((PREDIV2) == RCC_PREDIV2_Div16)) +/** + * @} + */ + + +/** @defgroup PLL2_multiplication_factor + * @{ + */ + + #define RCC_PLL2Mul_8 ((uint32_t)0x00000600) + #define RCC_PLL2Mul_9 ((uint32_t)0x00000700) + #define RCC_PLL2Mul_10 ((uint32_t)0x00000800) + #define RCC_PLL2Mul_11 ((uint32_t)0x00000900) + #define RCC_PLL2Mul_12 ((uint32_t)0x00000A00) + #define RCC_PLL2Mul_13 ((uint32_t)0x00000B00) + #define RCC_PLL2Mul_14 ((uint32_t)0x00000C00) + #define RCC_PLL2Mul_16 ((uint32_t)0x00000E00) + #define RCC_PLL2Mul_20 ((uint32_t)0x00000F00) + + #define IS_RCC_PLL2_MUL(MUL) (((MUL) == RCC_PLL2Mul_8) || ((MUL) == RCC_PLL2Mul_9) || \ + ((MUL) == RCC_PLL2Mul_10) || ((MUL) == RCC_PLL2Mul_11) || \ + ((MUL) == RCC_PLL2Mul_12) || ((MUL) == RCC_PLL2Mul_13) || \ + ((MUL) == RCC_PLL2Mul_14) || ((MUL) == RCC_PLL2Mul_16) || \ + ((MUL) == RCC_PLL2Mul_20)) +/** + * @} + */ + + +/** @defgroup PLL3_multiplication_factor + * @{ + */ + + #define RCC_PLL3Mul_8 ((uint32_t)0x00006000) + #define RCC_PLL3Mul_9 ((uint32_t)0x00007000) + #define RCC_PLL3Mul_10 ((uint32_t)0x00008000) + #define RCC_PLL3Mul_11 ((uint32_t)0x00009000) + #define RCC_PLL3Mul_12 ((uint32_t)0x0000A000) + #define RCC_PLL3Mul_13 ((uint32_t)0x0000B000) + #define RCC_PLL3Mul_14 ((uint32_t)0x0000C000) + #define RCC_PLL3Mul_16 ((uint32_t)0x0000E000) + #define RCC_PLL3Mul_20 ((uint32_t)0x0000F000) + + #define IS_RCC_PLL3_MUL(MUL) (((MUL) == RCC_PLL3Mul_8) || ((MUL) == RCC_PLL3Mul_9) || \ + ((MUL) == RCC_PLL3Mul_10) || ((MUL) == RCC_PLL3Mul_11) || \ + ((MUL) == RCC_PLL3Mul_12) || ((MUL) == RCC_PLL3Mul_13) || \ + ((MUL) == RCC_PLL3Mul_14) || ((MUL) == RCC_PLL3Mul_16) || \ + ((MUL) == RCC_PLL3Mul_20)) +/** + * @} + */ + +#endif /* STM32F10X_CL */ + + +/** @defgroup System_clock_source + * @{ + */ + +#define RCC_SYSCLKSource_HSI ((uint32_t)0x00000000) +#define RCC_SYSCLKSource_HSE ((uint32_t)0x00000001) +#define RCC_SYSCLKSource_PLLCLK ((uint32_t)0x00000002) +#define IS_RCC_SYSCLK_SOURCE(SOURCE) (((SOURCE) == RCC_SYSCLKSource_HSI) || \ + ((SOURCE) == RCC_SYSCLKSource_HSE) || \ + ((SOURCE) == RCC_SYSCLKSource_PLLCLK)) +/** + * @} + */ + +/** @defgroup AHB_clock_source + * @{ + */ + +#define RCC_SYSCLK_Div1 ((uint32_t)0x00000000) +#define RCC_SYSCLK_Div2 ((uint32_t)0x00000080) +#define RCC_SYSCLK_Div4 ((uint32_t)0x00000090) +#define RCC_SYSCLK_Div8 ((uint32_t)0x000000A0) +#define RCC_SYSCLK_Div16 ((uint32_t)0x000000B0) +#define RCC_SYSCLK_Div64 ((uint32_t)0x000000C0) +#define RCC_SYSCLK_Div128 ((uint32_t)0x000000D0) +#define RCC_SYSCLK_Div256 ((uint32_t)0x000000E0) +#define RCC_SYSCLK_Div512 ((uint32_t)0x000000F0) +#define IS_RCC_HCLK(HCLK) (((HCLK) == RCC_SYSCLK_Div1) || ((HCLK) == RCC_SYSCLK_Div2) || \ + ((HCLK) == RCC_SYSCLK_Div4) || ((HCLK) == RCC_SYSCLK_Div8) || \ + ((HCLK) == RCC_SYSCLK_Div16) || ((HCLK) == RCC_SYSCLK_Div64) || \ + ((HCLK) == RCC_SYSCLK_Div128) || ((HCLK) == RCC_SYSCLK_Div256) || \ + ((HCLK) == RCC_SYSCLK_Div512)) +/** + * @} + */ + +/** @defgroup APB1_APB2_clock_source + * @{ + */ + +#define RCC_HCLK_Div1 ((uint32_t)0x00000000) +#define RCC_HCLK_Div2 ((uint32_t)0x00000400) +#define RCC_HCLK_Div4 ((uint32_t)0x00000500) +#define RCC_HCLK_Div8 ((uint32_t)0x00000600) +#define RCC_HCLK_Div16 ((uint32_t)0x00000700) +#define IS_RCC_PCLK(PCLK) (((PCLK) == RCC_HCLK_Div1) || ((PCLK) == RCC_HCLK_Div2) || \ + ((PCLK) == RCC_HCLK_Div4) || ((PCLK) == RCC_HCLK_Div8) || \ + ((PCLK) == RCC_HCLK_Div16)) +/** + * @} + */ + +/** @defgroup RCC_Interrupt_source + * @{ + */ + +#define RCC_IT_LSIRDY ((uint8_t)0x01) +#define RCC_IT_LSERDY ((uint8_t)0x02) +#define RCC_IT_HSIRDY ((uint8_t)0x04) +#define RCC_IT_HSERDY ((uint8_t)0x08) +#define RCC_IT_PLLRDY ((uint8_t)0x10) +#define RCC_IT_CSS ((uint8_t)0x80) + +#ifndef STM32F10X_CL + #define IS_RCC_IT(IT) ((((IT) & (uint8_t)0xE0) == 0x00) && ((IT) != 0x00)) + #define IS_RCC_GET_IT(IT) (((IT) == RCC_IT_LSIRDY) || ((IT) == RCC_IT_LSERDY) || \ + ((IT) == RCC_IT_HSIRDY) || ((IT) == RCC_IT_HSERDY) || \ + ((IT) == RCC_IT_PLLRDY) || ((IT) == RCC_IT_CSS)) + #define IS_RCC_CLEAR_IT(IT) ((((IT) & (uint8_t)0x60) == 0x00) && ((IT) != 0x00)) +#else + #define RCC_IT_PLL2RDY ((uint8_t)0x20) + #define RCC_IT_PLL3RDY ((uint8_t)0x40) + #define IS_RCC_IT(IT) ((((IT) & (uint8_t)0x80) == 0x00) && ((IT) != 0x00)) + #define IS_RCC_GET_IT(IT) (((IT) == RCC_IT_LSIRDY) || ((IT) == RCC_IT_LSERDY) || \ + ((IT) == RCC_IT_HSIRDY) || ((IT) == RCC_IT_HSERDY) || \ + ((IT) == RCC_IT_PLLRDY) || ((IT) == RCC_IT_CSS) || \ + ((IT) == RCC_IT_PLL2RDY) || ((IT) == RCC_IT_PLL3RDY)) + #define IS_RCC_CLEAR_IT(IT) ((IT) != 0x00) +#endif /* STM32F10X_CL */ + + +/** + * @} + */ + +#ifndef STM32F10X_CL +/** @defgroup USB_Device_clock_source + * @{ + */ + + #define RCC_USBCLKSource_PLLCLK_1Div5 ((uint8_t)0x00) + #define RCC_USBCLKSource_PLLCLK_Div1 ((uint8_t)0x01) + + #define IS_RCC_USBCLK_SOURCE(SOURCE) (((SOURCE) == RCC_USBCLKSource_PLLCLK_1Div5) || \ + ((SOURCE) == RCC_USBCLKSource_PLLCLK_Div1)) +/** + * @} + */ +#else +/** @defgroup USB_OTG_FS_clock_source + * @{ + */ + #define RCC_OTGFSCLKSource_PLLVCO_Div3 ((uint8_t)0x00) + #define RCC_OTGFSCLKSource_PLLVCO_Div2 ((uint8_t)0x01) + + #define IS_RCC_OTGFSCLK_SOURCE(SOURCE) (((SOURCE) == RCC_OTGFSCLKSource_PLLVCO_Div3) || \ + ((SOURCE) == RCC_OTGFSCLKSource_PLLVCO_Div2)) +/** + * @} + */ +#endif /* STM32F10X_CL */ + + +#ifdef STM32F10X_CL +/** @defgroup I2S2_clock_source + * @{ + */ + #define RCC_I2S2CLKSource_SYSCLK ((uint8_t)0x00) + #define RCC_I2S2CLKSource_PLL3_VCO ((uint8_t)0x01) + + #define IS_RCC_I2S2CLK_SOURCE(SOURCE) (((SOURCE) == RCC_I2S2CLKSource_SYSCLK) || \ + ((SOURCE) == RCC_I2S2CLKSource_PLL3_VCO)) +/** + * @} + */ + +/** @defgroup I2S3_clock_source + * @{ + */ + #define RCC_I2S3CLKSource_SYSCLK ((uint8_t)0x00) + #define RCC_I2S3CLKSource_PLL3_VCO ((uint8_t)0x01) + + #define IS_RCC_I2S3CLK_SOURCE(SOURCE) (((SOURCE) == RCC_I2S3CLKSource_SYSCLK) || \ + ((SOURCE) == RCC_I2S3CLKSource_PLL3_VCO)) +/** + * @} + */ +#endif /* STM32F10X_CL */ + + +/** @defgroup ADC_clock_source + * @{ + */ + +#define RCC_PCLK2_Div2 ((uint32_t)0x00000000) +#define RCC_PCLK2_Div4 ((uint32_t)0x00004000) +#define RCC_PCLK2_Div6 ((uint32_t)0x00008000) +#define RCC_PCLK2_Div8 ((uint32_t)0x0000C000) +#define IS_RCC_ADCCLK(ADCCLK) (((ADCCLK) == RCC_PCLK2_Div2) || ((ADCCLK) == RCC_PCLK2_Div4) || \ + ((ADCCLK) == RCC_PCLK2_Div6) || ((ADCCLK) == RCC_PCLK2_Div8)) +/** + * @} + */ + +/** @defgroup LSE_configuration + * @{ + */ + +#define RCC_LSE_OFF ((uint8_t)0x00) +#define RCC_LSE_ON ((uint8_t)0x01) +#define RCC_LSE_Bypass ((uint8_t)0x04) +#define IS_RCC_LSE(LSE) (((LSE) == RCC_LSE_OFF) || ((LSE) == RCC_LSE_ON) || \ + ((LSE) == RCC_LSE_Bypass)) +/** + * @} + */ + +/** @defgroup RTC_clock_source + * @{ + */ + +#define RCC_RTCCLKSource_LSE ((uint32_t)0x00000100) +#define RCC_RTCCLKSource_LSI ((uint32_t)0x00000200) +#define RCC_RTCCLKSource_HSE_Div128 ((uint32_t)0x00000300) +#define IS_RCC_RTCCLK_SOURCE(SOURCE) (((SOURCE) == RCC_RTCCLKSource_LSE) || \ + ((SOURCE) == RCC_RTCCLKSource_LSI) || \ + ((SOURCE) == RCC_RTCCLKSource_HSE_Div128)) +/** + * @} + */ + +/** @defgroup AHB_peripheral + * @{ + */ + +#define RCC_AHBPeriph_DMA1 ((uint32_t)0x00000001) +#define RCC_AHBPeriph_DMA2 ((uint32_t)0x00000002) +#define RCC_AHBPeriph_SRAM ((uint32_t)0x00000004) +#define RCC_AHBPeriph_FLITF ((uint32_t)0x00000010) +#define RCC_AHBPeriph_CRC ((uint32_t)0x00000040) + +#ifndef STM32F10X_CL + #define RCC_AHBPeriph_FSMC ((uint32_t)0x00000100) + #define RCC_AHBPeriph_SDIO ((uint32_t)0x00000400) + #define IS_RCC_AHB_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFAA8) == 0x00) && ((PERIPH) != 0x00)) +#else + #define RCC_AHBPeriph_OTG_FS ((uint32_t)0x00001000) + #define RCC_AHBPeriph_ETH_MAC ((uint32_t)0x00004000) + #define RCC_AHBPeriph_ETH_MAC_Tx ((uint32_t)0x00008000) + #define RCC_AHBPeriph_ETH_MAC_Rx ((uint32_t)0x00010000) + + #define IS_RCC_AHB_PERIPH(PERIPH) ((((PERIPH) & 0xFFFE2FA8) == 0x00) && ((PERIPH) != 0x00)) + #define IS_RCC_AHB_PERIPH_RESET(PERIPH) ((((PERIPH) & 0xFFFFAFFF) == 0x00) && ((PERIPH) != 0x00)) +#endif /* STM32F10X_CL */ +/** + * @} + */ + +/** @defgroup APB2_peripheral + * @{ + */ + +#define RCC_APB2Periph_AFIO ((uint32_t)0x00000001) +#define RCC_APB2Periph_GPIOA ((uint32_t)0x00000004) +#define RCC_APB2Periph_GPIOB ((uint32_t)0x00000008) +#define RCC_APB2Periph_GPIOC ((uint32_t)0x00000010) +#define RCC_APB2Periph_GPIOD ((uint32_t)0x00000020) +#define RCC_APB2Periph_GPIOE ((uint32_t)0x00000040) +#define RCC_APB2Periph_GPIOF ((uint32_t)0x00000080) +#define RCC_APB2Periph_GPIOG ((uint32_t)0x00000100) +#define RCC_APB2Periph_ADC1 ((uint32_t)0x00000200) +#define RCC_APB2Periph_ADC2 ((uint32_t)0x00000400) +#define RCC_APB2Periph_TIM1 ((uint32_t)0x00000800) +#define RCC_APB2Periph_SPI1 ((uint32_t)0x00001000) +#define RCC_APB2Periph_TIM8 ((uint32_t)0x00002000) +#define RCC_APB2Periph_USART1 ((uint32_t)0x00004000) +#define RCC_APB2Periph_ADC3 ((uint32_t)0x00008000) +#define RCC_APB2Periph_TIM15 ((uint32_t)0x00010000) +#define RCC_APB2Periph_TIM16 ((uint32_t)0x00020000) +#define RCC_APB2Periph_TIM17 ((uint32_t)0x00040000) +#define RCC_APB2Periph_TIM9 ((uint32_t)0x00080000) +#define RCC_APB2Periph_TIM10 ((uint32_t)0x00100000) +#define RCC_APB2Periph_TIM11 ((uint32_t)0x00200000) + +#define IS_RCC_APB2_PERIPH(PERIPH) ((((PERIPH) & 0xFFC00002) == 0x00) && ((PERIPH) != 0x00)) +/** + * @} + */ + +/** @defgroup APB1_peripheral + * @{ + */ + +#define RCC_APB1Periph_TIM2 ((uint32_t)0x00000001) +#define RCC_APB1Periph_TIM3 ((uint32_t)0x00000002) +#define RCC_APB1Periph_TIM4 ((uint32_t)0x00000004) +#define RCC_APB1Periph_TIM5 ((uint32_t)0x00000008) +#define RCC_APB1Periph_TIM6 ((uint32_t)0x00000010) +#define RCC_APB1Periph_TIM7 ((uint32_t)0x00000020) +#define RCC_APB1Periph_TIM12 ((uint32_t)0x00000040) +#define RCC_APB1Periph_TIM13 ((uint32_t)0x00000080) +#define RCC_APB1Periph_TIM14 ((uint32_t)0x00000100) +#define RCC_APB1Periph_WWDG ((uint32_t)0x00000800) +#define RCC_APB1Periph_SPI2 ((uint32_t)0x00004000) +#define RCC_APB1Periph_SPI3 ((uint32_t)0x00008000) +#define RCC_APB1Periph_USART2 ((uint32_t)0x00020000) +#define RCC_APB1Periph_USART3 ((uint32_t)0x00040000) +#define RCC_APB1Periph_UART4 ((uint32_t)0x00080000) +#define RCC_APB1Periph_UART5 ((uint32_t)0x00100000) +#define RCC_APB1Periph_I2C1 ((uint32_t)0x00200000) +#define RCC_APB1Periph_I2C2 ((uint32_t)0x00400000) +#define RCC_APB1Periph_USB ((uint32_t)0x00800000) +#define RCC_APB1Periph_CAN1 ((uint32_t)0x02000000) +#define RCC_APB1Periph_CAN2 ((uint32_t)0x04000000) +#define RCC_APB1Periph_BKP ((uint32_t)0x08000000) +#define RCC_APB1Periph_PWR ((uint32_t)0x10000000) +#define RCC_APB1Periph_DAC ((uint32_t)0x20000000) +#define RCC_APB1Periph_CEC ((uint32_t)0x40000000) + +#define IS_RCC_APB1_PERIPH(PERIPH) ((((PERIPH) & 0x81013600) == 0x00) && ((PERIPH) != 0x00)) + +/** + * @} + */ + +/** @defgroup Clock_source_to_output_on_MCO_pin + * @{ + */ + +#define RCC_MCO_NoClock ((uint8_t)0x00) +#define RCC_MCO_SYSCLK ((uint8_t)0x04) +#define RCC_MCO_HSI ((uint8_t)0x05) +#define RCC_MCO_HSE ((uint8_t)0x06) +#define RCC_MCO_PLLCLK_Div2 ((uint8_t)0x07) + +#ifndef STM32F10X_CL + #define IS_RCC_MCO(MCO) (((MCO) == RCC_MCO_NoClock) || ((MCO) == RCC_MCO_HSI) || \ + ((MCO) == RCC_MCO_SYSCLK) || ((MCO) == RCC_MCO_HSE) || \ + ((MCO) == RCC_MCO_PLLCLK_Div2)) +#else + #define RCC_MCO_PLL2CLK ((uint8_t)0x08) + #define RCC_MCO_PLL3CLK_Div2 ((uint8_t)0x09) + #define RCC_MCO_XT1 ((uint8_t)0x0A) + #define RCC_MCO_PLL3CLK ((uint8_t)0x0B) + + #define IS_RCC_MCO(MCO) (((MCO) == RCC_MCO_NoClock) || ((MCO) == RCC_MCO_HSI) || \ + ((MCO) == RCC_MCO_SYSCLK) || ((MCO) == RCC_MCO_HSE) || \ + ((MCO) == RCC_MCO_PLLCLK_Div2) || ((MCO) == RCC_MCO_PLL2CLK) || \ + ((MCO) == RCC_MCO_PLL3CLK_Div2) || ((MCO) == RCC_MCO_XT1) || \ + ((MCO) == RCC_MCO_PLL3CLK)) +#endif /* STM32F10X_CL */ + +/** + * @} + */ + +/** @defgroup RCC_Flag + * @{ + */ + +#define RCC_FLAG_HSIRDY ((uint8_t)0x21) +#define RCC_FLAG_HSERDY ((uint8_t)0x31) +#define RCC_FLAG_PLLRDY ((uint8_t)0x39) +#define RCC_FLAG_LSERDY ((uint8_t)0x41) +#define RCC_FLAG_LSIRDY ((uint8_t)0x61) +#define RCC_FLAG_PINRST ((uint8_t)0x7A) +#define RCC_FLAG_PORRST ((uint8_t)0x7B) +#define RCC_FLAG_SFTRST ((uint8_t)0x7C) +#define RCC_FLAG_IWDGRST ((uint8_t)0x7D) +#define RCC_FLAG_WWDGRST ((uint8_t)0x7E) +#define RCC_FLAG_LPWRRST ((uint8_t)0x7F) + +#ifndef STM32F10X_CL + #define IS_RCC_FLAG(FLAG) (((FLAG) == RCC_FLAG_HSIRDY) || ((FLAG) == RCC_FLAG_HSERDY) || \ + ((FLAG) == RCC_FLAG_PLLRDY) || ((FLAG) == RCC_FLAG_LSERDY) || \ + ((FLAG) == RCC_FLAG_LSIRDY) || ((FLAG) == RCC_FLAG_PINRST) || \ + ((FLAG) == RCC_FLAG_PORRST) || ((FLAG) == RCC_FLAG_SFTRST) || \ + ((FLAG) == RCC_FLAG_IWDGRST)|| ((FLAG) == RCC_FLAG_WWDGRST)|| \ + ((FLAG) == RCC_FLAG_LPWRRST)) +#else + #define RCC_FLAG_PLL2RDY ((uint8_t)0x3B) + #define RCC_FLAG_PLL3RDY ((uint8_t)0x3D) + #define IS_RCC_FLAG(FLAG) (((FLAG) == RCC_FLAG_HSIRDY) || ((FLAG) == RCC_FLAG_HSERDY) || \ + ((FLAG) == RCC_FLAG_PLLRDY) || ((FLAG) == RCC_FLAG_LSERDY) || \ + ((FLAG) == RCC_FLAG_PLL2RDY) || ((FLAG) == RCC_FLAG_PLL3RDY) || \ + ((FLAG) == RCC_FLAG_LSIRDY) || ((FLAG) == RCC_FLAG_PINRST) || \ + ((FLAG) == RCC_FLAG_PORRST) || ((FLAG) == RCC_FLAG_SFTRST) || \ + ((FLAG) == RCC_FLAG_IWDGRST)|| ((FLAG) == RCC_FLAG_WWDGRST)|| \ + ((FLAG) == RCC_FLAG_LPWRRST)) +#endif /* STM32F10X_CL */ + +#define IS_RCC_CALIBRATION_VALUE(VALUE) ((VALUE) <= 0x1F) +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup RCC_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup RCC_Exported_Functions + * @{ + */ + +void RCC_DeInit(void); +void RCC_HSEConfig(uint32_t RCC_HSE); +ErrorStatus RCC_WaitForHSEStartUp(void); +void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue); +void RCC_HSICmd(FunctionalState NewState); +void RCC_PLLConfig(uint32_t RCC_PLLSource, uint32_t RCC_PLLMul); +void RCC_PLLCmd(FunctionalState NewState); + +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) || defined (STM32F10X_CL) + void RCC_PREDIV1Config(uint32_t RCC_PREDIV1_Source, uint32_t RCC_PREDIV1_Div); +#endif + +#ifdef STM32F10X_CL + void RCC_PREDIV2Config(uint32_t RCC_PREDIV2_Div); + void RCC_PLL2Config(uint32_t RCC_PLL2Mul); + void RCC_PLL2Cmd(FunctionalState NewState); + void RCC_PLL3Config(uint32_t RCC_PLL3Mul); + void RCC_PLL3Cmd(FunctionalState NewState); +#endif /* STM32F10X_CL */ + +void RCC_SYSCLKConfig(uint32_t RCC_SYSCLKSource); +uint8_t RCC_GetSYSCLKSource(void); +void RCC_HCLKConfig(uint32_t RCC_SYSCLK); +void RCC_PCLK1Config(uint32_t RCC_HCLK); +void RCC_PCLK2Config(uint32_t RCC_HCLK); +void RCC_ITConfig(uint8_t RCC_IT, FunctionalState NewState); + +#ifndef STM32F10X_CL + void RCC_USBCLKConfig(uint32_t RCC_USBCLKSource); +#else + void RCC_OTGFSCLKConfig(uint32_t RCC_OTGFSCLKSource); +#endif /* STM32F10X_CL */ + +void RCC_ADCCLKConfig(uint32_t RCC_PCLK2); + +#ifdef STM32F10X_CL + void RCC_I2S2CLKConfig(uint32_t RCC_I2S2CLKSource); + void RCC_I2S3CLKConfig(uint32_t RCC_I2S3CLKSource); +#endif /* STM32F10X_CL */ + +void RCC_LSEConfig(uint8_t RCC_LSE); +void RCC_LSICmd(FunctionalState NewState); +void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource); +void RCC_RTCCLKCmd(FunctionalState NewState); +void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks); +void RCC_AHBPeriphClockCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState); +void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState); +void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState); + +#ifdef STM32F10X_CL +void RCC_AHBPeriphResetCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState); +#endif /* STM32F10X_CL */ + +void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState); +void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState); +void RCC_BackupResetCmd(FunctionalState NewState); +void RCC_ClockSecuritySystemCmd(FunctionalState NewState); +void RCC_MCOConfig(uint8_t RCC_MCO); +FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG); +void RCC_ClearFlag(void); +ITStatus RCC_GetITStatus(uint8_t RCC_IT); +void RCC_ClearITPendingBit(uint8_t RCC_IT); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_RCC_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_rtc.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_rtc.h new file mode 100755 index 0000000..214a589 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_rtc.h @@ -0,0 +1,135 @@ +/** + ****************************************************************************** + * @file stm32f10x_rtc.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the RTC firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_RTC_H +#define __STM32F10x_RTC_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup RTC + * @{ + */ + +/** @defgroup RTC_Exported_Types + * @{ + */ + +/** + * @} + */ + +/** @defgroup RTC_Exported_Constants + * @{ + */ + +/** @defgroup RTC_interrupts_define + * @{ + */ + +#define RTC_IT_OW ((uint16_t)0x0004) /*!< Overflow interrupt */ +#define RTC_IT_ALR ((uint16_t)0x0002) /*!< Alarm interrupt */ +#define RTC_IT_SEC ((uint16_t)0x0001) /*!< Second interrupt */ +#define IS_RTC_IT(IT) ((((IT) & (uint16_t)0xFFF8) == 0x00) && ((IT) != 0x00)) +#define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_OW) || ((IT) == RTC_IT_ALR) || \ + ((IT) == RTC_IT_SEC)) +/** + * @} + */ + +/** @defgroup RTC_interrupts_flags + * @{ + */ + +#define RTC_FLAG_RTOFF ((uint16_t)0x0020) /*!< RTC Operation OFF flag */ +#define RTC_FLAG_RSF ((uint16_t)0x0008) /*!< Registers Synchronized flag */ +#define RTC_FLAG_OW ((uint16_t)0x0004) /*!< Overflow flag */ +#define RTC_FLAG_ALR ((uint16_t)0x0002) /*!< Alarm flag */ +#define RTC_FLAG_SEC ((uint16_t)0x0001) /*!< Second flag */ +#define IS_RTC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFFF0) == 0x00) && ((FLAG) != 0x00)) +#define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_RTOFF) || ((FLAG) == RTC_FLAG_RSF) || \ + ((FLAG) == RTC_FLAG_OW) || ((FLAG) == RTC_FLAG_ALR) || \ + ((FLAG) == RTC_FLAG_SEC)) +#define IS_RTC_PRESCALER(PRESCALER) ((PRESCALER) <= 0xFFFFF) + +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup RTC_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup RTC_Exported_Functions + * @{ + */ + +void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState); +void RTC_EnterConfigMode(void); +void RTC_ExitConfigMode(void); +uint32_t RTC_GetCounter(void); +void RTC_SetCounter(uint32_t CounterValue); +void RTC_SetPrescaler(uint32_t PrescalerValue); +void RTC_SetAlarm(uint32_t AlarmValue); +uint32_t RTC_GetDivider(void); +void RTC_WaitForLastTask(void); +void RTC_WaitForSynchro(void); +FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG); +void RTC_ClearFlag(uint16_t RTC_FLAG); +ITStatus RTC_GetITStatus(uint16_t RTC_IT); +void RTC_ClearITPendingBit(uint16_t RTC_IT); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_RTC_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_sdio.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_sdio.h new file mode 100755 index 0000000..40cfded --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_sdio.h @@ -0,0 +1,531 @@ +/** + ****************************************************************************** + * @file stm32f10x_sdio.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the SDIO firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_SDIO_H +#define __STM32F10x_SDIO_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup SDIO + * @{ + */ + +/** @defgroup SDIO_Exported_Types + * @{ + */ + +typedef struct +{ + uint32_t SDIO_ClockEdge; /*!< Specifies the clock transition on which the bit capture is made. + This parameter can be a value of @ref SDIO_Clock_Edge */ + + uint32_t SDIO_ClockBypass; /*!< Specifies whether the SDIO Clock divider bypass is + enabled or disabled. + This parameter can be a value of @ref SDIO_Clock_Bypass */ + + uint32_t SDIO_ClockPowerSave; /*!< Specifies whether SDIO Clock output is enabled or + disabled when the bus is idle. + This parameter can be a value of @ref SDIO_Clock_Power_Save */ + + uint32_t SDIO_BusWide; /*!< Specifies the SDIO bus width. + This parameter can be a value of @ref SDIO_Bus_Wide */ + + uint32_t SDIO_HardwareFlowControl; /*!< Specifies whether the SDIO hardware flow control is enabled or disabled. + This parameter can be a value of @ref SDIO_Hardware_Flow_Control */ + + uint8_t SDIO_ClockDiv; /*!< Specifies the clock frequency of the SDIO controller. + This parameter can be a value between 0x00 and 0xFF. */ + +} SDIO_InitTypeDef; + +typedef struct +{ + uint32_t SDIO_Argument; /*!< Specifies the SDIO command argument which is sent + to a card as part of a command message. If a command + contains an argument, it must be loaded into this register + before writing the command to the command register */ + + uint32_t SDIO_CmdIndex; /*!< Specifies the SDIO command index. It must be lower than 0x40. */ + + uint32_t SDIO_Response; /*!< Specifies the SDIO response type. + This parameter can be a value of @ref SDIO_Response_Type */ + + uint32_t SDIO_Wait; /*!< Specifies whether SDIO wait-for-interrupt request is enabled or disabled. + This parameter can be a value of @ref SDIO_Wait_Interrupt_State */ + + uint32_t SDIO_CPSM; /*!< Specifies whether SDIO Command path state machine (CPSM) + is enabled or disabled. + This parameter can be a value of @ref SDIO_CPSM_State */ +} SDIO_CmdInitTypeDef; + +typedef struct +{ + uint32_t SDIO_DataTimeOut; /*!< Specifies the data timeout period in card bus clock periods. */ + + uint32_t SDIO_DataLength; /*!< Specifies the number of data bytes to be transferred. */ + + uint32_t SDIO_DataBlockSize; /*!< Specifies the data block size for block transfer. + This parameter can be a value of @ref SDIO_Data_Block_Size */ + + uint32_t SDIO_TransferDir; /*!< Specifies the data transfer direction, whether the transfer + is a read or write. + This parameter can be a value of @ref SDIO_Transfer_Direction */ + + uint32_t SDIO_TransferMode; /*!< Specifies whether data transfer is in stream or block mode. + This parameter can be a value of @ref SDIO_Transfer_Type */ + + uint32_t SDIO_DPSM; /*!< Specifies whether SDIO Data path state machine (DPSM) + is enabled or disabled. + This parameter can be a value of @ref SDIO_DPSM_State */ +} SDIO_DataInitTypeDef; + +/** + * @} + */ + +/** @defgroup SDIO_Exported_Constants + * @{ + */ + +/** @defgroup SDIO_Clock_Edge + * @{ + */ + +#define SDIO_ClockEdge_Rising ((uint32_t)0x00000000) +#define SDIO_ClockEdge_Falling ((uint32_t)0x00002000) +#define IS_SDIO_CLOCK_EDGE(EDGE) (((EDGE) == SDIO_ClockEdge_Rising) || \ + ((EDGE) == SDIO_ClockEdge_Falling)) +/** + * @} + */ + +/** @defgroup SDIO_Clock_Bypass + * @{ + */ + +#define SDIO_ClockBypass_Disable ((uint32_t)0x00000000) +#define SDIO_ClockBypass_Enable ((uint32_t)0x00000400) +#define IS_SDIO_CLOCK_BYPASS(BYPASS) (((BYPASS) == SDIO_ClockBypass_Disable) || \ + ((BYPASS) == SDIO_ClockBypass_Enable)) +/** + * @} + */ + +/** @defgroup SDIO_Clock_Power_Save + * @{ + */ + +#define SDIO_ClockPowerSave_Disable ((uint32_t)0x00000000) +#define SDIO_ClockPowerSave_Enable ((uint32_t)0x00000200) +#define IS_SDIO_CLOCK_POWER_SAVE(SAVE) (((SAVE) == SDIO_ClockPowerSave_Disable) || \ + ((SAVE) == SDIO_ClockPowerSave_Enable)) +/** + * @} + */ + +/** @defgroup SDIO_Bus_Wide + * @{ + */ + +#define SDIO_BusWide_1b ((uint32_t)0x00000000) +#define SDIO_BusWide_4b ((uint32_t)0x00000800) +#define SDIO_BusWide_8b ((uint32_t)0x00001000) +#define IS_SDIO_BUS_WIDE(WIDE) (((WIDE) == SDIO_BusWide_1b) || ((WIDE) == SDIO_BusWide_4b) || \ + ((WIDE) == SDIO_BusWide_8b)) + +/** + * @} + */ + +/** @defgroup SDIO_Hardware_Flow_Control + * @{ + */ + +#define SDIO_HardwareFlowControl_Disable ((uint32_t)0x00000000) +#define SDIO_HardwareFlowControl_Enable ((uint32_t)0x00004000) +#define IS_SDIO_HARDWARE_FLOW_CONTROL(CONTROL) (((CONTROL) == SDIO_HardwareFlowControl_Disable) || \ + ((CONTROL) == SDIO_HardwareFlowControl_Enable)) +/** + * @} + */ + +/** @defgroup SDIO_Power_State + * @{ + */ + +#define SDIO_PowerState_OFF ((uint32_t)0x00000000) +#define SDIO_PowerState_ON ((uint32_t)0x00000003) +#define IS_SDIO_POWER_STATE(STATE) (((STATE) == SDIO_PowerState_OFF) || ((STATE) == SDIO_PowerState_ON)) +/** + * @} + */ + + +/** @defgroup SDIO_Interrupt_sources + * @{ + */ + +#define SDIO_IT_CCRCFAIL ((uint32_t)0x00000001) +#define SDIO_IT_DCRCFAIL ((uint32_t)0x00000002) +#define SDIO_IT_CTIMEOUT ((uint32_t)0x00000004) +#define SDIO_IT_DTIMEOUT ((uint32_t)0x00000008) +#define SDIO_IT_TXUNDERR ((uint32_t)0x00000010) +#define SDIO_IT_RXOVERR ((uint32_t)0x00000020) +#define SDIO_IT_CMDREND ((uint32_t)0x00000040) +#define SDIO_IT_CMDSENT ((uint32_t)0x00000080) +#define SDIO_IT_DATAEND ((uint32_t)0x00000100) +#define SDIO_IT_STBITERR ((uint32_t)0x00000200) +#define SDIO_IT_DBCKEND ((uint32_t)0x00000400) +#define SDIO_IT_CMDACT ((uint32_t)0x00000800) +#define SDIO_IT_TXACT ((uint32_t)0x00001000) +#define SDIO_IT_RXACT ((uint32_t)0x00002000) +#define SDIO_IT_TXFIFOHE ((uint32_t)0x00004000) +#define SDIO_IT_RXFIFOHF ((uint32_t)0x00008000) +#define SDIO_IT_TXFIFOF ((uint32_t)0x00010000) +#define SDIO_IT_RXFIFOF ((uint32_t)0x00020000) +#define SDIO_IT_TXFIFOE ((uint32_t)0x00040000) +#define SDIO_IT_RXFIFOE ((uint32_t)0x00080000) +#define SDIO_IT_TXDAVL ((uint32_t)0x00100000) +#define SDIO_IT_RXDAVL ((uint32_t)0x00200000) +#define SDIO_IT_SDIOIT ((uint32_t)0x00400000) +#define SDIO_IT_CEATAEND ((uint32_t)0x00800000) +#define IS_SDIO_IT(IT) ((((IT) & (uint32_t)0xFF000000) == 0x00) && ((IT) != (uint32_t)0x00)) +/** + * @} + */ + +/** @defgroup SDIO_Command_Index + * @{ + */ + +#define IS_SDIO_CMD_INDEX(INDEX) ((INDEX) < 0x40) +/** + * @} + */ + +/** @defgroup SDIO_Response_Type + * @{ + */ + +#define SDIO_Response_No ((uint32_t)0x00000000) +#define SDIO_Response_Short ((uint32_t)0x00000040) +#define SDIO_Response_Long ((uint32_t)0x000000C0) +#define IS_SDIO_RESPONSE(RESPONSE) (((RESPONSE) == SDIO_Response_No) || \ + ((RESPONSE) == SDIO_Response_Short) || \ + ((RESPONSE) == SDIO_Response_Long)) +/** + * @} + */ + +/** @defgroup SDIO_Wait_Interrupt_State + * @{ + */ + +#define SDIO_Wait_No ((uint32_t)0x00000000) /*!< SDIO No Wait, TimeOut is enabled */ +#define SDIO_Wait_IT ((uint32_t)0x00000100) /*!< SDIO Wait Interrupt Request */ +#define SDIO_Wait_Pend ((uint32_t)0x00000200) /*!< SDIO Wait End of transfer */ +#define IS_SDIO_WAIT(WAIT) (((WAIT) == SDIO_Wait_No) || ((WAIT) == SDIO_Wait_IT) || \ + ((WAIT) == SDIO_Wait_Pend)) +/** + * @} + */ + +/** @defgroup SDIO_CPSM_State + * @{ + */ + +#define SDIO_CPSM_Disable ((uint32_t)0x00000000) +#define SDIO_CPSM_Enable ((uint32_t)0x00000400) +#define IS_SDIO_CPSM(CPSM) (((CPSM) == SDIO_CPSM_Enable) || ((CPSM) == SDIO_CPSM_Disable)) +/** + * @} + */ + +/** @defgroup SDIO_Response_Registers + * @{ + */ + +#define SDIO_RESP1 ((uint32_t)0x00000000) +#define SDIO_RESP2 ((uint32_t)0x00000004) +#define SDIO_RESP3 ((uint32_t)0x00000008) +#define SDIO_RESP4 ((uint32_t)0x0000000C) +#define IS_SDIO_RESP(RESP) (((RESP) == SDIO_RESP1) || ((RESP) == SDIO_RESP2) || \ + ((RESP) == SDIO_RESP3) || ((RESP) == SDIO_RESP4)) +/** + * @} + */ + +/** @defgroup SDIO_Data_Length + * @{ + */ + +#define IS_SDIO_DATA_LENGTH(LENGTH) ((LENGTH) <= 0x01FFFFFF) +/** + * @} + */ + +/** @defgroup SDIO_Data_Block_Size + * @{ + */ + +#define SDIO_DataBlockSize_1b ((uint32_t)0x00000000) +#define SDIO_DataBlockSize_2b ((uint32_t)0x00000010) +#define SDIO_DataBlockSize_4b ((uint32_t)0x00000020) +#define SDIO_DataBlockSize_8b ((uint32_t)0x00000030) +#define SDIO_DataBlockSize_16b ((uint32_t)0x00000040) +#define SDIO_DataBlockSize_32b ((uint32_t)0x00000050) +#define SDIO_DataBlockSize_64b ((uint32_t)0x00000060) +#define SDIO_DataBlockSize_128b ((uint32_t)0x00000070) +#define SDIO_DataBlockSize_256b ((uint32_t)0x00000080) +#define SDIO_DataBlockSize_512b ((uint32_t)0x00000090) +#define SDIO_DataBlockSize_1024b ((uint32_t)0x000000A0) +#define SDIO_DataBlockSize_2048b ((uint32_t)0x000000B0) +#define SDIO_DataBlockSize_4096b ((uint32_t)0x000000C0) +#define SDIO_DataBlockSize_8192b ((uint32_t)0x000000D0) +#define SDIO_DataBlockSize_16384b ((uint32_t)0x000000E0) +#define IS_SDIO_BLOCK_SIZE(SIZE) (((SIZE) == SDIO_DataBlockSize_1b) || \ + ((SIZE) == SDIO_DataBlockSize_2b) || \ + ((SIZE) == SDIO_DataBlockSize_4b) || \ + ((SIZE) == SDIO_DataBlockSize_8b) || \ + ((SIZE) == SDIO_DataBlockSize_16b) || \ + ((SIZE) == SDIO_DataBlockSize_32b) || \ + ((SIZE) == SDIO_DataBlockSize_64b) || \ + ((SIZE) == SDIO_DataBlockSize_128b) || \ + ((SIZE) == SDIO_DataBlockSize_256b) || \ + ((SIZE) == SDIO_DataBlockSize_512b) || \ + ((SIZE) == SDIO_DataBlockSize_1024b) || \ + ((SIZE) == SDIO_DataBlockSize_2048b) || \ + ((SIZE) == SDIO_DataBlockSize_4096b) || \ + ((SIZE) == SDIO_DataBlockSize_8192b) || \ + ((SIZE) == SDIO_DataBlockSize_16384b)) +/** + * @} + */ + +/** @defgroup SDIO_Transfer_Direction + * @{ + */ + +#define SDIO_TransferDir_ToCard ((uint32_t)0x00000000) +#define SDIO_TransferDir_ToSDIO ((uint32_t)0x00000002) +#define IS_SDIO_TRANSFER_DIR(DIR) (((DIR) == SDIO_TransferDir_ToCard) || \ + ((DIR) == SDIO_TransferDir_ToSDIO)) +/** + * @} + */ + +/** @defgroup SDIO_Transfer_Type + * @{ + */ + +#define SDIO_TransferMode_Block ((uint32_t)0x00000000) +#define SDIO_TransferMode_Stream ((uint32_t)0x00000004) +#define IS_SDIO_TRANSFER_MODE(MODE) (((MODE) == SDIO_TransferMode_Stream) || \ + ((MODE) == SDIO_TransferMode_Block)) +/** + * @} + */ + +/** @defgroup SDIO_DPSM_State + * @{ + */ + +#define SDIO_DPSM_Disable ((uint32_t)0x00000000) +#define SDIO_DPSM_Enable ((uint32_t)0x00000001) +#define IS_SDIO_DPSM(DPSM) (((DPSM) == SDIO_DPSM_Enable) || ((DPSM) == SDIO_DPSM_Disable)) +/** + * @} + */ + +/** @defgroup SDIO_Flags + * @{ + */ + +#define SDIO_FLAG_CCRCFAIL ((uint32_t)0x00000001) +#define SDIO_FLAG_DCRCFAIL ((uint32_t)0x00000002) +#define SDIO_FLAG_CTIMEOUT ((uint32_t)0x00000004) +#define SDIO_FLAG_DTIMEOUT ((uint32_t)0x00000008) +#define SDIO_FLAG_TXUNDERR ((uint32_t)0x00000010) +#define SDIO_FLAG_RXOVERR ((uint32_t)0x00000020) +#define SDIO_FLAG_CMDREND ((uint32_t)0x00000040) +#define SDIO_FLAG_CMDSENT ((uint32_t)0x00000080) +#define SDIO_FLAG_DATAEND ((uint32_t)0x00000100) +#define SDIO_FLAG_STBITERR ((uint32_t)0x00000200) +#define SDIO_FLAG_DBCKEND ((uint32_t)0x00000400) +#define SDIO_FLAG_CMDACT ((uint32_t)0x00000800) +#define SDIO_FLAG_TXACT ((uint32_t)0x00001000) +#define SDIO_FLAG_RXACT ((uint32_t)0x00002000) +#define SDIO_FLAG_TXFIFOHE ((uint32_t)0x00004000) +#define SDIO_FLAG_RXFIFOHF ((uint32_t)0x00008000) +#define SDIO_FLAG_TXFIFOF ((uint32_t)0x00010000) +#define SDIO_FLAG_RXFIFOF ((uint32_t)0x00020000) +#define SDIO_FLAG_TXFIFOE ((uint32_t)0x00040000) +#define SDIO_FLAG_RXFIFOE ((uint32_t)0x00080000) +#define SDIO_FLAG_TXDAVL ((uint32_t)0x00100000) +#define SDIO_FLAG_RXDAVL ((uint32_t)0x00200000) +#define SDIO_FLAG_SDIOIT ((uint32_t)0x00400000) +#define SDIO_FLAG_CEATAEND ((uint32_t)0x00800000) +#define IS_SDIO_FLAG(FLAG) (((FLAG) == SDIO_FLAG_CCRCFAIL) || \ + ((FLAG) == SDIO_FLAG_DCRCFAIL) || \ + ((FLAG) == SDIO_FLAG_CTIMEOUT) || \ + ((FLAG) == SDIO_FLAG_DTIMEOUT) || \ + ((FLAG) == SDIO_FLAG_TXUNDERR) || \ + ((FLAG) == SDIO_FLAG_RXOVERR) || \ + ((FLAG) == SDIO_FLAG_CMDREND) || \ + ((FLAG) == SDIO_FLAG_CMDSENT) || \ + ((FLAG) == SDIO_FLAG_DATAEND) || \ + ((FLAG) == SDIO_FLAG_STBITERR) || \ + ((FLAG) == SDIO_FLAG_DBCKEND) || \ + ((FLAG) == SDIO_FLAG_CMDACT) || \ + ((FLAG) == SDIO_FLAG_TXACT) || \ + ((FLAG) == SDIO_FLAG_RXACT) || \ + ((FLAG) == SDIO_FLAG_TXFIFOHE) || \ + ((FLAG) == SDIO_FLAG_RXFIFOHF) || \ + ((FLAG) == SDIO_FLAG_TXFIFOF) || \ + ((FLAG) == SDIO_FLAG_RXFIFOF) || \ + ((FLAG) == SDIO_FLAG_TXFIFOE) || \ + ((FLAG) == SDIO_FLAG_RXFIFOE) || \ + ((FLAG) == SDIO_FLAG_TXDAVL) || \ + ((FLAG) == SDIO_FLAG_RXDAVL) || \ + ((FLAG) == SDIO_FLAG_SDIOIT) || \ + ((FLAG) == SDIO_FLAG_CEATAEND)) + +#define IS_SDIO_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFF3FF800) == 0x00) && ((FLAG) != (uint32_t)0x00)) + +#define IS_SDIO_GET_IT(IT) (((IT) == SDIO_IT_CCRCFAIL) || \ + ((IT) == SDIO_IT_DCRCFAIL) || \ + ((IT) == SDIO_IT_CTIMEOUT) || \ + ((IT) == SDIO_IT_DTIMEOUT) || \ + ((IT) == SDIO_IT_TXUNDERR) || \ + ((IT) == SDIO_IT_RXOVERR) || \ + ((IT) == SDIO_IT_CMDREND) || \ + ((IT) == SDIO_IT_CMDSENT) || \ + ((IT) == SDIO_IT_DATAEND) || \ + ((IT) == SDIO_IT_STBITERR) || \ + ((IT) == SDIO_IT_DBCKEND) || \ + ((IT) == SDIO_IT_CMDACT) || \ + ((IT) == SDIO_IT_TXACT) || \ + ((IT) == SDIO_IT_RXACT) || \ + ((IT) == SDIO_IT_TXFIFOHE) || \ + ((IT) == SDIO_IT_RXFIFOHF) || \ + ((IT) == SDIO_IT_TXFIFOF) || \ + ((IT) == SDIO_IT_RXFIFOF) || \ + ((IT) == SDIO_IT_TXFIFOE) || \ + ((IT) == SDIO_IT_RXFIFOE) || \ + ((IT) == SDIO_IT_TXDAVL) || \ + ((IT) == SDIO_IT_RXDAVL) || \ + ((IT) == SDIO_IT_SDIOIT) || \ + ((IT) == SDIO_IT_CEATAEND)) + +#define IS_SDIO_CLEAR_IT(IT) ((((IT) & (uint32_t)0xFF3FF800) == 0x00) && ((IT) != (uint32_t)0x00)) + +/** + * @} + */ + +/** @defgroup SDIO_Read_Wait_Mode + * @{ + */ + +#define SDIO_ReadWaitMode_CLK ((uint32_t)0x00000001) +#define SDIO_ReadWaitMode_DATA2 ((uint32_t)0x00000000) +#define IS_SDIO_READWAIT_MODE(MODE) (((MODE) == SDIO_ReadWaitMode_CLK) || \ + ((MODE) == SDIO_ReadWaitMode_DATA2)) +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup SDIO_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup SDIO_Exported_Functions + * @{ + */ + +void SDIO_DeInit(void); +void SDIO_Init(SDIO_InitTypeDef* SDIO_InitStruct); +void SDIO_StructInit(SDIO_InitTypeDef* SDIO_InitStruct); +void SDIO_ClockCmd(FunctionalState NewState); +void SDIO_SetPowerState(uint32_t SDIO_PowerState); +uint32_t SDIO_GetPowerState(void); +void SDIO_ITConfig(uint32_t SDIO_IT, FunctionalState NewState); +void SDIO_DMACmd(FunctionalState NewState); +void SDIO_SendCommand(SDIO_CmdInitTypeDef *SDIO_CmdInitStruct); +void SDIO_CmdStructInit(SDIO_CmdInitTypeDef* SDIO_CmdInitStruct); +uint8_t SDIO_GetCommandResponse(void); +uint32_t SDIO_GetResponse(uint32_t SDIO_RESP); +void SDIO_DataConfig(SDIO_DataInitTypeDef* SDIO_DataInitStruct); +void SDIO_DataStructInit(SDIO_DataInitTypeDef* SDIO_DataInitStruct); +uint32_t SDIO_GetDataCounter(void); +uint32_t SDIO_ReadData(void); +void SDIO_WriteData(uint32_t Data); +uint32_t SDIO_GetFIFOCount(void); +void SDIO_StartSDIOReadWait(FunctionalState NewState); +void SDIO_StopSDIOReadWait(FunctionalState NewState); +void SDIO_SetSDIOReadWaitMode(uint32_t SDIO_ReadWaitMode); +void SDIO_SetSDIOOperation(FunctionalState NewState); +void SDIO_SendSDIOSuspendCmd(FunctionalState NewState); +void SDIO_CommandCompletionCmd(FunctionalState NewState); +void SDIO_CEATAITCmd(FunctionalState NewState); +void SDIO_SendCEATACmd(FunctionalState NewState); +FlagStatus SDIO_GetFlagStatus(uint32_t SDIO_FLAG); +void SDIO_ClearFlag(uint32_t SDIO_FLAG); +ITStatus SDIO_GetITStatus(uint32_t SDIO_IT); +void SDIO_ClearITPendingBit(uint32_t SDIO_IT); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_SDIO_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_spi.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_spi.h new file mode 100755 index 0000000..6056c4c --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_spi.h @@ -0,0 +1,487 @@ +/** + ****************************************************************************** + * @file stm32f10x_spi.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the SPI firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_SPI_H +#define __STM32F10x_SPI_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup SPI + * @{ + */ + +/** @defgroup SPI_Exported_Types + * @{ + */ + +/** + * @brief SPI Init structure definition + */ + +typedef struct +{ + uint16_t SPI_Direction; /*!< Specifies the SPI unidirectional or bidirectional data mode. + This parameter can be a value of @ref SPI_data_direction */ + + uint16_t SPI_Mode; /*!< Specifies the SPI operating mode. + This parameter can be a value of @ref SPI_mode */ + + uint16_t SPI_DataSize; /*!< Specifies the SPI data size. + This parameter can be a value of @ref SPI_data_size */ + + uint16_t SPI_CPOL; /*!< Specifies the serial clock steady state. + This parameter can be a value of @ref SPI_Clock_Polarity */ + + uint16_t SPI_CPHA; /*!< Specifies the clock active edge for the bit capture. + This parameter can be a value of @ref SPI_Clock_Phase */ + + uint16_t SPI_NSS; /*!< Specifies whether the NSS signal is managed by + hardware (NSS pin) or by software using the SSI bit. + This parameter can be a value of @ref SPI_Slave_Select_management */ + + uint16_t SPI_BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be + used to configure the transmit and receive SCK clock. + This parameter can be a value of @ref SPI_BaudRate_Prescaler. + @note The communication clock is derived from the master + clock. The slave clock does not need to be set. */ + + uint16_t SPI_FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit. + This parameter can be a value of @ref SPI_MSB_LSB_transmission */ + + uint16_t SPI_CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation. */ +}SPI_InitTypeDef; + +/** + * @brief I2S Init structure definition + */ + +typedef struct +{ + + uint16_t I2S_Mode; /*!< Specifies the I2S operating mode. + This parameter can be a value of @ref I2S_Mode */ + + uint16_t I2S_Standard; /*!< Specifies the standard used for the I2S communication. + This parameter can be a value of @ref I2S_Standard */ + + uint16_t I2S_DataFormat; /*!< Specifies the data format for the I2S communication. + This parameter can be a value of @ref I2S_Data_Format */ + + uint16_t I2S_MCLKOutput; /*!< Specifies whether the I2S MCLK output is enabled or not. + This parameter can be a value of @ref I2S_MCLK_Output */ + + uint32_t I2S_AudioFreq; /*!< Specifies the frequency selected for the I2S communication. + This parameter can be a value of @ref I2S_Audio_Frequency */ + + uint16_t I2S_CPOL; /*!< Specifies the idle state of the I2S clock. + This parameter can be a value of @ref I2S_Clock_Polarity */ +}I2S_InitTypeDef; + +/** + * @} + */ + +/** @defgroup SPI_Exported_Constants + * @{ + */ + +#define IS_SPI_ALL_PERIPH(PERIPH) (((PERIPH) == SPI1) || \ + ((PERIPH) == SPI2) || \ + ((PERIPH) == SPI3)) + +#define IS_SPI_23_PERIPH(PERIPH) (((PERIPH) == SPI2) || \ + ((PERIPH) == SPI3)) + +/** @defgroup SPI_data_direction + * @{ + */ + +#define SPI_Direction_2Lines_FullDuplex ((uint16_t)0x0000) +#define SPI_Direction_2Lines_RxOnly ((uint16_t)0x0400) +#define SPI_Direction_1Line_Rx ((uint16_t)0x8000) +#define SPI_Direction_1Line_Tx ((uint16_t)0xC000) +#define IS_SPI_DIRECTION_MODE(MODE) (((MODE) == SPI_Direction_2Lines_FullDuplex) || \ + ((MODE) == SPI_Direction_2Lines_RxOnly) || \ + ((MODE) == SPI_Direction_1Line_Rx) || \ + ((MODE) == SPI_Direction_1Line_Tx)) +/** + * @} + */ + +/** @defgroup SPI_mode + * @{ + */ + +#define SPI_Mode_Master ((uint16_t)0x0104) +#define SPI_Mode_Slave ((uint16_t)0x0000) +#define IS_SPI_MODE(MODE) (((MODE) == SPI_Mode_Master) || \ + ((MODE) == SPI_Mode_Slave)) +/** + * @} + */ + +/** @defgroup SPI_data_size + * @{ + */ + +#define SPI_DataSize_16b ((uint16_t)0x0800) +#define SPI_DataSize_8b ((uint16_t)0x0000) +#define IS_SPI_DATASIZE(DATASIZE) (((DATASIZE) == SPI_DataSize_16b) || \ + ((DATASIZE) == SPI_DataSize_8b)) +/** + * @} + */ + +/** @defgroup SPI_Clock_Polarity + * @{ + */ + +#define SPI_CPOL_Low ((uint16_t)0x0000) +#define SPI_CPOL_High ((uint16_t)0x0002) +#define IS_SPI_CPOL(CPOL) (((CPOL) == SPI_CPOL_Low) || \ + ((CPOL) == SPI_CPOL_High)) +/** + * @} + */ + +/** @defgroup SPI_Clock_Phase + * @{ + */ + +#define SPI_CPHA_1Edge ((uint16_t)0x0000) +#define SPI_CPHA_2Edge ((uint16_t)0x0001) +#define IS_SPI_CPHA(CPHA) (((CPHA) == SPI_CPHA_1Edge) || \ + ((CPHA) == SPI_CPHA_2Edge)) +/** + * @} + */ + +/** @defgroup SPI_Slave_Select_management + * @{ + */ + +#define SPI_NSS_Soft ((uint16_t)0x0200) +#define SPI_NSS_Hard ((uint16_t)0x0000) +#define IS_SPI_NSS(NSS) (((NSS) == SPI_NSS_Soft) || \ + ((NSS) == SPI_NSS_Hard)) +/** + * @} + */ + +/** @defgroup SPI_BaudRate_Prescaler + * @{ + */ + +#define SPI_BaudRatePrescaler_2 ((uint16_t)0x0000) +#define SPI_BaudRatePrescaler_4 ((uint16_t)0x0008) +#define SPI_BaudRatePrescaler_8 ((uint16_t)0x0010) +#define SPI_BaudRatePrescaler_16 ((uint16_t)0x0018) +#define SPI_BaudRatePrescaler_32 ((uint16_t)0x0020) +#define SPI_BaudRatePrescaler_64 ((uint16_t)0x0028) +#define SPI_BaudRatePrescaler_128 ((uint16_t)0x0030) +#define SPI_BaudRatePrescaler_256 ((uint16_t)0x0038) +#define IS_SPI_BAUDRATE_PRESCALER(PRESCALER) (((PRESCALER) == SPI_BaudRatePrescaler_2) || \ + ((PRESCALER) == SPI_BaudRatePrescaler_4) || \ + ((PRESCALER) == SPI_BaudRatePrescaler_8) || \ + ((PRESCALER) == SPI_BaudRatePrescaler_16) || \ + ((PRESCALER) == SPI_BaudRatePrescaler_32) || \ + ((PRESCALER) == SPI_BaudRatePrescaler_64) || \ + ((PRESCALER) == SPI_BaudRatePrescaler_128) || \ + ((PRESCALER) == SPI_BaudRatePrescaler_256)) +/** + * @} + */ + +/** @defgroup SPI_MSB_LSB_transmission + * @{ + */ + +#define SPI_FirstBit_MSB ((uint16_t)0x0000) +#define SPI_FirstBit_LSB ((uint16_t)0x0080) +#define IS_SPI_FIRST_BIT(BIT) (((BIT) == SPI_FirstBit_MSB) || \ + ((BIT) == SPI_FirstBit_LSB)) +/** + * @} + */ + +/** @defgroup I2S_Mode + * @{ + */ + +#define I2S_Mode_SlaveTx ((uint16_t)0x0000) +#define I2S_Mode_SlaveRx ((uint16_t)0x0100) +#define I2S_Mode_MasterTx ((uint16_t)0x0200) +#define I2S_Mode_MasterRx ((uint16_t)0x0300) +#define IS_I2S_MODE(MODE) (((MODE) == I2S_Mode_SlaveTx) || \ + ((MODE) == I2S_Mode_SlaveRx) || \ + ((MODE) == I2S_Mode_MasterTx) || \ + ((MODE) == I2S_Mode_MasterRx) ) +/** + * @} + */ + +/** @defgroup I2S_Standard + * @{ + */ + +#define I2S_Standard_Phillips ((uint16_t)0x0000) +#define I2S_Standard_MSB ((uint16_t)0x0010) +#define I2S_Standard_LSB ((uint16_t)0x0020) +#define I2S_Standard_PCMShort ((uint16_t)0x0030) +#define I2S_Standard_PCMLong ((uint16_t)0x00B0) +#define IS_I2S_STANDARD(STANDARD) (((STANDARD) == I2S_Standard_Phillips) || \ + ((STANDARD) == I2S_Standard_MSB) || \ + ((STANDARD) == I2S_Standard_LSB) || \ + ((STANDARD) == I2S_Standard_PCMShort) || \ + ((STANDARD) == I2S_Standard_PCMLong)) +/** + * @} + */ + +/** @defgroup I2S_Data_Format + * @{ + */ + +#define I2S_DataFormat_16b ((uint16_t)0x0000) +#define I2S_DataFormat_16bextended ((uint16_t)0x0001) +#define I2S_DataFormat_24b ((uint16_t)0x0003) +#define I2S_DataFormat_32b ((uint16_t)0x0005) +#define IS_I2S_DATA_FORMAT(FORMAT) (((FORMAT) == I2S_DataFormat_16b) || \ + ((FORMAT) == I2S_DataFormat_16bextended) || \ + ((FORMAT) == I2S_DataFormat_24b) || \ + ((FORMAT) == I2S_DataFormat_32b)) +/** + * @} + */ + +/** @defgroup I2S_MCLK_Output + * @{ + */ + +#define I2S_MCLKOutput_Enable ((uint16_t)0x0200) +#define I2S_MCLKOutput_Disable ((uint16_t)0x0000) +#define IS_I2S_MCLK_OUTPUT(OUTPUT) (((OUTPUT) == I2S_MCLKOutput_Enable) || \ + ((OUTPUT) == I2S_MCLKOutput_Disable)) +/** + * @} + */ + +/** @defgroup I2S_Audio_Frequency + * @{ + */ + +#define I2S_AudioFreq_192k ((uint32_t)192000) +#define I2S_AudioFreq_96k ((uint32_t)96000) +#define I2S_AudioFreq_48k ((uint32_t)48000) +#define I2S_AudioFreq_44k ((uint32_t)44100) +#define I2S_AudioFreq_32k ((uint32_t)32000) +#define I2S_AudioFreq_22k ((uint32_t)22050) +#define I2S_AudioFreq_16k ((uint32_t)16000) +#define I2S_AudioFreq_11k ((uint32_t)11025) +#define I2S_AudioFreq_8k ((uint32_t)8000) +#define I2S_AudioFreq_Default ((uint32_t)2) + +#define IS_I2S_AUDIO_FREQ(FREQ) ((((FREQ) >= I2S_AudioFreq_8k) && \ + ((FREQ) <= I2S_AudioFreq_192k)) || \ + ((FREQ) == I2S_AudioFreq_Default)) +/** + * @} + */ + +/** @defgroup I2S_Clock_Polarity + * @{ + */ + +#define I2S_CPOL_Low ((uint16_t)0x0000) +#define I2S_CPOL_High ((uint16_t)0x0008) +#define IS_I2S_CPOL(CPOL) (((CPOL) == I2S_CPOL_Low) || \ + ((CPOL) == I2S_CPOL_High)) +/** + * @} + */ + +/** @defgroup SPI_I2S_DMA_transfer_requests + * @{ + */ + +#define SPI_I2S_DMAReq_Tx ((uint16_t)0x0002) +#define SPI_I2S_DMAReq_Rx ((uint16_t)0x0001) +#define IS_SPI_I2S_DMAREQ(DMAREQ) ((((DMAREQ) & (uint16_t)0xFFFC) == 0x00) && ((DMAREQ) != 0x00)) +/** + * @} + */ + +/** @defgroup SPI_NSS_internal_software_management + * @{ + */ + +#define SPI_NSSInternalSoft_Set ((uint16_t)0x0100) +#define SPI_NSSInternalSoft_Reset ((uint16_t)0xFEFF) +#define IS_SPI_NSS_INTERNAL(INTERNAL) (((INTERNAL) == SPI_NSSInternalSoft_Set) || \ + ((INTERNAL) == SPI_NSSInternalSoft_Reset)) +/** + * @} + */ + +/** @defgroup SPI_CRC_Transmit_Receive + * @{ + */ + +#define SPI_CRC_Tx ((uint8_t)0x00) +#define SPI_CRC_Rx ((uint8_t)0x01) +#define IS_SPI_CRC(CRC) (((CRC) == SPI_CRC_Tx) || ((CRC) == SPI_CRC_Rx)) +/** + * @} + */ + +/** @defgroup SPI_direction_transmit_receive + * @{ + */ + +#define SPI_Direction_Rx ((uint16_t)0xBFFF) +#define SPI_Direction_Tx ((uint16_t)0x4000) +#define IS_SPI_DIRECTION(DIRECTION) (((DIRECTION) == SPI_Direction_Rx) || \ + ((DIRECTION) == SPI_Direction_Tx)) +/** + * @} + */ + +/** @defgroup SPI_I2S_interrupts_definition + * @{ + */ + +#define SPI_I2S_IT_TXE ((uint8_t)0x71) +#define SPI_I2S_IT_RXNE ((uint8_t)0x60) +#define SPI_I2S_IT_ERR ((uint8_t)0x50) +#define IS_SPI_I2S_CONFIG_IT(IT) (((IT) == SPI_I2S_IT_TXE) || \ + ((IT) == SPI_I2S_IT_RXNE) || \ + ((IT) == SPI_I2S_IT_ERR)) +#define SPI_I2S_IT_OVR ((uint8_t)0x56) +#define SPI_IT_MODF ((uint8_t)0x55) +#define SPI_IT_CRCERR ((uint8_t)0x54) +#define I2S_IT_UDR ((uint8_t)0x53) +#define IS_SPI_I2S_CLEAR_IT(IT) (((IT) == SPI_IT_CRCERR)) +#define IS_SPI_I2S_GET_IT(IT) (((IT) == SPI_I2S_IT_RXNE) || ((IT) == SPI_I2S_IT_TXE) || \ + ((IT) == I2S_IT_UDR) || ((IT) == SPI_IT_CRCERR) || \ + ((IT) == SPI_IT_MODF) || ((IT) == SPI_I2S_IT_OVR)) +/** + * @} + */ + +/** @defgroup SPI_I2S_flags_definition + * @{ + */ + +#define SPI_I2S_FLAG_RXNE ((uint16_t)0x0001) +#define SPI_I2S_FLAG_TXE ((uint16_t)0x0002) +#define I2S_FLAG_CHSIDE ((uint16_t)0x0004) +#define I2S_FLAG_UDR ((uint16_t)0x0008) +#define SPI_FLAG_CRCERR ((uint16_t)0x0010) +#define SPI_FLAG_MODF ((uint16_t)0x0020) +#define SPI_I2S_FLAG_OVR ((uint16_t)0x0040) +#define SPI_I2S_FLAG_BSY ((uint16_t)0x0080) +#define IS_SPI_I2S_CLEAR_FLAG(FLAG) (((FLAG) == SPI_FLAG_CRCERR)) +#define IS_SPI_I2S_GET_FLAG(FLAG) (((FLAG) == SPI_I2S_FLAG_BSY) || ((FLAG) == SPI_I2S_FLAG_OVR) || \ + ((FLAG) == SPI_FLAG_MODF) || ((FLAG) == SPI_FLAG_CRCERR) || \ + ((FLAG) == I2S_FLAG_UDR) || ((FLAG) == I2S_FLAG_CHSIDE) || \ + ((FLAG) == SPI_I2S_FLAG_TXE) || ((FLAG) == SPI_I2S_FLAG_RXNE)) +/** + * @} + */ + +/** @defgroup SPI_CRC_polynomial + * @{ + */ + +#define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL) ((POLYNOMIAL) >= 0x1) +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup SPI_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup SPI_Exported_Functions + * @{ + */ + +void SPI_I2S_DeInit(SPI_TypeDef* SPIx); +void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct); +void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct); +void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct); +void I2S_StructInit(I2S_InitTypeDef* I2S_InitStruct); +void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState); +void I2S_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState); +void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState); +void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState); +void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data); +uint16_t SPI_I2S_ReceiveData(SPI_TypeDef* SPIx); +void SPI_NSSInternalSoftwareConfig(SPI_TypeDef* SPIx, uint16_t SPI_NSSInternalSoft); +void SPI_SSOutputCmd(SPI_TypeDef* SPIx, FunctionalState NewState); +void SPI_DataSizeConfig(SPI_TypeDef* SPIx, uint16_t SPI_DataSize); +void SPI_TransmitCRC(SPI_TypeDef* SPIx); +void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState); +uint16_t SPI_GetCRC(SPI_TypeDef* SPIx, uint8_t SPI_CRC); +uint16_t SPI_GetCRCPolynomial(SPI_TypeDef* SPIx); +void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, uint16_t SPI_Direction); +FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG); +void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG); +ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT); +void SPI_I2S_ClearITPendingBit(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT); + +#ifdef __cplusplus +} +#endif + +#endif /*__STM32F10x_SPI_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_tim.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_tim.h new file mode 100755 index 0000000..cd7ac3e --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_tim.h @@ -0,0 +1,1164 @@ +/** + ****************************************************************************** + * @file stm32f10x_tim.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the TIM firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_TIM_H +#define __STM32F10x_TIM_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup TIM + * @{ + */ + +/** @defgroup TIM_Exported_Types + * @{ + */ + +/** + * @brief TIM Time Base Init structure definition + * @note This structure is used with all TIMx except for TIM6 and TIM7. + */ + +typedef struct +{ + uint16_t TIM_Prescaler; /*!< Specifies the prescaler value used to divide the TIM clock. + This parameter can be a number between 0x0000 and 0xFFFF */ + + uint16_t TIM_CounterMode; /*!< Specifies the counter mode. + This parameter can be a value of @ref TIM_Counter_Mode */ + + uint16_t TIM_Period; /*!< Specifies the period value to be loaded into the active + Auto-Reload Register at the next update event. + This parameter must be a number between 0x0000 and 0xFFFF. */ + + uint16_t TIM_ClockDivision; /*!< Specifies the clock division. + This parameter can be a value of @ref TIM_Clock_Division_CKD */ + + uint8_t TIM_RepetitionCounter; /*!< Specifies the repetition counter value. Each time the RCR downcounter + reaches zero, an update event is generated and counting restarts + from the RCR value (N). + This means in PWM mode that (N+1) corresponds to: + - the number of PWM periods in edge-aligned mode + - the number of half PWM period in center-aligned mode + This parameter must be a number between 0x00 and 0xFF. + @note This parameter is valid only for TIM1 and TIM8. */ +} TIM_TimeBaseInitTypeDef; + +/** + * @brief TIM Output Compare Init structure definition + */ + +typedef struct +{ + uint16_t TIM_OCMode; /*!< Specifies the TIM mode. + This parameter can be a value of @ref TIM_Output_Compare_and_PWM_modes */ + + uint16_t TIM_OutputState; /*!< Specifies the TIM Output Compare state. + This parameter can be a value of @ref TIM_Output_Compare_state */ + + uint16_t TIM_OutputNState; /*!< Specifies the TIM complementary Output Compare state. + This parameter can be a value of @ref TIM_Output_Compare_N_state + @note This parameter is valid only for TIM1 and TIM8. */ + + uint16_t TIM_Pulse; /*!< Specifies the pulse value to be loaded into the Capture Compare Register. + This parameter can be a number between 0x0000 and 0xFFFF */ + + uint16_t TIM_OCPolarity; /*!< Specifies the output polarity. + This parameter can be a value of @ref TIM_Output_Compare_Polarity */ + + uint16_t TIM_OCNPolarity; /*!< Specifies the complementary output polarity. + This parameter can be a value of @ref TIM_Output_Compare_N_Polarity + @note This parameter is valid only for TIM1 and TIM8. */ + + uint16_t TIM_OCIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state. + This parameter can be a value of @ref TIM_Output_Compare_Idle_State + @note This parameter is valid only for TIM1 and TIM8. */ + + uint16_t TIM_OCNIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state. + This parameter can be a value of @ref TIM_Output_Compare_N_Idle_State + @note This parameter is valid only for TIM1 and TIM8. */ +} TIM_OCInitTypeDef; + +/** + * @brief TIM Input Capture Init structure definition + */ + +typedef struct +{ + + uint16_t TIM_Channel; /*!< Specifies the TIM channel. + This parameter can be a value of @ref TIM_Channel */ + + uint16_t TIM_ICPolarity; /*!< Specifies the active edge of the input signal. + This parameter can be a value of @ref TIM_Input_Capture_Polarity */ + + uint16_t TIM_ICSelection; /*!< Specifies the input. + This parameter can be a value of @ref TIM_Input_Capture_Selection */ + + uint16_t TIM_ICPrescaler; /*!< Specifies the Input Capture Prescaler. + This parameter can be a value of @ref TIM_Input_Capture_Prescaler */ + + uint16_t TIM_ICFilter; /*!< Specifies the input capture filter. + This parameter can be a number between 0x0 and 0xF */ +} TIM_ICInitTypeDef; + +/** + * @brief BDTR structure definition + * @note This structure is used only with TIM1 and TIM8. + */ + +typedef struct +{ + + uint16_t TIM_OSSRState; /*!< Specifies the Off-State selection used in Run mode. + This parameter can be a value of @ref OSSR_Off_State_Selection_for_Run_mode_state */ + + uint16_t TIM_OSSIState; /*!< Specifies the Off-State used in Idle state. + This parameter can be a value of @ref OSSI_Off_State_Selection_for_Idle_mode_state */ + + uint16_t TIM_LOCKLevel; /*!< Specifies the LOCK level parameters. + This parameter can be a value of @ref Lock_level */ + + uint16_t TIM_DeadTime; /*!< Specifies the delay time between the switching-off and the + switching-on of the outputs. + This parameter can be a number between 0x00 and 0xFF */ + + uint16_t TIM_Break; /*!< Specifies whether the TIM Break input is enabled or not. + This parameter can be a value of @ref Break_Input_enable_disable */ + + uint16_t TIM_BreakPolarity; /*!< Specifies the TIM Break Input pin polarity. + This parameter can be a value of @ref Break_Polarity */ + + uint16_t TIM_AutomaticOutput; /*!< Specifies whether the TIM Automatic Output feature is enabled or not. + This parameter can be a value of @ref TIM_AOE_Bit_Set_Reset */ +} TIM_BDTRInitTypeDef; + +/** @defgroup TIM_Exported_constants + * @{ + */ + +#define IS_TIM_ALL_PERIPH(PERIPH) (((PERIPH) == TIM1) || \ + ((PERIPH) == TIM2) || \ + ((PERIPH) == TIM3) || \ + ((PERIPH) == TIM4) || \ + ((PERIPH) == TIM5) || \ + ((PERIPH) == TIM6) || \ + ((PERIPH) == TIM7) || \ + ((PERIPH) == TIM8) || \ + ((PERIPH) == TIM9) || \ + ((PERIPH) == TIM10)|| \ + ((PERIPH) == TIM11)|| \ + ((PERIPH) == TIM12)|| \ + ((PERIPH) == TIM13)|| \ + ((PERIPH) == TIM14)|| \ + ((PERIPH) == TIM15)|| \ + ((PERIPH) == TIM16)|| \ + ((PERIPH) == TIM17)) + +/* LIST1: TIM 1 and 8 */ +#define IS_TIM_LIST1_PERIPH(PERIPH) (((PERIPH) == TIM1) || \ + ((PERIPH) == TIM8)) + +/* LIST2: TIM 1, 8, 15 16 and 17 */ +#define IS_TIM_LIST2_PERIPH(PERIPH) (((PERIPH) == TIM1) || \ + ((PERIPH) == TIM8) || \ + ((PERIPH) == TIM15)|| \ + ((PERIPH) == TIM16)|| \ + ((PERIPH) == TIM17)) + +/* LIST3: TIM 1, 2, 3, 4, 5 and 8 */ +#define IS_TIM_LIST3_PERIPH(PERIPH) (((PERIPH) == TIM1) || \ + ((PERIPH) == TIM2) || \ + ((PERIPH) == TIM3) || \ + ((PERIPH) == TIM4) || \ + ((PERIPH) == TIM5) || \ + ((PERIPH) == TIM8)) + +/* LIST4: TIM 1, 2, 3, 4, 5, 8, 15, 16 and 17 */ +#define IS_TIM_LIST4_PERIPH(PERIPH) (((PERIPH) == TIM1) || \ + ((PERIPH) == TIM2) || \ + ((PERIPH) == TIM3) || \ + ((PERIPH) == TIM4) || \ + ((PERIPH) == TIM5) || \ + ((PERIPH) == TIM8) || \ + ((PERIPH) == TIM15)|| \ + ((PERIPH) == TIM16)|| \ + ((PERIPH) == TIM17)) + +/* LIST5: TIM 1, 2, 3, 4, 5, 8 and 15 */ +#define IS_TIM_LIST5_PERIPH(PERIPH) (((PERIPH) == TIM1) || \ + ((PERIPH) == TIM2) || \ + ((PERIPH) == TIM3) || \ + ((PERIPH) == TIM4) || \ + ((PERIPH) == TIM5) || \ + ((PERIPH) == TIM8) || \ + ((PERIPH) == TIM15)) + +/* LIST6: TIM 1, 2, 3, 4, 5, 8, 9, 12 and 15 */ +#define IS_TIM_LIST6_PERIPH(PERIPH) (((PERIPH) == TIM1) || \ + ((PERIPH) == TIM2) || \ + ((PERIPH) == TIM3) || \ + ((PERIPH) == TIM4) || \ + ((PERIPH) == TIM5) || \ + ((PERIPH) == TIM8) || \ + ((PERIPH) == TIM9) || \ + ((PERIPH) == TIM12)|| \ + ((PERIPH) == TIM15)) + +/* LIST7: TIM 1, 2, 3, 4, 5, 6, 7, 8, 9, 12 and 15 */ +#define IS_TIM_LIST7_PERIPH(PERIPH) (((PERIPH) == TIM1) || \ + ((PERIPH) == TIM2) || \ + ((PERIPH) == TIM3) || \ + ((PERIPH) == TIM4) || \ + ((PERIPH) == TIM5) || \ + ((PERIPH) == TIM6) || \ + ((PERIPH) == TIM7) || \ + ((PERIPH) == TIM8) || \ + ((PERIPH) == TIM9) || \ + ((PERIPH) == TIM12)|| \ + ((PERIPH) == TIM15)) + +/* LIST8: TIM 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16 and 17 */ +#define IS_TIM_LIST8_PERIPH(PERIPH) (((PERIPH) == TIM1) || \ + ((PERIPH) == TIM2) || \ + ((PERIPH) == TIM3) || \ + ((PERIPH) == TIM4) || \ + ((PERIPH) == TIM5) || \ + ((PERIPH) == TIM8) || \ + ((PERIPH) == TIM9) || \ + ((PERIPH) == TIM10)|| \ + ((PERIPH) == TIM11)|| \ + ((PERIPH) == TIM12)|| \ + ((PERIPH) == TIM13)|| \ + ((PERIPH) == TIM14)|| \ + ((PERIPH) == TIM15)|| \ + ((PERIPH) == TIM16)|| \ + ((PERIPH) == TIM17)) + +/* LIST9: TIM 1, 2, 3, 4, 5, 6, 7, 8, 15, 16, and 17 */ +#define IS_TIM_LIST9_PERIPH(PERIPH) (((PERIPH) == TIM1) || \ + ((PERIPH) == TIM2) || \ + ((PERIPH) == TIM3) || \ + ((PERIPH) == TIM4) || \ + ((PERIPH) == TIM5) || \ + ((PERIPH) == TIM6) || \ + ((PERIPH) == TIM7) || \ + ((PERIPH) == TIM8) || \ + ((PERIPH) == TIM15)|| \ + ((PERIPH) == TIM16)|| \ + ((PERIPH) == TIM17)) + +/** + * @} + */ + +/** @defgroup TIM_Output_Compare_and_PWM_modes + * @{ + */ + +#define TIM_OCMode_Timing ((uint16_t)0x0000) +#define TIM_OCMode_Active ((uint16_t)0x0010) +#define TIM_OCMode_Inactive ((uint16_t)0x0020) +#define TIM_OCMode_Toggle ((uint16_t)0x0030) +#define TIM_OCMode_PWM1 ((uint16_t)0x0060) +#define TIM_OCMode_PWM2 ((uint16_t)0x0070) +#define IS_TIM_OC_MODE(MODE) (((MODE) == TIM_OCMode_Timing) || \ + ((MODE) == TIM_OCMode_Active) || \ + ((MODE) == TIM_OCMode_Inactive) || \ + ((MODE) == TIM_OCMode_Toggle)|| \ + ((MODE) == TIM_OCMode_PWM1) || \ + ((MODE) == TIM_OCMode_PWM2)) +#define IS_TIM_OCM(MODE) (((MODE) == TIM_OCMode_Timing) || \ + ((MODE) == TIM_OCMode_Active) || \ + ((MODE) == TIM_OCMode_Inactive) || \ + ((MODE) == TIM_OCMode_Toggle)|| \ + ((MODE) == TIM_OCMode_PWM1) || \ + ((MODE) == TIM_OCMode_PWM2) || \ + ((MODE) == TIM_ForcedAction_Active) || \ + ((MODE) == TIM_ForcedAction_InActive)) +/** + * @} + */ + +/** @defgroup TIM_One_Pulse_Mode + * @{ + */ + +#define TIM_OPMode_Single ((uint16_t)0x0008) +#define TIM_OPMode_Repetitive ((uint16_t)0x0000) +#define IS_TIM_OPM_MODE(MODE) (((MODE) == TIM_OPMode_Single) || \ + ((MODE) == TIM_OPMode_Repetitive)) +/** + * @} + */ + +/** @defgroup TIM_Channel + * @{ + */ + +#define TIM_Channel_1 ((uint16_t)0x0000) +#define TIM_Channel_2 ((uint16_t)0x0004) +#define TIM_Channel_3 ((uint16_t)0x0008) +#define TIM_Channel_4 ((uint16_t)0x000C) +#define IS_TIM_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \ + ((CHANNEL) == TIM_Channel_2) || \ + ((CHANNEL) == TIM_Channel_3) || \ + ((CHANNEL) == TIM_Channel_4)) +#define IS_TIM_PWMI_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \ + ((CHANNEL) == TIM_Channel_2)) +#define IS_TIM_COMPLEMENTARY_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \ + ((CHANNEL) == TIM_Channel_2) || \ + ((CHANNEL) == TIM_Channel_3)) +/** + * @} + */ + +/** @defgroup TIM_Clock_Division_CKD + * @{ + */ + +#define TIM_CKD_DIV1 ((uint16_t)0x0000) +#define TIM_CKD_DIV2 ((uint16_t)0x0100) +#define TIM_CKD_DIV4 ((uint16_t)0x0200) +#define IS_TIM_CKD_DIV(DIV) (((DIV) == TIM_CKD_DIV1) || \ + ((DIV) == TIM_CKD_DIV2) || \ + ((DIV) == TIM_CKD_DIV4)) +/** + * @} + */ + +/** @defgroup TIM_Counter_Mode + * @{ + */ + +#define TIM_CounterMode_Up ((uint16_t)0x0000) +#define TIM_CounterMode_Down ((uint16_t)0x0010) +#define TIM_CounterMode_CenterAligned1 ((uint16_t)0x0020) +#define TIM_CounterMode_CenterAligned2 ((uint16_t)0x0040) +#define TIM_CounterMode_CenterAligned3 ((uint16_t)0x0060) +#define IS_TIM_COUNTER_MODE(MODE) (((MODE) == TIM_CounterMode_Up) || \ + ((MODE) == TIM_CounterMode_Down) || \ + ((MODE) == TIM_CounterMode_CenterAligned1) || \ + ((MODE) == TIM_CounterMode_CenterAligned2) || \ + ((MODE) == TIM_CounterMode_CenterAligned3)) +/** + * @} + */ + +/** @defgroup TIM_Output_Compare_Polarity + * @{ + */ + +#define TIM_OCPolarity_High ((uint16_t)0x0000) +#define TIM_OCPolarity_Low ((uint16_t)0x0002) +#define IS_TIM_OC_POLARITY(POLARITY) (((POLARITY) == TIM_OCPolarity_High) || \ + ((POLARITY) == TIM_OCPolarity_Low)) +/** + * @} + */ + +/** @defgroup TIM_Output_Compare_N_Polarity + * @{ + */ + +#define TIM_OCNPolarity_High ((uint16_t)0x0000) +#define TIM_OCNPolarity_Low ((uint16_t)0x0008) +#define IS_TIM_OCN_POLARITY(POLARITY) (((POLARITY) == TIM_OCNPolarity_High) || \ + ((POLARITY) == TIM_OCNPolarity_Low)) +/** + * @} + */ + +/** @defgroup TIM_Output_Compare_state + * @{ + */ + +#define TIM_OutputState_Disable ((uint16_t)0x0000) +#define TIM_OutputState_Enable ((uint16_t)0x0001) +#define IS_TIM_OUTPUT_STATE(STATE) (((STATE) == TIM_OutputState_Disable) || \ + ((STATE) == TIM_OutputState_Enable)) +/** + * @} + */ + +/** @defgroup TIM_Output_Compare_N_state + * @{ + */ + +#define TIM_OutputNState_Disable ((uint16_t)0x0000) +#define TIM_OutputNState_Enable ((uint16_t)0x0004) +#define IS_TIM_OUTPUTN_STATE(STATE) (((STATE) == TIM_OutputNState_Disable) || \ + ((STATE) == TIM_OutputNState_Enable)) +/** + * @} + */ + +/** @defgroup TIM_Capture_Compare_state + * @{ + */ + +#define TIM_CCx_Enable ((uint16_t)0x0001) +#define TIM_CCx_Disable ((uint16_t)0x0000) +#define IS_TIM_CCX(CCX) (((CCX) == TIM_CCx_Enable) || \ + ((CCX) == TIM_CCx_Disable)) +/** + * @} + */ + +/** @defgroup TIM_Capture_Compare_N_state + * @{ + */ + +#define TIM_CCxN_Enable ((uint16_t)0x0004) +#define TIM_CCxN_Disable ((uint16_t)0x0000) +#define IS_TIM_CCXN(CCXN) (((CCXN) == TIM_CCxN_Enable) || \ + ((CCXN) == TIM_CCxN_Disable)) +/** + * @} + */ + +/** @defgroup Break_Input_enable_disable + * @{ + */ + +#define TIM_Break_Enable ((uint16_t)0x1000) +#define TIM_Break_Disable ((uint16_t)0x0000) +#define IS_TIM_BREAK_STATE(STATE) (((STATE) == TIM_Break_Enable) || \ + ((STATE) == TIM_Break_Disable)) +/** + * @} + */ + +/** @defgroup Break_Polarity + * @{ + */ + +#define TIM_BreakPolarity_Low ((uint16_t)0x0000) +#define TIM_BreakPolarity_High ((uint16_t)0x2000) +#define IS_TIM_BREAK_POLARITY(POLARITY) (((POLARITY) == TIM_BreakPolarity_Low) || \ + ((POLARITY) == TIM_BreakPolarity_High)) +/** + * @} + */ + +/** @defgroup TIM_AOE_Bit_Set_Reset + * @{ + */ + +#define TIM_AutomaticOutput_Enable ((uint16_t)0x4000) +#define TIM_AutomaticOutput_Disable ((uint16_t)0x0000) +#define IS_TIM_AUTOMATIC_OUTPUT_STATE(STATE) (((STATE) == TIM_AutomaticOutput_Enable) || \ + ((STATE) == TIM_AutomaticOutput_Disable)) +/** + * @} + */ + +/** @defgroup Lock_level + * @{ + */ + +#define TIM_LOCKLevel_OFF ((uint16_t)0x0000) +#define TIM_LOCKLevel_1 ((uint16_t)0x0100) +#define TIM_LOCKLevel_2 ((uint16_t)0x0200) +#define TIM_LOCKLevel_3 ((uint16_t)0x0300) +#define IS_TIM_LOCK_LEVEL(LEVEL) (((LEVEL) == TIM_LOCKLevel_OFF) || \ + ((LEVEL) == TIM_LOCKLevel_1) || \ + ((LEVEL) == TIM_LOCKLevel_2) || \ + ((LEVEL) == TIM_LOCKLevel_3)) +/** + * @} + */ + +/** @defgroup OSSI_Off_State_Selection_for_Idle_mode_state + * @{ + */ + +#define TIM_OSSIState_Enable ((uint16_t)0x0400) +#define TIM_OSSIState_Disable ((uint16_t)0x0000) +#define IS_TIM_OSSI_STATE(STATE) (((STATE) == TIM_OSSIState_Enable) || \ + ((STATE) == TIM_OSSIState_Disable)) +/** + * @} + */ + +/** @defgroup OSSR_Off_State_Selection_for_Run_mode_state + * @{ + */ + +#define TIM_OSSRState_Enable ((uint16_t)0x0800) +#define TIM_OSSRState_Disable ((uint16_t)0x0000) +#define IS_TIM_OSSR_STATE(STATE) (((STATE) == TIM_OSSRState_Enable) || \ + ((STATE) == TIM_OSSRState_Disable)) +/** + * @} + */ + +/** @defgroup TIM_Output_Compare_Idle_State + * @{ + */ + +#define TIM_OCIdleState_Set ((uint16_t)0x0100) +#define TIM_OCIdleState_Reset ((uint16_t)0x0000) +#define IS_TIM_OCIDLE_STATE(STATE) (((STATE) == TIM_OCIdleState_Set) || \ + ((STATE) == TIM_OCIdleState_Reset)) +/** + * @} + */ + +/** @defgroup TIM_Output_Compare_N_Idle_State + * @{ + */ + +#define TIM_OCNIdleState_Set ((uint16_t)0x0200) +#define TIM_OCNIdleState_Reset ((uint16_t)0x0000) +#define IS_TIM_OCNIDLE_STATE(STATE) (((STATE) == TIM_OCNIdleState_Set) || \ + ((STATE) == TIM_OCNIdleState_Reset)) +/** + * @} + */ + +/** @defgroup TIM_Input_Capture_Polarity + * @{ + */ + +#define TIM_ICPolarity_Rising ((uint16_t)0x0000) +#define TIM_ICPolarity_Falling ((uint16_t)0x0002) +#define TIM_ICPolarity_BothEdge ((uint16_t)0x000A) +#define IS_TIM_IC_POLARITY(POLARITY) (((POLARITY) == TIM_ICPolarity_Rising) || \ + ((POLARITY) == TIM_ICPolarity_Falling)) +#define IS_TIM_IC_POLARITY_LITE(POLARITY) (((POLARITY) == TIM_ICPolarity_Rising) || \ + ((POLARITY) == TIM_ICPolarity_Falling)|| \ + ((POLARITY) == TIM_ICPolarity_BothEdge)) +/** + * @} + */ + +/** @defgroup TIM_Input_Capture_Selection + * @{ + */ + +#define TIM_ICSelection_DirectTI ((uint16_t)0x0001) /*!< TIM Input 1, 2, 3 or 4 is selected to be + connected to IC1, IC2, IC3 or IC4, respectively */ +#define TIM_ICSelection_IndirectTI ((uint16_t)0x0002) /*!< TIM Input 1, 2, 3 or 4 is selected to be + connected to IC2, IC1, IC4 or IC3, respectively. */ +#define TIM_ICSelection_TRC ((uint16_t)0x0003) /*!< TIM Input 1, 2, 3 or 4 is selected to be connected to TRC. */ +#define IS_TIM_IC_SELECTION(SELECTION) (((SELECTION) == TIM_ICSelection_DirectTI) || \ + ((SELECTION) == TIM_ICSelection_IndirectTI) || \ + ((SELECTION) == TIM_ICSelection_TRC)) +/** + * @} + */ + +/** @defgroup TIM_Input_Capture_Prescaler + * @{ + */ + +#define TIM_ICPSC_DIV1 ((uint16_t)0x0000) /*!< Capture performed each time an edge is detected on the capture input. */ +#define TIM_ICPSC_DIV2 ((uint16_t)0x0004) /*!< Capture performed once every 2 events. */ +#define TIM_ICPSC_DIV4 ((uint16_t)0x0008) /*!< Capture performed once every 4 events. */ +#define TIM_ICPSC_DIV8 ((uint16_t)0x000C) /*!< Capture performed once every 8 events. */ +#define IS_TIM_IC_PRESCALER(PRESCALER) (((PRESCALER) == TIM_ICPSC_DIV1) || \ + ((PRESCALER) == TIM_ICPSC_DIV2) || \ + ((PRESCALER) == TIM_ICPSC_DIV4) || \ + ((PRESCALER) == TIM_ICPSC_DIV8)) +/** + * @} + */ + +/** @defgroup TIM_interrupt_sources + * @{ + */ + +#define TIM_IT_Update ((uint16_t)0x0001) +#define TIM_IT_CC1 ((uint16_t)0x0002) +#define TIM_IT_CC2 ((uint16_t)0x0004) +#define TIM_IT_CC3 ((uint16_t)0x0008) +#define TIM_IT_CC4 ((uint16_t)0x0010) +#define TIM_IT_COM ((uint16_t)0x0020) +#define TIM_IT_Trigger ((uint16_t)0x0040) +#define TIM_IT_Break ((uint16_t)0x0080) +#define IS_TIM_IT(IT) ((((IT) & (uint16_t)0xFF00) == 0x0000) && ((IT) != 0x0000)) + +#define IS_TIM_GET_IT(IT) (((IT) == TIM_IT_Update) || \ + ((IT) == TIM_IT_CC1) || \ + ((IT) == TIM_IT_CC2) || \ + ((IT) == TIM_IT_CC3) || \ + ((IT) == TIM_IT_CC4) || \ + ((IT) == TIM_IT_COM) || \ + ((IT) == TIM_IT_Trigger) || \ + ((IT) == TIM_IT_Break)) +/** + * @} + */ + +/** @defgroup TIM_DMA_Base_address + * @{ + */ + +#define TIM_DMABase_CR1 ((uint16_t)0x0000) +#define TIM_DMABase_CR2 ((uint16_t)0x0001) +#define TIM_DMABase_SMCR ((uint16_t)0x0002) +#define TIM_DMABase_DIER ((uint16_t)0x0003) +#define TIM_DMABase_SR ((uint16_t)0x0004) +#define TIM_DMABase_EGR ((uint16_t)0x0005) +#define TIM_DMABase_CCMR1 ((uint16_t)0x0006) +#define TIM_DMABase_CCMR2 ((uint16_t)0x0007) +#define TIM_DMABase_CCER ((uint16_t)0x0008) +#define TIM_DMABase_CNT ((uint16_t)0x0009) +#define TIM_DMABase_PSC ((uint16_t)0x000A) +#define TIM_DMABase_ARR ((uint16_t)0x000B) +#define TIM_DMABase_RCR ((uint16_t)0x000C) +#define TIM_DMABase_CCR1 ((uint16_t)0x000D) +#define TIM_DMABase_CCR2 ((uint16_t)0x000E) +#define TIM_DMABase_CCR3 ((uint16_t)0x000F) +#define TIM_DMABase_CCR4 ((uint16_t)0x0010) +#define TIM_DMABase_BDTR ((uint16_t)0x0011) +#define TIM_DMABase_DCR ((uint16_t)0x0012) +#define IS_TIM_DMA_BASE(BASE) (((BASE) == TIM_DMABase_CR1) || \ + ((BASE) == TIM_DMABase_CR2) || \ + ((BASE) == TIM_DMABase_SMCR) || \ + ((BASE) == TIM_DMABase_DIER) || \ + ((BASE) == TIM_DMABase_SR) || \ + ((BASE) == TIM_DMABase_EGR) || \ + ((BASE) == TIM_DMABase_CCMR1) || \ + ((BASE) == TIM_DMABase_CCMR2) || \ + ((BASE) == TIM_DMABase_CCER) || \ + ((BASE) == TIM_DMABase_CNT) || \ + ((BASE) == TIM_DMABase_PSC) || \ + ((BASE) == TIM_DMABase_ARR) || \ + ((BASE) == TIM_DMABase_RCR) || \ + ((BASE) == TIM_DMABase_CCR1) || \ + ((BASE) == TIM_DMABase_CCR2) || \ + ((BASE) == TIM_DMABase_CCR3) || \ + ((BASE) == TIM_DMABase_CCR4) || \ + ((BASE) == TIM_DMABase_BDTR) || \ + ((BASE) == TIM_DMABase_DCR)) +/** + * @} + */ + +/** @defgroup TIM_DMA_Burst_Length + * @{ + */ + +#define TIM_DMABurstLength_1Transfer ((uint16_t)0x0000) +#define TIM_DMABurstLength_2Transfers ((uint16_t)0x0100) +#define TIM_DMABurstLength_3Transfers ((uint16_t)0x0200) +#define TIM_DMABurstLength_4Transfers ((uint16_t)0x0300) +#define TIM_DMABurstLength_5Transfers ((uint16_t)0x0400) +#define TIM_DMABurstLength_6Transfers ((uint16_t)0x0500) +#define TIM_DMABurstLength_7Transfers ((uint16_t)0x0600) +#define TIM_DMABurstLength_8Transfers ((uint16_t)0x0700) +#define TIM_DMABurstLength_9Transfers ((uint16_t)0x0800) +#define TIM_DMABurstLength_10Transfers ((uint16_t)0x0900) +#define TIM_DMABurstLength_11Transfers ((uint16_t)0x0A00) +#define TIM_DMABurstLength_12Transfers ((uint16_t)0x0B00) +#define TIM_DMABurstLength_13Transfers ((uint16_t)0x0C00) +#define TIM_DMABurstLength_14Transfers ((uint16_t)0x0D00) +#define TIM_DMABurstLength_15Transfers ((uint16_t)0x0E00) +#define TIM_DMABurstLength_16Transfers ((uint16_t)0x0F00) +#define TIM_DMABurstLength_17Transfers ((uint16_t)0x1000) +#define TIM_DMABurstLength_18Transfers ((uint16_t)0x1100) +#define IS_TIM_DMA_LENGTH(LENGTH) (((LENGTH) == TIM_DMABurstLength_1Transfer) || \ + ((LENGTH) == TIM_DMABurstLength_2Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_3Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_4Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_5Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_6Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_7Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_8Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_9Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_10Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_11Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_12Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_13Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_14Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_15Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_16Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_17Transfers) || \ + ((LENGTH) == TIM_DMABurstLength_18Transfers)) +/** + * @} + */ + +/** @defgroup TIM_DMA_sources + * @{ + */ + +#define TIM_DMA_Update ((uint16_t)0x0100) +#define TIM_DMA_CC1 ((uint16_t)0x0200) +#define TIM_DMA_CC2 ((uint16_t)0x0400) +#define TIM_DMA_CC3 ((uint16_t)0x0800) +#define TIM_DMA_CC4 ((uint16_t)0x1000) +#define TIM_DMA_COM ((uint16_t)0x2000) +#define TIM_DMA_Trigger ((uint16_t)0x4000) +#define IS_TIM_DMA_SOURCE(SOURCE) ((((SOURCE) & (uint16_t)0x80FF) == 0x0000) && ((SOURCE) != 0x0000)) + +/** + * @} + */ + +/** @defgroup TIM_External_Trigger_Prescaler + * @{ + */ + +#define TIM_ExtTRGPSC_OFF ((uint16_t)0x0000) +#define TIM_ExtTRGPSC_DIV2 ((uint16_t)0x1000) +#define TIM_ExtTRGPSC_DIV4 ((uint16_t)0x2000) +#define TIM_ExtTRGPSC_DIV8 ((uint16_t)0x3000) +#define IS_TIM_EXT_PRESCALER(PRESCALER) (((PRESCALER) == TIM_ExtTRGPSC_OFF) || \ + ((PRESCALER) == TIM_ExtTRGPSC_DIV2) || \ + ((PRESCALER) == TIM_ExtTRGPSC_DIV4) || \ + ((PRESCALER) == TIM_ExtTRGPSC_DIV8)) +/** + * @} + */ + +/** @defgroup TIM_Internal_Trigger_Selection + * @{ + */ + +#define TIM_TS_ITR0 ((uint16_t)0x0000) +#define TIM_TS_ITR1 ((uint16_t)0x0010) +#define TIM_TS_ITR2 ((uint16_t)0x0020) +#define TIM_TS_ITR3 ((uint16_t)0x0030) +#define TIM_TS_TI1F_ED ((uint16_t)0x0040) +#define TIM_TS_TI1FP1 ((uint16_t)0x0050) +#define TIM_TS_TI2FP2 ((uint16_t)0x0060) +#define TIM_TS_ETRF ((uint16_t)0x0070) +#define IS_TIM_TRIGGER_SELECTION(SELECTION) (((SELECTION) == TIM_TS_ITR0) || \ + ((SELECTION) == TIM_TS_ITR1) || \ + ((SELECTION) == TIM_TS_ITR2) || \ + ((SELECTION) == TIM_TS_ITR3) || \ + ((SELECTION) == TIM_TS_TI1F_ED) || \ + ((SELECTION) == TIM_TS_TI1FP1) || \ + ((SELECTION) == TIM_TS_TI2FP2) || \ + ((SELECTION) == TIM_TS_ETRF)) +#define IS_TIM_INTERNAL_TRIGGER_SELECTION(SELECTION) (((SELECTION) == TIM_TS_ITR0) || \ + ((SELECTION) == TIM_TS_ITR1) || \ + ((SELECTION) == TIM_TS_ITR2) || \ + ((SELECTION) == TIM_TS_ITR3)) +/** + * @} + */ + +/** @defgroup TIM_TIx_External_Clock_Source + * @{ + */ + +#define TIM_TIxExternalCLK1Source_TI1 ((uint16_t)0x0050) +#define TIM_TIxExternalCLK1Source_TI2 ((uint16_t)0x0060) +#define TIM_TIxExternalCLK1Source_TI1ED ((uint16_t)0x0040) +#define IS_TIM_TIXCLK_SOURCE(SOURCE) (((SOURCE) == TIM_TIxExternalCLK1Source_TI1) || \ + ((SOURCE) == TIM_TIxExternalCLK1Source_TI2) || \ + ((SOURCE) == TIM_TIxExternalCLK1Source_TI1ED)) +/** + * @} + */ + +/** @defgroup TIM_External_Trigger_Polarity + * @{ + */ +#define TIM_ExtTRGPolarity_Inverted ((uint16_t)0x8000) +#define TIM_ExtTRGPolarity_NonInverted ((uint16_t)0x0000) +#define IS_TIM_EXT_POLARITY(POLARITY) (((POLARITY) == TIM_ExtTRGPolarity_Inverted) || \ + ((POLARITY) == TIM_ExtTRGPolarity_NonInverted)) +/** + * @} + */ + +/** @defgroup TIM_Prescaler_Reload_Mode + * @{ + */ + +#define TIM_PSCReloadMode_Update ((uint16_t)0x0000) +#define TIM_PSCReloadMode_Immediate ((uint16_t)0x0001) +#define IS_TIM_PRESCALER_RELOAD(RELOAD) (((RELOAD) == TIM_PSCReloadMode_Update) || \ + ((RELOAD) == TIM_PSCReloadMode_Immediate)) +/** + * @} + */ + +/** @defgroup TIM_Forced_Action + * @{ + */ + +#define TIM_ForcedAction_Active ((uint16_t)0x0050) +#define TIM_ForcedAction_InActive ((uint16_t)0x0040) +#define IS_TIM_FORCED_ACTION(ACTION) (((ACTION) == TIM_ForcedAction_Active) || \ + ((ACTION) == TIM_ForcedAction_InActive)) +/** + * @} + */ + +/** @defgroup TIM_Encoder_Mode + * @{ + */ + +#define TIM_EncoderMode_TI1 ((uint16_t)0x0001) +#define TIM_EncoderMode_TI2 ((uint16_t)0x0002) +#define TIM_EncoderMode_TI12 ((uint16_t)0x0003) +#define IS_TIM_ENCODER_MODE(MODE) (((MODE) == TIM_EncoderMode_TI1) || \ + ((MODE) == TIM_EncoderMode_TI2) || \ + ((MODE) == TIM_EncoderMode_TI12)) +/** + * @} + */ + + +/** @defgroup TIM_Event_Source + * @{ + */ + +#define TIM_EventSource_Update ((uint16_t)0x0001) +#define TIM_EventSource_CC1 ((uint16_t)0x0002) +#define TIM_EventSource_CC2 ((uint16_t)0x0004) +#define TIM_EventSource_CC3 ((uint16_t)0x0008) +#define TIM_EventSource_CC4 ((uint16_t)0x0010) +#define TIM_EventSource_COM ((uint16_t)0x0020) +#define TIM_EventSource_Trigger ((uint16_t)0x0040) +#define TIM_EventSource_Break ((uint16_t)0x0080) +#define IS_TIM_EVENT_SOURCE(SOURCE) ((((SOURCE) & (uint16_t)0xFF00) == 0x0000) && ((SOURCE) != 0x0000)) + +/** + * @} + */ + +/** @defgroup TIM_Update_Source + * @{ + */ + +#define TIM_UpdateSource_Global ((uint16_t)0x0000) /*!< Source of update is the counter overflow/underflow + or the setting of UG bit, or an update generation + through the slave mode controller. */ +#define TIM_UpdateSource_Regular ((uint16_t)0x0001) /*!< Source of update is counter overflow/underflow. */ +#define IS_TIM_UPDATE_SOURCE(SOURCE) (((SOURCE) == TIM_UpdateSource_Global) || \ + ((SOURCE) == TIM_UpdateSource_Regular)) +/** + * @} + */ + +/** @defgroup TIM_Output_Compare_Preload_State + * @{ + */ + +#define TIM_OCPreload_Enable ((uint16_t)0x0008) +#define TIM_OCPreload_Disable ((uint16_t)0x0000) +#define IS_TIM_OCPRELOAD_STATE(STATE) (((STATE) == TIM_OCPreload_Enable) || \ + ((STATE) == TIM_OCPreload_Disable)) +/** + * @} + */ + +/** @defgroup TIM_Output_Compare_Fast_State + * @{ + */ + +#define TIM_OCFast_Enable ((uint16_t)0x0004) +#define TIM_OCFast_Disable ((uint16_t)0x0000) +#define IS_TIM_OCFAST_STATE(STATE) (((STATE) == TIM_OCFast_Enable) || \ + ((STATE) == TIM_OCFast_Disable)) + +/** + * @} + */ + +/** @defgroup TIM_Output_Compare_Clear_State + * @{ + */ + +#define TIM_OCClear_Enable ((uint16_t)0x0080) +#define TIM_OCClear_Disable ((uint16_t)0x0000) +#define IS_TIM_OCCLEAR_STATE(STATE) (((STATE) == TIM_OCClear_Enable) || \ + ((STATE) == TIM_OCClear_Disable)) +/** + * @} + */ + +/** @defgroup TIM_Trigger_Output_Source + * @{ + */ + +#define TIM_TRGOSource_Reset ((uint16_t)0x0000) +#define TIM_TRGOSource_Enable ((uint16_t)0x0010) +#define TIM_TRGOSource_Update ((uint16_t)0x0020) +#define TIM_TRGOSource_OC1 ((uint16_t)0x0030) +#define TIM_TRGOSource_OC1Ref ((uint16_t)0x0040) +#define TIM_TRGOSource_OC2Ref ((uint16_t)0x0050) +#define TIM_TRGOSource_OC3Ref ((uint16_t)0x0060) +#define TIM_TRGOSource_OC4Ref ((uint16_t)0x0070) +#define IS_TIM_TRGO_SOURCE(SOURCE) (((SOURCE) == TIM_TRGOSource_Reset) || \ + ((SOURCE) == TIM_TRGOSource_Enable) || \ + ((SOURCE) == TIM_TRGOSource_Update) || \ + ((SOURCE) == TIM_TRGOSource_OC1) || \ + ((SOURCE) == TIM_TRGOSource_OC1Ref) || \ + ((SOURCE) == TIM_TRGOSource_OC2Ref) || \ + ((SOURCE) == TIM_TRGOSource_OC3Ref) || \ + ((SOURCE) == TIM_TRGOSource_OC4Ref)) +/** + * @} + */ + +/** @defgroup TIM_Slave_Mode + * @{ + */ + +#define TIM_SlaveMode_Reset ((uint16_t)0x0004) +#define TIM_SlaveMode_Gated ((uint16_t)0x0005) +#define TIM_SlaveMode_Trigger ((uint16_t)0x0006) +#define TIM_SlaveMode_External1 ((uint16_t)0x0007) +#define IS_TIM_SLAVE_MODE(MODE) (((MODE) == TIM_SlaveMode_Reset) || \ + ((MODE) == TIM_SlaveMode_Gated) || \ + ((MODE) == TIM_SlaveMode_Trigger) || \ + ((MODE) == TIM_SlaveMode_External1)) +/** + * @} + */ + +/** @defgroup TIM_Master_Slave_Mode + * @{ + */ + +#define TIM_MasterSlaveMode_Enable ((uint16_t)0x0080) +#define TIM_MasterSlaveMode_Disable ((uint16_t)0x0000) +#define IS_TIM_MSM_STATE(STATE) (((STATE) == TIM_MasterSlaveMode_Enable) || \ + ((STATE) == TIM_MasterSlaveMode_Disable)) +/** + * @} + */ + +/** @defgroup TIM_Flags + * @{ + */ + +#define TIM_FLAG_Update ((uint16_t)0x0001) +#define TIM_FLAG_CC1 ((uint16_t)0x0002) +#define TIM_FLAG_CC2 ((uint16_t)0x0004) +#define TIM_FLAG_CC3 ((uint16_t)0x0008) +#define TIM_FLAG_CC4 ((uint16_t)0x0010) +#define TIM_FLAG_COM ((uint16_t)0x0020) +#define TIM_FLAG_Trigger ((uint16_t)0x0040) +#define TIM_FLAG_Break ((uint16_t)0x0080) +#define TIM_FLAG_CC1OF ((uint16_t)0x0200) +#define TIM_FLAG_CC2OF ((uint16_t)0x0400) +#define TIM_FLAG_CC3OF ((uint16_t)0x0800) +#define TIM_FLAG_CC4OF ((uint16_t)0x1000) +#define IS_TIM_GET_FLAG(FLAG) (((FLAG) == TIM_FLAG_Update) || \ + ((FLAG) == TIM_FLAG_CC1) || \ + ((FLAG) == TIM_FLAG_CC2) || \ + ((FLAG) == TIM_FLAG_CC3) || \ + ((FLAG) == TIM_FLAG_CC4) || \ + ((FLAG) == TIM_FLAG_COM) || \ + ((FLAG) == TIM_FLAG_Trigger) || \ + ((FLAG) == TIM_FLAG_Break) || \ + ((FLAG) == TIM_FLAG_CC1OF) || \ + ((FLAG) == TIM_FLAG_CC2OF) || \ + ((FLAG) == TIM_FLAG_CC3OF) || \ + ((FLAG) == TIM_FLAG_CC4OF)) + + +#define IS_TIM_CLEAR_FLAG(TIM_FLAG) ((((TIM_FLAG) & (uint16_t)0xE100) == 0x0000) && ((TIM_FLAG) != 0x0000)) +/** + * @} + */ + +/** @defgroup TIM_Input_Capture_Filer_Value + * @{ + */ + +#define IS_TIM_IC_FILTER(ICFILTER) ((ICFILTER) <= 0xF) +/** + * @} + */ + +/** @defgroup TIM_External_Trigger_Filter + * @{ + */ + +#define IS_TIM_EXT_FILTER(EXTFILTER) ((EXTFILTER) <= 0xF) +/** + * @} + */ + +/** @defgroup TIM_Legacy + * @{ + */ + +#define TIM_DMABurstLength_1Byte TIM_DMABurstLength_1Transfer +#define TIM_DMABurstLength_2Bytes TIM_DMABurstLength_2Transfers +#define TIM_DMABurstLength_3Bytes TIM_DMABurstLength_3Transfers +#define TIM_DMABurstLength_4Bytes TIM_DMABurstLength_4Transfers +#define TIM_DMABurstLength_5Bytes TIM_DMABurstLength_5Transfers +#define TIM_DMABurstLength_6Bytes TIM_DMABurstLength_6Transfers +#define TIM_DMABurstLength_7Bytes TIM_DMABurstLength_7Transfers +#define TIM_DMABurstLength_8Bytes TIM_DMABurstLength_8Transfers +#define TIM_DMABurstLength_9Bytes TIM_DMABurstLength_9Transfers +#define TIM_DMABurstLength_10Bytes TIM_DMABurstLength_10Transfers +#define TIM_DMABurstLength_11Bytes TIM_DMABurstLength_11Transfers +#define TIM_DMABurstLength_12Bytes TIM_DMABurstLength_12Transfers +#define TIM_DMABurstLength_13Bytes TIM_DMABurstLength_13Transfers +#define TIM_DMABurstLength_14Bytes TIM_DMABurstLength_14Transfers +#define TIM_DMABurstLength_15Bytes TIM_DMABurstLength_15Transfers +#define TIM_DMABurstLength_16Bytes TIM_DMABurstLength_16Transfers +#define TIM_DMABurstLength_17Bytes TIM_DMABurstLength_17Transfers +#define TIM_DMABurstLength_18Bytes TIM_DMABurstLength_18Transfers +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup TIM_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup TIM_Exported_Functions + * @{ + */ + +void TIM_DeInit(TIM_TypeDef* TIMx); +void TIM_TimeBaseInit(TIM_TypeDef* TIMx, TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct); +void TIM_OC1Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct); +void TIM_OC2Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct); +void TIM_OC3Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct); +void TIM_OC4Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct); +void TIM_ICInit(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct); +void TIM_PWMIConfig(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct); +void TIM_BDTRConfig(TIM_TypeDef* TIMx, TIM_BDTRInitTypeDef *TIM_BDTRInitStruct); +void TIM_TimeBaseStructInit(TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct); +void TIM_OCStructInit(TIM_OCInitTypeDef* TIM_OCInitStruct); +void TIM_ICStructInit(TIM_ICInitTypeDef* TIM_ICInitStruct); +void TIM_BDTRStructInit(TIM_BDTRInitTypeDef* TIM_BDTRInitStruct); +void TIM_Cmd(TIM_TypeDef* TIMx, FunctionalState NewState); +void TIM_CtrlPWMOutputs(TIM_TypeDef* TIMx, FunctionalState NewState); +void TIM_ITConfig(TIM_TypeDef* TIMx, uint16_t TIM_IT, FunctionalState NewState); +void TIM_GenerateEvent(TIM_TypeDef* TIMx, uint16_t TIM_EventSource); +void TIM_DMAConfig(TIM_TypeDef* TIMx, uint16_t TIM_DMABase, uint16_t TIM_DMABurstLength); +void TIM_DMACmd(TIM_TypeDef* TIMx, uint16_t TIM_DMASource, FunctionalState NewState); +void TIM_InternalClockConfig(TIM_TypeDef* TIMx); +void TIM_ITRxExternalClockConfig(TIM_TypeDef* TIMx, uint16_t TIM_InputTriggerSource); +void TIM_TIxExternalClockConfig(TIM_TypeDef* TIMx, uint16_t TIM_TIxExternalCLKSource, + uint16_t TIM_ICPolarity, uint16_t ICFilter); +void TIM_ETRClockMode1Config(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity, + uint16_t ExtTRGFilter); +void TIM_ETRClockMode2Config(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, + uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter); +void TIM_ETRConfig(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity, + uint16_t ExtTRGFilter); +void TIM_PrescalerConfig(TIM_TypeDef* TIMx, uint16_t Prescaler, uint16_t TIM_PSCReloadMode); +void TIM_CounterModeConfig(TIM_TypeDef* TIMx, uint16_t TIM_CounterMode); +void TIM_SelectInputTrigger(TIM_TypeDef* TIMx, uint16_t TIM_InputTriggerSource); +void TIM_EncoderInterfaceConfig(TIM_TypeDef* TIMx, uint16_t TIM_EncoderMode, + uint16_t TIM_IC1Polarity, uint16_t TIM_IC2Polarity); +void TIM_ForcedOC1Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction); +void TIM_ForcedOC2Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction); +void TIM_ForcedOC3Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction); +void TIM_ForcedOC4Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction); +void TIM_ARRPreloadConfig(TIM_TypeDef* TIMx, FunctionalState NewState); +void TIM_SelectCOM(TIM_TypeDef* TIMx, FunctionalState NewState); +void TIM_SelectCCDMA(TIM_TypeDef* TIMx, FunctionalState NewState); +void TIM_CCPreloadControl(TIM_TypeDef* TIMx, FunctionalState NewState); +void TIM_OC1PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload); +void TIM_OC2PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload); +void TIM_OC3PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload); +void TIM_OC4PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload); +void TIM_OC1FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast); +void TIM_OC2FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast); +void TIM_OC3FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast); +void TIM_OC4FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast); +void TIM_ClearOC1Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear); +void TIM_ClearOC2Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear); +void TIM_ClearOC3Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear); +void TIM_ClearOC4Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear); +void TIM_OC1PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity); +void TIM_OC1NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity); +void TIM_OC2PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity); +void TIM_OC2NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity); +void TIM_OC3PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity); +void TIM_OC3NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity); +void TIM_OC4PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity); +void TIM_CCxCmd(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx); +void TIM_CCxNCmd(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_CCxN); +void TIM_SelectOCxM(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_OCMode); +void TIM_UpdateDisableConfig(TIM_TypeDef* TIMx, FunctionalState NewState); +void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource); +void TIM_SelectHallSensor(TIM_TypeDef* TIMx, FunctionalState NewState); +void TIM_SelectOnePulseMode(TIM_TypeDef* TIMx, uint16_t TIM_OPMode); +void TIM_SelectOutputTrigger(TIM_TypeDef* TIMx, uint16_t TIM_TRGOSource); +void TIM_SelectSlaveMode(TIM_TypeDef* TIMx, uint16_t TIM_SlaveMode); +void TIM_SelectMasterSlaveMode(TIM_TypeDef* TIMx, uint16_t TIM_MasterSlaveMode); +void TIM_SetCounter(TIM_TypeDef* TIMx, uint16_t Counter); +void TIM_SetAutoreload(TIM_TypeDef* TIMx, uint16_t Autoreload); +void TIM_SetCompare1(TIM_TypeDef* TIMx, uint16_t Compare1); +void TIM_SetCompare2(TIM_TypeDef* TIMx, uint16_t Compare2); +void TIM_SetCompare3(TIM_TypeDef* TIMx, uint16_t Compare3); +void TIM_SetCompare4(TIM_TypeDef* TIMx, uint16_t Compare4); +void TIM_SetIC1Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC); +void TIM_SetIC2Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC); +void TIM_SetIC3Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC); +void TIM_SetIC4Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC); +void TIM_SetClockDivision(TIM_TypeDef* TIMx, uint16_t TIM_CKD); +uint16_t TIM_GetCapture1(TIM_TypeDef* TIMx); +uint16_t TIM_GetCapture2(TIM_TypeDef* TIMx); +uint16_t TIM_GetCapture3(TIM_TypeDef* TIMx); +uint16_t TIM_GetCapture4(TIM_TypeDef* TIMx); +uint16_t TIM_GetCounter(TIM_TypeDef* TIMx); +uint16_t TIM_GetPrescaler(TIM_TypeDef* TIMx); +FlagStatus TIM_GetFlagStatus(TIM_TypeDef* TIMx, uint16_t TIM_FLAG); +void TIM_ClearFlag(TIM_TypeDef* TIMx, uint16_t TIM_FLAG); +ITStatus TIM_GetITStatus(TIM_TypeDef* TIMx, uint16_t TIM_IT); +void TIM_ClearITPendingBit(TIM_TypeDef* TIMx, uint16_t TIM_IT); + +#ifdef __cplusplus +} +#endif + +#endif /*__STM32F10x_TIM_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_usart.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_usart.h new file mode 100755 index 0000000..61ae249 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_usart.h @@ -0,0 +1,412 @@ +/** + ****************************************************************************** + * @file stm32f10x_usart.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the USART + * firmware library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_USART_H +#define __STM32F10x_USART_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup USART + * @{ + */ + +/** @defgroup USART_Exported_Types + * @{ + */ + +/** + * @brief USART Init Structure definition + */ + +typedef struct +{ + uint32_t USART_BaudRate; /*!< This member configures the USART communication baud rate. + The baud rate is computed using the following formula: + - IntegerDivider = ((PCLKx) / (16 * (USART_InitStruct->USART_BaudRate))) + - FractionalDivider = ((IntegerDivider - ((u32) IntegerDivider)) * 16) + 0.5 */ + + uint16_t USART_WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. + This parameter can be a value of @ref USART_Word_Length */ + + uint16_t USART_StopBits; /*!< Specifies the number of stop bits transmitted. + This parameter can be a value of @ref USART_Stop_Bits */ + + uint16_t USART_Parity; /*!< Specifies the parity mode. + This parameter can be a value of @ref USART_Parity + @note When parity is enabled, the computed parity is inserted + at the MSB position of the transmitted data (9th bit when + the word length is set to 9 data bits; 8th bit when the + word length is set to 8 data bits). */ + + uint16_t USART_Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled. + This parameter can be a value of @ref USART_Mode */ + + uint16_t USART_HardwareFlowControl; /*!< Specifies wether the hardware flow control mode is enabled + or disabled. + This parameter can be a value of @ref USART_Hardware_Flow_Control */ +} USART_InitTypeDef; + +/** + * @brief USART Clock Init Structure definition + */ + +typedef struct +{ + + uint16_t USART_Clock; /*!< Specifies whether the USART clock is enabled or disabled. + This parameter can be a value of @ref USART_Clock */ + + uint16_t USART_CPOL; /*!< Specifies the steady state value of the serial clock. + This parameter can be a value of @ref USART_Clock_Polarity */ + + uint16_t USART_CPHA; /*!< Specifies the clock transition on which the bit capture is made. + This parameter can be a value of @ref USART_Clock_Phase */ + + uint16_t USART_LastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted + data bit (MSB) has to be output on the SCLK pin in synchronous mode. + This parameter can be a value of @ref USART_Last_Bit */ +} USART_ClockInitTypeDef; + +/** + * @} + */ + +/** @defgroup USART_Exported_Constants + * @{ + */ + +#define IS_USART_ALL_PERIPH(PERIPH) (((PERIPH) == USART1) || \ + ((PERIPH) == USART2) || \ + ((PERIPH) == USART3) || \ + ((PERIPH) == UART4) || \ + ((PERIPH) == UART5)) + +#define IS_USART_123_PERIPH(PERIPH) (((PERIPH) == USART1) || \ + ((PERIPH) == USART2) || \ + ((PERIPH) == USART3)) + +#define IS_USART_1234_PERIPH(PERIPH) (((PERIPH) == USART1) || \ + ((PERIPH) == USART2) || \ + ((PERIPH) == USART3) || \ + ((PERIPH) == UART4)) +/** @defgroup USART_Word_Length + * @{ + */ + +#define USART_WordLength_8b ((uint16_t)0x0000) +#define USART_WordLength_9b ((uint16_t)0x1000) + +#define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WordLength_8b) || \ + ((LENGTH) == USART_WordLength_9b)) +/** + * @} + */ + +/** @defgroup USART_Stop_Bits + * @{ + */ + +#define USART_StopBits_1 ((uint16_t)0x0000) +#define USART_StopBits_0_5 ((uint16_t)0x1000) +#define USART_StopBits_2 ((uint16_t)0x2000) +#define USART_StopBits_1_5 ((uint16_t)0x3000) +#define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_StopBits_1) || \ + ((STOPBITS) == USART_StopBits_0_5) || \ + ((STOPBITS) == USART_StopBits_2) || \ + ((STOPBITS) == USART_StopBits_1_5)) +/** + * @} + */ + +/** @defgroup USART_Parity + * @{ + */ + +#define USART_Parity_No ((uint16_t)0x0000) +#define USART_Parity_Even ((uint16_t)0x0400) +#define USART_Parity_Odd ((uint16_t)0x0600) +#define IS_USART_PARITY(PARITY) (((PARITY) == USART_Parity_No) || \ + ((PARITY) == USART_Parity_Even) || \ + ((PARITY) == USART_Parity_Odd)) +/** + * @} + */ + +/** @defgroup USART_Mode + * @{ + */ + +#define USART_Mode_Rx ((uint16_t)0x0004) +#define USART_Mode_Tx ((uint16_t)0x0008) +#define IS_USART_MODE(MODE) ((((MODE) & (uint16_t)0xFFF3) == 0x00) && ((MODE) != (uint16_t)0x00)) +/** + * @} + */ + +/** @defgroup USART_Hardware_Flow_Control + * @{ + */ +#define USART_HardwareFlowControl_None ((uint16_t)0x0000) +#define USART_HardwareFlowControl_RTS ((uint16_t)0x0100) +#define USART_HardwareFlowControl_CTS ((uint16_t)0x0200) +#define USART_HardwareFlowControl_RTS_CTS ((uint16_t)0x0300) +#define IS_USART_HARDWARE_FLOW_CONTROL(CONTROL)\ + (((CONTROL) == USART_HardwareFlowControl_None) || \ + ((CONTROL) == USART_HardwareFlowControl_RTS) || \ + ((CONTROL) == USART_HardwareFlowControl_CTS) || \ + ((CONTROL) == USART_HardwareFlowControl_RTS_CTS)) +/** + * @} + */ + +/** @defgroup USART_Clock + * @{ + */ +#define USART_Clock_Disable ((uint16_t)0x0000) +#define USART_Clock_Enable ((uint16_t)0x0800) +#define IS_USART_CLOCK(CLOCK) (((CLOCK) == USART_Clock_Disable) || \ + ((CLOCK) == USART_Clock_Enable)) +/** + * @} + */ + +/** @defgroup USART_Clock_Polarity + * @{ + */ + +#define USART_CPOL_Low ((uint16_t)0x0000) +#define USART_CPOL_High ((uint16_t)0x0400) +#define IS_USART_CPOL(CPOL) (((CPOL) == USART_CPOL_Low) || ((CPOL) == USART_CPOL_High)) + +/** + * @} + */ + +/** @defgroup USART_Clock_Phase + * @{ + */ + +#define USART_CPHA_1Edge ((uint16_t)0x0000) +#define USART_CPHA_2Edge ((uint16_t)0x0200) +#define IS_USART_CPHA(CPHA) (((CPHA) == USART_CPHA_1Edge) || ((CPHA) == USART_CPHA_2Edge)) + +/** + * @} + */ + +/** @defgroup USART_Last_Bit + * @{ + */ + +#define USART_LastBit_Disable ((uint16_t)0x0000) +#define USART_LastBit_Enable ((uint16_t)0x0100) +#define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LastBit_Disable) || \ + ((LASTBIT) == USART_LastBit_Enable)) +/** + * @} + */ + +/** @defgroup USART_Interrupt_definition + * @{ + */ + +#define USART_IT_PE ((uint16_t)0x0028) +#define USART_IT_TXE ((uint16_t)0x0727) +#define USART_IT_TC ((uint16_t)0x0626) +#define USART_IT_RXNE ((uint16_t)0x0525) +#define USART_IT_IDLE ((uint16_t)0x0424) +#define USART_IT_LBD ((uint16_t)0x0846) +#define USART_IT_CTS ((uint16_t)0x096A) +#define USART_IT_ERR ((uint16_t)0x0060) +#define USART_IT_ORE ((uint16_t)0x0360) +#define USART_IT_NE ((uint16_t)0x0260) +#define USART_IT_FE ((uint16_t)0x0160) +#define IS_USART_CONFIG_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \ + ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \ + ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \ + ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ERR)) +#define IS_USART_GET_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \ + ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \ + ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \ + ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ORE) || \ + ((IT) == USART_IT_NE) || ((IT) == USART_IT_FE)) +#define IS_USART_CLEAR_IT(IT) (((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \ + ((IT) == USART_IT_LBD) || ((IT) == USART_IT_CTS)) +/** + * @} + */ + +/** @defgroup USART_DMA_Requests + * @{ + */ + +#define USART_DMAReq_Tx ((uint16_t)0x0080) +#define USART_DMAReq_Rx ((uint16_t)0x0040) +#define IS_USART_DMAREQ(DMAREQ) ((((DMAREQ) & (uint16_t)0xFF3F) == 0x00) && ((DMAREQ) != (uint16_t)0x00)) + +/** + * @} + */ + +/** @defgroup USART_WakeUp_methods + * @{ + */ + +#define USART_WakeUp_IdleLine ((uint16_t)0x0000) +#define USART_WakeUp_AddressMark ((uint16_t)0x0800) +#define IS_USART_WAKEUP(WAKEUP) (((WAKEUP) == USART_WakeUp_IdleLine) || \ + ((WAKEUP) == USART_WakeUp_AddressMark)) +/** + * @} + */ + +/** @defgroup USART_LIN_Break_Detection_Length + * @{ + */ + +#define USART_LINBreakDetectLength_10b ((uint16_t)0x0000) +#define USART_LINBreakDetectLength_11b ((uint16_t)0x0020) +#define IS_USART_LIN_BREAK_DETECT_LENGTH(LENGTH) \ + (((LENGTH) == USART_LINBreakDetectLength_10b) || \ + ((LENGTH) == USART_LINBreakDetectLength_11b)) +/** + * @} + */ + +/** @defgroup USART_IrDA_Low_Power + * @{ + */ + +#define USART_IrDAMode_LowPower ((uint16_t)0x0004) +#define USART_IrDAMode_Normal ((uint16_t)0x0000) +#define IS_USART_IRDA_MODE(MODE) (((MODE) == USART_IrDAMode_LowPower) || \ + ((MODE) == USART_IrDAMode_Normal)) +/** + * @} + */ + +/** @defgroup USART_Flags + * @{ + */ + +#define USART_FLAG_CTS ((uint16_t)0x0200) +#define USART_FLAG_LBD ((uint16_t)0x0100) +#define USART_FLAG_TXE ((uint16_t)0x0080) +#define USART_FLAG_TC ((uint16_t)0x0040) +#define USART_FLAG_RXNE ((uint16_t)0x0020) +#define USART_FLAG_IDLE ((uint16_t)0x0010) +#define USART_FLAG_ORE ((uint16_t)0x0008) +#define USART_FLAG_NE ((uint16_t)0x0004) +#define USART_FLAG_FE ((uint16_t)0x0002) +#define USART_FLAG_PE ((uint16_t)0x0001) +#define IS_USART_FLAG(FLAG) (((FLAG) == USART_FLAG_PE) || ((FLAG) == USART_FLAG_TXE) || \ + ((FLAG) == USART_FLAG_TC) || ((FLAG) == USART_FLAG_RXNE) || \ + ((FLAG) == USART_FLAG_IDLE) || ((FLAG) == USART_FLAG_LBD) || \ + ((FLAG) == USART_FLAG_CTS) || ((FLAG) == USART_FLAG_ORE) || \ + ((FLAG) == USART_FLAG_NE) || ((FLAG) == USART_FLAG_FE)) + +#define IS_USART_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFC9F) == 0x00) && ((FLAG) != (uint16_t)0x00)) +#define IS_USART_PERIPH_FLAG(PERIPH, USART_FLAG) ((((*(uint32_t*)&(PERIPH)) != UART4_BASE) &&\ + ((*(uint32_t*)&(PERIPH)) != UART5_BASE)) \ + || ((USART_FLAG) != USART_FLAG_CTS)) +#define IS_USART_BAUDRATE(BAUDRATE) (((BAUDRATE) > 0) && ((BAUDRATE) < 0x0044AA21)) +#define IS_USART_ADDRESS(ADDRESS) ((ADDRESS) <= 0xF) +#define IS_USART_DATA(DATA) ((DATA) <= 0x1FF) + +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup USART_Exported_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup USART_Exported_Functions + * @{ + */ + +void USART_DeInit(USART_TypeDef* USARTx); +void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct); +void USART_StructInit(USART_InitTypeDef* USART_InitStruct); +void USART_ClockInit(USART_TypeDef* USARTx, USART_ClockInitTypeDef* USART_ClockInitStruct); +void USART_ClockStructInit(USART_ClockInitTypeDef* USART_ClockInitStruct); +void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState); +void USART_ITConfig(USART_TypeDef* USARTx, uint16_t USART_IT, FunctionalState NewState); +void USART_DMACmd(USART_TypeDef* USARTx, uint16_t USART_DMAReq, FunctionalState NewState); +void USART_SetAddress(USART_TypeDef* USARTx, uint8_t USART_Address); +void USART_WakeUpConfig(USART_TypeDef* USARTx, uint16_t USART_WakeUp); +void USART_ReceiverWakeUpCmd(USART_TypeDef* USARTx, FunctionalState NewState); +void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, uint16_t USART_LINBreakDetectLength); +void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState); +void USART_SendData(USART_TypeDef* USARTx, uint16_t Data); +uint16_t USART_ReceiveData(USART_TypeDef* USARTx); +void USART_SendBreak(USART_TypeDef* USARTx); +void USART_SetGuardTime(USART_TypeDef* USARTx, uint8_t USART_GuardTime); +void USART_SetPrescaler(USART_TypeDef* USARTx, uint8_t USART_Prescaler); +void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState); +void USART_SmartCardNACKCmd(USART_TypeDef* USARTx, FunctionalState NewState); +void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState); +void USART_OverSampling8Cmd(USART_TypeDef* USARTx, FunctionalState NewState); +void USART_OneBitMethodCmd(USART_TypeDef* USARTx, FunctionalState NewState); +void USART_IrDAConfig(USART_TypeDef* USARTx, uint16_t USART_IrDAMode); +void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState); +FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint16_t USART_FLAG); +void USART_ClearFlag(USART_TypeDef* USARTx, uint16_t USART_FLAG); +ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint16_t USART_IT); +void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint16_t USART_IT); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_USART_H */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_wwdg.h b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_wwdg.h new file mode 100755 index 0000000..cd573da --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/inc/stm32f10x_wwdg.h @@ -0,0 +1,115 @@ +/** + ****************************************************************************** + * @file stm32f10x_wwdg.h + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file contains all the functions prototypes for the WWDG firmware + * library. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_WWDG_H +#define __STM32F10x_WWDG_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup WWDG + * @{ + */ + +/** @defgroup WWDG_Exported_Types + * @{ + */ + +/** + * @} + */ + +/** @defgroup WWDG_Exported_Constants + * @{ + */ + +/** @defgroup WWDG_Prescaler + * @{ + */ + +#define WWDG_Prescaler_1 ((uint32_t)0x00000000) +#define WWDG_Prescaler_2 ((uint32_t)0x00000080) +#define WWDG_Prescaler_4 ((uint32_t)0x00000100) +#define WWDG_Prescaler_8 ((uint32_t)0x00000180) +#define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \ + ((PRESCALER) == WWDG_Prescaler_2) || \ + ((PRESCALER) == WWDG_Prescaler_4) || \ + ((PRESCALER) == WWDG_Prescaler_8)) +#define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F) +#define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F)) + +/** + * @} + */ + +/** + * @} + */ + +/** @defgroup WWDG_Exported_Macros + * @{ + */ +/** + * @} + */ + +/** @defgroup WWDG_Exported_Functions + * @{ + */ + +void WWDG_DeInit(void); +void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); +void WWDG_SetWindowValue(uint8_t WindowValue); +void WWDG_EnableIT(void); +void WWDG_SetCounter(uint8_t Counter); +void WWDG_Enable(uint8_t Counter); +FlagStatus WWDG_GetFlagStatus(void); +void WWDG_ClearFlag(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F10x_WWDG_H */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/misc.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/misc.c new file mode 100755 index 0000000..ec9165f --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/misc.c @@ -0,0 +1,225 @@ +/** + ****************************************************************************** + * @file misc.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the miscellaneous firmware functions (add-on + * to CMSIS functions). + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "misc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup MISC + * @brief MISC driver modules + * @{ + */ + +/** @defgroup MISC_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup MISC_Private_Defines + * @{ + */ + +#define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000) +/** + * @} + */ + +/** @defgroup MISC_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup MISC_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup MISC_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup MISC_Private_Functions + * @{ + */ + +/** + * @brief Configures the priority grouping: pre-emption priority and subpriority. + * @param NVIC_PriorityGroup: specifies the priority grouping bits length. + * This parameter can be one of the following values: + * @arg NVIC_PriorityGroup_0: 0 bits for pre-emption priority + * 4 bits for subpriority + * @arg NVIC_PriorityGroup_1: 1 bits for pre-emption priority + * 3 bits for subpriority + * @arg NVIC_PriorityGroup_2: 2 bits for pre-emption priority + * 2 bits for subpriority + * @arg NVIC_PriorityGroup_3: 3 bits for pre-emption priority + * 1 bits for subpriority + * @arg NVIC_PriorityGroup_4: 4 bits for pre-emption priority + * 0 bits for subpriority + * @retval None + */ +void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup) +{ + /* Check the parameters */ + assert_param(IS_NVIC_PRIORITY_GROUP(NVIC_PriorityGroup)); + + /* Set the PRIGROUP[10:8] bits according to NVIC_PriorityGroup value */ + SCB->AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup; +} + +/** + * @brief Initializes the NVIC peripheral according to the specified + * parameters in the NVIC_InitStruct. + * @param NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure that contains + * the configuration information for the specified NVIC peripheral. + * @retval None + */ +void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct) +{ + uint32_t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F; + + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NVIC_InitStruct->NVIC_IRQChannelCmd)); + assert_param(IS_NVIC_PREEMPTION_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority)); + assert_param(IS_NVIC_SUB_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelSubPriority)); + + if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE) + { + /* Compute the Corresponding IRQ Priority --------------------------------*/ + tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08; + tmppre = (0x4 - tmppriority); + tmpsub = tmpsub >> tmppriority; + + tmppriority = (uint32_t)NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre; + tmppriority |= NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub; + tmppriority = tmppriority << 0x04; + + NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority; + + /* Enable the Selected IRQ Channels --------------------------------------*/ + NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] = + (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); + } + else + { + /* Disable the Selected IRQ Channels -------------------------------------*/ + NVIC->ICER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] = + (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); + } +} + +/** + * @brief Sets the vector table location and Offset. + * @param NVIC_VectTab: specifies if the vector table is in RAM or FLASH memory. + * This parameter can be one of the following values: + * @arg NVIC_VectTab_RAM + * @arg NVIC_VectTab_FLASH + * @param Offset: Vector Table base offset field. This value must be a multiple + * of 0x200. + * @retval None + */ +void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset) +{ + /* Check the parameters */ + assert_param(IS_NVIC_VECTTAB(NVIC_VectTab)); + assert_param(IS_NVIC_OFFSET(Offset)); + + SCB->VTOR = NVIC_VectTab | (Offset & (uint32_t)0x1FFFFF80); +} + +/** + * @brief Selects the condition for the system to enter low power mode. + * @param LowPowerMode: Specifies the new mode for the system to enter low power mode. + * This parameter can be one of the following values: + * @arg NVIC_LP_SEVONPEND + * @arg NVIC_LP_SLEEPDEEP + * @arg NVIC_LP_SLEEPONEXIT + * @param NewState: new state of LP condition. This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_NVIC_LP(LowPowerMode)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + SCB->SCR |= LowPowerMode; + } + else + { + SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode); + } +} + +/** + * @brief Configures the SysTick clock source. + * @param SysTick_CLKSource: specifies the SysTick clock source. + * This parameter can be one of the following values: + * @arg SysTick_CLKSource_HCLK_Div8: AHB clock divided by 8 selected as SysTick clock source. + * @arg SysTick_CLKSource_HCLK: AHB clock selected as SysTick clock source. + * @retval None + */ +void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource) +{ + /* Check the parameters */ + assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource)); + if (SysTick_CLKSource == SysTick_CLKSource_HCLK) + { + SysTick->CTRL |= SysTick_CLKSource_HCLK; + } + else + { + SysTick->CTRL &= SysTick_CLKSource_HCLK_Div8; + } +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_adc.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_adc.c new file mode 100755 index 0000000..916a096 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_adc.c @@ -0,0 +1,1307 @@ +/** + ****************************************************************************** + * @file stm32f10x_adc.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the ADC firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_adc.h" +#include "stm32f10x_rcc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup ADC + * @brief ADC driver modules + * @{ + */ + +/** @defgroup ADC_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup ADC_Private_Defines + * @{ + */ + +/* ADC DISCNUM mask */ +#define CR1_DISCNUM_Reset ((uint32_t)0xFFFF1FFF) + +/* ADC DISCEN mask */ +#define CR1_DISCEN_Set ((uint32_t)0x00000800) +#define CR1_DISCEN_Reset ((uint32_t)0xFFFFF7FF) + +/* ADC JAUTO mask */ +#define CR1_JAUTO_Set ((uint32_t)0x00000400) +#define CR1_JAUTO_Reset ((uint32_t)0xFFFFFBFF) + +/* ADC JDISCEN mask */ +#define CR1_JDISCEN_Set ((uint32_t)0x00001000) +#define CR1_JDISCEN_Reset ((uint32_t)0xFFFFEFFF) + +/* ADC AWDCH mask */ +#define CR1_AWDCH_Reset ((uint32_t)0xFFFFFFE0) + +/* ADC Analog watchdog enable mode mask */ +#define CR1_AWDMode_Reset ((uint32_t)0xFF3FFDFF) + +/* CR1 register Mask */ +#define CR1_CLEAR_Mask ((uint32_t)0xFFF0FEFF) + +/* ADC ADON mask */ +#define CR2_ADON_Set ((uint32_t)0x00000001) +#define CR2_ADON_Reset ((uint32_t)0xFFFFFFFE) + +/* ADC DMA mask */ +#define CR2_DMA_Set ((uint32_t)0x00000100) +#define CR2_DMA_Reset ((uint32_t)0xFFFFFEFF) + +/* ADC RSTCAL mask */ +#define CR2_RSTCAL_Set ((uint32_t)0x00000008) + +/* ADC CAL mask */ +#define CR2_CAL_Set ((uint32_t)0x00000004) + +/* ADC SWSTART mask */ +#define CR2_SWSTART_Set ((uint32_t)0x00400000) + +/* ADC EXTTRIG mask */ +#define CR2_EXTTRIG_Set ((uint32_t)0x00100000) +#define CR2_EXTTRIG_Reset ((uint32_t)0xFFEFFFFF) + +/* ADC Software start mask */ +#define CR2_EXTTRIG_SWSTART_Set ((uint32_t)0x00500000) +#define CR2_EXTTRIG_SWSTART_Reset ((uint32_t)0xFFAFFFFF) + +/* ADC JEXTSEL mask */ +#define CR2_JEXTSEL_Reset ((uint32_t)0xFFFF8FFF) + +/* ADC JEXTTRIG mask */ +#define CR2_JEXTTRIG_Set ((uint32_t)0x00008000) +#define CR2_JEXTTRIG_Reset ((uint32_t)0xFFFF7FFF) + +/* ADC JSWSTART mask */ +#define CR2_JSWSTART_Set ((uint32_t)0x00200000) + +/* ADC injected software start mask */ +#define CR2_JEXTTRIG_JSWSTART_Set ((uint32_t)0x00208000) +#define CR2_JEXTTRIG_JSWSTART_Reset ((uint32_t)0xFFDF7FFF) + +/* ADC TSPD mask */ +#define CR2_TSVREFE_Set ((uint32_t)0x00800000) +#define CR2_TSVREFE_Reset ((uint32_t)0xFF7FFFFF) + +/* CR2 register Mask */ +#define CR2_CLEAR_Mask ((uint32_t)0xFFF1F7FD) + +/* ADC SQx mask */ +#define SQR3_SQ_Set ((uint32_t)0x0000001F) +#define SQR2_SQ_Set ((uint32_t)0x0000001F) +#define SQR1_SQ_Set ((uint32_t)0x0000001F) + +/* SQR1 register Mask */ +#define SQR1_CLEAR_Mask ((uint32_t)0xFF0FFFFF) + +/* ADC JSQx mask */ +#define JSQR_JSQ_Set ((uint32_t)0x0000001F) + +/* ADC JL mask */ +#define JSQR_JL_Set ((uint32_t)0x00300000) +#define JSQR_JL_Reset ((uint32_t)0xFFCFFFFF) + +/* ADC SMPx mask */ +#define SMPR1_SMP_Set ((uint32_t)0x00000007) +#define SMPR2_SMP_Set ((uint32_t)0x00000007) + +/* ADC JDRx registers offset */ +#define JDR_Offset ((uint8_t)0x28) + +/* ADC1 DR register base address */ +#define DR_ADDRESS ((uint32_t)0x4001244C) + +/** + * @} + */ + +/** @defgroup ADC_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup ADC_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup ADC_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup ADC_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the ADCx peripheral registers to their default reset values. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @retval None + */ +void ADC_DeInit(ADC_TypeDef* ADCx) +{ + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + + if (ADCx == ADC1) + { + /* Enable ADC1 reset state */ + RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC1, ENABLE); + /* Release ADC1 from reset state */ + RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC1, DISABLE); + } + else if (ADCx == ADC2) + { + /* Enable ADC2 reset state */ + RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC2, ENABLE); + /* Release ADC2 from reset state */ + RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC2, DISABLE); + } + else + { + if (ADCx == ADC3) + { + /* Enable ADC3 reset state */ + RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC3, ENABLE); + /* Release ADC3 from reset state */ + RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC3, DISABLE); + } + } +} + +/** + * @brief Initializes the ADCx peripheral according to the specified parameters + * in the ADC_InitStruct. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param ADC_InitStruct: pointer to an ADC_InitTypeDef structure that contains + * the configuration information for the specified ADC peripheral. + * @retval None + */ +void ADC_Init(ADC_TypeDef* ADCx, ADC_InitTypeDef* ADC_InitStruct) +{ + uint32_t tmpreg1 = 0; + uint8_t tmpreg2 = 0; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_ADC_MODE(ADC_InitStruct->ADC_Mode)); + assert_param(IS_FUNCTIONAL_STATE(ADC_InitStruct->ADC_ScanConvMode)); + assert_param(IS_FUNCTIONAL_STATE(ADC_InitStruct->ADC_ContinuousConvMode)); + assert_param(IS_ADC_EXT_TRIG(ADC_InitStruct->ADC_ExternalTrigConv)); + assert_param(IS_ADC_DATA_ALIGN(ADC_InitStruct->ADC_DataAlign)); + assert_param(IS_ADC_REGULAR_LENGTH(ADC_InitStruct->ADC_NbrOfChannel)); + + /*---------------------------- ADCx CR1 Configuration -----------------*/ + /* Get the ADCx CR1 value */ + tmpreg1 = ADCx->CR1; + /* Clear DUALMOD and SCAN bits */ + tmpreg1 &= CR1_CLEAR_Mask; + /* Configure ADCx: Dual mode and scan conversion mode */ + /* Set DUALMOD bits according to ADC_Mode value */ + /* Set SCAN bit according to ADC_ScanConvMode value */ + tmpreg1 |= (uint32_t)(ADC_InitStruct->ADC_Mode | ((uint32_t)ADC_InitStruct->ADC_ScanConvMode << 8)); + /* Write to ADCx CR1 */ + ADCx->CR1 = tmpreg1; + + /*---------------------------- ADCx CR2 Configuration -----------------*/ + /* Get the ADCx CR2 value */ + tmpreg1 = ADCx->CR2; + /* Clear CONT, ALIGN and EXTSEL bits */ + tmpreg1 &= CR2_CLEAR_Mask; + /* Configure ADCx: external trigger event and continuous conversion mode */ + /* Set ALIGN bit according to ADC_DataAlign value */ + /* Set EXTSEL bits according to ADC_ExternalTrigConv value */ + /* Set CONT bit according to ADC_ContinuousConvMode value */ + tmpreg1 |= (uint32_t)(ADC_InitStruct->ADC_DataAlign | ADC_InitStruct->ADC_ExternalTrigConv | + ((uint32_t)ADC_InitStruct->ADC_ContinuousConvMode << 1)); + /* Write to ADCx CR2 */ + ADCx->CR2 = tmpreg1; + + /*---------------------------- ADCx SQR1 Configuration -----------------*/ + /* Get the ADCx SQR1 value */ + tmpreg1 = ADCx->SQR1; + /* Clear L bits */ + tmpreg1 &= SQR1_CLEAR_Mask; + /* Configure ADCx: regular channel sequence length */ + /* Set L bits according to ADC_NbrOfChannel value */ + tmpreg2 |= (uint8_t) (ADC_InitStruct->ADC_NbrOfChannel - (uint8_t)1); + tmpreg1 |= (uint32_t)tmpreg2 << 20; + /* Write to ADCx SQR1 */ + ADCx->SQR1 = tmpreg1; +} + +/** + * @brief Fills each ADC_InitStruct member with its default value. + * @param ADC_InitStruct : pointer to an ADC_InitTypeDef structure which will be initialized. + * @retval None + */ +void ADC_StructInit(ADC_InitTypeDef* ADC_InitStruct) +{ + /* Reset ADC init structure parameters values */ + /* Initialize the ADC_Mode member */ + ADC_InitStruct->ADC_Mode = ADC_Mode_Independent; + /* initialize the ADC_ScanConvMode member */ + ADC_InitStruct->ADC_ScanConvMode = DISABLE; + /* Initialize the ADC_ContinuousConvMode member */ + ADC_InitStruct->ADC_ContinuousConvMode = DISABLE; + /* Initialize the ADC_ExternalTrigConv member */ + ADC_InitStruct->ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1; + /* Initialize the ADC_DataAlign member */ + ADC_InitStruct->ADC_DataAlign = ADC_DataAlign_Right; + /* Initialize the ADC_NbrOfChannel member */ + ADC_InitStruct->ADC_NbrOfChannel = 1; +} + +/** + * @brief Enables or disables the specified ADC peripheral. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param NewState: new state of the ADCx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void ADC_Cmd(ADC_TypeDef* ADCx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Set the ADON bit to wake up the ADC from power down mode */ + ADCx->CR2 |= CR2_ADON_Set; + } + else + { + /* Disable the selected ADC peripheral */ + ADCx->CR2 &= CR2_ADON_Reset; + } +} + +/** + * @brief Enables or disables the specified ADC DMA request. + * @param ADCx: where x can be 1 or 3 to select the ADC peripheral. + * Note: ADC2 hasn't a DMA capability. + * @param NewState: new state of the selected ADC DMA transfer. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void ADC_DMACmd(ADC_TypeDef* ADCx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_ADC_DMA_PERIPH(ADCx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected ADC DMA request */ + ADCx->CR2 |= CR2_DMA_Set; + } + else + { + /* Disable the selected ADC DMA request */ + ADCx->CR2 &= CR2_DMA_Reset; + } +} + +/** + * @brief Enables or disables the specified ADC interrupts. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param ADC_IT: specifies the ADC interrupt sources to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg ADC_IT_EOC: End of conversion interrupt mask + * @arg ADC_IT_AWD: Analog watchdog interrupt mask + * @arg ADC_IT_JEOC: End of injected conversion interrupt mask + * @param NewState: new state of the specified ADC interrupts. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void ADC_ITConfig(ADC_TypeDef* ADCx, uint16_t ADC_IT, FunctionalState NewState) +{ + uint8_t itmask = 0; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + assert_param(IS_ADC_IT(ADC_IT)); + /* Get the ADC IT index */ + itmask = (uint8_t)ADC_IT; + if (NewState != DISABLE) + { + /* Enable the selected ADC interrupts */ + ADCx->CR1 |= itmask; + } + else + { + /* Disable the selected ADC interrupts */ + ADCx->CR1 &= (~(uint32_t)itmask); + } +} + +/** + * @brief Resets the selected ADC calibration registers. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @retval None + */ +void ADC_ResetCalibration(ADC_TypeDef* ADCx) +{ + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + /* Resets the selected ADC calibration registers */ + ADCx->CR2 |= CR2_RSTCAL_Set; +} + +/** + * @brief Gets the selected ADC reset calibration registers status. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @retval The new state of ADC reset calibration registers (SET or RESET). + */ +FlagStatus ADC_GetResetCalibrationStatus(ADC_TypeDef* ADCx) +{ + FlagStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + /* Check the status of RSTCAL bit */ + if ((ADCx->CR2 & CR2_RSTCAL_Set) != (uint32_t)RESET) + { + /* RSTCAL bit is set */ + bitstatus = SET; + } + else + { + /* RSTCAL bit is reset */ + bitstatus = RESET; + } + /* Return the RSTCAL bit status */ + return bitstatus; +} + +/** + * @brief Starts the selected ADC calibration process. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @retval None + */ +void ADC_StartCalibration(ADC_TypeDef* ADCx) +{ + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + /* Enable the selected ADC calibration process */ + ADCx->CR2 |= CR2_CAL_Set; +} + +/** + * @brief Gets the selected ADC calibration status. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @retval The new state of ADC calibration (SET or RESET). + */ +FlagStatus ADC_GetCalibrationStatus(ADC_TypeDef* ADCx) +{ + FlagStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + /* Check the status of CAL bit */ + if ((ADCx->CR2 & CR2_CAL_Set) != (uint32_t)RESET) + { + /* CAL bit is set: calibration on going */ + bitstatus = SET; + } + else + { + /* CAL bit is reset: end of calibration */ + bitstatus = RESET; + } + /* Return the CAL bit status */ + return bitstatus; +} + +/** + * @brief Enables or disables the selected ADC software start conversion . + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param NewState: new state of the selected ADC software start conversion. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void ADC_SoftwareStartConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected ADC conversion on external event and start the selected + ADC conversion */ + ADCx->CR2 |= CR2_EXTTRIG_SWSTART_Set; + } + else + { + /* Disable the selected ADC conversion on external event and stop the selected + ADC conversion */ + ADCx->CR2 &= CR2_EXTTRIG_SWSTART_Reset; + } +} + +/** + * @brief Gets the selected ADC Software start conversion Status. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @retval The new state of ADC software start conversion (SET or RESET). + */ +FlagStatus ADC_GetSoftwareStartConvStatus(ADC_TypeDef* ADCx) +{ + FlagStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + /* Check the status of SWSTART bit */ + if ((ADCx->CR2 & CR2_SWSTART_Set) != (uint32_t)RESET) + { + /* SWSTART bit is set */ + bitstatus = SET; + } + else + { + /* SWSTART bit is reset */ + bitstatus = RESET; + } + /* Return the SWSTART bit status */ + return bitstatus; +} + +/** + * @brief Configures the discontinuous mode for the selected ADC regular + * group channel. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param Number: specifies the discontinuous mode regular channel + * count value. This number must be between 1 and 8. + * @retval None + */ +void ADC_DiscModeChannelCountConfig(ADC_TypeDef* ADCx, uint8_t Number) +{ + uint32_t tmpreg1 = 0; + uint32_t tmpreg2 = 0; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_ADC_REGULAR_DISC_NUMBER(Number)); + /* Get the old register value */ + tmpreg1 = ADCx->CR1; + /* Clear the old discontinuous mode channel count */ + tmpreg1 &= CR1_DISCNUM_Reset; + /* Set the discontinuous mode channel count */ + tmpreg2 = Number - 1; + tmpreg1 |= tmpreg2 << 13; + /* Store the new register value */ + ADCx->CR1 = tmpreg1; +} + +/** + * @brief Enables or disables the discontinuous mode on regular group + * channel for the specified ADC + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param NewState: new state of the selected ADC discontinuous mode + * on regular group channel. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void ADC_DiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected ADC regular discontinuous mode */ + ADCx->CR1 |= CR1_DISCEN_Set; + } + else + { + /* Disable the selected ADC regular discontinuous mode */ + ADCx->CR1 &= CR1_DISCEN_Reset; + } +} + +/** + * @brief Configures for the selected ADC regular channel its corresponding + * rank in the sequencer and its sample time. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param ADC_Channel: the ADC channel to configure. + * This parameter can be one of the following values: + * @arg ADC_Channel_0: ADC Channel0 selected + * @arg ADC_Channel_1: ADC Channel1 selected + * @arg ADC_Channel_2: ADC Channel2 selected + * @arg ADC_Channel_3: ADC Channel3 selected + * @arg ADC_Channel_4: ADC Channel4 selected + * @arg ADC_Channel_5: ADC Channel5 selected + * @arg ADC_Channel_6: ADC Channel6 selected + * @arg ADC_Channel_7: ADC Channel7 selected + * @arg ADC_Channel_8: ADC Channel8 selected + * @arg ADC_Channel_9: ADC Channel9 selected + * @arg ADC_Channel_10: ADC Channel10 selected + * @arg ADC_Channel_11: ADC Channel11 selected + * @arg ADC_Channel_12: ADC Channel12 selected + * @arg ADC_Channel_13: ADC Channel13 selected + * @arg ADC_Channel_14: ADC Channel14 selected + * @arg ADC_Channel_15: ADC Channel15 selected + * @arg ADC_Channel_16: ADC Channel16 selected + * @arg ADC_Channel_17: ADC Channel17 selected + * @param Rank: The rank in the regular group sequencer. This parameter must be between 1 to 16. + * @param ADC_SampleTime: The sample time value to be set for the selected channel. + * This parameter can be one of the following values: + * @arg ADC_SampleTime_1Cycles5: Sample time equal to 1.5 cycles + * @arg ADC_SampleTime_7Cycles5: Sample time equal to 7.5 cycles + * @arg ADC_SampleTime_13Cycles5: Sample time equal to 13.5 cycles + * @arg ADC_SampleTime_28Cycles5: Sample time equal to 28.5 cycles + * @arg ADC_SampleTime_41Cycles5: Sample time equal to 41.5 cycles + * @arg ADC_SampleTime_55Cycles5: Sample time equal to 55.5 cycles + * @arg ADC_SampleTime_71Cycles5: Sample time equal to 71.5 cycles + * @arg ADC_SampleTime_239Cycles5: Sample time equal to 239.5 cycles + * @retval None + */ +void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime) +{ + uint32_t tmpreg1 = 0, tmpreg2 = 0; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_ADC_CHANNEL(ADC_Channel)); + assert_param(IS_ADC_REGULAR_RANK(Rank)); + assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime)); + /* if ADC_Channel_10 ... ADC_Channel_17 is selected */ + if (ADC_Channel > ADC_Channel_9) + { + /* Get the old register value */ + tmpreg1 = ADCx->SMPR1; + /* Calculate the mask to clear */ + tmpreg2 = SMPR1_SMP_Set << (3 * (ADC_Channel - 10)); + /* Clear the old channel sample time */ + tmpreg1 &= ~tmpreg2; + /* Calculate the mask to set */ + tmpreg2 = (uint32_t)ADC_SampleTime << (3 * (ADC_Channel - 10)); + /* Set the new channel sample time */ + tmpreg1 |= tmpreg2; + /* Store the new register value */ + ADCx->SMPR1 = tmpreg1; + } + else /* ADC_Channel include in ADC_Channel_[0..9] */ + { + /* Get the old register value */ + tmpreg1 = ADCx->SMPR2; + /* Calculate the mask to clear */ + tmpreg2 = SMPR2_SMP_Set << (3 * ADC_Channel); + /* Clear the old channel sample time */ + tmpreg1 &= ~tmpreg2; + /* Calculate the mask to set */ + tmpreg2 = (uint32_t)ADC_SampleTime << (3 * ADC_Channel); + /* Set the new channel sample time */ + tmpreg1 |= tmpreg2; + /* Store the new register value */ + ADCx->SMPR2 = tmpreg1; + } + /* For Rank 1 to 6 */ + if (Rank < 7) + { + /* Get the old register value */ + tmpreg1 = ADCx->SQR3; + /* Calculate the mask to clear */ + tmpreg2 = SQR3_SQ_Set << (5 * (Rank - 1)); + /* Clear the old SQx bits for the selected rank */ + tmpreg1 &= ~tmpreg2; + /* Calculate the mask to set */ + tmpreg2 = (uint32_t)ADC_Channel << (5 * (Rank - 1)); + /* Set the SQx bits for the selected rank */ + tmpreg1 |= tmpreg2; + /* Store the new register value */ + ADCx->SQR3 = tmpreg1; + } + /* For Rank 7 to 12 */ + else if (Rank < 13) + { + /* Get the old register value */ + tmpreg1 = ADCx->SQR2; + /* Calculate the mask to clear */ + tmpreg2 = SQR2_SQ_Set << (5 * (Rank - 7)); + /* Clear the old SQx bits for the selected rank */ + tmpreg1 &= ~tmpreg2; + /* Calculate the mask to set */ + tmpreg2 = (uint32_t)ADC_Channel << (5 * (Rank - 7)); + /* Set the SQx bits for the selected rank */ + tmpreg1 |= tmpreg2; + /* Store the new register value */ + ADCx->SQR2 = tmpreg1; + } + /* For Rank 13 to 16 */ + else + { + /* Get the old register value */ + tmpreg1 = ADCx->SQR1; + /* Calculate the mask to clear */ + tmpreg2 = SQR1_SQ_Set << (5 * (Rank - 13)); + /* Clear the old SQx bits for the selected rank */ + tmpreg1 &= ~tmpreg2; + /* Calculate the mask to set */ + tmpreg2 = (uint32_t)ADC_Channel << (5 * (Rank - 13)); + /* Set the SQx bits for the selected rank */ + tmpreg1 |= tmpreg2; + /* Store the new register value */ + ADCx->SQR1 = tmpreg1; + } +} + +/** + * @brief Enables or disables the ADCx conversion through external trigger. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param NewState: new state of the selected ADC external trigger start of conversion. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void ADC_ExternalTrigConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected ADC conversion on external event */ + ADCx->CR2 |= CR2_EXTTRIG_Set; + } + else + { + /* Disable the selected ADC conversion on external event */ + ADCx->CR2 &= CR2_EXTTRIG_Reset; + } +} + +/** + * @brief Returns the last ADCx conversion result data for regular channel. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @retval The Data conversion value. + */ +uint16_t ADC_GetConversionValue(ADC_TypeDef* ADCx) +{ + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + /* Return the selected ADC conversion value */ + return (uint16_t) ADCx->DR; +} + +/** + * @brief Returns the last ADC1 and ADC2 conversion result data in dual mode. + * @retval The Data conversion value. + */ +uint32_t ADC_GetDualModeConversionValue(void) +{ + /* Return the dual mode conversion value */ + return (*(__IO uint32_t *) DR_ADDRESS); +} + +/** + * @brief Enables or disables the selected ADC automatic injected group + * conversion after regular one. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param NewState: new state of the selected ADC auto injected conversion + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void ADC_AutoInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected ADC automatic injected group conversion */ + ADCx->CR1 |= CR1_JAUTO_Set; + } + else + { + /* Disable the selected ADC automatic injected group conversion */ + ADCx->CR1 &= CR1_JAUTO_Reset; + } +} + +/** + * @brief Enables or disables the discontinuous mode for injected group + * channel for the specified ADC + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param NewState: new state of the selected ADC discontinuous mode + * on injected group channel. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void ADC_InjectedDiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected ADC injected discontinuous mode */ + ADCx->CR1 |= CR1_JDISCEN_Set; + } + else + { + /* Disable the selected ADC injected discontinuous mode */ + ADCx->CR1 &= CR1_JDISCEN_Reset; + } +} + +/** + * @brief Configures the ADCx external trigger for injected channels conversion. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param ADC_ExternalTrigInjecConv: specifies the ADC trigger to start injected conversion. + * This parameter can be one of the following values: + * @arg ADC_ExternalTrigInjecConv_T1_TRGO: Timer1 TRGO event selected (for ADC1, ADC2 and ADC3) + * @arg ADC_ExternalTrigInjecConv_T1_CC4: Timer1 capture compare4 selected (for ADC1, ADC2 and ADC3) + * @arg ADC_ExternalTrigInjecConv_T2_TRGO: Timer2 TRGO event selected (for ADC1 and ADC2) + * @arg ADC_ExternalTrigInjecConv_T2_CC1: Timer2 capture compare1 selected (for ADC1 and ADC2) + * @arg ADC_ExternalTrigInjecConv_T3_CC4: Timer3 capture compare4 selected (for ADC1 and ADC2) + * @arg ADC_ExternalTrigInjecConv_T4_TRGO: Timer4 TRGO event selected (for ADC1 and ADC2) + * @arg ADC_ExternalTrigInjecConv_Ext_IT15_TIM8_CC4: External interrupt line 15 or Timer8 + * capture compare4 event selected (for ADC1 and ADC2) + * @arg ADC_ExternalTrigInjecConv_T4_CC3: Timer4 capture compare3 selected (for ADC3 only) + * @arg ADC_ExternalTrigInjecConv_T8_CC2: Timer8 capture compare2 selected (for ADC3 only) + * @arg ADC_ExternalTrigInjecConv_T8_CC4: Timer8 capture compare4 selected (for ADC3 only) + * @arg ADC_ExternalTrigInjecConv_T5_TRGO: Timer5 TRGO event selected (for ADC3 only) + * @arg ADC_ExternalTrigInjecConv_T5_CC4: Timer5 capture compare4 selected (for ADC3 only) + * @arg ADC_ExternalTrigInjecConv_None: Injected conversion started by software and not + * by external trigger (for ADC1, ADC2 and ADC3) + * @retval None + */ +void ADC_ExternalTrigInjectedConvConfig(ADC_TypeDef* ADCx, uint32_t ADC_ExternalTrigInjecConv) +{ + uint32_t tmpreg = 0; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_ADC_EXT_INJEC_TRIG(ADC_ExternalTrigInjecConv)); + /* Get the old register value */ + tmpreg = ADCx->CR2; + /* Clear the old external event selection for injected group */ + tmpreg &= CR2_JEXTSEL_Reset; + /* Set the external event selection for injected group */ + tmpreg |= ADC_ExternalTrigInjecConv; + /* Store the new register value */ + ADCx->CR2 = tmpreg; +} + +/** + * @brief Enables or disables the ADCx injected channels conversion through + * external trigger + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param NewState: new state of the selected ADC external trigger start of + * injected conversion. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void ADC_ExternalTrigInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected ADC external event selection for injected group */ + ADCx->CR2 |= CR2_JEXTTRIG_Set; + } + else + { + /* Disable the selected ADC external event selection for injected group */ + ADCx->CR2 &= CR2_JEXTTRIG_Reset; + } +} + +/** + * @brief Enables or disables the selected ADC start of the injected + * channels conversion. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param NewState: new state of the selected ADC software start injected conversion. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void ADC_SoftwareStartInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected ADC conversion for injected group on external event and start the selected + ADC injected conversion */ + ADCx->CR2 |= CR2_JEXTTRIG_JSWSTART_Set; + } + else + { + /* Disable the selected ADC conversion on external event for injected group and stop the selected + ADC injected conversion */ + ADCx->CR2 &= CR2_JEXTTRIG_JSWSTART_Reset; + } +} + +/** + * @brief Gets the selected ADC Software start injected conversion Status. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @retval The new state of ADC software start injected conversion (SET or RESET). + */ +FlagStatus ADC_GetSoftwareStartInjectedConvCmdStatus(ADC_TypeDef* ADCx) +{ + FlagStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + /* Check the status of JSWSTART bit */ + if ((ADCx->CR2 & CR2_JSWSTART_Set) != (uint32_t)RESET) + { + /* JSWSTART bit is set */ + bitstatus = SET; + } + else + { + /* JSWSTART bit is reset */ + bitstatus = RESET; + } + /* Return the JSWSTART bit status */ + return bitstatus; +} + +/** + * @brief Configures for the selected ADC injected channel its corresponding + * rank in the sequencer and its sample time. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param ADC_Channel: the ADC channel to configure. + * This parameter can be one of the following values: + * @arg ADC_Channel_0: ADC Channel0 selected + * @arg ADC_Channel_1: ADC Channel1 selected + * @arg ADC_Channel_2: ADC Channel2 selected + * @arg ADC_Channel_3: ADC Channel3 selected + * @arg ADC_Channel_4: ADC Channel4 selected + * @arg ADC_Channel_5: ADC Channel5 selected + * @arg ADC_Channel_6: ADC Channel6 selected + * @arg ADC_Channel_7: ADC Channel7 selected + * @arg ADC_Channel_8: ADC Channel8 selected + * @arg ADC_Channel_9: ADC Channel9 selected + * @arg ADC_Channel_10: ADC Channel10 selected + * @arg ADC_Channel_11: ADC Channel11 selected + * @arg ADC_Channel_12: ADC Channel12 selected + * @arg ADC_Channel_13: ADC Channel13 selected + * @arg ADC_Channel_14: ADC Channel14 selected + * @arg ADC_Channel_15: ADC Channel15 selected + * @arg ADC_Channel_16: ADC Channel16 selected + * @arg ADC_Channel_17: ADC Channel17 selected + * @param Rank: The rank in the injected group sequencer. This parameter must be between 1 and 4. + * @param ADC_SampleTime: The sample time value to be set for the selected channel. + * This parameter can be one of the following values: + * @arg ADC_SampleTime_1Cycles5: Sample time equal to 1.5 cycles + * @arg ADC_SampleTime_7Cycles5: Sample time equal to 7.5 cycles + * @arg ADC_SampleTime_13Cycles5: Sample time equal to 13.5 cycles + * @arg ADC_SampleTime_28Cycles5: Sample time equal to 28.5 cycles + * @arg ADC_SampleTime_41Cycles5: Sample time equal to 41.5 cycles + * @arg ADC_SampleTime_55Cycles5: Sample time equal to 55.5 cycles + * @arg ADC_SampleTime_71Cycles5: Sample time equal to 71.5 cycles + * @arg ADC_SampleTime_239Cycles5: Sample time equal to 239.5 cycles + * @retval None + */ +void ADC_InjectedChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime) +{ + uint32_t tmpreg1 = 0, tmpreg2 = 0, tmpreg3 = 0; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_ADC_CHANNEL(ADC_Channel)); + assert_param(IS_ADC_INJECTED_RANK(Rank)); + assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime)); + /* if ADC_Channel_10 ... ADC_Channel_17 is selected */ + if (ADC_Channel > ADC_Channel_9) + { + /* Get the old register value */ + tmpreg1 = ADCx->SMPR1; + /* Calculate the mask to clear */ + tmpreg2 = SMPR1_SMP_Set << (3*(ADC_Channel - 10)); + /* Clear the old channel sample time */ + tmpreg1 &= ~tmpreg2; + /* Calculate the mask to set */ + tmpreg2 = (uint32_t)ADC_SampleTime << (3*(ADC_Channel - 10)); + /* Set the new channel sample time */ + tmpreg1 |= tmpreg2; + /* Store the new register value */ + ADCx->SMPR1 = tmpreg1; + } + else /* ADC_Channel include in ADC_Channel_[0..9] */ + { + /* Get the old register value */ + tmpreg1 = ADCx->SMPR2; + /* Calculate the mask to clear */ + tmpreg2 = SMPR2_SMP_Set << (3 * ADC_Channel); + /* Clear the old channel sample time */ + tmpreg1 &= ~tmpreg2; + /* Calculate the mask to set */ + tmpreg2 = (uint32_t)ADC_SampleTime << (3 * ADC_Channel); + /* Set the new channel sample time */ + tmpreg1 |= tmpreg2; + /* Store the new register value */ + ADCx->SMPR2 = tmpreg1; + } + /* Rank configuration */ + /* Get the old register value */ + tmpreg1 = ADCx->JSQR; + /* Get JL value: Number = JL+1 */ + tmpreg3 = (tmpreg1 & JSQR_JL_Set)>> 20; + /* Calculate the mask to clear: ((Rank-1)+(4-JL-1)) */ + tmpreg2 = JSQR_JSQ_Set << (5 * (uint8_t)((Rank + 3) - (tmpreg3 + 1))); + /* Clear the old JSQx bits for the selected rank */ + tmpreg1 &= ~tmpreg2; + /* Calculate the mask to set: ((Rank-1)+(4-JL-1)) */ + tmpreg2 = (uint32_t)ADC_Channel << (5 * (uint8_t)((Rank + 3) - (tmpreg3 + 1))); + /* Set the JSQx bits for the selected rank */ + tmpreg1 |= tmpreg2; + /* Store the new register value */ + ADCx->JSQR = tmpreg1; +} + +/** + * @brief Configures the sequencer length for injected channels + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param Length: The sequencer length. + * This parameter must be a number between 1 to 4. + * @retval None + */ +void ADC_InjectedSequencerLengthConfig(ADC_TypeDef* ADCx, uint8_t Length) +{ + uint32_t tmpreg1 = 0; + uint32_t tmpreg2 = 0; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_ADC_INJECTED_LENGTH(Length)); + + /* Get the old register value */ + tmpreg1 = ADCx->JSQR; + /* Clear the old injected sequnence lenght JL bits */ + tmpreg1 &= JSQR_JL_Reset; + /* Set the injected sequnence lenght JL bits */ + tmpreg2 = Length - 1; + tmpreg1 |= tmpreg2 << 20; + /* Store the new register value */ + ADCx->JSQR = tmpreg1; +} + +/** + * @brief Set the injected channels conversion value offset + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param ADC_InjectedChannel: the ADC injected channel to set its offset. + * This parameter can be one of the following values: + * @arg ADC_InjectedChannel_1: Injected Channel1 selected + * @arg ADC_InjectedChannel_2: Injected Channel2 selected + * @arg ADC_InjectedChannel_3: Injected Channel3 selected + * @arg ADC_InjectedChannel_4: Injected Channel4 selected + * @param Offset: the offset value for the selected ADC injected channel + * This parameter must be a 12bit value. + * @retval None + */ +void ADC_SetInjectedOffset(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel, uint16_t Offset) +{ + __IO uint32_t tmp = 0; + + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedChannel)); + assert_param(IS_ADC_OFFSET(Offset)); + + tmp = (uint32_t)ADCx; + tmp += ADC_InjectedChannel; + + /* Set the selected injected channel data offset */ + *(__IO uint32_t *) tmp = (uint32_t)Offset; +} + +/** + * @brief Returns the ADC injected channel conversion result + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param ADC_InjectedChannel: the converted ADC injected channel. + * This parameter can be one of the following values: + * @arg ADC_InjectedChannel_1: Injected Channel1 selected + * @arg ADC_InjectedChannel_2: Injected Channel2 selected + * @arg ADC_InjectedChannel_3: Injected Channel3 selected + * @arg ADC_InjectedChannel_4: Injected Channel4 selected + * @retval The Data conversion value. + */ +uint16_t ADC_GetInjectedConversionValue(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel) +{ + __IO uint32_t tmp = 0; + + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedChannel)); + + tmp = (uint32_t)ADCx; + tmp += ADC_InjectedChannel + JDR_Offset; + + /* Returns the selected injected channel conversion data value */ + return (uint16_t) (*(__IO uint32_t*) tmp); +} + +/** + * @brief Enables or disables the analog watchdog on single/all regular + * or injected channels + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param ADC_AnalogWatchdog: the ADC analog watchdog configuration. + * This parameter can be one of the following values: + * @arg ADC_AnalogWatchdog_SingleRegEnable: Analog watchdog on a single regular channel + * @arg ADC_AnalogWatchdog_SingleInjecEnable: Analog watchdog on a single injected channel + * @arg ADC_AnalogWatchdog_SingleRegOrInjecEnable: Analog watchdog on a single regular or injected channel + * @arg ADC_AnalogWatchdog_AllRegEnable: Analog watchdog on all regular channel + * @arg ADC_AnalogWatchdog_AllInjecEnable: Analog watchdog on all injected channel + * @arg ADC_AnalogWatchdog_AllRegAllInjecEnable: Analog watchdog on all regular and injected channels + * @arg ADC_AnalogWatchdog_None: No channel guarded by the analog watchdog + * @retval None + */ +void ADC_AnalogWatchdogCmd(ADC_TypeDef* ADCx, uint32_t ADC_AnalogWatchdog) +{ + uint32_t tmpreg = 0; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_ADC_ANALOG_WATCHDOG(ADC_AnalogWatchdog)); + /* Get the old register value */ + tmpreg = ADCx->CR1; + /* Clear AWDEN, AWDENJ and AWDSGL bits */ + tmpreg &= CR1_AWDMode_Reset; + /* Set the analog watchdog enable mode */ + tmpreg |= ADC_AnalogWatchdog; + /* Store the new register value */ + ADCx->CR1 = tmpreg; +} + +/** + * @brief Configures the high and low thresholds of the analog watchdog. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param HighThreshold: the ADC analog watchdog High threshold value. + * This parameter must be a 12bit value. + * @param LowThreshold: the ADC analog watchdog Low threshold value. + * This parameter must be a 12bit value. + * @retval None + */ +void ADC_AnalogWatchdogThresholdsConfig(ADC_TypeDef* ADCx, uint16_t HighThreshold, + uint16_t LowThreshold) +{ + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_ADC_THRESHOLD(HighThreshold)); + assert_param(IS_ADC_THRESHOLD(LowThreshold)); + /* Set the ADCx high threshold */ + ADCx->HTR = HighThreshold; + /* Set the ADCx low threshold */ + ADCx->LTR = LowThreshold; +} + +/** + * @brief Configures the analog watchdog guarded single channel + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param ADC_Channel: the ADC channel to configure for the analog watchdog. + * This parameter can be one of the following values: + * @arg ADC_Channel_0: ADC Channel0 selected + * @arg ADC_Channel_1: ADC Channel1 selected + * @arg ADC_Channel_2: ADC Channel2 selected + * @arg ADC_Channel_3: ADC Channel3 selected + * @arg ADC_Channel_4: ADC Channel4 selected + * @arg ADC_Channel_5: ADC Channel5 selected + * @arg ADC_Channel_6: ADC Channel6 selected + * @arg ADC_Channel_7: ADC Channel7 selected + * @arg ADC_Channel_8: ADC Channel8 selected + * @arg ADC_Channel_9: ADC Channel9 selected + * @arg ADC_Channel_10: ADC Channel10 selected + * @arg ADC_Channel_11: ADC Channel11 selected + * @arg ADC_Channel_12: ADC Channel12 selected + * @arg ADC_Channel_13: ADC Channel13 selected + * @arg ADC_Channel_14: ADC Channel14 selected + * @arg ADC_Channel_15: ADC Channel15 selected + * @arg ADC_Channel_16: ADC Channel16 selected + * @arg ADC_Channel_17: ADC Channel17 selected + * @retval None + */ +void ADC_AnalogWatchdogSingleChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel) +{ + uint32_t tmpreg = 0; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_ADC_CHANNEL(ADC_Channel)); + /* Get the old register value */ + tmpreg = ADCx->CR1; + /* Clear the Analog watchdog channel select bits */ + tmpreg &= CR1_AWDCH_Reset; + /* Set the Analog watchdog channel */ + tmpreg |= ADC_Channel; + /* Store the new register value */ + ADCx->CR1 = tmpreg; +} + +/** + * @brief Enables or disables the temperature sensor and Vrefint channel. + * @param NewState: new state of the temperature sensor. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void ADC_TempSensorVrefintCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the temperature sensor and Vrefint channel*/ + ADC1->CR2 |= CR2_TSVREFE_Set; + } + else + { + /* Disable the temperature sensor and Vrefint channel*/ + ADC1->CR2 &= CR2_TSVREFE_Reset; + } +} + +/** + * @brief Checks whether the specified ADC flag is set or not. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param ADC_FLAG: specifies the flag to check. + * This parameter can be one of the following values: + * @arg ADC_FLAG_AWD: Analog watchdog flag + * @arg ADC_FLAG_EOC: End of conversion flag + * @arg ADC_FLAG_JEOC: End of injected group conversion flag + * @arg ADC_FLAG_JSTRT: Start of injected group conversion flag + * @arg ADC_FLAG_STRT: Start of regular group conversion flag + * @retval The new state of ADC_FLAG (SET or RESET). + */ +FlagStatus ADC_GetFlagStatus(ADC_TypeDef* ADCx, uint8_t ADC_FLAG) +{ + FlagStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_ADC_GET_FLAG(ADC_FLAG)); + /* Check the status of the specified ADC flag */ + if ((ADCx->SR & ADC_FLAG) != (uint8_t)RESET) + { + /* ADC_FLAG is set */ + bitstatus = SET; + } + else + { + /* ADC_FLAG is reset */ + bitstatus = RESET; + } + /* Return the ADC_FLAG status */ + return bitstatus; +} + +/** + * @brief Clears the ADCx's pending flags. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param ADC_FLAG: specifies the flag to clear. + * This parameter can be any combination of the following values: + * @arg ADC_FLAG_AWD: Analog watchdog flag + * @arg ADC_FLAG_EOC: End of conversion flag + * @arg ADC_FLAG_JEOC: End of injected group conversion flag + * @arg ADC_FLAG_JSTRT: Start of injected group conversion flag + * @arg ADC_FLAG_STRT: Start of regular group conversion flag + * @retval None + */ +void ADC_ClearFlag(ADC_TypeDef* ADCx, uint8_t ADC_FLAG) +{ + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_ADC_CLEAR_FLAG(ADC_FLAG)); + /* Clear the selected ADC flags */ + ADCx->SR = ~(uint32_t)ADC_FLAG; +} + +/** + * @brief Checks whether the specified ADC interrupt has occurred or not. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param ADC_IT: specifies the ADC interrupt source to check. + * This parameter can be one of the following values: + * @arg ADC_IT_EOC: End of conversion interrupt mask + * @arg ADC_IT_AWD: Analog watchdog interrupt mask + * @arg ADC_IT_JEOC: End of injected conversion interrupt mask + * @retval The new state of ADC_IT (SET or RESET). + */ +ITStatus ADC_GetITStatus(ADC_TypeDef* ADCx, uint16_t ADC_IT) +{ + ITStatus bitstatus = RESET; + uint32_t itmask = 0, enablestatus = 0; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_ADC_GET_IT(ADC_IT)); + /* Get the ADC IT index */ + itmask = ADC_IT >> 8; + /* Get the ADC_IT enable bit status */ + enablestatus = (ADCx->CR1 & (uint8_t)ADC_IT) ; + /* Check the status of the specified ADC interrupt */ + if (((ADCx->SR & itmask) != (uint32_t)RESET) && enablestatus) + { + /* ADC_IT is set */ + bitstatus = SET; + } + else + { + /* ADC_IT is reset */ + bitstatus = RESET; + } + /* Return the ADC_IT status */ + return bitstatus; +} + +/** + * @brief Clears the ADCx's interrupt pending bits. + * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral. + * @param ADC_IT: specifies the ADC interrupt pending bit to clear. + * This parameter can be any combination of the following values: + * @arg ADC_IT_EOC: End of conversion interrupt mask + * @arg ADC_IT_AWD: Analog watchdog interrupt mask + * @arg ADC_IT_JEOC: End of injected conversion interrupt mask + * @retval None + */ +void ADC_ClearITPendingBit(ADC_TypeDef* ADCx, uint16_t ADC_IT) +{ + uint8_t itmask = 0; + /* Check the parameters */ + assert_param(IS_ADC_ALL_PERIPH(ADCx)); + assert_param(IS_ADC_IT(ADC_IT)); + /* Get the ADC IT index */ + itmask = (uint8_t)(ADC_IT >> 8); + /* Clear the selected ADC interrupt pending bits */ + ADCx->SR = ~(uint32_t)itmask; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_bkp.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_bkp.c new file mode 100755 index 0000000..3004b9e --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_bkp.c @@ -0,0 +1,308 @@ +/** + ****************************************************************************** + * @file stm32f10x_bkp.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the BKP firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_bkp.h" +#include "stm32f10x_rcc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup BKP + * @brief BKP driver modules + * @{ + */ + +/** @defgroup BKP_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup BKP_Private_Defines + * @{ + */ + +/* ------------ BKP registers bit address in the alias region --------------- */ +#define BKP_OFFSET (BKP_BASE - PERIPH_BASE) + +/* --- CR Register ----*/ + +/* Alias word address of TPAL bit */ +#define CR_OFFSET (BKP_OFFSET + 0x30) +#define TPAL_BitNumber 0x01 +#define CR_TPAL_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (TPAL_BitNumber * 4)) + +/* Alias word address of TPE bit */ +#define TPE_BitNumber 0x00 +#define CR_TPE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (TPE_BitNumber * 4)) + +/* --- CSR Register ---*/ + +/* Alias word address of TPIE bit */ +#define CSR_OFFSET (BKP_OFFSET + 0x34) +#define TPIE_BitNumber 0x02 +#define CSR_TPIE_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TPIE_BitNumber * 4)) + +/* Alias word address of TIF bit */ +#define TIF_BitNumber 0x09 +#define CSR_TIF_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TIF_BitNumber * 4)) + +/* Alias word address of TEF bit */ +#define TEF_BitNumber 0x08 +#define CSR_TEF_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TEF_BitNumber * 4)) + +/* ---------------------- BKP registers bit mask ------------------------ */ + +/* RTCCR register bit mask */ +#define RTCCR_CAL_MASK ((uint16_t)0xFF80) +#define RTCCR_MASK ((uint16_t)0xFC7F) + +/** + * @} + */ + + +/** @defgroup BKP_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup BKP_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup BKP_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup BKP_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the BKP peripheral registers to their default reset values. + * @param None + * @retval None + */ +void BKP_DeInit(void) +{ + RCC_BackupResetCmd(ENABLE); + RCC_BackupResetCmd(DISABLE); +} + +/** + * @brief Configures the Tamper Pin active level. + * @param BKP_TamperPinLevel: specifies the Tamper Pin active level. + * This parameter can be one of the following values: + * @arg BKP_TamperPinLevel_High: Tamper pin active on high level + * @arg BKP_TamperPinLevel_Low: Tamper pin active on low level + * @retval None + */ +void BKP_TamperPinLevelConfig(uint16_t BKP_TamperPinLevel) +{ + /* Check the parameters */ + assert_param(IS_BKP_TAMPER_PIN_LEVEL(BKP_TamperPinLevel)); + *(__IO uint32_t *) CR_TPAL_BB = BKP_TamperPinLevel; +} + +/** + * @brief Enables or disables the Tamper Pin activation. + * @param NewState: new state of the Tamper Pin activation. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void BKP_TamperPinCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + *(__IO uint32_t *) CR_TPE_BB = (uint32_t)NewState; +} + +/** + * @brief Enables or disables the Tamper Pin Interrupt. + * @param NewState: new state of the Tamper Pin Interrupt. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void BKP_ITConfig(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + *(__IO uint32_t *) CSR_TPIE_BB = (uint32_t)NewState; +} + +/** + * @brief Select the RTC output source to output on the Tamper pin. + * @param BKP_RTCOutputSource: specifies the RTC output source. + * This parameter can be one of the following values: + * @arg BKP_RTCOutputSource_None: no RTC output on the Tamper pin. + * @arg BKP_RTCOutputSource_CalibClock: output the RTC clock with frequency + * divided by 64 on the Tamper pin. + * @arg BKP_RTCOutputSource_Alarm: output the RTC Alarm pulse signal on + * the Tamper pin. + * @arg BKP_RTCOutputSource_Second: output the RTC Second pulse signal on + * the Tamper pin. + * @retval None + */ +void BKP_RTCOutputConfig(uint16_t BKP_RTCOutputSource) +{ + uint16_t tmpreg = 0; + /* Check the parameters */ + assert_param(IS_BKP_RTC_OUTPUT_SOURCE(BKP_RTCOutputSource)); + tmpreg = BKP->RTCCR; + /* Clear CCO, ASOE and ASOS bits */ + tmpreg &= RTCCR_MASK; + + /* Set CCO, ASOE and ASOS bits according to BKP_RTCOutputSource value */ + tmpreg |= BKP_RTCOutputSource; + /* Store the new value */ + BKP->RTCCR = tmpreg; +} + +/** + * @brief Sets RTC Clock Calibration value. + * @param CalibrationValue: specifies the RTC Clock Calibration value. + * This parameter must be a number between 0 and 0x7F. + * @retval None + */ +void BKP_SetRTCCalibrationValue(uint8_t CalibrationValue) +{ + uint16_t tmpreg = 0; + /* Check the parameters */ + assert_param(IS_BKP_CALIBRATION_VALUE(CalibrationValue)); + tmpreg = BKP->RTCCR; + /* Clear CAL[6:0] bits */ + tmpreg &= RTCCR_CAL_MASK; + /* Set CAL[6:0] bits according to CalibrationValue value */ + tmpreg |= CalibrationValue; + /* Store the new value */ + BKP->RTCCR = tmpreg; +} + +/** + * @brief Writes user data to the specified Data Backup Register. + * @param BKP_DR: specifies the Data Backup Register. + * This parameter can be BKP_DRx where x:[1, 42] + * @param Data: data to write + * @retval None + */ +void BKP_WriteBackupRegister(uint16_t BKP_DR, uint16_t Data) +{ + __IO uint32_t tmp = 0; + + /* Check the parameters */ + assert_param(IS_BKP_DR(BKP_DR)); + + tmp = (uint32_t)BKP_BASE; + tmp += BKP_DR; + + *(__IO uint32_t *) tmp = Data; +} + +/** + * @brief Reads data from the specified Data Backup Register. + * @param BKP_DR: specifies the Data Backup Register. + * This parameter can be BKP_DRx where x:[1, 42] + * @retval The content of the specified Data Backup Register + */ +uint16_t BKP_ReadBackupRegister(uint16_t BKP_DR) +{ + __IO uint32_t tmp = 0; + + /* Check the parameters */ + assert_param(IS_BKP_DR(BKP_DR)); + + tmp = (uint32_t)BKP_BASE; + tmp += BKP_DR; + + return (*(__IO uint16_t *) tmp); +} + +/** + * @brief Checks whether the Tamper Pin Event flag is set or not. + * @param None + * @retval The new state of the Tamper Pin Event flag (SET or RESET). + */ +FlagStatus BKP_GetFlagStatus(void) +{ + return (FlagStatus)(*(__IO uint32_t *) CSR_TEF_BB); +} + +/** + * @brief Clears Tamper Pin Event pending flag. + * @param None + * @retval None + */ +void BKP_ClearFlag(void) +{ + /* Set CTE bit to clear Tamper Pin Event flag */ + BKP->CSR |= BKP_CSR_CTE; +} + +/** + * @brief Checks whether the Tamper Pin Interrupt has occurred or not. + * @param None + * @retval The new state of the Tamper Pin Interrupt (SET or RESET). + */ +ITStatus BKP_GetITStatus(void) +{ + return (ITStatus)(*(__IO uint32_t *) CSR_TIF_BB); +} + +/** + * @brief Clears Tamper Pin Interrupt pending bit. + * @param None + * @retval None + */ +void BKP_ClearITPendingBit(void) +{ + /* Set CTI bit to clear Tamper Pin Interrupt pending bit */ + BKP->CSR |= BKP_CSR_CTI; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_can.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_can.c new file mode 100755 index 0000000..607d692 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_can.c @@ -0,0 +1,1415 @@ +/** + ****************************************************************************** + * @file stm32f10x_can.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the CAN firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_can.h" +#include "stm32f10x_rcc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup CAN + * @brief CAN driver modules + * @{ + */ + +/** @defgroup CAN_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup CAN_Private_Defines + * @{ + */ + +/* CAN Master Control Register bits */ + +#define MCR_DBF ((uint32_t)0x00010000) /* software master reset */ + +/* CAN Mailbox Transmit Request */ +#define TMIDxR_TXRQ ((uint32_t)0x00000001) /* Transmit mailbox request */ + +/* CAN Filter Master Register bits */ +#define FMR_FINIT ((uint32_t)0x00000001) /* Filter init mode */ + +/* Time out for INAK bit */ +#define INAK_TIMEOUT ((uint32_t)0x0000FFFF) +/* Time out for SLAK bit */ +#define SLAK_TIMEOUT ((uint32_t)0x0000FFFF) + + + +/* Flags in TSR register */ +#define CAN_FLAGS_TSR ((uint32_t)0x08000000) +/* Flags in RF1R register */ +#define CAN_FLAGS_RF1R ((uint32_t)0x04000000) +/* Flags in RF0R register */ +#define CAN_FLAGS_RF0R ((uint32_t)0x02000000) +/* Flags in MSR register */ +#define CAN_FLAGS_MSR ((uint32_t)0x01000000) +/* Flags in ESR register */ +#define CAN_FLAGS_ESR ((uint32_t)0x00F00000) + +/* Mailboxes definition */ +#define CAN_TXMAILBOX_0 ((uint8_t)0x00) +#define CAN_TXMAILBOX_1 ((uint8_t)0x01) +#define CAN_TXMAILBOX_2 ((uint8_t)0x02) + + + +#define CAN_MODE_MASK ((uint32_t) 0x00000003) +/** + * @} + */ + +/** @defgroup CAN_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup CAN_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup CAN_Private_FunctionPrototypes + * @{ + */ + +static ITStatus CheckITStatus(uint32_t CAN_Reg, uint32_t It_Bit); + +/** + * @} + */ + +/** @defgroup CAN_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the CAN peripheral registers to their default reset values. + * @param CANx: where x can be 1 or 2 to select the CAN peripheral. + * @retval None. + */ +void CAN_DeInit(CAN_TypeDef* CANx) +{ + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + + if (CANx == CAN1) + { + /* Enable CAN1 reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_CAN1, ENABLE); + /* Release CAN1 from reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_CAN1, DISABLE); + } + else + { + /* Enable CAN2 reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_CAN2, ENABLE); + /* Release CAN2 from reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_CAN2, DISABLE); + } +} + +/** + * @brief Initializes the CAN peripheral according to the specified + * parameters in the CAN_InitStruct. + * @param CANx: where x can be 1 or 2 to to select the CAN + * peripheral. + * @param CAN_InitStruct: pointer to a CAN_InitTypeDef structure that + * contains the configuration information for the + * CAN peripheral. + * @retval Constant indicates initialization succeed which will be + * CAN_InitStatus_Failed or CAN_InitStatus_Success. + */ +uint8_t CAN_Init(CAN_TypeDef* CANx, CAN_InitTypeDef* CAN_InitStruct) +{ + uint8_t InitStatus = CAN_InitStatus_Failed; + uint32_t wait_ack = 0x00000000; + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_TTCM)); + assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_ABOM)); + assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_AWUM)); + assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_NART)); + assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_RFLM)); + assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_TXFP)); + assert_param(IS_CAN_MODE(CAN_InitStruct->CAN_Mode)); + assert_param(IS_CAN_SJW(CAN_InitStruct->CAN_SJW)); + assert_param(IS_CAN_BS1(CAN_InitStruct->CAN_BS1)); + assert_param(IS_CAN_BS2(CAN_InitStruct->CAN_BS2)); + assert_param(IS_CAN_PRESCALER(CAN_InitStruct->CAN_Prescaler)); + + /* Exit from sleep mode */ + CANx->MCR &= (~(uint32_t)CAN_MCR_SLEEP); + + /* Request initialisation */ + CANx->MCR |= CAN_MCR_INRQ ; + + /* Wait the acknowledge */ + while (((CANx->MSR & CAN_MSR_INAK) != CAN_MSR_INAK) && (wait_ack != INAK_TIMEOUT)) + { + wait_ack++; + } + + /* Check acknowledge */ + if ((CANx->MSR & CAN_MSR_INAK) != CAN_MSR_INAK) + { + InitStatus = CAN_InitStatus_Failed; + } + else + { + /* Set the time triggered communication mode */ + if (CAN_InitStruct->CAN_TTCM == ENABLE) + { + CANx->MCR |= CAN_MCR_TTCM; + } + else + { + CANx->MCR &= ~(uint32_t)CAN_MCR_TTCM; + } + + /* Set the automatic bus-off management */ + if (CAN_InitStruct->CAN_ABOM == ENABLE) + { + CANx->MCR |= CAN_MCR_ABOM; + } + else + { + CANx->MCR &= ~(uint32_t)CAN_MCR_ABOM; + } + + /* Set the automatic wake-up mode */ + if (CAN_InitStruct->CAN_AWUM == ENABLE) + { + CANx->MCR |= CAN_MCR_AWUM; + } + else + { + CANx->MCR &= ~(uint32_t)CAN_MCR_AWUM; + } + + /* Set the no automatic retransmission */ + if (CAN_InitStruct->CAN_NART == ENABLE) + { + CANx->MCR |= CAN_MCR_NART; + } + else + { + CANx->MCR &= ~(uint32_t)CAN_MCR_NART; + } + + /* Set the receive FIFO locked mode */ + if (CAN_InitStruct->CAN_RFLM == ENABLE) + { + CANx->MCR |= CAN_MCR_RFLM; + } + else + { + CANx->MCR &= ~(uint32_t)CAN_MCR_RFLM; + } + + /* Set the transmit FIFO priority */ + if (CAN_InitStruct->CAN_TXFP == ENABLE) + { + CANx->MCR |= CAN_MCR_TXFP; + } + else + { + CANx->MCR &= ~(uint32_t)CAN_MCR_TXFP; + } + + /* Set the bit timing register */ + CANx->BTR = (uint32_t)((uint32_t)CAN_InitStruct->CAN_Mode << 30) | \ + ((uint32_t)CAN_InitStruct->CAN_SJW << 24) | \ + ((uint32_t)CAN_InitStruct->CAN_BS1 << 16) | \ + ((uint32_t)CAN_InitStruct->CAN_BS2 << 20) | \ + ((uint32_t)CAN_InitStruct->CAN_Prescaler - 1); + + /* Request leave initialisation */ + CANx->MCR &= ~(uint32_t)CAN_MCR_INRQ; + + /* Wait the acknowledge */ + wait_ack = 0; + + while (((CANx->MSR & CAN_MSR_INAK) == CAN_MSR_INAK) && (wait_ack != INAK_TIMEOUT)) + { + wait_ack++; + } + + /* ...and check acknowledged */ + if ((CANx->MSR & CAN_MSR_INAK) == CAN_MSR_INAK) + { + InitStatus = CAN_InitStatus_Failed; + } + else + { + InitStatus = CAN_InitStatus_Success ; + } + } + + /* At this step, return the status of initialization */ + return InitStatus; +} + +/** + * @brief Initializes the CAN peripheral according to the specified + * parameters in the CAN_FilterInitStruct. + * @param CAN_FilterInitStruct: pointer to a CAN_FilterInitTypeDef + * structure that contains the configuration + * information. + * @retval None. + */ +void CAN_FilterInit(CAN_FilterInitTypeDef* CAN_FilterInitStruct) +{ + uint32_t filter_number_bit_pos = 0; + /* Check the parameters */ + assert_param(IS_CAN_FILTER_NUMBER(CAN_FilterInitStruct->CAN_FilterNumber)); + assert_param(IS_CAN_FILTER_MODE(CAN_FilterInitStruct->CAN_FilterMode)); + assert_param(IS_CAN_FILTER_SCALE(CAN_FilterInitStruct->CAN_FilterScale)); + assert_param(IS_CAN_FILTER_FIFO(CAN_FilterInitStruct->CAN_FilterFIFOAssignment)); + assert_param(IS_FUNCTIONAL_STATE(CAN_FilterInitStruct->CAN_FilterActivation)); + + filter_number_bit_pos = ((uint32_t)1) << CAN_FilterInitStruct->CAN_FilterNumber; + + /* Initialisation mode for the filter */ + CAN1->FMR |= FMR_FINIT; + + /* Filter Deactivation */ + CAN1->FA1R &= ~(uint32_t)filter_number_bit_pos; + + /* Filter Scale */ + if (CAN_FilterInitStruct->CAN_FilterScale == CAN_FilterScale_16bit) + { + /* 16-bit scale for the filter */ + CAN1->FS1R &= ~(uint32_t)filter_number_bit_pos; + + /* First 16-bit identifier and First 16-bit mask */ + /* Or First 16-bit identifier and Second 16-bit identifier */ + CAN1->sFilterRegister[CAN_FilterInitStruct->CAN_FilterNumber].FR1 = + ((0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterMaskIdLow) << 16) | + (0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterIdLow); + + /* Second 16-bit identifier and Second 16-bit mask */ + /* Or Third 16-bit identifier and Fourth 16-bit identifier */ + CAN1->sFilterRegister[CAN_FilterInitStruct->CAN_FilterNumber].FR2 = + ((0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterMaskIdHigh) << 16) | + (0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterIdHigh); + } + + if (CAN_FilterInitStruct->CAN_FilterScale == CAN_FilterScale_32bit) + { + /* 32-bit scale for the filter */ + CAN1->FS1R |= filter_number_bit_pos; + /* 32-bit identifier or First 32-bit identifier */ + CAN1->sFilterRegister[CAN_FilterInitStruct->CAN_FilterNumber].FR1 = + ((0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterIdHigh) << 16) | + (0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterIdLow); + /* 32-bit mask or Second 32-bit identifier */ + CAN1->sFilterRegister[CAN_FilterInitStruct->CAN_FilterNumber].FR2 = + ((0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterMaskIdHigh) << 16) | + (0x0000FFFF & (uint32_t)CAN_FilterInitStruct->CAN_FilterMaskIdLow); + } + + /* Filter Mode */ + if (CAN_FilterInitStruct->CAN_FilterMode == CAN_FilterMode_IdMask) + { + /*Id/Mask mode for the filter*/ + CAN1->FM1R &= ~(uint32_t)filter_number_bit_pos; + } + else /* CAN_FilterInitStruct->CAN_FilterMode == CAN_FilterMode_IdList */ + { + /*Identifier list mode for the filter*/ + CAN1->FM1R |= (uint32_t)filter_number_bit_pos; + } + + /* Filter FIFO assignment */ + if (CAN_FilterInitStruct->CAN_FilterFIFOAssignment == CAN_Filter_FIFO0) + { + /* FIFO 0 assignation for the filter */ + CAN1->FFA1R &= ~(uint32_t)filter_number_bit_pos; + } + + if (CAN_FilterInitStruct->CAN_FilterFIFOAssignment == CAN_Filter_FIFO1) + { + /* FIFO 1 assignation for the filter */ + CAN1->FFA1R |= (uint32_t)filter_number_bit_pos; + } + + /* Filter activation */ + if (CAN_FilterInitStruct->CAN_FilterActivation == ENABLE) + { + CAN1->FA1R |= filter_number_bit_pos; + } + + /* Leave the initialisation mode for the filter */ + CAN1->FMR &= ~FMR_FINIT; +} + +/** + * @brief Fills each CAN_InitStruct member with its default value. + * @param CAN_InitStruct: pointer to a CAN_InitTypeDef structure which + * will be initialized. + * @retval None. + */ +void CAN_StructInit(CAN_InitTypeDef* CAN_InitStruct) +{ + /* Reset CAN init structure parameters values */ + + /* Initialize the time triggered communication mode */ + CAN_InitStruct->CAN_TTCM = DISABLE; + + /* Initialize the automatic bus-off management */ + CAN_InitStruct->CAN_ABOM = DISABLE; + + /* Initialize the automatic wake-up mode */ + CAN_InitStruct->CAN_AWUM = DISABLE; + + /* Initialize the no automatic retransmission */ + CAN_InitStruct->CAN_NART = DISABLE; + + /* Initialize the receive FIFO locked mode */ + CAN_InitStruct->CAN_RFLM = DISABLE; + + /* Initialize the transmit FIFO priority */ + CAN_InitStruct->CAN_TXFP = DISABLE; + + /* Initialize the CAN_Mode member */ + CAN_InitStruct->CAN_Mode = CAN_Mode_Normal; + + /* Initialize the CAN_SJW member */ + CAN_InitStruct->CAN_SJW = CAN_SJW_1tq; + + /* Initialize the CAN_BS1 member */ + CAN_InitStruct->CAN_BS1 = CAN_BS1_4tq; + + /* Initialize the CAN_BS2 member */ + CAN_InitStruct->CAN_BS2 = CAN_BS2_3tq; + + /* Initialize the CAN_Prescaler member */ + CAN_InitStruct->CAN_Prescaler = 1; +} + +/** + * @brief Select the start bank filter for slave CAN. + * @note This function applies only to STM32 Connectivity line devices. + * @param CAN_BankNumber: Select the start slave bank filter from 1..27. + * @retval None. + */ +void CAN_SlaveStartBank(uint8_t CAN_BankNumber) +{ + /* Check the parameters */ + assert_param(IS_CAN_BANKNUMBER(CAN_BankNumber)); + + /* Enter Initialisation mode for the filter */ + CAN1->FMR |= FMR_FINIT; + + /* Select the start slave bank */ + CAN1->FMR &= (uint32_t)0xFFFFC0F1 ; + CAN1->FMR |= (uint32_t)(CAN_BankNumber)<<8; + + /* Leave Initialisation mode for the filter */ + CAN1->FMR &= ~FMR_FINIT; +} + +/** + * @brief Enables or disables the DBG Freeze for CAN. + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @param NewState: new state of the CAN peripheral. This parameter can + * be: ENABLE or DISABLE. + * @retval None. + */ +void CAN_DBGFreeze(CAN_TypeDef* CANx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable Debug Freeze */ + CANx->MCR |= MCR_DBF; + } + else + { + /* Disable Debug Freeze */ + CANx->MCR &= ~MCR_DBF; + } +} + + +/** + * @brief Enables or disabes the CAN Time TriggerOperation communication mode. + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @param NewState : Mode new state , can be one of @ref FunctionalState. + * @note when enabled, Time stamp (TIME[15:0]) value is sent in the last + * two data bytes of the 8-byte message: TIME[7:0] in data byte 6 + * and TIME[15:8] in data byte 7 + * @note DLC must be programmed as 8 in order Time Stamp (2 bytes) to be + * sent over the CAN bus. + * @retval None + */ +void CAN_TTComModeCmd(CAN_TypeDef* CANx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the TTCM mode */ + CANx->MCR |= CAN_MCR_TTCM; + + /* Set TGT bits */ + CANx->sTxMailBox[0].TDTR |= ((uint32_t)CAN_TDT0R_TGT); + CANx->sTxMailBox[1].TDTR |= ((uint32_t)CAN_TDT1R_TGT); + CANx->sTxMailBox[2].TDTR |= ((uint32_t)CAN_TDT2R_TGT); + } + else + { + /* Disable the TTCM mode */ + CANx->MCR &= (uint32_t)(~(uint32_t)CAN_MCR_TTCM); + + /* Reset TGT bits */ + CANx->sTxMailBox[0].TDTR &= ((uint32_t)~CAN_TDT0R_TGT); + CANx->sTxMailBox[1].TDTR &= ((uint32_t)~CAN_TDT1R_TGT); + CANx->sTxMailBox[2].TDTR &= ((uint32_t)~CAN_TDT2R_TGT); + } +} +/** + * @brief Initiates the transmission of a message. + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @param TxMessage: pointer to a structure which contains CAN Id, CAN + * DLC and CAN data. + * @retval The number of the mailbox that is used for transmission + * or CAN_TxStatus_NoMailBox if there is no empty mailbox. + */ +uint8_t CAN_Transmit(CAN_TypeDef* CANx, CanTxMsg* TxMessage) +{ + uint8_t transmit_mailbox = 0; + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + assert_param(IS_CAN_IDTYPE(TxMessage->IDE)); + assert_param(IS_CAN_RTR(TxMessage->RTR)); + assert_param(IS_CAN_DLC(TxMessage->DLC)); + + /* Select one empty transmit mailbox */ + if ((CANx->TSR&CAN_TSR_TME0) == CAN_TSR_TME0) + { + transmit_mailbox = 0; + } + else if ((CANx->TSR&CAN_TSR_TME1) == CAN_TSR_TME1) + { + transmit_mailbox = 1; + } + else if ((CANx->TSR&CAN_TSR_TME2) == CAN_TSR_TME2) + { + transmit_mailbox = 2; + } + else + { + transmit_mailbox = CAN_TxStatus_NoMailBox; + } + + if (transmit_mailbox != CAN_TxStatus_NoMailBox) + { + /* Set up the Id */ + CANx->sTxMailBox[transmit_mailbox].TIR &= TMIDxR_TXRQ; + if (TxMessage->IDE == CAN_Id_Standard) + { + assert_param(IS_CAN_STDID(TxMessage->StdId)); + CANx->sTxMailBox[transmit_mailbox].TIR |= ((TxMessage->StdId << 21) | \ + TxMessage->RTR); + } + else + { + assert_param(IS_CAN_EXTID(TxMessage->ExtId)); + CANx->sTxMailBox[transmit_mailbox].TIR |= ((TxMessage->ExtId << 3) | \ + TxMessage->IDE | \ + TxMessage->RTR); + } + + /* Set up the DLC */ + TxMessage->DLC &= (uint8_t)0x0000000F; + CANx->sTxMailBox[transmit_mailbox].TDTR &= (uint32_t)0xFFFFFFF0; + CANx->sTxMailBox[transmit_mailbox].TDTR |= TxMessage->DLC; + + /* Set up the data field */ + CANx->sTxMailBox[transmit_mailbox].TDLR = (((uint32_t)TxMessage->Data[3] << 24) | + ((uint32_t)TxMessage->Data[2] << 16) | + ((uint32_t)TxMessage->Data[1] << 8) | + ((uint32_t)TxMessage->Data[0])); + CANx->sTxMailBox[transmit_mailbox].TDHR = (((uint32_t)TxMessage->Data[7] << 24) | + ((uint32_t)TxMessage->Data[6] << 16) | + ((uint32_t)TxMessage->Data[5] << 8) | + ((uint32_t)TxMessage->Data[4])); + /* Request transmission */ + CANx->sTxMailBox[transmit_mailbox].TIR |= TMIDxR_TXRQ; + } + return transmit_mailbox; +} + +/** + * @brief Checks the transmission of a message. + * @param CANx: where x can be 1 or 2 to to select the + * CAN peripheral. + * @param TransmitMailbox: the number of the mailbox that is used for + * transmission. + * @retval CAN_TxStatus_Ok if the CAN driver transmits the message, CAN_TxStatus_Failed + * in an other case. + */ +uint8_t CAN_TransmitStatus(CAN_TypeDef* CANx, uint8_t TransmitMailbox) +{ + uint32_t state = 0; + + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + assert_param(IS_CAN_TRANSMITMAILBOX(TransmitMailbox)); + + switch (TransmitMailbox) + { + case (CAN_TXMAILBOX_0): + state = CANx->TSR & (CAN_TSR_RQCP0 | CAN_TSR_TXOK0 | CAN_TSR_TME0); + break; + case (CAN_TXMAILBOX_1): + state = CANx->TSR & (CAN_TSR_RQCP1 | CAN_TSR_TXOK1 | CAN_TSR_TME1); + break; + case (CAN_TXMAILBOX_2): + state = CANx->TSR & (CAN_TSR_RQCP2 | CAN_TSR_TXOK2 | CAN_TSR_TME2); + break; + default: + state = CAN_TxStatus_Failed; + break; + } + switch (state) + { + /* transmit pending */ + case (0x0): state = CAN_TxStatus_Pending; + break; + /* transmit failed */ + case (CAN_TSR_RQCP0 | CAN_TSR_TME0): state = CAN_TxStatus_Failed; + break; + case (CAN_TSR_RQCP1 | CAN_TSR_TME1): state = CAN_TxStatus_Failed; + break; + case (CAN_TSR_RQCP2 | CAN_TSR_TME2): state = CAN_TxStatus_Failed; + break; + /* transmit succeeded */ + case (CAN_TSR_RQCP0 | CAN_TSR_TXOK0 | CAN_TSR_TME0):state = CAN_TxStatus_Ok; + break; + case (CAN_TSR_RQCP1 | CAN_TSR_TXOK1 | CAN_TSR_TME1):state = CAN_TxStatus_Ok; + break; + case (CAN_TSR_RQCP2 | CAN_TSR_TXOK2 | CAN_TSR_TME2):state = CAN_TxStatus_Ok; + break; + default: state = CAN_TxStatus_Failed; + break; + } + return (uint8_t) state; +} + +/** + * @brief Cancels a transmit request. + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @param Mailbox: Mailbox number. + * @retval None. + */ +void CAN_CancelTransmit(CAN_TypeDef* CANx, uint8_t Mailbox) +{ + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + assert_param(IS_CAN_TRANSMITMAILBOX(Mailbox)); + /* abort transmission */ + switch (Mailbox) + { + case (CAN_TXMAILBOX_0): CANx->TSR |= CAN_TSR_ABRQ0; + break; + case (CAN_TXMAILBOX_1): CANx->TSR |= CAN_TSR_ABRQ1; + break; + case (CAN_TXMAILBOX_2): CANx->TSR |= CAN_TSR_ABRQ2; + break; + default: + break; + } +} + + +/** + * @brief Receives a message. + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @param FIFONumber: Receive FIFO number, CAN_FIFO0 or CAN_FIFO1. + * @param RxMessage: pointer to a structure receive message which contains + * CAN Id, CAN DLC, CAN datas and FMI number. + * @retval None. + */ +void CAN_Receive(CAN_TypeDef* CANx, uint8_t FIFONumber, CanRxMsg* RxMessage) +{ + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + assert_param(IS_CAN_FIFO(FIFONumber)); + /* Get the Id */ + RxMessage->IDE = (uint8_t)0x04 & CANx->sFIFOMailBox[FIFONumber].RIR; + if (RxMessage->IDE == CAN_Id_Standard) + { + RxMessage->StdId = (uint32_t)0x000007FF & (CANx->sFIFOMailBox[FIFONumber].RIR >> 21); + } + else + { + RxMessage->ExtId = (uint32_t)0x1FFFFFFF & (CANx->sFIFOMailBox[FIFONumber].RIR >> 3); + } + + RxMessage->RTR = (uint8_t)0x02 & CANx->sFIFOMailBox[FIFONumber].RIR; + /* Get the DLC */ + RxMessage->DLC = (uint8_t)0x0F & CANx->sFIFOMailBox[FIFONumber].RDTR; + /* Get the FMI */ + RxMessage->FMI = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDTR >> 8); + /* Get the data field */ + RxMessage->Data[0] = (uint8_t)0xFF & CANx->sFIFOMailBox[FIFONumber].RDLR; + RxMessage->Data[1] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDLR >> 8); + RxMessage->Data[2] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDLR >> 16); + RxMessage->Data[3] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDLR >> 24); + RxMessage->Data[4] = (uint8_t)0xFF & CANx->sFIFOMailBox[FIFONumber].RDHR; + RxMessage->Data[5] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDHR >> 8); + RxMessage->Data[6] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDHR >> 16); + RxMessage->Data[7] = (uint8_t)0xFF & (CANx->sFIFOMailBox[FIFONumber].RDHR >> 24); + /* Release the FIFO */ + /* Release FIFO0 */ + if (FIFONumber == CAN_FIFO0) + { + CANx->RF0R |= CAN_RF0R_RFOM0; + } + /* Release FIFO1 */ + else /* FIFONumber == CAN_FIFO1 */ + { + CANx->RF1R |= CAN_RF1R_RFOM1; + } +} + +/** + * @brief Releases the specified FIFO. + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @param FIFONumber: FIFO to release, CAN_FIFO0 or CAN_FIFO1. + * @retval None. + */ +void CAN_FIFORelease(CAN_TypeDef* CANx, uint8_t FIFONumber) +{ + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + assert_param(IS_CAN_FIFO(FIFONumber)); + /* Release FIFO0 */ + if (FIFONumber == CAN_FIFO0) + { + CANx->RF0R |= CAN_RF0R_RFOM0; + } + /* Release FIFO1 */ + else /* FIFONumber == CAN_FIFO1 */ + { + CANx->RF1R |= CAN_RF1R_RFOM1; + } +} + +/** + * @brief Returns the number of pending messages. + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @param FIFONumber: Receive FIFO number, CAN_FIFO0 or CAN_FIFO1. + * @retval NbMessage : which is the number of pending message. + */ +uint8_t CAN_MessagePending(CAN_TypeDef* CANx, uint8_t FIFONumber) +{ + uint8_t message_pending=0; + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + assert_param(IS_CAN_FIFO(FIFONumber)); + if (FIFONumber == CAN_FIFO0) + { + message_pending = (uint8_t)(CANx->RF0R&(uint32_t)0x03); + } + else if (FIFONumber == CAN_FIFO1) + { + message_pending = (uint8_t)(CANx->RF1R&(uint32_t)0x03); + } + else + { + message_pending = 0; + } + return message_pending; +} + + +/** + * @brief Select the CAN Operation mode. + * @param CAN_OperatingMode : CAN Operating Mode. This parameter can be one + * of @ref CAN_OperatingMode_TypeDef enumeration. + * @retval status of the requested mode which can be + * - CAN_ModeStatus_Failed CAN failed entering the specific mode + * - CAN_ModeStatus_Success CAN Succeed entering the specific mode + + */ +uint8_t CAN_OperatingModeRequest(CAN_TypeDef* CANx, uint8_t CAN_OperatingMode) +{ + uint8_t status = CAN_ModeStatus_Failed; + + /* Timeout for INAK or also for SLAK bits*/ + uint32_t timeout = INAK_TIMEOUT; + + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + assert_param(IS_CAN_OPERATING_MODE(CAN_OperatingMode)); + + if (CAN_OperatingMode == CAN_OperatingMode_Initialization) + { + /* Request initialisation */ + CANx->MCR = (uint32_t)((CANx->MCR & (uint32_t)(~(uint32_t)CAN_MCR_SLEEP)) | CAN_MCR_INRQ); + + /* Wait the acknowledge */ + while (((CANx->MSR & CAN_MODE_MASK) != CAN_MSR_INAK) && (timeout != 0)) + { + timeout--; + } + if ((CANx->MSR & CAN_MODE_MASK) != CAN_MSR_INAK) + { + status = CAN_ModeStatus_Failed; + } + else + { + status = CAN_ModeStatus_Success; + } + } + else if (CAN_OperatingMode == CAN_OperatingMode_Normal) + { + /* Request leave initialisation and sleep mode and enter Normal mode */ + CANx->MCR &= (uint32_t)(~(CAN_MCR_SLEEP|CAN_MCR_INRQ)); + + /* Wait the acknowledge */ + while (((CANx->MSR & CAN_MODE_MASK) != 0) && (timeout!=0)) + { + timeout--; + } + if ((CANx->MSR & CAN_MODE_MASK) != 0) + { + status = CAN_ModeStatus_Failed; + } + else + { + status = CAN_ModeStatus_Success; + } + } + else if (CAN_OperatingMode == CAN_OperatingMode_Sleep) + { + /* Request Sleep mode */ + CANx->MCR = (uint32_t)((CANx->MCR & (uint32_t)(~(uint32_t)CAN_MCR_INRQ)) | CAN_MCR_SLEEP); + + /* Wait the acknowledge */ + while (((CANx->MSR & CAN_MODE_MASK) != CAN_MSR_SLAK) && (timeout!=0)) + { + timeout--; + } + if ((CANx->MSR & CAN_MODE_MASK) != CAN_MSR_SLAK) + { + status = CAN_ModeStatus_Failed; + } + else + { + status = CAN_ModeStatus_Success; + } + } + else + { + status = CAN_ModeStatus_Failed; + } + + return (uint8_t) status; +} + +/** + * @brief Enters the low power mode. + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @retval status: CAN_Sleep_Ok if sleep entered, CAN_Sleep_Failed in an + * other case. + */ +uint8_t CAN_Sleep(CAN_TypeDef* CANx) +{ + uint8_t sleepstatus = CAN_Sleep_Failed; + + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + + /* Request Sleep mode */ + CANx->MCR = (((CANx->MCR) & (uint32_t)(~(uint32_t)CAN_MCR_INRQ)) | CAN_MCR_SLEEP); + + /* Sleep mode status */ + if ((CANx->MSR & (CAN_MSR_SLAK|CAN_MSR_INAK)) == CAN_MSR_SLAK) + { + /* Sleep mode not entered */ + sleepstatus = CAN_Sleep_Ok; + } + /* return sleep mode status */ + return (uint8_t)sleepstatus; +} + +/** + * @brief Wakes the CAN up. + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @retval status: CAN_WakeUp_Ok if sleep mode left, CAN_WakeUp_Failed in an + * other case. + */ +uint8_t CAN_WakeUp(CAN_TypeDef* CANx) +{ + uint32_t wait_slak = SLAK_TIMEOUT; + uint8_t wakeupstatus = CAN_WakeUp_Failed; + + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + + /* Wake up request */ + CANx->MCR &= ~(uint32_t)CAN_MCR_SLEEP; + + /* Sleep mode status */ + while(((CANx->MSR & CAN_MSR_SLAK) == CAN_MSR_SLAK)&&(wait_slak!=0x00)) + { + wait_slak--; + } + if((CANx->MSR & CAN_MSR_SLAK) != CAN_MSR_SLAK) + { + /* wake up done : Sleep mode exited */ + wakeupstatus = CAN_WakeUp_Ok; + } + /* return wakeup status */ + return (uint8_t)wakeupstatus; +} + + +/** + * @brief Returns the CANx's last error code (LEC). + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @retval CAN_ErrorCode: specifies the Error code : + * - CAN_ERRORCODE_NoErr No Error + * - CAN_ERRORCODE_StuffErr Stuff Error + * - CAN_ERRORCODE_FormErr Form Error + * - CAN_ERRORCODE_ACKErr Acknowledgment Error + * - CAN_ERRORCODE_BitRecessiveErr Bit Recessive Error + * - CAN_ERRORCODE_BitDominantErr Bit Dominant Error + * - CAN_ERRORCODE_CRCErr CRC Error + * - CAN_ERRORCODE_SoftwareSetErr Software Set Error + */ + +uint8_t CAN_GetLastErrorCode(CAN_TypeDef* CANx) +{ + uint8_t errorcode=0; + + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + + /* Get the error code*/ + errorcode = (((uint8_t)CANx->ESR) & (uint8_t)CAN_ESR_LEC); + + /* Return the error code*/ + return errorcode; +} +/** + * @brief Returns the CANx Receive Error Counter (REC). + * @note In case of an error during reception, this counter is incremented + * by 1 or by 8 depending on the error condition as defined by the CAN + * standard. After every successful reception, the counter is + * decremented by 1 or reset to 120 if its value was higher than 128. + * When the counter value exceeds 127, the CAN controller enters the + * error passive state. + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @retval CAN Receive Error Counter. + */ +uint8_t CAN_GetReceiveErrorCounter(CAN_TypeDef* CANx) +{ + uint8_t counter=0; + + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + + /* Get the Receive Error Counter*/ + counter = (uint8_t)((CANx->ESR & CAN_ESR_REC)>> 24); + + /* Return the Receive Error Counter*/ + return counter; +} + + +/** + * @brief Returns the LSB of the 9-bit CANx Transmit Error Counter(TEC). + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @retval LSB of the 9-bit CAN Transmit Error Counter. + */ +uint8_t CAN_GetLSBTransmitErrorCounter(CAN_TypeDef* CANx) +{ + uint8_t counter=0; + + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + + /* Get the LSB of the 9-bit CANx Transmit Error Counter(TEC) */ + counter = (uint8_t)((CANx->ESR & CAN_ESR_TEC)>> 16); + + /* Return the LSB of the 9-bit CANx Transmit Error Counter(TEC) */ + return counter; +} + + +/** + * @brief Enables or disables the specified CANx interrupts. + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @param CAN_IT: specifies the CAN interrupt sources to be enabled or disabled. + * This parameter can be: + * - CAN_IT_TME, + * - CAN_IT_FMP0, + * - CAN_IT_FF0, + * - CAN_IT_FOV0, + * - CAN_IT_FMP1, + * - CAN_IT_FF1, + * - CAN_IT_FOV1, + * - CAN_IT_EWG, + * - CAN_IT_EPV, + * - CAN_IT_LEC, + * - CAN_IT_ERR, + * - CAN_IT_WKU or + * - CAN_IT_SLK. + * @param NewState: new state of the CAN interrupts. + * This parameter can be: ENABLE or DISABLE. + * @retval None. + */ +void CAN_ITConfig(CAN_TypeDef* CANx, uint32_t CAN_IT, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + assert_param(IS_CAN_IT(CAN_IT)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the selected CANx interrupt */ + CANx->IER |= CAN_IT; + } + else + { + /* Disable the selected CANx interrupt */ + CANx->IER &= ~CAN_IT; + } +} +/** + * @brief Checks whether the specified CAN flag is set or not. + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @param CAN_FLAG: specifies the flag to check. + * This parameter can be one of the following flags: + * - CAN_FLAG_EWG + * - CAN_FLAG_EPV + * - CAN_FLAG_BOF + * - CAN_FLAG_RQCP0 + * - CAN_FLAG_RQCP1 + * - CAN_FLAG_RQCP2 + * - CAN_FLAG_FMP1 + * - CAN_FLAG_FF1 + * - CAN_FLAG_FOV1 + * - CAN_FLAG_FMP0 + * - CAN_FLAG_FF0 + * - CAN_FLAG_FOV0 + * - CAN_FLAG_WKU + * - CAN_FLAG_SLAK + * - CAN_FLAG_LEC + * @retval The new state of CAN_FLAG (SET or RESET). + */ +FlagStatus CAN_GetFlagStatus(CAN_TypeDef* CANx, uint32_t CAN_FLAG) +{ + FlagStatus bitstatus = RESET; + + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + assert_param(IS_CAN_GET_FLAG(CAN_FLAG)); + + + if((CAN_FLAG & CAN_FLAGS_ESR) != (uint32_t)RESET) + { + /* Check the status of the specified CAN flag */ + if ((CANx->ESR & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET) + { + /* CAN_FLAG is set */ + bitstatus = SET; + } + else + { + /* CAN_FLAG is reset */ + bitstatus = RESET; + } + } + else if((CAN_FLAG & CAN_FLAGS_MSR) != (uint32_t)RESET) + { + /* Check the status of the specified CAN flag */ + if ((CANx->MSR & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET) + { + /* CAN_FLAG is set */ + bitstatus = SET; + } + else + { + /* CAN_FLAG is reset */ + bitstatus = RESET; + } + } + else if((CAN_FLAG & CAN_FLAGS_TSR) != (uint32_t)RESET) + { + /* Check the status of the specified CAN flag */ + if ((CANx->TSR & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET) + { + /* CAN_FLAG is set */ + bitstatus = SET; + } + else + { + /* CAN_FLAG is reset */ + bitstatus = RESET; + } + } + else if((CAN_FLAG & CAN_FLAGS_RF0R) != (uint32_t)RESET) + { + /* Check the status of the specified CAN flag */ + if ((CANx->RF0R & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET) + { + /* CAN_FLAG is set */ + bitstatus = SET; + } + else + { + /* CAN_FLAG is reset */ + bitstatus = RESET; + } + } + else /* If(CAN_FLAG & CAN_FLAGS_RF1R != (uint32_t)RESET) */ + { + /* Check the status of the specified CAN flag */ + if ((uint32_t)(CANx->RF1R & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET) + { + /* CAN_FLAG is set */ + bitstatus = SET; + } + else + { + /* CAN_FLAG is reset */ + bitstatus = RESET; + } + } + /* Return the CAN_FLAG status */ + return bitstatus; +} + +/** + * @brief Clears the CAN's pending flags. + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @param CAN_FLAG: specifies the flag to clear. + * This parameter can be one of the following flags: + * - CAN_FLAG_RQCP0 + * - CAN_FLAG_RQCP1 + * - CAN_FLAG_RQCP2 + * - CAN_FLAG_FF1 + * - CAN_FLAG_FOV1 + * - CAN_FLAG_FF0 + * - CAN_FLAG_FOV0 + * - CAN_FLAG_WKU + * - CAN_FLAG_SLAK + * - CAN_FLAG_LEC + * @retval None. + */ +void CAN_ClearFlag(CAN_TypeDef* CANx, uint32_t CAN_FLAG) +{ + uint32_t flagtmp=0; + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + assert_param(IS_CAN_CLEAR_FLAG(CAN_FLAG)); + + if (CAN_FLAG == CAN_FLAG_LEC) /* ESR register */ + { + /* Clear the selected CAN flags */ + CANx->ESR = (uint32_t)RESET; + } + else /* MSR or TSR or RF0R or RF1R */ + { + flagtmp = CAN_FLAG & 0x000FFFFF; + + if ((CAN_FLAG & CAN_FLAGS_RF0R)!=(uint32_t)RESET) + { + /* Receive Flags */ + CANx->RF0R = (uint32_t)(flagtmp); + } + else if ((CAN_FLAG & CAN_FLAGS_RF1R)!=(uint32_t)RESET) + { + /* Receive Flags */ + CANx->RF1R = (uint32_t)(flagtmp); + } + else if ((CAN_FLAG & CAN_FLAGS_TSR)!=(uint32_t)RESET) + { + /* Transmit Flags */ + CANx->TSR = (uint32_t)(flagtmp); + } + else /* If((CAN_FLAG & CAN_FLAGS_MSR)!=(uint32_t)RESET) */ + { + /* Operating mode Flags */ + CANx->MSR = (uint32_t)(flagtmp); + } + } +} + +/** + * @brief Checks whether the specified CANx interrupt has occurred or not. + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @param CAN_IT: specifies the CAN interrupt source to check. + * This parameter can be one of the following flags: + * - CAN_IT_TME + * - CAN_IT_FMP0 + * - CAN_IT_FF0 + * - CAN_IT_FOV0 + * - CAN_IT_FMP1 + * - CAN_IT_FF1 + * - CAN_IT_FOV1 + * - CAN_IT_WKU + * - CAN_IT_SLK + * - CAN_IT_EWG + * - CAN_IT_EPV + * - CAN_IT_BOF + * - CAN_IT_LEC + * - CAN_IT_ERR + * @retval The current state of CAN_IT (SET or RESET). + */ +ITStatus CAN_GetITStatus(CAN_TypeDef* CANx, uint32_t CAN_IT) +{ + ITStatus itstatus = RESET; + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + assert_param(IS_CAN_IT(CAN_IT)); + + /* check the enable interrupt bit */ + if((CANx->IER & CAN_IT) != RESET) + { + /* in case the Interrupt is enabled, .... */ + switch (CAN_IT) + { + case CAN_IT_TME: + /* Check CAN_TSR_RQCPx bits */ + itstatus = CheckITStatus(CANx->TSR, CAN_TSR_RQCP0|CAN_TSR_RQCP1|CAN_TSR_RQCP2); + break; + case CAN_IT_FMP0: + /* Check CAN_RF0R_FMP0 bit */ + itstatus = CheckITStatus(CANx->RF0R, CAN_RF0R_FMP0); + break; + case CAN_IT_FF0: + /* Check CAN_RF0R_FULL0 bit */ + itstatus = CheckITStatus(CANx->RF0R, CAN_RF0R_FULL0); + break; + case CAN_IT_FOV0: + /* Check CAN_RF0R_FOVR0 bit */ + itstatus = CheckITStatus(CANx->RF0R, CAN_RF0R_FOVR0); + break; + case CAN_IT_FMP1: + /* Check CAN_RF1R_FMP1 bit */ + itstatus = CheckITStatus(CANx->RF1R, CAN_RF1R_FMP1); + break; + case CAN_IT_FF1: + /* Check CAN_RF1R_FULL1 bit */ + itstatus = CheckITStatus(CANx->RF1R, CAN_RF1R_FULL1); + break; + case CAN_IT_FOV1: + /* Check CAN_RF1R_FOVR1 bit */ + itstatus = CheckITStatus(CANx->RF1R, CAN_RF1R_FOVR1); + break; + case CAN_IT_WKU: + /* Check CAN_MSR_WKUI bit */ + itstatus = CheckITStatus(CANx->MSR, CAN_MSR_WKUI); + break; + case CAN_IT_SLK: + /* Check CAN_MSR_SLAKI bit */ + itstatus = CheckITStatus(CANx->MSR, CAN_MSR_SLAKI); + break; + case CAN_IT_EWG: + /* Check CAN_ESR_EWGF bit */ + itstatus = CheckITStatus(CANx->ESR, CAN_ESR_EWGF); + break; + case CAN_IT_EPV: + /* Check CAN_ESR_EPVF bit */ + itstatus = CheckITStatus(CANx->ESR, CAN_ESR_EPVF); + break; + case CAN_IT_BOF: + /* Check CAN_ESR_BOFF bit */ + itstatus = CheckITStatus(CANx->ESR, CAN_ESR_BOFF); + break; + case CAN_IT_LEC: + /* Check CAN_ESR_LEC bit */ + itstatus = CheckITStatus(CANx->ESR, CAN_ESR_LEC); + break; + case CAN_IT_ERR: + /* Check CAN_MSR_ERRI bit */ + itstatus = CheckITStatus(CANx->MSR, CAN_MSR_ERRI); + break; + default : + /* in case of error, return RESET */ + itstatus = RESET; + break; + } + } + else + { + /* in case the Interrupt is not enabled, return RESET */ + itstatus = RESET; + } + + /* Return the CAN_IT status */ + return itstatus; +} + +/** + * @brief Clears the CANx's interrupt pending bits. + * @param CANx: where x can be 1 or 2 to to select the CAN peripheral. + * @param CAN_IT: specifies the interrupt pending bit to clear. + * - CAN_IT_TME + * - CAN_IT_FF0 + * - CAN_IT_FOV0 + * - CAN_IT_FF1 + * - CAN_IT_FOV1 + * - CAN_IT_WKU + * - CAN_IT_SLK + * - CAN_IT_EWG + * - CAN_IT_EPV + * - CAN_IT_BOF + * - CAN_IT_LEC + * - CAN_IT_ERR + * @retval None. + */ +void CAN_ClearITPendingBit(CAN_TypeDef* CANx, uint32_t CAN_IT) +{ + /* Check the parameters */ + assert_param(IS_CAN_ALL_PERIPH(CANx)); + assert_param(IS_CAN_CLEAR_IT(CAN_IT)); + + switch (CAN_IT) + { + case CAN_IT_TME: + /* Clear CAN_TSR_RQCPx (rc_w1)*/ + CANx->TSR = CAN_TSR_RQCP0|CAN_TSR_RQCP1|CAN_TSR_RQCP2; + break; + case CAN_IT_FF0: + /* Clear CAN_RF0R_FULL0 (rc_w1)*/ + CANx->RF0R = CAN_RF0R_FULL0; + break; + case CAN_IT_FOV0: + /* Clear CAN_RF0R_FOVR0 (rc_w1)*/ + CANx->RF0R = CAN_RF0R_FOVR0; + break; + case CAN_IT_FF1: + /* Clear CAN_RF1R_FULL1 (rc_w1)*/ + CANx->RF1R = CAN_RF1R_FULL1; + break; + case CAN_IT_FOV1: + /* Clear CAN_RF1R_FOVR1 (rc_w1)*/ + CANx->RF1R = CAN_RF1R_FOVR1; + break; + case CAN_IT_WKU: + /* Clear CAN_MSR_WKUI (rc_w1)*/ + CANx->MSR = CAN_MSR_WKUI; + break; + case CAN_IT_SLK: + /* Clear CAN_MSR_SLAKI (rc_w1)*/ + CANx->MSR = CAN_MSR_SLAKI; + break; + case CAN_IT_EWG: + /* Clear CAN_MSR_ERRI (rc_w1) */ + CANx->MSR = CAN_MSR_ERRI; + /* Note : the corresponding Flag is cleared by hardware depending + of the CAN Bus status*/ + break; + case CAN_IT_EPV: + /* Clear CAN_MSR_ERRI (rc_w1) */ + CANx->MSR = CAN_MSR_ERRI; + /* Note : the corresponding Flag is cleared by hardware depending + of the CAN Bus status*/ + break; + case CAN_IT_BOF: + /* Clear CAN_MSR_ERRI (rc_w1) */ + CANx->MSR = CAN_MSR_ERRI; + /* Note : the corresponding Flag is cleared by hardware depending + of the CAN Bus status*/ + break; + case CAN_IT_LEC: + /* Clear LEC bits */ + CANx->ESR = RESET; + /* Clear CAN_MSR_ERRI (rc_w1) */ + CANx->MSR = CAN_MSR_ERRI; + break; + case CAN_IT_ERR: + /*Clear LEC bits */ + CANx->ESR = RESET; + /* Clear CAN_MSR_ERRI (rc_w1) */ + CANx->MSR = CAN_MSR_ERRI; + /* Note : BOFF, EPVF and EWGF Flags are cleared by hardware depending + of the CAN Bus status*/ + break; + default : + break; + } +} + +/** + * @brief Checks whether the CAN interrupt has occurred or not. + * @param CAN_Reg: specifies the CAN interrupt register to check. + * @param It_Bit: specifies the interrupt source bit to check. + * @retval The new state of the CAN Interrupt (SET or RESET). + */ +static ITStatus CheckITStatus(uint32_t CAN_Reg, uint32_t It_Bit) +{ + ITStatus pendingbitstatus = RESET; + + if ((CAN_Reg & It_Bit) != (uint32_t)RESET) + { + /* CAN_IT is set */ + pendingbitstatus = SET; + } + else + { + /* CAN_IT is reset */ + pendingbitstatus = RESET; + } + return pendingbitstatus; +} + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_cec.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_cec.c new file mode 100755 index 0000000..08b501a --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_cec.c @@ -0,0 +1,433 @@ +/** + ****************************************************************************** + * @file stm32f10x_cec.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the CEC firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_cec.h" +#include "stm32f10x_rcc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup CEC + * @brief CEC driver modules + * @{ + */ + +/** @defgroup CEC_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + + +/** @defgroup CEC_Private_Defines + * @{ + */ + +/* ------------ CEC registers bit address in the alias region ----------- */ +#define CEC_OFFSET (CEC_BASE - PERIPH_BASE) + +/* --- CFGR Register ---*/ + +/* Alias word address of PE bit */ +#define CFGR_OFFSET (CEC_OFFSET + 0x00) +#define PE_BitNumber 0x00 +#define CFGR_PE_BB (PERIPH_BB_BASE + (CFGR_OFFSET * 32) + (PE_BitNumber * 4)) + +/* Alias word address of IE bit */ +#define IE_BitNumber 0x01 +#define CFGR_IE_BB (PERIPH_BB_BASE + (CFGR_OFFSET * 32) + (IE_BitNumber * 4)) + +/* --- CSR Register ---*/ + +/* Alias word address of TSOM bit */ +#define CSR_OFFSET (CEC_OFFSET + 0x10) +#define TSOM_BitNumber 0x00 +#define CSR_TSOM_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TSOM_BitNumber * 4)) + +/* Alias word address of TEOM bit */ +#define TEOM_BitNumber 0x01 +#define CSR_TEOM_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TEOM_BitNumber * 4)) + +#define CFGR_CLEAR_Mask (uint8_t)(0xF3) /* CFGR register Mask */ +#define FLAG_Mask ((uint32_t)0x00FFFFFF) /* CEC FLAG mask */ + +/** + * @} + */ + + +/** @defgroup CEC_Private_Macros + * @{ + */ + +/** + * @} + */ + + +/** @defgroup CEC_Private_Variables + * @{ + */ + +/** + * @} + */ + + +/** @defgroup CEC_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + + +/** @defgroup CEC_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the CEC peripheral registers to their default reset + * values. + * @param None + * @retval None + */ +void CEC_DeInit(void) +{ + /* Enable CEC reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_CEC, ENABLE); + /* Release CEC from reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_CEC, DISABLE); +} + + +/** + * @brief Initializes the CEC peripheral according to the specified + * parameters in the CEC_InitStruct. + * @param CEC_InitStruct: pointer to an CEC_InitTypeDef structure that + * contains the configuration information for the specified + * CEC peripheral. + * @retval None + */ +void CEC_Init(CEC_InitTypeDef* CEC_InitStruct) +{ + uint16_t tmpreg = 0; + + /* Check the parameters */ + assert_param(IS_CEC_BIT_TIMING_ERROR_MODE(CEC_InitStruct->CEC_BitTimingMode)); + assert_param(IS_CEC_BIT_PERIOD_ERROR_MODE(CEC_InitStruct->CEC_BitPeriodMode)); + + /*---------------------------- CEC CFGR Configuration -----------------*/ + /* Get the CEC CFGR value */ + tmpreg = CEC->CFGR; + + /* Clear BTEM and BPEM bits */ + tmpreg &= CFGR_CLEAR_Mask; + + /* Configure CEC: Bit Timing Error and Bit Period Error */ + tmpreg |= (uint16_t)(CEC_InitStruct->CEC_BitTimingMode | CEC_InitStruct->CEC_BitPeriodMode); + + /* Write to CEC CFGR register*/ + CEC->CFGR = tmpreg; + +} + +/** + * @brief Enables or disables the specified CEC peripheral. + * @param NewState: new state of the CEC peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void CEC_Cmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + *(__IO uint32_t *) CFGR_PE_BB = (uint32_t)NewState; + + if(NewState == DISABLE) + { + /* Wait until the PE bit is cleared by hardware (Idle Line detected) */ + while((CEC->CFGR & CEC_CFGR_PE) != (uint32_t)RESET) + { + } + } +} + +/** + * @brief Enables or disables the CEC interrupt. + * @param NewState: new state of the CEC interrupt. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void CEC_ITConfig(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + *(__IO uint32_t *) CFGR_IE_BB = (uint32_t)NewState; +} + +/** + * @brief Defines the Own Address of the CEC device. + * @param CEC_OwnAddress: The CEC own address + * @retval None + */ +void CEC_OwnAddressConfig(uint8_t CEC_OwnAddress) +{ + /* Check the parameters */ + assert_param(IS_CEC_ADDRESS(CEC_OwnAddress)); + + /* Set the CEC own address */ + CEC->OAR = CEC_OwnAddress; +} + +/** + * @brief Sets the CEC prescaler value. + * @param CEC_Prescaler: CEC prescaler new value + * @retval None + */ +void CEC_SetPrescaler(uint16_t CEC_Prescaler) +{ + /* Check the parameters */ + assert_param(IS_CEC_PRESCALER(CEC_Prescaler)); + + /* Set the Prescaler value*/ + CEC->PRES = CEC_Prescaler; +} + +/** + * @brief Transmits single data through the CEC peripheral. + * @param Data: the data to transmit. + * @retval None + */ +void CEC_SendDataByte(uint8_t Data) +{ + /* Transmit Data */ + CEC->TXD = Data ; +} + + +/** + * @brief Returns the most recent received data by the CEC peripheral. + * @param None + * @retval The received data. + */ +uint8_t CEC_ReceiveDataByte(void) +{ + /* Receive Data */ + return (uint8_t)(CEC->RXD); +} + +/** + * @brief Starts a new message. + * @param None + * @retval None + */ +void CEC_StartOfMessage(void) +{ + /* Starts of new message */ + *(__IO uint32_t *) CSR_TSOM_BB = (uint32_t)0x1; +} + +/** + * @brief Transmits message with or without an EOM bit. + * @param NewState: new state of the CEC Tx End Of Message. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void CEC_EndOfMessageCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + /* The data byte will be transmitted with or without an EOM bit*/ + *(__IO uint32_t *) CSR_TEOM_BB = (uint32_t)NewState; +} + +/** + * @brief Gets the CEC flag status + * @param CEC_FLAG: specifies the CEC flag to check. + * This parameter can be one of the following values: + * @arg CEC_FLAG_BTE: Bit Timing Error + * @arg CEC_FLAG_BPE: Bit Period Error + * @arg CEC_FLAG_RBTFE: Rx Block Transfer Finished Error + * @arg CEC_FLAG_SBE: Start Bit Error + * @arg CEC_FLAG_ACKE: Block Acknowledge Error + * @arg CEC_FLAG_LINE: Line Error + * @arg CEC_FLAG_TBTFE: Tx Block Transfer Finished Error + * @arg CEC_FLAG_TEOM: Tx End Of Message + * @arg CEC_FLAG_TERR: Tx Error + * @arg CEC_FLAG_TBTRF: Tx Byte Transfer Request or Block Transfer Finished + * @arg CEC_FLAG_RSOM: Rx Start Of Message + * @arg CEC_FLAG_REOM: Rx End Of Message + * @arg CEC_FLAG_RERR: Rx Error + * @arg CEC_FLAG_RBTF: Rx Byte/Block Transfer Finished + * @retval The new state of CEC_FLAG (SET or RESET) + */ +FlagStatus CEC_GetFlagStatus(uint32_t CEC_FLAG) +{ + FlagStatus bitstatus = RESET; + uint32_t cecreg = 0, cecbase = 0; + + /* Check the parameters */ + assert_param(IS_CEC_GET_FLAG(CEC_FLAG)); + + /* Get the CEC peripheral base address */ + cecbase = (uint32_t)(CEC_BASE); + + /* Read flag register index */ + cecreg = CEC_FLAG >> 28; + + /* Get bit[23:0] of the flag */ + CEC_FLAG &= FLAG_Mask; + + if(cecreg != 0) + { + /* Flag in CEC ESR Register */ + CEC_FLAG = (uint32_t)(CEC_FLAG >> 16); + + /* Get the CEC ESR register address */ + cecbase += 0xC; + } + else + { + /* Get the CEC CSR register address */ + cecbase += 0x10; + } + + if(((*(__IO uint32_t *)cecbase) & CEC_FLAG) != (uint32_t)RESET) + { + /* CEC_FLAG is set */ + bitstatus = SET; + } + else + { + /* CEC_FLAG is reset */ + bitstatus = RESET; + } + + /* Return the CEC_FLAG status */ + return bitstatus; +} + +/** + * @brief Clears the CEC's pending flags. + * @param CEC_FLAG: specifies the flag to clear. + * This parameter can be any combination of the following values: + * @arg CEC_FLAG_TERR: Tx Error + * @arg CEC_FLAG_TBTRF: Tx Byte Transfer Request or Block Transfer Finished + * @arg CEC_FLAG_RSOM: Rx Start Of Message + * @arg CEC_FLAG_REOM: Rx End Of Message + * @arg CEC_FLAG_RERR: Rx Error + * @arg CEC_FLAG_RBTF: Rx Byte/Block Transfer Finished + * @retval None + */ +void CEC_ClearFlag(uint32_t CEC_FLAG) +{ + uint32_t tmp = 0x0; + + /* Check the parameters */ + assert_param(IS_CEC_CLEAR_FLAG(CEC_FLAG)); + + tmp = CEC->CSR & 0x2; + + /* Clear the selected CEC flags */ + CEC->CSR &= (uint32_t)(((~(uint32_t)CEC_FLAG) & 0xFFFFFFFC) | tmp); +} + +/** + * @brief Checks whether the specified CEC interrupt has occurred or not. + * @param CEC_IT: specifies the CEC interrupt source to check. + * This parameter can be one of the following values: + * @arg CEC_IT_TERR: Tx Error + * @arg CEC_IT_TBTF: Tx Block Transfer Finished + * @arg CEC_IT_RERR: Rx Error + * @arg CEC_IT_RBTF: Rx Block Transfer Finished + * @retval The new state of CEC_IT (SET or RESET). + */ +ITStatus CEC_GetITStatus(uint8_t CEC_IT) +{ + ITStatus bitstatus = RESET; + uint32_t enablestatus = 0; + + /* Check the parameters */ + assert_param(IS_CEC_GET_IT(CEC_IT)); + + /* Get the CEC IT enable bit status */ + enablestatus = (CEC->CFGR & (uint8_t)CEC_CFGR_IE) ; + + /* Check the status of the specified CEC interrupt */ + if (((CEC->CSR & CEC_IT) != (uint32_t)RESET) && enablestatus) + { + /* CEC_IT is set */ + bitstatus = SET; + } + else + { + /* CEC_IT is reset */ + bitstatus = RESET; + } + /* Return the CEC_IT status */ + return bitstatus; +} + +/** + * @brief Clears the CEC's interrupt pending bits. + * @param CEC_IT: specifies the CEC interrupt pending bit to clear. + * This parameter can be any combination of the following values: + * @arg CEC_IT_TERR: Tx Error + * @arg CEC_IT_TBTF: Tx Block Transfer Finished + * @arg CEC_IT_RERR: Rx Error + * @arg CEC_IT_RBTF: Rx Block Transfer Finished + * @retval None + */ +void CEC_ClearITPendingBit(uint16_t CEC_IT) +{ + uint32_t tmp = 0x0; + + /* Check the parameters */ + assert_param(IS_CEC_GET_IT(CEC_IT)); + + tmp = CEC->CSR & 0x2; + + /* Clear the selected CEC interrupt pending bits */ + CEC->CSR &= (uint32_t)(((~(uint32_t)CEC_IT) & 0xFFFFFFFC) | tmp); +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_crc.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_crc.c new file mode 100755 index 0000000..ef0c047 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_crc.c @@ -0,0 +1,160 @@ +/** + ****************************************************************************** + * @file stm32f10x_crc.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the CRC firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_crc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup CRC + * @brief CRC driver modules + * @{ + */ + +/** @defgroup CRC_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup CRC_Private_Defines + * @{ + */ + +/** + * @} + */ + +/** @defgroup CRC_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup CRC_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup CRC_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup CRC_Private_Functions + * @{ + */ + +/** + * @brief Resets the CRC Data register (DR). + * @param None + * @retval None + */ +void CRC_ResetDR(void) +{ + /* Reset CRC generator */ + CRC->CR = CRC_CR_RESET; +} + +/** + * @brief Computes the 32-bit CRC of a given data word(32-bit). + * @param Data: data word(32-bit) to compute its CRC + * @retval 32-bit CRC + */ +uint32_t CRC_CalcCRC(uint32_t Data) +{ + CRC->DR = Data; + + return (CRC->DR); +} + +/** + * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit). + * @param pBuffer: pointer to the buffer containing the data to be computed + * @param BufferLength: length of the buffer to be computed + * @retval 32-bit CRC + */ +uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength) +{ + uint32_t index = 0; + + for(index = 0; index < BufferLength; index++) + { + CRC->DR = pBuffer[index]; + } + return (CRC->DR); +} + +/** + * @brief Returns the current CRC value. + * @param None + * @retval 32-bit CRC + */ +uint32_t CRC_GetCRC(void) +{ + return (CRC->DR); +} + +/** + * @brief Stores a 8-bit data in the Independent Data(ID) register. + * @param IDValue: 8-bit value to be stored in the ID register + * @retval None + */ +void CRC_SetIDRegister(uint8_t IDValue) +{ + CRC->IDR = IDValue; +} + +/** + * @brief Returns the 8-bit data stored in the Independent Data(ID) register + * @param None + * @retval 8-bit value of the ID register + */ +uint8_t CRC_GetIDRegister(void) +{ + return (CRC->IDR); +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_dac.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_dac.c new file mode 100755 index 0000000..025b8e2 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_dac.c @@ -0,0 +1,571 @@ +/** + ****************************************************************************** + * @file stm32f10x_dac.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the DAC firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_dac.h" +#include "stm32f10x_rcc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup DAC + * @brief DAC driver modules + * @{ + */ + +/** @defgroup DAC_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup DAC_Private_Defines + * @{ + */ + +/* CR register Mask */ +#define CR_CLEAR_MASK ((uint32_t)0x00000FFE) + +/* DAC Dual Channels SWTRIG masks */ +#define DUAL_SWTRIG_SET ((uint32_t)0x00000003) +#define DUAL_SWTRIG_RESET ((uint32_t)0xFFFFFFFC) + +/* DHR registers offsets */ +#define DHR12R1_OFFSET ((uint32_t)0x00000008) +#define DHR12R2_OFFSET ((uint32_t)0x00000014) +#define DHR12RD_OFFSET ((uint32_t)0x00000020) + +/* DOR register offset */ +#define DOR_OFFSET ((uint32_t)0x0000002C) +/** + * @} + */ + +/** @defgroup DAC_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup DAC_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup DAC_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup DAC_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the DAC peripheral registers to their default reset values. + * @param None + * @retval None + */ +void DAC_DeInit(void) +{ + /* Enable DAC reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC, ENABLE); + /* Release DAC from reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC, DISABLE); +} + +/** + * @brief Initializes the DAC peripheral according to the specified + * parameters in the DAC_InitStruct. + * @param DAC_Channel: the selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_Channel_1: DAC Channel1 selected + * @arg DAC_Channel_2: DAC Channel2 selected + * @param DAC_InitStruct: pointer to a DAC_InitTypeDef structure that + * contains the configuration information for the specified DAC channel. + * @retval None + */ +void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct) +{ + uint32_t tmpreg1 = 0, tmpreg2 = 0; + /* Check the DAC parameters */ + assert_param(IS_DAC_TRIGGER(DAC_InitStruct->DAC_Trigger)); + assert_param(IS_DAC_GENERATE_WAVE(DAC_InitStruct->DAC_WaveGeneration)); + assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude)); + assert_param(IS_DAC_OUTPUT_BUFFER_STATE(DAC_InitStruct->DAC_OutputBuffer)); +/*---------------------------- DAC CR Configuration --------------------------*/ + /* Get the DAC CR value */ + tmpreg1 = DAC->CR; + /* Clear BOFFx, TENx, TSELx, WAVEx and MAMPx bits */ + tmpreg1 &= ~(CR_CLEAR_MASK << DAC_Channel); + /* Configure for the selected DAC channel: buffer output, trigger, wave generation, + mask/amplitude for wave generation */ + /* Set TSELx and TENx bits according to DAC_Trigger value */ + /* Set WAVEx bits according to DAC_WaveGeneration value */ + /* Set MAMPx bits according to DAC_LFSRUnmask_TriangleAmplitude value */ + /* Set BOFFx bit according to DAC_OutputBuffer value */ + tmpreg2 = (DAC_InitStruct->DAC_Trigger | DAC_InitStruct->DAC_WaveGeneration | + DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude | DAC_InitStruct->DAC_OutputBuffer); + /* Calculate CR register value depending on DAC_Channel */ + tmpreg1 |= tmpreg2 << DAC_Channel; + /* Write to DAC CR */ + DAC->CR = tmpreg1; +} + +/** + * @brief Fills each DAC_InitStruct member with its default value. + * @param DAC_InitStruct : pointer to a DAC_InitTypeDef structure which will + * be initialized. + * @retval None + */ +void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct) +{ +/*--------------- Reset DAC init structure parameters values -----------------*/ + /* Initialize the DAC_Trigger member */ + DAC_InitStruct->DAC_Trigger = DAC_Trigger_None; + /* Initialize the DAC_WaveGeneration member */ + DAC_InitStruct->DAC_WaveGeneration = DAC_WaveGeneration_None; + /* Initialize the DAC_LFSRUnmask_TriangleAmplitude member */ + DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude = DAC_LFSRUnmask_Bit0; + /* Initialize the DAC_OutputBuffer member */ + DAC_InitStruct->DAC_OutputBuffer = DAC_OutputBuffer_Enable; +} + +/** + * @brief Enables or disables the specified DAC channel. + * @param DAC_Channel: the selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_Channel_1: DAC Channel1 selected + * @arg DAC_Channel_2: DAC Channel2 selected + * @param NewState: new state of the DAC channel. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_DAC_CHANNEL(DAC_Channel)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected DAC channel */ + DAC->CR |= (DAC_CR_EN1 << DAC_Channel); + } + else + { + /* Disable the selected DAC channel */ + DAC->CR &= ~(DAC_CR_EN1 << DAC_Channel); + } +} +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) +/** + * @brief Enables or disables the specified DAC interrupts. + * @param DAC_Channel: the selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_Channel_1: DAC Channel1 selected + * @arg DAC_Channel_2: DAC Channel2 selected + * @param DAC_IT: specifies the DAC interrupt sources to be enabled or disabled. + * This parameter can be the following values: + * @arg DAC_IT_DMAUDR: DMA underrun interrupt mask + * @param NewState: new state of the specified DAC interrupts. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_DAC_CHANNEL(DAC_Channel)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + assert_param(IS_DAC_IT(DAC_IT)); + + if (NewState != DISABLE) + { + /* Enable the selected DAC interrupts */ + DAC->CR |= (DAC_IT << DAC_Channel); + } + else + { + /* Disable the selected DAC interrupts */ + DAC->CR &= (~(uint32_t)(DAC_IT << DAC_Channel)); + } +} +#endif + +/** + * @brief Enables or disables the specified DAC channel DMA request. + * @param DAC_Channel: the selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_Channel_1: DAC Channel1 selected + * @arg DAC_Channel_2: DAC Channel2 selected + * @param NewState: new state of the selected DAC channel DMA request. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_DAC_CHANNEL(DAC_Channel)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected DAC channel DMA request */ + DAC->CR |= (DAC_CR_DMAEN1 << DAC_Channel); + } + else + { + /* Disable the selected DAC channel DMA request */ + DAC->CR &= ~(DAC_CR_DMAEN1 << DAC_Channel); + } +} + +/** + * @brief Enables or disables the selected DAC channel software trigger. + * @param DAC_Channel: the selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_Channel_1: DAC Channel1 selected + * @arg DAC_Channel_2: DAC Channel2 selected + * @param NewState: new state of the selected DAC channel software trigger. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_DAC_CHANNEL(DAC_Channel)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable software trigger for the selected DAC channel */ + DAC->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG1 << (DAC_Channel >> 4); + } + else + { + /* Disable software trigger for the selected DAC channel */ + DAC->SWTRIGR &= ~((uint32_t)DAC_SWTRIGR_SWTRIG1 << (DAC_Channel >> 4)); + } +} + +/** + * @brief Enables or disables simultaneously the two DAC channels software + * triggers. + * @param NewState: new state of the DAC channels software triggers. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void DAC_DualSoftwareTriggerCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable software trigger for both DAC channels */ + DAC->SWTRIGR |= DUAL_SWTRIG_SET ; + } + else + { + /* Disable software trigger for both DAC channels */ + DAC->SWTRIGR &= DUAL_SWTRIG_RESET; + } +} + +/** + * @brief Enables or disables the selected DAC channel wave generation. + * @param DAC_Channel: the selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_Channel_1: DAC Channel1 selected + * @arg DAC_Channel_2: DAC Channel2 selected + * @param DAC_Wave: Specifies the wave type to enable or disable. + * This parameter can be one of the following values: + * @arg DAC_Wave_Noise: noise wave generation + * @arg DAC_Wave_Triangle: triangle wave generation + * @param NewState: new state of the selected DAC channel wave generation. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_DAC_CHANNEL(DAC_Channel)); + assert_param(IS_DAC_WAVE(DAC_Wave)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected wave generation for the selected DAC channel */ + DAC->CR |= DAC_Wave << DAC_Channel; + } + else + { + /* Disable the selected wave generation for the selected DAC channel */ + DAC->CR &= ~(DAC_Wave << DAC_Channel); + } +} + +/** + * @brief Set the specified data holding register value for DAC channel1. + * @param DAC_Align: Specifies the data alignment for DAC channel1. + * This parameter can be one of the following values: + * @arg DAC_Align_8b_R: 8bit right data alignment selected + * @arg DAC_Align_12b_L: 12bit left data alignment selected + * @arg DAC_Align_12b_R: 12bit right data alignment selected + * @param Data : Data to be loaded in the selected data holding register. + * @retval None + */ +void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data) +{ + __IO uint32_t tmp = 0; + + /* Check the parameters */ + assert_param(IS_DAC_ALIGN(DAC_Align)); + assert_param(IS_DAC_DATA(Data)); + + tmp = (uint32_t)DAC_BASE; + tmp += DHR12R1_OFFSET + DAC_Align; + + /* Set the DAC channel1 selected data holding register */ + *(__IO uint32_t *) tmp = Data; +} + +/** + * @brief Set the specified data holding register value for DAC channel2. + * @param DAC_Align: Specifies the data alignment for DAC channel2. + * This parameter can be one of the following values: + * @arg DAC_Align_8b_R: 8bit right data alignment selected + * @arg DAC_Align_12b_L: 12bit left data alignment selected + * @arg DAC_Align_12b_R: 12bit right data alignment selected + * @param Data : Data to be loaded in the selected data holding register. + * @retval None + */ +void DAC_SetChannel2Data(uint32_t DAC_Align, uint16_t Data) +{ + __IO uint32_t tmp = 0; + + /* Check the parameters */ + assert_param(IS_DAC_ALIGN(DAC_Align)); + assert_param(IS_DAC_DATA(Data)); + + tmp = (uint32_t)DAC_BASE; + tmp += DHR12R2_OFFSET + DAC_Align; + + /* Set the DAC channel2 selected data holding register */ + *(__IO uint32_t *)tmp = Data; +} + +/** + * @brief Set the specified data holding register value for dual channel + * DAC. + * @param DAC_Align: Specifies the data alignment for dual channel DAC. + * This parameter can be one of the following values: + * @arg DAC_Align_8b_R: 8bit right data alignment selected + * @arg DAC_Align_12b_L: 12bit left data alignment selected + * @arg DAC_Align_12b_R: 12bit right data alignment selected + * @param Data2: Data for DAC Channel2 to be loaded in the selected data + * holding register. + * @param Data1: Data for DAC Channel1 to be loaded in the selected data + * holding register. + * @retval None + */ +void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1) +{ + uint32_t data = 0, tmp = 0; + + /* Check the parameters */ + assert_param(IS_DAC_ALIGN(DAC_Align)); + assert_param(IS_DAC_DATA(Data1)); + assert_param(IS_DAC_DATA(Data2)); + + /* Calculate and set dual DAC data holding register value */ + if (DAC_Align == DAC_Align_8b_R) + { + data = ((uint32_t)Data2 << 8) | Data1; + } + else + { + data = ((uint32_t)Data2 << 16) | Data1; + } + + tmp = (uint32_t)DAC_BASE; + tmp += DHR12RD_OFFSET + DAC_Align; + + /* Set the dual DAC selected data holding register */ + *(__IO uint32_t *)tmp = data; +} + +/** + * @brief Returns the last data output value of the selected DAC channel. + * @param DAC_Channel: the selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_Channel_1: DAC Channel1 selected + * @arg DAC_Channel_2: DAC Channel2 selected + * @retval The selected DAC channel data output value. + */ +uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel) +{ + __IO uint32_t tmp = 0; + + /* Check the parameters */ + assert_param(IS_DAC_CHANNEL(DAC_Channel)); + + tmp = (uint32_t) DAC_BASE ; + tmp += DOR_OFFSET + ((uint32_t)DAC_Channel >> 2); + + /* Returns the DAC channel data output register value */ + return (uint16_t) (*(__IO uint32_t*) tmp); +} + +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) +/** + * @brief Checks whether the specified DAC flag is set or not. + * @param DAC_Channel: thee selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_Channel_1: DAC Channel1 selected + * @arg DAC_Channel_2: DAC Channel2 selected + * @param DAC_FLAG: specifies the flag to check. + * This parameter can be only of the following value: + * @arg DAC_FLAG_DMAUDR: DMA underrun flag + * @retval The new state of DAC_FLAG (SET or RESET). + */ +FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG) +{ + FlagStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_DAC_CHANNEL(DAC_Channel)); + assert_param(IS_DAC_FLAG(DAC_FLAG)); + + /* Check the status of the specified DAC flag */ + if ((DAC->SR & (DAC_FLAG << DAC_Channel)) != (uint8_t)RESET) + { + /* DAC_FLAG is set */ + bitstatus = SET; + } + else + { + /* DAC_FLAG is reset */ + bitstatus = RESET; + } + /* Return the DAC_FLAG status */ + return bitstatus; +} + +/** + * @brief Clears the DAC channelx's pending flags. + * @param DAC_Channel: the selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_Channel_1: DAC Channel1 selected + * @arg DAC_Channel_2: DAC Channel2 selected + * @param DAC_FLAG: specifies the flag to clear. + * This parameter can be of the following value: + * @arg DAC_FLAG_DMAUDR: DMA underrun flag + * @retval None + */ +void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG) +{ + /* Check the parameters */ + assert_param(IS_DAC_CHANNEL(DAC_Channel)); + assert_param(IS_DAC_FLAG(DAC_FLAG)); + + /* Clear the selected DAC flags */ + DAC->SR = (DAC_FLAG << DAC_Channel); +} + +/** + * @brief Checks whether the specified DAC interrupt has occurred or not. + * @param DAC_Channel: the selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_Channel_1: DAC Channel1 selected + * @arg DAC_Channel_2: DAC Channel2 selected + * @param DAC_IT: specifies the DAC interrupt source to check. + * This parameter can be the following values: + * @arg DAC_IT_DMAUDR: DMA underrun interrupt mask + * @retval The new state of DAC_IT (SET or RESET). + */ +ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT) +{ + ITStatus bitstatus = RESET; + uint32_t enablestatus = 0; + + /* Check the parameters */ + assert_param(IS_DAC_CHANNEL(DAC_Channel)); + assert_param(IS_DAC_IT(DAC_IT)); + + /* Get the DAC_IT enable bit status */ + enablestatus = (DAC->CR & (DAC_IT << DAC_Channel)) ; + + /* Check the status of the specified DAC interrupt */ + if (((DAC->SR & (DAC_IT << DAC_Channel)) != (uint32_t)RESET) && enablestatus) + { + /* DAC_IT is set */ + bitstatus = SET; + } + else + { + /* DAC_IT is reset */ + bitstatus = RESET; + } + /* Return the DAC_IT status */ + return bitstatus; +} + +/** + * @brief Clears the DAC channelx's interrupt pending bits. + * @param DAC_Channel: the selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_Channel_1: DAC Channel1 selected + * @arg DAC_Channel_2: DAC Channel2 selected + * @param DAC_IT: specifies the DAC interrupt pending bit to clear. + * This parameter can be the following values: + * @arg DAC_IT_DMAUDR: DMA underrun interrupt mask + * @retval None + */ +void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT) +{ + /* Check the parameters */ + assert_param(IS_DAC_CHANNEL(DAC_Channel)); + assert_param(IS_DAC_IT(DAC_IT)); + + /* Clear the selected DAC interrupt pending bits */ + DAC->SR = (DAC_IT << DAC_Channel); +} +#endif + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_dbgmcu.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_dbgmcu.c new file mode 100755 index 0000000..d34307b --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_dbgmcu.c @@ -0,0 +1,162 @@ +/** + ****************************************************************************** + * @file stm32f10x_dbgmcu.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the DBGMCU firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_dbgmcu.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup DBGMCU + * @brief DBGMCU driver modules + * @{ + */ + +/** @defgroup DBGMCU_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup DBGMCU_Private_Defines + * @{ + */ + +#define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF) +/** + * @} + */ + +/** @defgroup DBGMCU_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup DBGMCU_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup DBGMCU_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup DBGMCU_Private_Functions + * @{ + */ + +/** + * @brief Returns the device revision identifier. + * @param None + * @retval Device revision identifier + */ +uint32_t DBGMCU_GetREVID(void) +{ + return(DBGMCU->IDCODE >> 16); +} + +/** + * @brief Returns the device identifier. + * @param None + * @retval Device identifier + */ +uint32_t DBGMCU_GetDEVID(void) +{ + return(DBGMCU->IDCODE & IDCODE_DEVID_MASK); +} + +/** + * @brief Configures the specified peripheral and low power mode behavior + * when the MCU under Debug mode. + * @param DBGMCU_Periph: specifies the peripheral and low power mode. + * This parameter can be any combination of the following values: + * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode + * @arg DBGMCU_STOP: Keep debugger connection during STOP mode + * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode + * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted + * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted + * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted + * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted + * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted + * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted + * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted + * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted + * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted + * @arg DBGMCU_TIM5_STOP: TIM5 counter stopped when Core is halted + * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted + * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted + * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted + * @arg DBGMCU_CAN2_STOP: Debug CAN2 stopped when Core is halted + * @arg DBGMCU_TIM15_STOP: TIM15 counter stopped when Core is halted + * @arg DBGMCU_TIM16_STOP: TIM16 counter stopped when Core is halted + * @arg DBGMCU_TIM17_STOP: TIM17 counter stopped when Core is halted + * @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted + * @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted + * @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted + * @arg DBGMCU_TIM12_STOP: TIM12 counter stopped when Core is halted + * @arg DBGMCU_TIM13_STOP: TIM13 counter stopped when Core is halted + * @arg DBGMCU_TIM14_STOP: TIM14 counter stopped when Core is halted + * @param NewState: new state of the specified peripheral in Debug mode. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + DBGMCU->CR |= DBGMCU_Periph; + } + else + { + DBGMCU->CR &= ~DBGMCU_Periph; + } +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_dma.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_dma.c new file mode 100755 index 0000000..0c86f90 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_dma.c @@ -0,0 +1,714 @@ +/** + ****************************************************************************** + * @file stm32f10x_dma.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the DMA firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_dma.h" +#include "stm32f10x_rcc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup DMA + * @brief DMA driver modules + * @{ + */ + +/** @defgroup DMA_Private_TypesDefinitions + * @{ + */ +/** + * @} + */ + +/** @defgroup DMA_Private_Defines + * @{ + */ + + +/* DMA1 Channelx interrupt pending bit masks */ +#define DMA1_Channel1_IT_Mask ((uint32_t)(DMA_ISR_GIF1 | DMA_ISR_TCIF1 | DMA_ISR_HTIF1 | DMA_ISR_TEIF1)) +#define DMA1_Channel2_IT_Mask ((uint32_t)(DMA_ISR_GIF2 | DMA_ISR_TCIF2 | DMA_ISR_HTIF2 | DMA_ISR_TEIF2)) +#define DMA1_Channel3_IT_Mask ((uint32_t)(DMA_ISR_GIF3 | DMA_ISR_TCIF3 | DMA_ISR_HTIF3 | DMA_ISR_TEIF3)) +#define DMA1_Channel4_IT_Mask ((uint32_t)(DMA_ISR_GIF4 | DMA_ISR_TCIF4 | DMA_ISR_HTIF4 | DMA_ISR_TEIF4)) +#define DMA1_Channel5_IT_Mask ((uint32_t)(DMA_ISR_GIF5 | DMA_ISR_TCIF5 | DMA_ISR_HTIF5 | DMA_ISR_TEIF5)) +#define DMA1_Channel6_IT_Mask ((uint32_t)(DMA_ISR_GIF6 | DMA_ISR_TCIF6 | DMA_ISR_HTIF6 | DMA_ISR_TEIF6)) +#define DMA1_Channel7_IT_Mask ((uint32_t)(DMA_ISR_GIF7 | DMA_ISR_TCIF7 | DMA_ISR_HTIF7 | DMA_ISR_TEIF7)) + +/* DMA2 Channelx interrupt pending bit masks */ +#define DMA2_Channel1_IT_Mask ((uint32_t)(DMA_ISR_GIF1 | DMA_ISR_TCIF1 | DMA_ISR_HTIF1 | DMA_ISR_TEIF1)) +#define DMA2_Channel2_IT_Mask ((uint32_t)(DMA_ISR_GIF2 | DMA_ISR_TCIF2 | DMA_ISR_HTIF2 | DMA_ISR_TEIF2)) +#define DMA2_Channel3_IT_Mask ((uint32_t)(DMA_ISR_GIF3 | DMA_ISR_TCIF3 | DMA_ISR_HTIF3 | DMA_ISR_TEIF3)) +#define DMA2_Channel4_IT_Mask ((uint32_t)(DMA_ISR_GIF4 | DMA_ISR_TCIF4 | DMA_ISR_HTIF4 | DMA_ISR_TEIF4)) +#define DMA2_Channel5_IT_Mask ((uint32_t)(DMA_ISR_GIF5 | DMA_ISR_TCIF5 | DMA_ISR_HTIF5 | DMA_ISR_TEIF5)) + +/* DMA2 FLAG mask */ +#define FLAG_Mask ((uint32_t)0x10000000) + +/* DMA registers Masks */ +#define CCR_CLEAR_Mask ((uint32_t)0xFFFF800F) + +/** + * @} + */ + +/** @defgroup DMA_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup DMA_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup DMA_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup DMA_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the DMAy Channelx registers to their default reset + * values. + * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and + * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel. + * @retval None + */ +void DMA_DeInit(DMA_Channel_TypeDef* DMAy_Channelx) +{ + /* Check the parameters */ + assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx)); + + /* Disable the selected DMAy Channelx */ + DMAy_Channelx->CCR &= (uint16_t)(~DMA_CCR1_EN); + + /* Reset DMAy Channelx control register */ + DMAy_Channelx->CCR = 0; + + /* Reset DMAy Channelx remaining bytes register */ + DMAy_Channelx->CNDTR = 0; + + /* Reset DMAy Channelx peripheral address register */ + DMAy_Channelx->CPAR = 0; + + /* Reset DMAy Channelx memory address register */ + DMAy_Channelx->CMAR = 0; + + if (DMAy_Channelx == DMA1_Channel1) + { + /* Reset interrupt pending bits for DMA1 Channel1 */ + DMA1->IFCR |= DMA1_Channel1_IT_Mask; + } + else if (DMAy_Channelx == DMA1_Channel2) + { + /* Reset interrupt pending bits for DMA1 Channel2 */ + DMA1->IFCR |= DMA1_Channel2_IT_Mask; + } + else if (DMAy_Channelx == DMA1_Channel3) + { + /* Reset interrupt pending bits for DMA1 Channel3 */ + DMA1->IFCR |= DMA1_Channel3_IT_Mask; + } + else if (DMAy_Channelx == DMA1_Channel4) + { + /* Reset interrupt pending bits for DMA1 Channel4 */ + DMA1->IFCR |= DMA1_Channel4_IT_Mask; + } + else if (DMAy_Channelx == DMA1_Channel5) + { + /* Reset interrupt pending bits for DMA1 Channel5 */ + DMA1->IFCR |= DMA1_Channel5_IT_Mask; + } + else if (DMAy_Channelx == DMA1_Channel6) + { + /* Reset interrupt pending bits for DMA1 Channel6 */ + DMA1->IFCR |= DMA1_Channel6_IT_Mask; + } + else if (DMAy_Channelx == DMA1_Channel7) + { + /* Reset interrupt pending bits for DMA1 Channel7 */ + DMA1->IFCR |= DMA1_Channel7_IT_Mask; + } + else if (DMAy_Channelx == DMA2_Channel1) + { + /* Reset interrupt pending bits for DMA2 Channel1 */ + DMA2->IFCR |= DMA2_Channel1_IT_Mask; + } + else if (DMAy_Channelx == DMA2_Channel2) + { + /* Reset interrupt pending bits for DMA2 Channel2 */ + DMA2->IFCR |= DMA2_Channel2_IT_Mask; + } + else if (DMAy_Channelx == DMA2_Channel3) + { + /* Reset interrupt pending bits for DMA2 Channel3 */ + DMA2->IFCR |= DMA2_Channel3_IT_Mask; + } + else if (DMAy_Channelx == DMA2_Channel4) + { + /* Reset interrupt pending bits for DMA2 Channel4 */ + DMA2->IFCR |= DMA2_Channel4_IT_Mask; + } + else + { + if (DMAy_Channelx == DMA2_Channel5) + { + /* Reset interrupt pending bits for DMA2 Channel5 */ + DMA2->IFCR |= DMA2_Channel5_IT_Mask; + } + } +} + +/** + * @brief Initializes the DMAy Channelx according to the specified + * parameters in the DMA_InitStruct. + * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and + * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel. + * @param DMA_InitStruct: pointer to a DMA_InitTypeDef structure that + * contains the configuration information for the specified DMA Channel. + * @retval None + */ +void DMA_Init(DMA_Channel_TypeDef* DMAy_Channelx, DMA_InitTypeDef* DMA_InitStruct) +{ + uint32_t tmpreg = 0; + + /* Check the parameters */ + assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx)); + assert_param(IS_DMA_DIR(DMA_InitStruct->DMA_DIR)); + assert_param(IS_DMA_BUFFER_SIZE(DMA_InitStruct->DMA_BufferSize)); + assert_param(IS_DMA_PERIPHERAL_INC_STATE(DMA_InitStruct->DMA_PeripheralInc)); + assert_param(IS_DMA_MEMORY_INC_STATE(DMA_InitStruct->DMA_MemoryInc)); + assert_param(IS_DMA_PERIPHERAL_DATA_SIZE(DMA_InitStruct->DMA_PeripheralDataSize)); + assert_param(IS_DMA_MEMORY_DATA_SIZE(DMA_InitStruct->DMA_MemoryDataSize)); + assert_param(IS_DMA_MODE(DMA_InitStruct->DMA_Mode)); + assert_param(IS_DMA_PRIORITY(DMA_InitStruct->DMA_Priority)); + assert_param(IS_DMA_M2M_STATE(DMA_InitStruct->DMA_M2M)); + +/*--------------------------- DMAy Channelx CCR Configuration -----------------*/ + /* Get the DMAy_Channelx CCR value */ + tmpreg = DMAy_Channelx->CCR; + /* Clear MEM2MEM, PL, MSIZE, PSIZE, MINC, PINC, CIRC and DIR bits */ + tmpreg &= CCR_CLEAR_Mask; + /* Configure DMAy Channelx: data transfer, data size, priority level and mode */ + /* Set DIR bit according to DMA_DIR value */ + /* Set CIRC bit according to DMA_Mode value */ + /* Set PINC bit according to DMA_PeripheralInc value */ + /* Set MINC bit according to DMA_MemoryInc value */ + /* Set PSIZE bits according to DMA_PeripheralDataSize value */ + /* Set MSIZE bits according to DMA_MemoryDataSize value */ + /* Set PL bits according to DMA_Priority value */ + /* Set the MEM2MEM bit according to DMA_M2M value */ + tmpreg |= DMA_InitStruct->DMA_DIR | DMA_InitStruct->DMA_Mode | + DMA_InitStruct->DMA_PeripheralInc | DMA_InitStruct->DMA_MemoryInc | + DMA_InitStruct->DMA_PeripheralDataSize | DMA_InitStruct->DMA_MemoryDataSize | + DMA_InitStruct->DMA_Priority | DMA_InitStruct->DMA_M2M; + + /* Write to DMAy Channelx CCR */ + DMAy_Channelx->CCR = tmpreg; + +/*--------------------------- DMAy Channelx CNDTR Configuration ---------------*/ + /* Write to DMAy Channelx CNDTR */ + DMAy_Channelx->CNDTR = DMA_InitStruct->DMA_BufferSize; + +/*--------------------------- DMAy Channelx CPAR Configuration ----------------*/ + /* Write to DMAy Channelx CPAR */ + DMAy_Channelx->CPAR = DMA_InitStruct->DMA_PeripheralBaseAddr; + +/*--------------------------- DMAy Channelx CMAR Configuration ----------------*/ + /* Write to DMAy Channelx CMAR */ + DMAy_Channelx->CMAR = DMA_InitStruct->DMA_MemoryBaseAddr; +} + +/** + * @brief Fills each DMA_InitStruct member with its default value. + * @param DMA_InitStruct : pointer to a DMA_InitTypeDef structure which will + * be initialized. + * @retval None + */ +void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct) +{ +/*-------------- Reset DMA init structure parameters values ------------------*/ + /* Initialize the DMA_PeripheralBaseAddr member */ + DMA_InitStruct->DMA_PeripheralBaseAddr = 0; + /* Initialize the DMA_MemoryBaseAddr member */ + DMA_InitStruct->DMA_MemoryBaseAddr = 0; + /* Initialize the DMA_DIR member */ + DMA_InitStruct->DMA_DIR = DMA_DIR_PeripheralSRC; + /* Initialize the DMA_BufferSize member */ + DMA_InitStruct->DMA_BufferSize = 0; + /* Initialize the DMA_PeripheralInc member */ + DMA_InitStruct->DMA_PeripheralInc = DMA_PeripheralInc_Disable; + /* Initialize the DMA_MemoryInc member */ + DMA_InitStruct->DMA_MemoryInc = DMA_MemoryInc_Disable; + /* Initialize the DMA_PeripheralDataSize member */ + DMA_InitStruct->DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; + /* Initialize the DMA_MemoryDataSize member */ + DMA_InitStruct->DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; + /* Initialize the DMA_Mode member */ + DMA_InitStruct->DMA_Mode = DMA_Mode_Normal; + /* Initialize the DMA_Priority member */ + DMA_InitStruct->DMA_Priority = DMA_Priority_Low; + /* Initialize the DMA_M2M member */ + DMA_InitStruct->DMA_M2M = DMA_M2M_Disable; +} + +/** + * @brief Enables or disables the specified DMAy Channelx. + * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and + * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel. + * @param NewState: new state of the DMAy Channelx. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void DMA_Cmd(DMA_Channel_TypeDef* DMAy_Channelx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the selected DMAy Channelx */ + DMAy_Channelx->CCR |= DMA_CCR1_EN; + } + else + { + /* Disable the selected DMAy Channelx */ + DMAy_Channelx->CCR &= (uint16_t)(~DMA_CCR1_EN); + } +} + +/** + * @brief Enables or disables the specified DMAy Channelx interrupts. + * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and + * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel. + * @param DMA_IT: specifies the DMA interrupts sources to be enabled + * or disabled. + * This parameter can be any combination of the following values: + * @arg DMA_IT_TC: Transfer complete interrupt mask + * @arg DMA_IT_HT: Half transfer interrupt mask + * @arg DMA_IT_TE: Transfer error interrupt mask + * @param NewState: new state of the specified DMA interrupts. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx)); + assert_param(IS_DMA_CONFIG_IT(DMA_IT)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected DMA interrupts */ + DMAy_Channelx->CCR |= DMA_IT; + } + else + { + /* Disable the selected DMA interrupts */ + DMAy_Channelx->CCR &= ~DMA_IT; + } +} + +/** + * @brief Sets the number of data units in the current DMAy Channelx transfer. + * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and + * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel. + * @param DataNumber: The number of data units in the current DMAy Channelx + * transfer. + * @note This function can only be used when the DMAy_Channelx is disabled. + * @retval None. + */ +void DMA_SetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx, uint16_t DataNumber) +{ + /* Check the parameters */ + assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx)); + +/*--------------------------- DMAy Channelx CNDTR Configuration ---------------*/ + /* Write to DMAy Channelx CNDTR */ + DMAy_Channelx->CNDTR = DataNumber; +} + +/** + * @brief Returns the number of remaining data units in the current + * DMAy Channelx transfer. + * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and + * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel. + * @retval The number of remaining data units in the current DMAy Channelx + * transfer. + */ +uint16_t DMA_GetCurrDataCounter(DMA_Channel_TypeDef* DMAy_Channelx) +{ + /* Check the parameters */ + assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx)); + /* Return the number of remaining data units for DMAy Channelx */ + return ((uint16_t)(DMAy_Channelx->CNDTR)); +} + +/** + * @brief Checks whether the specified DMAy Channelx flag is set or not. + * @param DMAy_FLAG: specifies the flag to check. + * This parameter can be one of the following values: + * @arg DMA1_FLAG_GL1: DMA1 Channel1 global flag. + * @arg DMA1_FLAG_TC1: DMA1 Channel1 transfer complete flag. + * @arg DMA1_FLAG_HT1: DMA1 Channel1 half transfer flag. + * @arg DMA1_FLAG_TE1: DMA1 Channel1 transfer error flag. + * @arg DMA1_FLAG_GL2: DMA1 Channel2 global flag. + * @arg DMA1_FLAG_TC2: DMA1 Channel2 transfer complete flag. + * @arg DMA1_FLAG_HT2: DMA1 Channel2 half transfer flag. + * @arg DMA1_FLAG_TE2: DMA1 Channel2 transfer error flag. + * @arg DMA1_FLAG_GL3: DMA1 Channel3 global flag. + * @arg DMA1_FLAG_TC3: DMA1 Channel3 transfer complete flag. + * @arg DMA1_FLAG_HT3: DMA1 Channel3 half transfer flag. + * @arg DMA1_FLAG_TE3: DMA1 Channel3 transfer error flag. + * @arg DMA1_FLAG_GL4: DMA1 Channel4 global flag. + * @arg DMA1_FLAG_TC4: DMA1 Channel4 transfer complete flag. + * @arg DMA1_FLAG_HT4: DMA1 Channel4 half transfer flag. + * @arg DMA1_FLAG_TE4: DMA1 Channel4 transfer error flag. + * @arg DMA1_FLAG_GL5: DMA1 Channel5 global flag. + * @arg DMA1_FLAG_TC5: DMA1 Channel5 transfer complete flag. + * @arg DMA1_FLAG_HT5: DMA1 Channel5 half transfer flag. + * @arg DMA1_FLAG_TE5: DMA1 Channel5 transfer error flag. + * @arg DMA1_FLAG_GL6: DMA1 Channel6 global flag. + * @arg DMA1_FLAG_TC6: DMA1 Channel6 transfer complete flag. + * @arg DMA1_FLAG_HT6: DMA1 Channel6 half transfer flag. + * @arg DMA1_FLAG_TE6: DMA1 Channel6 transfer error flag. + * @arg DMA1_FLAG_GL7: DMA1 Channel7 global flag. + * @arg DMA1_FLAG_TC7: DMA1 Channel7 transfer complete flag. + * @arg DMA1_FLAG_HT7: DMA1 Channel7 half transfer flag. + * @arg DMA1_FLAG_TE7: DMA1 Channel7 transfer error flag. + * @arg DMA2_FLAG_GL1: DMA2 Channel1 global flag. + * @arg DMA2_FLAG_TC1: DMA2 Channel1 transfer complete flag. + * @arg DMA2_FLAG_HT1: DMA2 Channel1 half transfer flag. + * @arg DMA2_FLAG_TE1: DMA2 Channel1 transfer error flag. + * @arg DMA2_FLAG_GL2: DMA2 Channel2 global flag. + * @arg DMA2_FLAG_TC2: DMA2 Channel2 transfer complete flag. + * @arg DMA2_FLAG_HT2: DMA2 Channel2 half transfer flag. + * @arg DMA2_FLAG_TE2: DMA2 Channel2 transfer error flag. + * @arg DMA2_FLAG_GL3: DMA2 Channel3 global flag. + * @arg DMA2_FLAG_TC3: DMA2 Channel3 transfer complete flag. + * @arg DMA2_FLAG_HT3: DMA2 Channel3 half transfer flag. + * @arg DMA2_FLAG_TE3: DMA2 Channel3 transfer error flag. + * @arg DMA2_FLAG_GL4: DMA2 Channel4 global flag. + * @arg DMA2_FLAG_TC4: DMA2 Channel4 transfer complete flag. + * @arg DMA2_FLAG_HT4: DMA2 Channel4 half transfer flag. + * @arg DMA2_FLAG_TE4: DMA2 Channel4 transfer error flag. + * @arg DMA2_FLAG_GL5: DMA2 Channel5 global flag. + * @arg DMA2_FLAG_TC5: DMA2 Channel5 transfer complete flag. + * @arg DMA2_FLAG_HT5: DMA2 Channel5 half transfer flag. + * @arg DMA2_FLAG_TE5: DMA2 Channel5 transfer error flag. + * @retval The new state of DMAy_FLAG (SET or RESET). + */ +FlagStatus DMA_GetFlagStatus(uint32_t DMAy_FLAG) +{ + FlagStatus bitstatus = RESET; + uint32_t tmpreg = 0; + + /* Check the parameters */ + assert_param(IS_DMA_GET_FLAG(DMAy_FLAG)); + + /* Calculate the used DMAy */ + if ((DMAy_FLAG & FLAG_Mask) != (uint32_t)RESET) + { + /* Get DMA2 ISR register value */ + tmpreg = DMA2->ISR ; + } + else + { + /* Get DMA1 ISR register value */ + tmpreg = DMA1->ISR ; + } + + /* Check the status of the specified DMAy flag */ + if ((tmpreg & DMAy_FLAG) != (uint32_t)RESET) + { + /* DMAy_FLAG is set */ + bitstatus = SET; + } + else + { + /* DMAy_FLAG is reset */ + bitstatus = RESET; + } + + /* Return the DMAy_FLAG status */ + return bitstatus; +} + +/** + * @brief Clears the DMAy Channelx's pending flags. + * @param DMAy_FLAG: specifies the flag to clear. + * This parameter can be any combination (for the same DMA) of the following values: + * @arg DMA1_FLAG_GL1: DMA1 Channel1 global flag. + * @arg DMA1_FLAG_TC1: DMA1 Channel1 transfer complete flag. + * @arg DMA1_FLAG_HT1: DMA1 Channel1 half transfer flag. + * @arg DMA1_FLAG_TE1: DMA1 Channel1 transfer error flag. + * @arg DMA1_FLAG_GL2: DMA1 Channel2 global flag. + * @arg DMA1_FLAG_TC2: DMA1 Channel2 transfer complete flag. + * @arg DMA1_FLAG_HT2: DMA1 Channel2 half transfer flag. + * @arg DMA1_FLAG_TE2: DMA1 Channel2 transfer error flag. + * @arg DMA1_FLAG_GL3: DMA1 Channel3 global flag. + * @arg DMA1_FLAG_TC3: DMA1 Channel3 transfer complete flag. + * @arg DMA1_FLAG_HT3: DMA1 Channel3 half transfer flag. + * @arg DMA1_FLAG_TE3: DMA1 Channel3 transfer error flag. + * @arg DMA1_FLAG_GL4: DMA1 Channel4 global flag. + * @arg DMA1_FLAG_TC4: DMA1 Channel4 transfer complete flag. + * @arg DMA1_FLAG_HT4: DMA1 Channel4 half transfer flag. + * @arg DMA1_FLAG_TE4: DMA1 Channel4 transfer error flag. + * @arg DMA1_FLAG_GL5: DMA1 Channel5 global flag. + * @arg DMA1_FLAG_TC5: DMA1 Channel5 transfer complete flag. + * @arg DMA1_FLAG_HT5: DMA1 Channel5 half transfer flag. + * @arg DMA1_FLAG_TE5: DMA1 Channel5 transfer error flag. + * @arg DMA1_FLAG_GL6: DMA1 Channel6 global flag. + * @arg DMA1_FLAG_TC6: DMA1 Channel6 transfer complete flag. + * @arg DMA1_FLAG_HT6: DMA1 Channel6 half transfer flag. + * @arg DMA1_FLAG_TE6: DMA1 Channel6 transfer error flag. + * @arg DMA1_FLAG_GL7: DMA1 Channel7 global flag. + * @arg DMA1_FLAG_TC7: DMA1 Channel7 transfer complete flag. + * @arg DMA1_FLAG_HT7: DMA1 Channel7 half transfer flag. + * @arg DMA1_FLAG_TE7: DMA1 Channel7 transfer error flag. + * @arg DMA2_FLAG_GL1: DMA2 Channel1 global flag. + * @arg DMA2_FLAG_TC1: DMA2 Channel1 transfer complete flag. + * @arg DMA2_FLAG_HT1: DMA2 Channel1 half transfer flag. + * @arg DMA2_FLAG_TE1: DMA2 Channel1 transfer error flag. + * @arg DMA2_FLAG_GL2: DMA2 Channel2 global flag. + * @arg DMA2_FLAG_TC2: DMA2 Channel2 transfer complete flag. + * @arg DMA2_FLAG_HT2: DMA2 Channel2 half transfer flag. + * @arg DMA2_FLAG_TE2: DMA2 Channel2 transfer error flag. + * @arg DMA2_FLAG_GL3: DMA2 Channel3 global flag. + * @arg DMA2_FLAG_TC3: DMA2 Channel3 transfer complete flag. + * @arg DMA2_FLAG_HT3: DMA2 Channel3 half transfer flag. + * @arg DMA2_FLAG_TE3: DMA2 Channel3 transfer error flag. + * @arg DMA2_FLAG_GL4: DMA2 Channel4 global flag. + * @arg DMA2_FLAG_TC4: DMA2 Channel4 transfer complete flag. + * @arg DMA2_FLAG_HT4: DMA2 Channel4 half transfer flag. + * @arg DMA2_FLAG_TE4: DMA2 Channel4 transfer error flag. + * @arg DMA2_FLAG_GL5: DMA2 Channel5 global flag. + * @arg DMA2_FLAG_TC5: DMA2 Channel5 transfer complete flag. + * @arg DMA2_FLAG_HT5: DMA2 Channel5 half transfer flag. + * @arg DMA2_FLAG_TE5: DMA2 Channel5 transfer error flag. + * @retval None + */ +void DMA_ClearFlag(uint32_t DMAy_FLAG) +{ + /* Check the parameters */ + assert_param(IS_DMA_CLEAR_FLAG(DMAy_FLAG)); + + /* Calculate the used DMAy */ + if ((DMAy_FLAG & FLAG_Mask) != (uint32_t)RESET) + { + /* Clear the selected DMAy flags */ + DMA2->IFCR = DMAy_FLAG; + } + else + { + /* Clear the selected DMAy flags */ + DMA1->IFCR = DMAy_FLAG; + } +} + +/** + * @brief Checks whether the specified DMAy Channelx interrupt has occurred or not. + * @param DMAy_IT: specifies the DMAy interrupt source to check. + * This parameter can be one of the following values: + * @arg DMA1_IT_GL1: DMA1 Channel1 global interrupt. + * @arg DMA1_IT_TC1: DMA1 Channel1 transfer complete interrupt. + * @arg DMA1_IT_HT1: DMA1 Channel1 half transfer interrupt. + * @arg DMA1_IT_TE1: DMA1 Channel1 transfer error interrupt. + * @arg DMA1_IT_GL2: DMA1 Channel2 global interrupt. + * @arg DMA1_IT_TC2: DMA1 Channel2 transfer complete interrupt. + * @arg DMA1_IT_HT2: DMA1 Channel2 half transfer interrupt. + * @arg DMA1_IT_TE2: DMA1 Channel2 transfer error interrupt. + * @arg DMA1_IT_GL3: DMA1 Channel3 global interrupt. + * @arg DMA1_IT_TC3: DMA1 Channel3 transfer complete interrupt. + * @arg DMA1_IT_HT3: DMA1 Channel3 half transfer interrupt. + * @arg DMA1_IT_TE3: DMA1 Channel3 transfer error interrupt. + * @arg DMA1_IT_GL4: DMA1 Channel4 global interrupt. + * @arg DMA1_IT_TC4: DMA1 Channel4 transfer complete interrupt. + * @arg DMA1_IT_HT4: DMA1 Channel4 half transfer interrupt. + * @arg DMA1_IT_TE4: DMA1 Channel4 transfer error interrupt. + * @arg DMA1_IT_GL5: DMA1 Channel5 global interrupt. + * @arg DMA1_IT_TC5: DMA1 Channel5 transfer complete interrupt. + * @arg DMA1_IT_HT5: DMA1 Channel5 half transfer interrupt. + * @arg DMA1_IT_TE5: DMA1 Channel5 transfer error interrupt. + * @arg DMA1_IT_GL6: DMA1 Channel6 global interrupt. + * @arg DMA1_IT_TC6: DMA1 Channel6 transfer complete interrupt. + * @arg DMA1_IT_HT6: DMA1 Channel6 half transfer interrupt. + * @arg DMA1_IT_TE6: DMA1 Channel6 transfer error interrupt. + * @arg DMA1_IT_GL7: DMA1 Channel7 global interrupt. + * @arg DMA1_IT_TC7: DMA1 Channel7 transfer complete interrupt. + * @arg DMA1_IT_HT7: DMA1 Channel7 half transfer interrupt. + * @arg DMA1_IT_TE7: DMA1 Channel7 transfer error interrupt. + * @arg DMA2_IT_GL1: DMA2 Channel1 global interrupt. + * @arg DMA2_IT_TC1: DMA2 Channel1 transfer complete interrupt. + * @arg DMA2_IT_HT1: DMA2 Channel1 half transfer interrupt. + * @arg DMA2_IT_TE1: DMA2 Channel1 transfer error interrupt. + * @arg DMA2_IT_GL2: DMA2 Channel2 global interrupt. + * @arg DMA2_IT_TC2: DMA2 Channel2 transfer complete interrupt. + * @arg DMA2_IT_HT2: DMA2 Channel2 half transfer interrupt. + * @arg DMA2_IT_TE2: DMA2 Channel2 transfer error interrupt. + * @arg DMA2_IT_GL3: DMA2 Channel3 global interrupt. + * @arg DMA2_IT_TC3: DMA2 Channel3 transfer complete interrupt. + * @arg DMA2_IT_HT3: DMA2 Channel3 half transfer interrupt. + * @arg DMA2_IT_TE3: DMA2 Channel3 transfer error interrupt. + * @arg DMA2_IT_GL4: DMA2 Channel4 global interrupt. + * @arg DMA2_IT_TC4: DMA2 Channel4 transfer complete interrupt. + * @arg DMA2_IT_HT4: DMA2 Channel4 half transfer interrupt. + * @arg DMA2_IT_TE4: DMA2 Channel4 transfer error interrupt. + * @arg DMA2_IT_GL5: DMA2 Channel5 global interrupt. + * @arg DMA2_IT_TC5: DMA2 Channel5 transfer complete interrupt. + * @arg DMA2_IT_HT5: DMA2 Channel5 half transfer interrupt. + * @arg DMA2_IT_TE5: DMA2 Channel5 transfer error interrupt. + * @retval The new state of DMAy_IT (SET or RESET). + */ +ITStatus DMA_GetITStatus(uint32_t DMAy_IT) +{ + ITStatus bitstatus = RESET; + uint32_t tmpreg = 0; + + /* Check the parameters */ + assert_param(IS_DMA_GET_IT(DMAy_IT)); + + /* Calculate the used DMA */ + if ((DMAy_IT & FLAG_Mask) != (uint32_t)RESET) + { + /* Get DMA2 ISR register value */ + tmpreg = DMA2->ISR; + } + else + { + /* Get DMA1 ISR register value */ + tmpreg = DMA1->ISR; + } + + /* Check the status of the specified DMAy interrupt */ + if ((tmpreg & DMAy_IT) != (uint32_t)RESET) + { + /* DMAy_IT is set */ + bitstatus = SET; + } + else + { + /* DMAy_IT is reset */ + bitstatus = RESET; + } + /* Return the DMA_IT status */ + return bitstatus; +} + +/** + * @brief Clears the DMAy Channelx's interrupt pending bits. + * @param DMAy_IT: specifies the DMAy interrupt pending bit to clear. + * This parameter can be any combination (for the same DMA) of the following values: + * @arg DMA1_IT_GL1: DMA1 Channel1 global interrupt. + * @arg DMA1_IT_TC1: DMA1 Channel1 transfer complete interrupt. + * @arg DMA1_IT_HT1: DMA1 Channel1 half transfer interrupt. + * @arg DMA1_IT_TE1: DMA1 Channel1 transfer error interrupt. + * @arg DMA1_IT_GL2: DMA1 Channel2 global interrupt. + * @arg DMA1_IT_TC2: DMA1 Channel2 transfer complete interrupt. + * @arg DMA1_IT_HT2: DMA1 Channel2 half transfer interrupt. + * @arg DMA1_IT_TE2: DMA1 Channel2 transfer error interrupt. + * @arg DMA1_IT_GL3: DMA1 Channel3 global interrupt. + * @arg DMA1_IT_TC3: DMA1 Channel3 transfer complete interrupt. + * @arg DMA1_IT_HT3: DMA1 Channel3 half transfer interrupt. + * @arg DMA1_IT_TE3: DMA1 Channel3 transfer error interrupt. + * @arg DMA1_IT_GL4: DMA1 Channel4 global interrupt. + * @arg DMA1_IT_TC4: DMA1 Channel4 transfer complete interrupt. + * @arg DMA1_IT_HT4: DMA1 Channel4 half transfer interrupt. + * @arg DMA1_IT_TE4: DMA1 Channel4 transfer error interrupt. + * @arg DMA1_IT_GL5: DMA1 Channel5 global interrupt. + * @arg DMA1_IT_TC5: DMA1 Channel5 transfer complete interrupt. + * @arg DMA1_IT_HT5: DMA1 Channel5 half transfer interrupt. + * @arg DMA1_IT_TE5: DMA1 Channel5 transfer error interrupt. + * @arg DMA1_IT_GL6: DMA1 Channel6 global interrupt. + * @arg DMA1_IT_TC6: DMA1 Channel6 transfer complete interrupt. + * @arg DMA1_IT_HT6: DMA1 Channel6 half transfer interrupt. + * @arg DMA1_IT_TE6: DMA1 Channel6 transfer error interrupt. + * @arg DMA1_IT_GL7: DMA1 Channel7 global interrupt. + * @arg DMA1_IT_TC7: DMA1 Channel7 transfer complete interrupt. + * @arg DMA1_IT_HT7: DMA1 Channel7 half transfer interrupt. + * @arg DMA1_IT_TE7: DMA1 Channel7 transfer error interrupt. + * @arg DMA2_IT_GL1: DMA2 Channel1 global interrupt. + * @arg DMA2_IT_TC1: DMA2 Channel1 transfer complete interrupt. + * @arg DMA2_IT_HT1: DMA2 Channel1 half transfer interrupt. + * @arg DMA2_IT_TE1: DMA2 Channel1 transfer error interrupt. + * @arg DMA2_IT_GL2: DMA2 Channel2 global interrupt. + * @arg DMA2_IT_TC2: DMA2 Channel2 transfer complete interrupt. + * @arg DMA2_IT_HT2: DMA2 Channel2 half transfer interrupt. + * @arg DMA2_IT_TE2: DMA2 Channel2 transfer error interrupt. + * @arg DMA2_IT_GL3: DMA2 Channel3 global interrupt. + * @arg DMA2_IT_TC3: DMA2 Channel3 transfer complete interrupt. + * @arg DMA2_IT_HT3: DMA2 Channel3 half transfer interrupt. + * @arg DMA2_IT_TE3: DMA2 Channel3 transfer error interrupt. + * @arg DMA2_IT_GL4: DMA2 Channel4 global interrupt. + * @arg DMA2_IT_TC4: DMA2 Channel4 transfer complete interrupt. + * @arg DMA2_IT_HT4: DMA2 Channel4 half transfer interrupt. + * @arg DMA2_IT_TE4: DMA2 Channel4 transfer error interrupt. + * @arg DMA2_IT_GL5: DMA2 Channel5 global interrupt. + * @arg DMA2_IT_TC5: DMA2 Channel5 transfer complete interrupt. + * @arg DMA2_IT_HT5: DMA2 Channel5 half transfer interrupt. + * @arg DMA2_IT_TE5: DMA2 Channel5 transfer error interrupt. + * @retval None + */ +void DMA_ClearITPendingBit(uint32_t DMAy_IT) +{ + /* Check the parameters */ + assert_param(IS_DMA_CLEAR_IT(DMAy_IT)); + + /* Calculate the used DMAy */ + if ((DMAy_IT & FLAG_Mask) != (uint32_t)RESET) + { + /* Clear the selected DMAy interrupt pending bits */ + DMA2->IFCR = DMAy_IT; + } + else + { + /* Clear the selected DMAy interrupt pending bits */ + DMA1->IFCR = DMAy_IT; + } +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_exti.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_exti.c new file mode 100755 index 0000000..ab73462 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_exti.c @@ -0,0 +1,269 @@ +/** + ****************************************************************************** + * @file stm32f10x_exti.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the EXTI firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_exti.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup EXTI + * @brief EXTI driver modules + * @{ + */ + +/** @defgroup EXTI_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup EXTI_Private_Defines + * @{ + */ + +#define EXTI_LINENONE ((uint32_t)0x00000) /* No interrupt selected */ + +/** + * @} + */ + +/** @defgroup EXTI_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup EXTI_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup EXTI_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup EXTI_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the EXTI peripheral registers to their default reset values. + * @param None + * @retval None + */ +void EXTI_DeInit(void) +{ + EXTI->IMR = 0x00000000; + EXTI->EMR = 0x00000000; + EXTI->RTSR = 0x00000000; + EXTI->FTSR = 0x00000000; + EXTI->PR = 0x000FFFFF; +} + +/** + * @brief Initializes the EXTI peripheral according to the specified + * parameters in the EXTI_InitStruct. + * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure + * that contains the configuration information for the EXTI peripheral. + * @retval None + */ +void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct) +{ + uint32_t tmp = 0; + + /* Check the parameters */ + assert_param(IS_EXTI_MODE(EXTI_InitStruct->EXTI_Mode)); + assert_param(IS_EXTI_TRIGGER(EXTI_InitStruct->EXTI_Trigger)); + assert_param(IS_EXTI_LINE(EXTI_InitStruct->EXTI_Line)); + assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd)); + + tmp = (uint32_t)EXTI_BASE; + + if (EXTI_InitStruct->EXTI_LineCmd != DISABLE) + { + /* Clear EXTI line configuration */ + EXTI->IMR &= ~EXTI_InitStruct->EXTI_Line; + EXTI->EMR &= ~EXTI_InitStruct->EXTI_Line; + + tmp += EXTI_InitStruct->EXTI_Mode; + + *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line; + + /* Clear Rising Falling edge configuration */ + EXTI->RTSR &= ~EXTI_InitStruct->EXTI_Line; + EXTI->FTSR &= ~EXTI_InitStruct->EXTI_Line; + + /* Select the trigger for the selected external interrupts */ + if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling) + { + /* Rising Falling edge */ + EXTI->RTSR |= EXTI_InitStruct->EXTI_Line; + EXTI->FTSR |= EXTI_InitStruct->EXTI_Line; + } + else + { + tmp = (uint32_t)EXTI_BASE; + tmp += EXTI_InitStruct->EXTI_Trigger; + + *(__IO uint32_t *) tmp |= EXTI_InitStruct->EXTI_Line; + } + } + else + { + tmp += EXTI_InitStruct->EXTI_Mode; + + /* Disable the selected external lines */ + *(__IO uint32_t *) tmp &= ~EXTI_InitStruct->EXTI_Line; + } +} + +/** + * @brief Fills each EXTI_InitStruct member with its reset value. + * @param EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure which will + * be initialized. + * @retval None + */ +void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct) +{ + EXTI_InitStruct->EXTI_Line = EXTI_LINENONE; + EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt; + EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling; + EXTI_InitStruct->EXTI_LineCmd = DISABLE; +} + +/** + * @brief Generates a Software interrupt. + * @param EXTI_Line: specifies the EXTI lines to be enabled or disabled. + * This parameter can be any combination of EXTI_Linex where x can be (0..19). + * @retval None + */ +void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line) +{ + /* Check the parameters */ + assert_param(IS_EXTI_LINE(EXTI_Line)); + + EXTI->SWIER |= EXTI_Line; +} + +/** + * @brief Checks whether the specified EXTI line flag is set or not. + * @param EXTI_Line: specifies the EXTI line flag to check. + * This parameter can be: + * @arg EXTI_Linex: External interrupt line x where x(0..19) + * @retval The new state of EXTI_Line (SET or RESET). + */ +FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line) +{ + FlagStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_GET_EXTI_LINE(EXTI_Line)); + + if ((EXTI->PR & EXTI_Line) != (uint32_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + return bitstatus; +} + +/** + * @brief Clears the EXTI's line pending flags. + * @param EXTI_Line: specifies the EXTI lines flags to clear. + * This parameter can be any combination of EXTI_Linex where x can be (0..19). + * @retval None + */ +void EXTI_ClearFlag(uint32_t EXTI_Line) +{ + /* Check the parameters */ + assert_param(IS_EXTI_LINE(EXTI_Line)); + + EXTI->PR = EXTI_Line; +} + +/** + * @brief Checks whether the specified EXTI line is asserted or not. + * @param EXTI_Line: specifies the EXTI line to check. + * This parameter can be: + * @arg EXTI_Linex: External interrupt line x where x(0..19) + * @retval The new state of EXTI_Line (SET or RESET). + */ +ITStatus EXTI_GetITStatus(uint32_t EXTI_Line) +{ + ITStatus bitstatus = RESET; + uint32_t enablestatus = 0; + /* Check the parameters */ + assert_param(IS_GET_EXTI_LINE(EXTI_Line)); + + enablestatus = EXTI->IMR & EXTI_Line; + if (((EXTI->PR & EXTI_Line) != (uint32_t)RESET) && (enablestatus != (uint32_t)RESET)) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + return bitstatus; +} + +/** + * @brief Clears the EXTI's line pending bits. + * @param EXTI_Line: specifies the EXTI lines to clear. + * This parameter can be any combination of EXTI_Linex where x can be (0..19). + * @retval None + */ +void EXTI_ClearITPendingBit(uint32_t EXTI_Line) +{ + /* Check the parameters */ + assert_param(IS_EXTI_LINE(EXTI_Line)); + + EXTI->PR = EXTI_Line; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_flash.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_flash.c new file mode 100755 index 0000000..f6c7bf1 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_flash.c @@ -0,0 +1,1684 @@ +/** + ****************************************************************************** + * @file stm32f10x_flash.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the FLASH firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_flash.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup FLASH + * @brief FLASH driver modules + * @{ + */ + +/** @defgroup FLASH_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup FLASH_Private_Defines + * @{ + */ + +/* Flash Access Control Register bits */ +#define ACR_LATENCY_Mask ((uint32_t)0x00000038) +#define ACR_HLFCYA_Mask ((uint32_t)0xFFFFFFF7) +#define ACR_PRFTBE_Mask ((uint32_t)0xFFFFFFEF) + +/* Flash Access Control Register bits */ +#define ACR_PRFTBS_Mask ((uint32_t)0x00000020) + +/* Flash Control Register bits */ +#define CR_PG_Set ((uint32_t)0x00000001) +#define CR_PG_Reset ((uint32_t)0x00001FFE) +#define CR_PER_Set ((uint32_t)0x00000002) +#define CR_PER_Reset ((uint32_t)0x00001FFD) +#define CR_MER_Set ((uint32_t)0x00000004) +#define CR_MER_Reset ((uint32_t)0x00001FFB) +#define CR_OPTPG_Set ((uint32_t)0x00000010) +#define CR_OPTPG_Reset ((uint32_t)0x00001FEF) +#define CR_OPTER_Set ((uint32_t)0x00000020) +#define CR_OPTER_Reset ((uint32_t)0x00001FDF) +#define CR_STRT_Set ((uint32_t)0x00000040) +#define CR_LOCK_Set ((uint32_t)0x00000080) + +/* FLASH Mask */ +#define RDPRT_Mask ((uint32_t)0x00000002) +#define WRP0_Mask ((uint32_t)0x000000FF) +#define WRP1_Mask ((uint32_t)0x0000FF00) +#define WRP2_Mask ((uint32_t)0x00FF0000) +#define WRP3_Mask ((uint32_t)0xFF000000) +#define OB_USER_BFB2 ((uint16_t)0x0008) + +/* FLASH Keys */ +#define RDP_Key ((uint16_t)0x00A5) +#define FLASH_KEY1 ((uint32_t)0x45670123) +#define FLASH_KEY2 ((uint32_t)0xCDEF89AB) + +/* FLASH BANK address */ +#define FLASH_BANK1_END_ADDRESS ((uint32_t)0x807FFFF) + +/* Delay definition */ +#define EraseTimeout ((uint32_t)0x000B0000) +#define ProgramTimeout ((uint32_t)0x00002000) +/** + * @} + */ + +/** @defgroup FLASH_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup FLASH_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup FLASH_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup FLASH_Private_Functions + * @{ + */ + +/** +@code + + This driver provides functions to configure and program the Flash memory of all STM32F10x devices, + including the latest STM32F10x_XL density devices. + + STM32F10x_XL devices feature up to 1 Mbyte with dual bank architecture for read-while-write (RWW) capability: + - bank1: fixed size of 512 Kbytes (256 pages of 2Kbytes each) + - bank2: up to 512 Kbytes (up to 256 pages of 2Kbytes each) + While other STM32F10x devices features only one bank with memory up to 512 Kbytes. + + In version V3.3.0, some functions were updated and new ones were added to support + STM32F10x_XL devices. Thus some functions manages all devices, while other are + dedicated for XL devices only. + + The table below presents the list of available functions depending on the used STM32F10x devices. + + *************************************************** + * Legacy functions used for all STM32F10x devices * + *************************************************** + +----------------------------------------------------------------------------------------------------------------------------------+ + | Functions prototypes |STM32F10x_XL|Other STM32F10x| Comments | + | | devices | devices | | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_SetLatency | Yes | Yes | No change | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_HalfCycleAccessCmd | Yes | Yes | No change | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_PrefetchBufferCmd | Yes | Yes | No change | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_Unlock | Yes | Yes | - For STM32F10X_XL devices: unlock Bank1 and Bank2. | + | | | | - For other devices: unlock Bank1 and it is equivalent | + | | | | to FLASH_UnlockBank1 function. | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_Lock | Yes | Yes | - For STM32F10X_XL devices: lock Bank1 and Bank2. | + | | | | - For other devices: lock Bank1 and it is equivalent | + | | | | to FLASH_LockBank1 function. | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_ErasePage | Yes | Yes | - For STM32F10x_XL devices: erase a page in Bank1 and Bank2 | + | | | | - For other devices: erase a page in Bank1 | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_EraseAllPages | Yes | Yes | - For STM32F10x_XL devices: erase all pages in Bank1 and Bank2 | + | | | | - For other devices: erase all pages in Bank1 | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_EraseOptionBytes | Yes | Yes | No change | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_ProgramWord | Yes | Yes | Updated to program up to 1MByte (depending on the used device) | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_ProgramHalfWord | Yes | Yes | Updated to program up to 1MByte (depending on the used device) | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_ProgramOptionByteData | Yes | Yes | No change | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_EnableWriteProtection | Yes | Yes | No change | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_ReadOutProtection | Yes | Yes | No change | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_UserOptionByteConfig | Yes | Yes | No change | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_GetUserOptionByte | Yes | Yes | No change | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_GetWriteProtectionOptionByte | Yes | Yes | No change | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_GetReadOutProtectionStatus | Yes | Yes | No change | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_GetPrefetchBufferStatus | Yes | Yes | No change | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_ITConfig | Yes | Yes | - For STM32F10x_XL devices: enable Bank1 and Bank2's interrupts| + | | | | - For other devices: enable Bank1's interrupts | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_GetFlagStatus | Yes | Yes | - For STM32F10x_XL devices: return Bank1 and Bank2's flag status| + | | | | - For other devices: return Bank1's flag status | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_ClearFlag | Yes | Yes | - For STM32F10x_XL devices: clear Bank1 and Bank2's flag | + | | | | - For other devices: clear Bank1's flag | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_GetStatus | Yes | Yes | - Return the status of Bank1 (for all devices) | + | | | | equivalent to FLASH_GetBank1Status function | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_WaitForLastOperation | Yes | Yes | - Wait for Bank1 last operation (for all devices) | + | | | | equivalent to: FLASH_WaitForLastBank1Operation function | + +----------------------------------------------------------------------------------------------------------------------------------+ + + ************************************************************************************************************************ + * New functions used for all STM32F10x devices to manage Bank1: * + * - These functions are mainly useful for STM32F10x_XL density devices, to have separate control for Bank1 and bank2 * + * - For other devices, these functions are optional (covered by functions listed above) * + ************************************************************************************************************************ + +----------------------------------------------------------------------------------------------------------------------------------+ + | Functions prototypes |STM32F10x_XL|Other STM32F10x| Comments | + | | devices | devices | | + |----------------------------------------------------------------------------------------------------------------------------------| + | FLASH_UnlockBank1 | Yes | Yes | - Unlock Bank1 | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_LockBank1 | Yes | Yes | - Lock Bank1 | + |----------------------------------------------------------------------------------------------------------------------------------| + | FLASH_EraseAllBank1Pages | Yes | Yes | - Erase all pages in Bank1 | + |----------------------------------------------------------------------------------------------------------------------------------| + | FLASH_GetBank1Status | Yes | Yes | - Return the status of Bank1 | + |----------------------------------------------------------------------------------------------------------------------------------| + | FLASH_WaitForLastBank1Operation | Yes | Yes | - Wait for Bank1 last operation | + +----------------------------------------------------------------------------------------------------------------------------------+ + + ***************************************************************************** + * New Functions used only with STM32F10x_XL density devices to manage Bank2 * + ***************************************************************************** + +----------------------------------------------------------------------------------------------------------------------------------+ + | Functions prototypes |STM32F10x_XL|Other STM32F10x| Comments | + | | devices | devices | | + |----------------------------------------------------------------------------------------------------------------------------------| + | FLASH_UnlockBank2 | Yes | No | - Unlock Bank2 | + |----------------------------------------------------------------------------------------------------------------------------------| + |FLASH_LockBank2 | Yes | No | - Lock Bank2 | + |----------------------------------------------------------------------------------------------------------------------------------| + | FLASH_EraseAllBank2Pages | Yes | No | - Erase all pages in Bank2 | + |----------------------------------------------------------------------------------------------------------------------------------| + | FLASH_GetBank2Status | Yes | No | - Return the status of Bank2 | + |----------------------------------------------------------------------------------------------------------------------------------| + | FLASH_WaitForLastBank2Operation | Yes | No | - Wait for Bank2 last operation | + |----------------------------------------------------------------------------------------------------------------------------------| + | FLASH_BootConfig | Yes | No | - Configure to boot from Bank1 or Bank2 | + +----------------------------------------------------------------------------------------------------------------------------------+ +@endcode +*/ + + +/** + * @brief Sets the code latency value. + * @note This function can be used for all STM32F10x devices. + * @param FLASH_Latency: specifies the FLASH Latency value. + * This parameter can be one of the following values: + * @arg FLASH_Latency_0: FLASH Zero Latency cycle + * @arg FLASH_Latency_1: FLASH One Latency cycle + * @arg FLASH_Latency_2: FLASH Two Latency cycles + * @retval None + */ +void FLASH_SetLatency(uint32_t FLASH_Latency) +{ + uint32_t tmpreg = 0; + + /* Check the parameters */ + assert_param(IS_FLASH_LATENCY(FLASH_Latency)); + + /* Read the ACR register */ + tmpreg = FLASH->ACR; + + /* Sets the Latency value */ + tmpreg &= ACR_LATENCY_Mask; + tmpreg |= FLASH_Latency; + + /* Write the ACR register */ + FLASH->ACR = tmpreg; +} + +/** + * @brief Enables or disables the Half cycle flash access. + * @note This function can be used for all STM32F10x devices. + * @param FLASH_HalfCycleAccess: specifies the FLASH Half cycle Access mode. + * This parameter can be one of the following values: + * @arg FLASH_HalfCycleAccess_Enable: FLASH Half Cycle Enable + * @arg FLASH_HalfCycleAccess_Disable: FLASH Half Cycle Disable + * @retval None + */ +void FLASH_HalfCycleAccessCmd(uint32_t FLASH_HalfCycleAccess) +{ + /* Check the parameters */ + assert_param(IS_FLASH_HALFCYCLEACCESS_STATE(FLASH_HalfCycleAccess)); + + /* Enable or disable the Half cycle access */ + FLASH->ACR &= ACR_HLFCYA_Mask; + FLASH->ACR |= FLASH_HalfCycleAccess; +} + +/** + * @brief Enables or disables the Prefetch Buffer. + * @note This function can be used for all STM32F10x devices. + * @param FLASH_PrefetchBuffer: specifies the Prefetch buffer status. + * This parameter can be one of the following values: + * @arg FLASH_PrefetchBuffer_Enable: FLASH Prefetch Buffer Enable + * @arg FLASH_PrefetchBuffer_Disable: FLASH Prefetch Buffer Disable + * @retval None + */ +void FLASH_PrefetchBufferCmd(uint32_t FLASH_PrefetchBuffer) +{ + /* Check the parameters */ + assert_param(IS_FLASH_PREFETCHBUFFER_STATE(FLASH_PrefetchBuffer)); + + /* Enable or disable the Prefetch Buffer */ + FLASH->ACR &= ACR_PRFTBE_Mask; + FLASH->ACR |= FLASH_PrefetchBuffer; +} + +/** + * @brief Unlocks the FLASH Program Erase Controller. + * @note This function can be used for all STM32F10x devices. + * - For STM32F10X_XL devices this function unlocks Bank1 and Bank2. + * - For all other devices it unlocks Bank1 and it is equivalent + * to FLASH_UnlockBank1 function.. + * @param None + * @retval None + */ +void FLASH_Unlock(void) +{ + /* Authorize the FPEC of Bank1 Access */ + FLASH->KEYR = FLASH_KEY1; + FLASH->KEYR = FLASH_KEY2; + +#ifdef STM32F10X_XL + /* Authorize the FPEC of Bank2 Access */ + FLASH->KEYR2 = FLASH_KEY1; + FLASH->KEYR2 = FLASH_KEY2; +#endif /* STM32F10X_XL */ +} +/** + * @brief Unlocks the FLASH Bank1 Program Erase Controller. + * @note This function can be used for all STM32F10x devices. + * - For STM32F10X_XL devices this function unlocks Bank1. + * - For all other devices it unlocks Bank1 and it is + * equivalent to FLASH_Unlock function. + * @param None + * @retval None + */ +void FLASH_UnlockBank1(void) +{ + /* Authorize the FPEC of Bank1 Access */ + FLASH->KEYR = FLASH_KEY1; + FLASH->KEYR = FLASH_KEY2; +} + +#ifdef STM32F10X_XL +/** + * @brief Unlocks the FLASH Bank2 Program Erase Controller. + * @note This function can be used only for STM32F10X_XL density devices. + * @param None + * @retval None + */ +void FLASH_UnlockBank2(void) +{ + /* Authorize the FPEC of Bank2 Access */ + FLASH->KEYR2 = FLASH_KEY1; + FLASH->KEYR2 = FLASH_KEY2; + +} +#endif /* STM32F10X_XL */ + +/** + * @brief Locks the FLASH Program Erase Controller. + * @note This function can be used for all STM32F10x devices. + * - For STM32F10X_XL devices this function Locks Bank1 and Bank2. + * - For all other devices it Locks Bank1 and it is equivalent + * to FLASH_LockBank1 function. + * @param None + * @retval None + */ +void FLASH_Lock(void) +{ + /* Set the Lock Bit to lock the FPEC and the CR of Bank1 */ + FLASH->CR |= CR_LOCK_Set; + +#ifdef STM32F10X_XL + /* Set the Lock Bit to lock the FPEC and the CR of Bank2 */ + FLASH->CR2 |= CR_LOCK_Set; +#endif /* STM32F10X_XL */ +} + +/** + * @brief Locks the FLASH Bank1 Program Erase Controller. + * @note this function can be used for all STM32F10x devices. + * - For STM32F10X_XL devices this function Locks Bank1. + * - For all other devices it Locks Bank1 and it is equivalent + * to FLASH_Lock function. + * @param None + * @retval None + */ +void FLASH_LockBank1(void) +{ + /* Set the Lock Bit to lock the FPEC and the CR of Bank1 */ + FLASH->CR |= CR_LOCK_Set; +} + +#ifdef STM32F10X_XL +/** + * @brief Locks the FLASH Bank2 Program Erase Controller. + * @note This function can be used only for STM32F10X_XL density devices. + * @param None + * @retval None + */ +void FLASH_LockBank2(void) +{ + /* Set the Lock Bit to lock the FPEC and the CR of Bank2 */ + FLASH->CR2 |= CR_LOCK_Set; +} +#endif /* STM32F10X_XL */ + +/** + * @brief Erases a specified FLASH page. + * @note This function can be used for all STM32F10x devices. + * @param Page_Address: The page address to be erased. + * @retval FLASH Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PG, + * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. + */ +FLASH_Status FLASH_ErasePage(uint32_t Page_Address) +{ + FLASH_Status status = FLASH_COMPLETE; + /* Check the parameters */ + assert_param(IS_FLASH_ADDRESS(Page_Address)); + +#ifdef STM32F10X_XL + if(Page_Address < FLASH_BANK1_END_ADDRESS) + { + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank1Operation(EraseTimeout); + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to erase the page */ + FLASH->CR|= CR_PER_Set; + FLASH->AR = Page_Address; + FLASH->CR|= CR_STRT_Set; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank1Operation(EraseTimeout); + + /* Disable the PER Bit */ + FLASH->CR &= CR_PER_Reset; + } + } + else + { + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank2Operation(EraseTimeout); + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to erase the page */ + FLASH->CR2|= CR_PER_Set; + FLASH->AR2 = Page_Address; + FLASH->CR2|= CR_STRT_Set; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank2Operation(EraseTimeout); + + /* Disable the PER Bit */ + FLASH->CR2 &= CR_PER_Reset; + } + } +#else + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(EraseTimeout); + + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to erase the page */ + FLASH->CR|= CR_PER_Set; + FLASH->AR = Page_Address; + FLASH->CR|= CR_STRT_Set; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(EraseTimeout); + + /* Disable the PER Bit */ + FLASH->CR &= CR_PER_Reset; + } +#endif /* STM32F10X_XL */ + + /* Return the Erase Status */ + return status; +} + +/** + * @brief Erases all FLASH pages. + * @note This function can be used for all STM32F10x devices. + * @param None + * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, + * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. + */ +FLASH_Status FLASH_EraseAllPages(void) +{ + FLASH_Status status = FLASH_COMPLETE; + +#ifdef STM32F10X_XL + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank1Operation(EraseTimeout); + + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to erase all pages */ + FLASH->CR |= CR_MER_Set; + FLASH->CR |= CR_STRT_Set; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank1Operation(EraseTimeout); + + /* Disable the MER Bit */ + FLASH->CR &= CR_MER_Reset; + } + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to erase all pages */ + FLASH->CR2 |= CR_MER_Set; + FLASH->CR2 |= CR_STRT_Set; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank2Operation(EraseTimeout); + + /* Disable the MER Bit */ + FLASH->CR2 &= CR_MER_Reset; + } +#else + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(EraseTimeout); + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to erase all pages */ + FLASH->CR |= CR_MER_Set; + FLASH->CR |= CR_STRT_Set; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(EraseTimeout); + + /* Disable the MER Bit */ + FLASH->CR &= CR_MER_Reset; + } +#endif /* STM32F10X_XL */ + + /* Return the Erase Status */ + return status; +} + +/** + * @brief Erases all Bank1 FLASH pages. + * @note This function can be used for all STM32F10x devices. + * - For STM32F10X_XL devices this function erases all Bank1 pages. + * - For all other devices it erases all Bank1 pages and it is equivalent + * to FLASH_EraseAllPages function. + * @param None + * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, + * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. + */ +FLASH_Status FLASH_EraseAllBank1Pages(void) +{ + FLASH_Status status = FLASH_COMPLETE; + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank1Operation(EraseTimeout); + + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to erase all pages */ + FLASH->CR |= CR_MER_Set; + FLASH->CR |= CR_STRT_Set; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank1Operation(EraseTimeout); + + /* Disable the MER Bit */ + FLASH->CR &= CR_MER_Reset; + } + /* Return the Erase Status */ + return status; +} + +#ifdef STM32F10X_XL +/** + * @brief Erases all Bank2 FLASH pages. + * @note This function can be used only for STM32F10x_XL density devices. + * @param None + * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, + * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. + */ +FLASH_Status FLASH_EraseAllBank2Pages(void) +{ + FLASH_Status status = FLASH_COMPLETE; + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank2Operation(EraseTimeout); + + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to erase all pages */ + FLASH->CR2 |= CR_MER_Set; + FLASH->CR2 |= CR_STRT_Set; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank2Operation(EraseTimeout); + + /* Disable the MER Bit */ + FLASH->CR2 &= CR_MER_Reset; + } + /* Return the Erase Status */ + return status; +} +#endif /* STM32F10X_XL */ + +/** + * @brief Erases the FLASH option bytes. + * @note This functions erases all option bytes except the Read protection (RDP). + * @note This function can be used for all STM32F10x devices. + * @param None + * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, + * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. + */ +FLASH_Status FLASH_EraseOptionBytes(void) +{ + uint16_t rdptmp = RDP_Key; + + FLASH_Status status = FLASH_COMPLETE; + + /* Get the actual read protection Option Byte value */ + if(FLASH_GetReadOutProtectionStatus() != RESET) + { + rdptmp = 0x00; + } + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(EraseTimeout); + if(status == FLASH_COMPLETE) + { + /* Authorize the small information block programming */ + FLASH->OPTKEYR = FLASH_KEY1; + FLASH->OPTKEYR = FLASH_KEY2; + + /* if the previous operation is completed, proceed to erase the option bytes */ + FLASH->CR |= CR_OPTER_Set; + FLASH->CR |= CR_STRT_Set; + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(EraseTimeout); + + if(status == FLASH_COMPLETE) + { + /* if the erase operation is completed, disable the OPTER Bit */ + FLASH->CR &= CR_OPTER_Reset; + + /* Enable the Option Bytes Programming operation */ + FLASH->CR |= CR_OPTPG_Set; + /* Restore the last read protection Option Byte value */ + OB->RDP = (uint16_t)rdptmp; + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + + if(status != FLASH_TIMEOUT) + { + /* if the program operation is completed, disable the OPTPG Bit */ + FLASH->CR &= CR_OPTPG_Reset; + } + } + else + { + if (status != FLASH_TIMEOUT) + { + /* Disable the OPTPG Bit */ + FLASH->CR &= CR_OPTPG_Reset; + } + } + } + /* Return the erase status */ + return status; +} + +/** + * @brief Programs a word at a specified address. + * @note This function can be used for all STM32F10x devices. + * @param Address: specifies the address to be programmed. + * @param Data: specifies the data to be programmed. + * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, + * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. + */ +FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data) +{ + FLASH_Status status = FLASH_COMPLETE; + __IO uint32_t tmp = 0; + + /* Check the parameters */ + assert_param(IS_FLASH_ADDRESS(Address)); + +#ifdef STM32F10X_XL + if(Address < FLASH_BANK1_END_ADDRESS - 2) + { + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank1Operation(ProgramTimeout); + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to program the new first + half word */ + FLASH->CR |= CR_PG_Set; + + *(__IO uint16_t*)Address = (uint16_t)Data; + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to program the new second + half word */ + tmp = Address + 2; + + *(__IO uint16_t*) tmp = Data >> 16; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + + /* Disable the PG Bit */ + FLASH->CR &= CR_PG_Reset; + } + else + { + /* Disable the PG Bit */ + FLASH->CR &= CR_PG_Reset; + } + } + } + else if(Address == (FLASH_BANK1_END_ADDRESS - 1)) + { + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank1Operation(ProgramTimeout); + + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to program the new first + half word */ + FLASH->CR |= CR_PG_Set; + + *(__IO uint16_t*)Address = (uint16_t)Data; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank1Operation(ProgramTimeout); + + /* Disable the PG Bit */ + FLASH->CR &= CR_PG_Reset; + } + else + { + /* Disable the PG Bit */ + FLASH->CR &= CR_PG_Reset; + } + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank2Operation(ProgramTimeout); + + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to program the new second + half word */ + FLASH->CR2 |= CR_PG_Set; + tmp = Address + 2; + + *(__IO uint16_t*) tmp = Data >> 16; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank2Operation(ProgramTimeout); + + /* Disable the PG Bit */ + FLASH->CR2 &= CR_PG_Reset; + } + else + { + /* Disable the PG Bit */ + FLASH->CR2 &= CR_PG_Reset; + } + } + else + { + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank2Operation(ProgramTimeout); + + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to program the new first + half word */ + FLASH->CR2 |= CR_PG_Set; + + *(__IO uint16_t*)Address = (uint16_t)Data; + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank2Operation(ProgramTimeout); + + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to program the new second + half word */ + tmp = Address + 2; + + *(__IO uint16_t*) tmp = Data >> 16; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank2Operation(ProgramTimeout); + + /* Disable the PG Bit */ + FLASH->CR2 &= CR_PG_Reset; + } + else + { + /* Disable the PG Bit */ + FLASH->CR2 &= CR_PG_Reset; + } + } + } +#else + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to program the new first + half word */ + FLASH->CR |= CR_PG_Set; + + *(__IO uint16_t*)Address = (uint16_t)Data; + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to program the new second + half word */ + tmp = Address + 2; + + *(__IO uint16_t*) tmp = Data >> 16; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + + /* Disable the PG Bit */ + FLASH->CR &= CR_PG_Reset; + } + else + { + /* Disable the PG Bit */ + FLASH->CR &= CR_PG_Reset; + } + } +#endif /* STM32F10X_XL */ + + /* Return the Program Status */ + return status; +} + +/** + * @brief Programs a half word at a specified address. + * @note This function can be used for all STM32F10x devices. + * @param Address: specifies the address to be programmed. + * @param Data: specifies the data to be programmed. + * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, + * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. + */ +FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data) +{ + FLASH_Status status = FLASH_COMPLETE; + /* Check the parameters */ + assert_param(IS_FLASH_ADDRESS(Address)); + +#ifdef STM32F10X_XL + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + + if(Address < FLASH_BANK1_END_ADDRESS) + { + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to program the new data */ + FLASH->CR |= CR_PG_Set; + + *(__IO uint16_t*)Address = Data; + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank1Operation(ProgramTimeout); + + /* Disable the PG Bit */ + FLASH->CR &= CR_PG_Reset; + } + } + else + { + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to program the new data */ + FLASH->CR2 |= CR_PG_Set; + + *(__IO uint16_t*)Address = Data; + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastBank2Operation(ProgramTimeout); + + /* Disable the PG Bit */ + FLASH->CR2 &= CR_PG_Reset; + } + } +#else + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + + if(status == FLASH_COMPLETE) + { + /* if the previous operation is completed, proceed to program the new data */ + FLASH->CR |= CR_PG_Set; + + *(__IO uint16_t*)Address = Data; + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + + /* Disable the PG Bit */ + FLASH->CR &= CR_PG_Reset; + } +#endif /* STM32F10X_XL */ + + /* Return the Program Status */ + return status; +} + +/** + * @brief Programs a half word at a specified Option Byte Data address. + * @note This function can be used for all STM32F10x devices. + * @param Address: specifies the address to be programmed. + * This parameter can be 0x1FFFF804 or 0x1FFFF806. + * @param Data: specifies the data to be programmed. + * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, + * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. + */ +FLASH_Status FLASH_ProgramOptionByteData(uint32_t Address, uint8_t Data) +{ + FLASH_Status status = FLASH_COMPLETE; + /* Check the parameters */ + assert_param(IS_OB_DATA_ADDRESS(Address)); + status = FLASH_WaitForLastOperation(ProgramTimeout); + + if(status == FLASH_COMPLETE) + { + /* Authorize the small information block programming */ + FLASH->OPTKEYR = FLASH_KEY1; + FLASH->OPTKEYR = FLASH_KEY2; + /* Enables the Option Bytes Programming operation */ + FLASH->CR |= CR_OPTPG_Set; + *(__IO uint16_t*)Address = Data; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + if(status != FLASH_TIMEOUT) + { + /* if the program operation is completed, disable the OPTPG Bit */ + FLASH->CR &= CR_OPTPG_Reset; + } + } + /* Return the Option Byte Data Program Status */ + return status; +} + +/** + * @brief Write protects the desired pages + * @note This function can be used for all STM32F10x devices. + * @param FLASH_Pages: specifies the address of the pages to be write protected. + * This parameter can be: + * @arg For @b STM32_Low-density_devices: value between FLASH_WRProt_Pages0to3 and FLASH_WRProt_Pages28to31 + * @arg For @b STM32_Medium-density_devices: value between FLASH_WRProt_Pages0to3 + * and FLASH_WRProt_Pages124to127 + * @arg For @b STM32_High-density_devices: value between FLASH_WRProt_Pages0to1 and + * FLASH_WRProt_Pages60to61 or FLASH_WRProt_Pages62to255 + * @arg For @b STM32_Connectivity_line_devices: value between FLASH_WRProt_Pages0to1 and + * FLASH_WRProt_Pages60to61 or FLASH_WRProt_Pages62to127 + * @arg For @b STM32_XL-density_devices: value between FLASH_WRProt_Pages0to1 and + * FLASH_WRProt_Pages60to61 or FLASH_WRProt_Pages62to511 + * @arg FLASH_WRProt_AllPages + * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, + * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. + */ +FLASH_Status FLASH_EnableWriteProtection(uint32_t FLASH_Pages) +{ + uint16_t WRP0_Data = 0xFFFF, WRP1_Data = 0xFFFF, WRP2_Data = 0xFFFF, WRP3_Data = 0xFFFF; + + FLASH_Status status = FLASH_COMPLETE; + + /* Check the parameters */ + assert_param(IS_FLASH_WRPROT_PAGE(FLASH_Pages)); + + FLASH_Pages = (uint32_t)(~FLASH_Pages); + WRP0_Data = (uint16_t)(FLASH_Pages & WRP0_Mask); + WRP1_Data = (uint16_t)((FLASH_Pages & WRP1_Mask) >> 8); + WRP2_Data = (uint16_t)((FLASH_Pages & WRP2_Mask) >> 16); + WRP3_Data = (uint16_t)((FLASH_Pages & WRP3_Mask) >> 24); + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + + if(status == FLASH_COMPLETE) + { + /* Authorizes the small information block programming */ + FLASH->OPTKEYR = FLASH_KEY1; + FLASH->OPTKEYR = FLASH_KEY2; + FLASH->CR |= CR_OPTPG_Set; + if(WRP0_Data != 0xFF) + { + OB->WRP0 = WRP0_Data; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + } + if((status == FLASH_COMPLETE) && (WRP1_Data != 0xFF)) + { + OB->WRP1 = WRP1_Data; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + } + if((status == FLASH_COMPLETE) && (WRP2_Data != 0xFF)) + { + OB->WRP2 = WRP2_Data; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + } + + if((status == FLASH_COMPLETE)&& (WRP3_Data != 0xFF)) + { + OB->WRP3 = WRP3_Data; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + } + + if(status != FLASH_TIMEOUT) + { + /* if the program operation is completed, disable the OPTPG Bit */ + FLASH->CR &= CR_OPTPG_Reset; + } + } + /* Return the write protection operation Status */ + return status; +} + +/** + * @brief Enables or disables the read out protection. + * @note If the user has already programmed the other option bytes before calling + * this function, he must re-program them since this function erases all option bytes. + * @note This function can be used for all STM32F10x devices. + * @param Newstate: new state of the ReadOut Protection. + * This parameter can be: ENABLE or DISABLE. + * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, + * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. + */ +FLASH_Status FLASH_ReadOutProtection(FunctionalState NewState) +{ + FLASH_Status status = FLASH_COMPLETE; + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + status = FLASH_WaitForLastOperation(EraseTimeout); + if(status == FLASH_COMPLETE) + { + /* Authorizes the small information block programming */ + FLASH->OPTKEYR = FLASH_KEY1; + FLASH->OPTKEYR = FLASH_KEY2; + FLASH->CR |= CR_OPTER_Set; + FLASH->CR |= CR_STRT_Set; + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(EraseTimeout); + if(status == FLASH_COMPLETE) + { + /* if the erase operation is completed, disable the OPTER Bit */ + FLASH->CR &= CR_OPTER_Reset; + /* Enable the Option Bytes Programming operation */ + FLASH->CR |= CR_OPTPG_Set; + if(NewState != DISABLE) + { + OB->RDP = 0x00; + } + else + { + OB->RDP = RDP_Key; + } + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(EraseTimeout); + + if(status != FLASH_TIMEOUT) + { + /* if the program operation is completed, disable the OPTPG Bit */ + FLASH->CR &= CR_OPTPG_Reset; + } + } + else + { + if(status != FLASH_TIMEOUT) + { + /* Disable the OPTER Bit */ + FLASH->CR &= CR_OPTER_Reset; + } + } + } + /* Return the protection operation Status */ + return status; +} + +/** + * @brief Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY. + * @note This function can be used for all STM32F10x devices. + * @param OB_IWDG: Selects the IWDG mode + * This parameter can be one of the following values: + * @arg OB_IWDG_SW: Software IWDG selected + * @arg OB_IWDG_HW: Hardware IWDG selected + * @param OB_STOP: Reset event when entering STOP mode. + * This parameter can be one of the following values: + * @arg OB_STOP_NoRST: No reset generated when entering in STOP + * @arg OB_STOP_RST: Reset generated when entering in STOP + * @param OB_STDBY: Reset event when entering Standby mode. + * This parameter can be one of the following values: + * @arg OB_STDBY_NoRST: No reset generated when entering in STANDBY + * @arg OB_STDBY_RST: Reset generated when entering in STANDBY + * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, + * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. + */ +FLASH_Status FLASH_UserOptionByteConfig(uint16_t OB_IWDG, uint16_t OB_STOP, uint16_t OB_STDBY) +{ + FLASH_Status status = FLASH_COMPLETE; + + /* Check the parameters */ + assert_param(IS_OB_IWDG_SOURCE(OB_IWDG)); + assert_param(IS_OB_STOP_SOURCE(OB_STOP)); + assert_param(IS_OB_STDBY_SOURCE(OB_STDBY)); + + /* Authorize the small information block programming */ + FLASH->OPTKEYR = FLASH_KEY1; + FLASH->OPTKEYR = FLASH_KEY2; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + + if(status == FLASH_COMPLETE) + { + /* Enable the Option Bytes Programming operation */ + FLASH->CR |= CR_OPTPG_Set; + + OB->USER = OB_IWDG | (uint16_t)(OB_STOP | (uint16_t)(OB_STDBY | ((uint16_t)0xF8))); + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + if(status != FLASH_TIMEOUT) + { + /* if the program operation is completed, disable the OPTPG Bit */ + FLASH->CR &= CR_OPTPG_Reset; + } + } + /* Return the Option Byte program Status */ + return status; +} + +#ifdef STM32F10X_XL +/** + * @brief Configures to boot from Bank1 or Bank2. + * @note This function can be used only for STM32F10x_XL density devices. + * @param FLASH_BOOT: select the FLASH Bank to boot from. + * This parameter can be one of the following values: + * @arg FLASH_BOOT_Bank1: At startup, if boot pins are set in boot from user Flash + * position and this parameter is selected the device will boot from Bank1(Default). + * @arg FLASH_BOOT_Bank2: At startup, if boot pins are set in boot from user Flash + * position and this parameter is selected the device will boot from Bank2 or Bank1, + * depending on the activation of the bank. The active banks are checked in + * the following order: Bank2, followed by Bank1. + * The active bank is recognized by the value programmed at the base address + * of the respective bank (corresponding to the initial stack pointer value + * in the interrupt vector table). + * For more information, please refer to AN2606 from www.st.com. + * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, + * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. + */ +FLASH_Status FLASH_BootConfig(uint16_t FLASH_BOOT) +{ + FLASH_Status status = FLASH_COMPLETE; + assert_param(IS_FLASH_BOOT(FLASH_BOOT)); + /* Authorize the small information block programming */ + FLASH->OPTKEYR = FLASH_KEY1; + FLASH->OPTKEYR = FLASH_KEY2; + + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + + if(status == FLASH_COMPLETE) + { + /* Enable the Option Bytes Programming operation */ + FLASH->CR |= CR_OPTPG_Set; + + if(FLASH_BOOT == FLASH_BOOT_Bank1) + { + OB->USER |= OB_USER_BFB2; + } + else + { + OB->USER &= (uint16_t)(~(uint16_t)(OB_USER_BFB2)); + } + /* Wait for last operation to be completed */ + status = FLASH_WaitForLastOperation(ProgramTimeout); + if(status != FLASH_TIMEOUT) + { + /* if the program operation is completed, disable the OPTPG Bit */ + FLASH->CR &= CR_OPTPG_Reset; + } + } + /* Return the Option Byte program Status */ + return status; +} +#endif /* STM32F10X_XL */ + +/** + * @brief Returns the FLASH User Option Bytes values. + * @note This function can be used for all STM32F10x devices. + * @param None + * @retval The FLASH User Option Bytes values:IWDG_SW(Bit0), RST_STOP(Bit1) + * and RST_STDBY(Bit2). + */ +uint32_t FLASH_GetUserOptionByte(void) +{ + /* Return the User Option Byte */ + return (uint32_t)(FLASH->OBR >> 2); +} + +/** + * @brief Returns the FLASH Write Protection Option Bytes Register value. + * @note This function can be used for all STM32F10x devices. + * @param None + * @retval The FLASH Write Protection Option Bytes Register value + */ +uint32_t FLASH_GetWriteProtectionOptionByte(void) +{ + /* Return the Flash write protection Register value */ + return (uint32_t)(FLASH->WRPR); +} + +/** + * @brief Checks whether the FLASH Read Out Protection Status is set or not. + * @note This function can be used for all STM32F10x devices. + * @param None + * @retval FLASH ReadOut Protection Status(SET or RESET) + */ +FlagStatus FLASH_GetReadOutProtectionStatus(void) +{ + FlagStatus readoutstatus = RESET; + if ((FLASH->OBR & RDPRT_Mask) != (uint32_t)RESET) + { + readoutstatus = SET; + } + else + { + readoutstatus = RESET; + } + return readoutstatus; +} + +/** + * @brief Checks whether the FLASH Prefetch Buffer status is set or not. + * @note This function can be used for all STM32F10x devices. + * @param None + * @retval FLASH Prefetch Buffer Status (SET or RESET). + */ +FlagStatus FLASH_GetPrefetchBufferStatus(void) +{ + FlagStatus bitstatus = RESET; + + if ((FLASH->ACR & ACR_PRFTBS_Mask) != (uint32_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + /* Return the new state of FLASH Prefetch Buffer Status (SET or RESET) */ + return bitstatus; +} + +/** + * @brief Enables or disables the specified FLASH interrupts. + * @note This function can be used for all STM32F10x devices. + * - For STM32F10X_XL devices, enables or disables the specified FLASH interrupts + for Bank1 and Bank2. + * - For other devices it enables or disables the specified FLASH interrupts for Bank1. + * @param FLASH_IT: specifies the FLASH interrupt sources to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg FLASH_IT_ERROR: FLASH Error Interrupt + * @arg FLASH_IT_EOP: FLASH end of operation Interrupt + * @param NewState: new state of the specified Flash interrupts. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState) +{ +#ifdef STM32F10X_XL + /* Check the parameters */ + assert_param(IS_FLASH_IT(FLASH_IT)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if((FLASH_IT & 0x80000000) != 0x0) + { + if(NewState != DISABLE) + { + /* Enable the interrupt sources */ + FLASH->CR2 |= (FLASH_IT & 0x7FFFFFFF); + } + else + { + /* Disable the interrupt sources */ + FLASH->CR2 &= ~(uint32_t)(FLASH_IT & 0x7FFFFFFF); + } + } + else + { + if(NewState != DISABLE) + { + /* Enable the interrupt sources */ + FLASH->CR |= FLASH_IT; + } + else + { + /* Disable the interrupt sources */ + FLASH->CR &= ~(uint32_t)FLASH_IT; + } + } +#else + /* Check the parameters */ + assert_param(IS_FLASH_IT(FLASH_IT)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if(NewState != DISABLE) + { + /* Enable the interrupt sources */ + FLASH->CR |= FLASH_IT; + } + else + { + /* Disable the interrupt sources */ + FLASH->CR &= ~(uint32_t)FLASH_IT; + } +#endif /* STM32F10X_XL */ +} + +/** + * @brief Checks whether the specified FLASH flag is set or not. + * @note This function can be used for all STM32F10x devices. + * - For STM32F10X_XL devices, this function checks whether the specified + * Bank1 or Bank2 flag is set or not. + * - For other devices, it checks whether the specified Bank1 flag is + * set or not. + * @param FLASH_FLAG: specifies the FLASH flag to check. + * This parameter can be one of the following values: + * @arg FLASH_FLAG_BSY: FLASH Busy flag + * @arg FLASH_FLAG_PGERR: FLASH Program error flag + * @arg FLASH_FLAG_WRPRTERR: FLASH Write protected error flag + * @arg FLASH_FLAG_EOP: FLASH End of Operation flag + * @arg FLASH_FLAG_OPTERR: FLASH Option Byte error flag + * @retval The new state of FLASH_FLAG (SET or RESET). + */ +FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG) +{ + FlagStatus bitstatus = RESET; + +#ifdef STM32F10X_XL + /* Check the parameters */ + assert_param(IS_FLASH_GET_FLAG(FLASH_FLAG)) ; + if(FLASH_FLAG == FLASH_FLAG_OPTERR) + { + if((FLASH->OBR & FLASH_FLAG_OPTERR) != (uint32_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + } + else + { + if((FLASH_FLAG & 0x80000000) != 0x0) + { + if((FLASH->SR2 & FLASH_FLAG) != (uint32_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + } + else + { + if((FLASH->SR & FLASH_FLAG) != (uint32_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + } + } +#else + /* Check the parameters */ + assert_param(IS_FLASH_GET_FLAG(FLASH_FLAG)) ; + if(FLASH_FLAG == FLASH_FLAG_OPTERR) + { + if((FLASH->OBR & FLASH_FLAG_OPTERR) != (uint32_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + } + else + { + if((FLASH->SR & FLASH_FLAG) != (uint32_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + } +#endif /* STM32F10X_XL */ + + /* Return the new state of FLASH_FLAG (SET or RESET) */ + return bitstatus; +} + +/** + * @brief Clears the FLASH's pending flags. + * @note This function can be used for all STM32F10x devices. + * - For STM32F10X_XL devices, this function clears Bank1 or Bank2s pending flags + * - For other devices, it clears Bank1s pending flags. + * @param FLASH_FLAG: specifies the FLASH flags to clear. + * This parameter can be any combination of the following values: + * @arg FLASH_FLAG_PGERR: FLASH Program error flag + * @arg FLASH_FLAG_WRPRTERR: FLASH Write protected error flag + * @arg FLASH_FLAG_EOP: FLASH End of Operation flag + * @retval None + */ +void FLASH_ClearFlag(uint32_t FLASH_FLAG) +{ +#ifdef STM32F10X_XL + /* Check the parameters */ + assert_param(IS_FLASH_CLEAR_FLAG(FLASH_FLAG)) ; + + if((FLASH_FLAG & 0x80000000) != 0x0) + { + /* Clear the flags */ + FLASH->SR2 = FLASH_FLAG; + } + else + { + /* Clear the flags */ + FLASH->SR = FLASH_FLAG; + } + +#else + /* Check the parameters */ + assert_param(IS_FLASH_CLEAR_FLAG(FLASH_FLAG)) ; + + /* Clear the flags */ + FLASH->SR = FLASH_FLAG; +#endif /* STM32F10X_XL */ +} + +/** + * @brief Returns the FLASH Status. + * @note This function can be used for all STM32F10x devices, it is equivalent + * to FLASH_GetBank1Status function. + * @param None + * @retval FLASH Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PG, + * FLASH_ERROR_WRP or FLASH_COMPLETE + */ +FLASH_Status FLASH_GetStatus(void) +{ + FLASH_Status flashstatus = FLASH_COMPLETE; + + if((FLASH->SR & FLASH_FLAG_BSY) == FLASH_FLAG_BSY) + { + flashstatus = FLASH_BUSY; + } + else + { + if((FLASH->SR & FLASH_FLAG_PGERR) != 0) + { + flashstatus = FLASH_ERROR_PG; + } + else + { + if((FLASH->SR & FLASH_FLAG_WRPRTERR) != 0 ) + { + flashstatus = FLASH_ERROR_WRP; + } + else + { + flashstatus = FLASH_COMPLETE; + } + } + } + /* Return the Flash Status */ + return flashstatus; +} + +/** + * @brief Returns the FLASH Bank1 Status. + * @note This function can be used for all STM32F10x devices, it is equivalent + * to FLASH_GetStatus function. + * @param None + * @retval FLASH Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PG, + * FLASH_ERROR_WRP or FLASH_COMPLETE + */ +FLASH_Status FLASH_GetBank1Status(void) +{ + FLASH_Status flashstatus = FLASH_COMPLETE; + + if((FLASH->SR & FLASH_FLAG_BANK1_BSY) == FLASH_FLAG_BSY) + { + flashstatus = FLASH_BUSY; + } + else + { + if((FLASH->SR & FLASH_FLAG_BANK1_PGERR) != 0) + { + flashstatus = FLASH_ERROR_PG; + } + else + { + if((FLASH->SR & FLASH_FLAG_BANK1_WRPRTERR) != 0 ) + { + flashstatus = FLASH_ERROR_WRP; + } + else + { + flashstatus = FLASH_COMPLETE; + } + } + } + /* Return the Flash Status */ + return flashstatus; +} + +#ifdef STM32F10X_XL +/** + * @brief Returns the FLASH Bank2 Status. + * @note This function can be used for STM32F10x_XL density devices. + * @param None + * @retval FLASH Status: The returned value can be: FLASH_BUSY, FLASH_ERROR_PG, + * FLASH_ERROR_WRP or FLASH_COMPLETE + */ +FLASH_Status FLASH_GetBank2Status(void) +{ + FLASH_Status flashstatus = FLASH_COMPLETE; + + if((FLASH->SR2 & (FLASH_FLAG_BANK2_BSY & 0x7FFFFFFF)) == (FLASH_FLAG_BANK2_BSY & 0x7FFFFFFF)) + { + flashstatus = FLASH_BUSY; + } + else + { + if((FLASH->SR2 & (FLASH_FLAG_BANK2_PGERR & 0x7FFFFFFF)) != 0) + { + flashstatus = FLASH_ERROR_PG; + } + else + { + if((FLASH->SR2 & (FLASH_FLAG_BANK2_WRPRTERR & 0x7FFFFFFF)) != 0 ) + { + flashstatus = FLASH_ERROR_WRP; + } + else + { + flashstatus = FLASH_COMPLETE; + } + } + } + /* Return the Flash Status */ + return flashstatus; +} +#endif /* STM32F10X_XL */ +/** + * @brief Waits for a Flash operation to complete or a TIMEOUT to occur. + * @note This function can be used for all STM32F10x devices, + * it is equivalent to FLASH_WaitForLastBank1Operation. + * - For STM32F10X_XL devices this function waits for a Bank1 Flash operation + * to complete or a TIMEOUT to occur. + * - For all other devices it waits for a Flash operation to complete + * or a TIMEOUT to occur. + * @param Timeout: FLASH programming Timeout + * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, + * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. + */ +FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout) +{ + FLASH_Status status = FLASH_COMPLETE; + + /* Check for the Flash Status */ + status = FLASH_GetBank1Status(); + /* Wait for a Flash operation to complete or a TIMEOUT to occur */ + while((status == FLASH_BUSY) && (Timeout != 0x00)) + { + status = FLASH_GetBank1Status(); + Timeout--; + } + if(Timeout == 0x00 ) + { + status = FLASH_TIMEOUT; + } + /* Return the operation status */ + return status; +} + +/** + * @brief Waits for a Flash operation on Bank1 to complete or a TIMEOUT to occur. + * @note This function can be used for all STM32F10x devices, + * it is equivalent to FLASH_WaitForLastOperation. + * @param Timeout: FLASH programming Timeout + * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, + * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. + */ +FLASH_Status FLASH_WaitForLastBank1Operation(uint32_t Timeout) +{ + FLASH_Status status = FLASH_COMPLETE; + + /* Check for the Flash Status */ + status = FLASH_GetBank1Status(); + /* Wait for a Flash operation to complete or a TIMEOUT to occur */ + while((status == FLASH_FLAG_BANK1_BSY) && (Timeout != 0x00)) + { + status = FLASH_GetBank1Status(); + Timeout--; + } + if(Timeout == 0x00 ) + { + status = FLASH_TIMEOUT; + } + /* Return the operation status */ + return status; +} + +#ifdef STM32F10X_XL +/** + * @brief Waits for a Flash operation on Bank2 to complete or a TIMEOUT to occur. + * @note This function can be used only for STM32F10x_XL density devices. + * @param Timeout: FLASH programming Timeout + * @retval FLASH Status: The returned value can be: FLASH_ERROR_PG, + * FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT. + */ +FLASH_Status FLASH_WaitForLastBank2Operation(uint32_t Timeout) +{ + FLASH_Status status = FLASH_COMPLETE; + + /* Check for the Flash Status */ + status = FLASH_GetBank2Status(); + /* Wait for a Flash operation to complete or a TIMEOUT to occur */ + while((status == (FLASH_FLAG_BANK2_BSY & 0x7FFFFFFF)) && (Timeout != 0x00)) + { + status = FLASH_GetBank2Status(); + Timeout--; + } + if(Timeout == 0x00 ) + { + status = FLASH_TIMEOUT; + } + /* Return the operation status */ + return status; +} +#endif /* STM32F10X_XL */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_fsmc.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_fsmc.c new file mode 100755 index 0000000..c75137c --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_fsmc.c @@ -0,0 +1,866 @@ +/** + ****************************************************************************** + * @file stm32f10x_fsmc.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the FSMC firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_fsmc.h" +#include "stm32f10x_rcc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup FSMC + * @brief FSMC driver modules + * @{ + */ + +/** @defgroup FSMC_Private_TypesDefinitions + * @{ + */ +/** + * @} + */ + +/** @defgroup FSMC_Private_Defines + * @{ + */ + +/* --------------------- FSMC registers bit mask ---------------------------- */ + +/* FSMC BCRx Mask */ +#define BCR_MBKEN_Set ((uint32_t)0x00000001) +#define BCR_MBKEN_Reset ((uint32_t)0x000FFFFE) +#define BCR_FACCEN_Set ((uint32_t)0x00000040) + +/* FSMC PCRx Mask */ +#define PCR_PBKEN_Set ((uint32_t)0x00000004) +#define PCR_PBKEN_Reset ((uint32_t)0x000FFFFB) +#define PCR_ECCEN_Set ((uint32_t)0x00000040) +#define PCR_ECCEN_Reset ((uint32_t)0x000FFFBF) +#define PCR_MemoryType_NAND ((uint32_t)0x00000008) +/** + * @} + */ + +/** @defgroup FSMC_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup FSMC_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup FSMC_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup FSMC_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the FSMC NOR/SRAM Banks registers to their default + * reset values. + * @param FSMC_Bank: specifies the FSMC Bank to be used + * This parameter can be one of the following values: + * @arg FSMC_Bank1_NORSRAM1: FSMC Bank1 NOR/SRAM1 + * @arg FSMC_Bank1_NORSRAM2: FSMC Bank1 NOR/SRAM2 + * @arg FSMC_Bank1_NORSRAM3: FSMC Bank1 NOR/SRAM3 + * @arg FSMC_Bank1_NORSRAM4: FSMC Bank1 NOR/SRAM4 + * @retval None + */ +void FSMC_NORSRAMDeInit(uint32_t FSMC_Bank) +{ + /* Check the parameter */ + assert_param(IS_FSMC_NORSRAM_BANK(FSMC_Bank)); + + /* FSMC_Bank1_NORSRAM1 */ + if(FSMC_Bank == FSMC_Bank1_NORSRAM1) + { + FSMC_Bank1->BTCR[FSMC_Bank] = 0x000030DB; + } + /* FSMC_Bank1_NORSRAM2, FSMC_Bank1_NORSRAM3 or FSMC_Bank1_NORSRAM4 */ + else + { + FSMC_Bank1->BTCR[FSMC_Bank] = 0x000030D2; + } + FSMC_Bank1->BTCR[FSMC_Bank + 1] = 0x0FFFFFFF; + FSMC_Bank1E->BWTR[FSMC_Bank] = 0x0FFFFFFF; +} + +/** + * @brief Deinitializes the FSMC NAND Banks registers to their default reset values. + * @param FSMC_Bank: specifies the FSMC Bank to be used + * This parameter can be one of the following values: + * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND + * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND + * @retval None + */ +void FSMC_NANDDeInit(uint32_t FSMC_Bank) +{ + /* Check the parameter */ + assert_param(IS_FSMC_NAND_BANK(FSMC_Bank)); + + if(FSMC_Bank == FSMC_Bank2_NAND) + { + /* Set the FSMC_Bank2 registers to their reset values */ + FSMC_Bank2->PCR2 = 0x00000018; + FSMC_Bank2->SR2 = 0x00000040; + FSMC_Bank2->PMEM2 = 0xFCFCFCFC; + FSMC_Bank2->PATT2 = 0xFCFCFCFC; + } + /* FSMC_Bank3_NAND */ + else + { + /* Set the FSMC_Bank3 registers to their reset values */ + FSMC_Bank3->PCR3 = 0x00000018; + FSMC_Bank3->SR3 = 0x00000040; + FSMC_Bank3->PMEM3 = 0xFCFCFCFC; + FSMC_Bank3->PATT3 = 0xFCFCFCFC; + } +} + +/** + * @brief Deinitializes the FSMC PCCARD Bank registers to their default reset values. + * @param None + * @retval None + */ +void FSMC_PCCARDDeInit(void) +{ + /* Set the FSMC_Bank4 registers to their reset values */ + FSMC_Bank4->PCR4 = 0x00000018; + FSMC_Bank4->SR4 = 0x00000000; + FSMC_Bank4->PMEM4 = 0xFCFCFCFC; + FSMC_Bank4->PATT4 = 0xFCFCFCFC; + FSMC_Bank4->PIO4 = 0xFCFCFCFC; +} + +/** + * @brief Initializes the FSMC NOR/SRAM Banks according to the specified + * parameters in the FSMC_NORSRAMInitStruct. + * @param FSMC_NORSRAMInitStruct : pointer to a FSMC_NORSRAMInitTypeDef + * structure that contains the configuration information for + * the FSMC NOR/SRAM specified Banks. + * @retval None + */ +void FSMC_NORSRAMInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct) +{ + /* Check the parameters */ + assert_param(IS_FSMC_NORSRAM_BANK(FSMC_NORSRAMInitStruct->FSMC_Bank)); + assert_param(IS_FSMC_MUX(FSMC_NORSRAMInitStruct->FSMC_DataAddressMux)); + assert_param(IS_FSMC_MEMORY(FSMC_NORSRAMInitStruct->FSMC_MemoryType)); + assert_param(IS_FSMC_MEMORY_WIDTH(FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth)); + assert_param(IS_FSMC_BURSTMODE(FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode)); + assert_param(IS_FSMC_ASYNWAIT(FSMC_NORSRAMInitStruct->FSMC_AsynchronousWait)); + assert_param(IS_FSMC_WAIT_POLARITY(FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity)); + assert_param(IS_FSMC_WRAP_MODE(FSMC_NORSRAMInitStruct->FSMC_WrapMode)); + assert_param(IS_FSMC_WAIT_SIGNAL_ACTIVE(FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive)); + assert_param(IS_FSMC_WRITE_OPERATION(FSMC_NORSRAMInitStruct->FSMC_WriteOperation)); + assert_param(IS_FSMC_WAITE_SIGNAL(FSMC_NORSRAMInitStruct->FSMC_WaitSignal)); + assert_param(IS_FSMC_EXTENDED_MODE(FSMC_NORSRAMInitStruct->FSMC_ExtendedMode)); + assert_param(IS_FSMC_WRITE_BURST(FSMC_NORSRAMInitStruct->FSMC_WriteBurst)); + assert_param(IS_FSMC_ADDRESS_SETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime)); + assert_param(IS_FSMC_ADDRESS_HOLD_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime)); + assert_param(IS_FSMC_DATASETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime)); + assert_param(IS_FSMC_TURNAROUND_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration)); + assert_param(IS_FSMC_CLK_DIV(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision)); + assert_param(IS_FSMC_DATA_LATENCY(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency)); + assert_param(IS_FSMC_ACCESS_MODE(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode)); + + /* Bank1 NOR/SRAM control register configuration */ + FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank] = + (uint32_t)FSMC_NORSRAMInitStruct->FSMC_DataAddressMux | + FSMC_NORSRAMInitStruct->FSMC_MemoryType | + FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth | + FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode | + FSMC_NORSRAMInitStruct->FSMC_AsynchronousWait | + FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity | + FSMC_NORSRAMInitStruct->FSMC_WrapMode | + FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive | + FSMC_NORSRAMInitStruct->FSMC_WriteOperation | + FSMC_NORSRAMInitStruct->FSMC_WaitSignal | + FSMC_NORSRAMInitStruct->FSMC_ExtendedMode | + FSMC_NORSRAMInitStruct->FSMC_WriteBurst; + + if(FSMC_NORSRAMInitStruct->FSMC_MemoryType == FSMC_MemoryType_NOR) + { + FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank] |= (uint32_t)BCR_FACCEN_Set; + } + + /* Bank1 NOR/SRAM timing register configuration */ + FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank+1] = + (uint32_t)FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime | + (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime << 4) | + (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime << 8) | + (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration << 16) | + (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision << 20) | + (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency << 24) | + FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode; + + + /* Bank1 NOR/SRAM timing register for write configuration, if extended mode is used */ + if(FSMC_NORSRAMInitStruct->FSMC_ExtendedMode == FSMC_ExtendedMode_Enable) + { + assert_param(IS_FSMC_ADDRESS_SETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime)); + assert_param(IS_FSMC_ADDRESS_HOLD_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime)); + assert_param(IS_FSMC_DATASETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime)); + assert_param(IS_FSMC_CLK_DIV(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision)); + assert_param(IS_FSMC_DATA_LATENCY(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency)); + assert_param(IS_FSMC_ACCESS_MODE(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode)); + FSMC_Bank1E->BWTR[FSMC_NORSRAMInitStruct->FSMC_Bank] = + (uint32_t)FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime | + (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime << 4 )| + (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime << 8) | + (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision << 20) | + (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency << 24) | + FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode; + } + else + { + FSMC_Bank1E->BWTR[FSMC_NORSRAMInitStruct->FSMC_Bank] = 0x0FFFFFFF; + } +} + +/** + * @brief Initializes the FSMC NAND Banks according to the specified + * parameters in the FSMC_NANDInitStruct. + * @param FSMC_NANDInitStruct : pointer to a FSMC_NANDInitTypeDef + * structure that contains the configuration information for the FSMC + * NAND specified Banks. + * @retval None + */ +void FSMC_NANDInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct) +{ + uint32_t tmppcr = 0x00000000, tmppmem = 0x00000000, tmppatt = 0x00000000; + + /* Check the parameters */ + assert_param( IS_FSMC_NAND_BANK(FSMC_NANDInitStruct->FSMC_Bank)); + assert_param( IS_FSMC_WAIT_FEATURE(FSMC_NANDInitStruct->FSMC_Waitfeature)); + assert_param( IS_FSMC_MEMORY_WIDTH(FSMC_NANDInitStruct->FSMC_MemoryDataWidth)); + assert_param( IS_FSMC_ECC_STATE(FSMC_NANDInitStruct->FSMC_ECC)); + assert_param( IS_FSMC_ECCPAGE_SIZE(FSMC_NANDInitStruct->FSMC_ECCPageSize)); + assert_param( IS_FSMC_TCLR_TIME(FSMC_NANDInitStruct->FSMC_TCLRSetupTime)); + assert_param( IS_FSMC_TAR_TIME(FSMC_NANDInitStruct->FSMC_TARSetupTime)); + assert_param(IS_FSMC_SETUP_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime)); + assert_param(IS_FSMC_WAIT_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime)); + assert_param(IS_FSMC_HOLD_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime)); + assert_param(IS_FSMC_HIZ_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime)); + assert_param(IS_FSMC_SETUP_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime)); + assert_param(IS_FSMC_WAIT_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime)); + assert_param(IS_FSMC_HOLD_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime)); + assert_param(IS_FSMC_HIZ_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime)); + + /* Set the tmppcr value according to FSMC_NANDInitStruct parameters */ + tmppcr = (uint32_t)FSMC_NANDInitStruct->FSMC_Waitfeature | + PCR_MemoryType_NAND | + FSMC_NANDInitStruct->FSMC_MemoryDataWidth | + FSMC_NANDInitStruct->FSMC_ECC | + FSMC_NANDInitStruct->FSMC_ECCPageSize | + (FSMC_NANDInitStruct->FSMC_TCLRSetupTime << 9 )| + (FSMC_NANDInitStruct->FSMC_TARSetupTime << 13); + + /* Set tmppmem value according to FSMC_CommonSpaceTimingStructure parameters */ + tmppmem = (uint32_t)FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime | + (FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime << 8) | + (FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime << 16)| + (FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime << 24); + + /* Set tmppatt value according to FSMC_AttributeSpaceTimingStructure parameters */ + tmppatt = (uint32_t)FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime | + (FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime << 8) | + (FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime << 16)| + (FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime << 24); + + if(FSMC_NANDInitStruct->FSMC_Bank == FSMC_Bank2_NAND) + { + /* FSMC_Bank2_NAND registers configuration */ + FSMC_Bank2->PCR2 = tmppcr; + FSMC_Bank2->PMEM2 = tmppmem; + FSMC_Bank2->PATT2 = tmppatt; + } + else + { + /* FSMC_Bank3_NAND registers configuration */ + FSMC_Bank3->PCR3 = tmppcr; + FSMC_Bank3->PMEM3 = tmppmem; + FSMC_Bank3->PATT3 = tmppatt; + } +} + +/** + * @brief Initializes the FSMC PCCARD Bank according to the specified + * parameters in the FSMC_PCCARDInitStruct. + * @param FSMC_PCCARDInitStruct : pointer to a FSMC_PCCARDInitTypeDef + * structure that contains the configuration information for the FSMC + * PCCARD Bank. + * @retval None + */ +void FSMC_PCCARDInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct) +{ + /* Check the parameters */ + assert_param(IS_FSMC_WAIT_FEATURE(FSMC_PCCARDInitStruct->FSMC_Waitfeature)); + assert_param(IS_FSMC_TCLR_TIME(FSMC_PCCARDInitStruct->FSMC_TCLRSetupTime)); + assert_param(IS_FSMC_TAR_TIME(FSMC_PCCARDInitStruct->FSMC_TARSetupTime)); + + assert_param(IS_FSMC_SETUP_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime)); + assert_param(IS_FSMC_WAIT_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime)); + assert_param(IS_FSMC_HOLD_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime)); + assert_param(IS_FSMC_HIZ_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime)); + + assert_param(IS_FSMC_SETUP_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime)); + assert_param(IS_FSMC_WAIT_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime)); + assert_param(IS_FSMC_HOLD_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime)); + assert_param(IS_FSMC_HIZ_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime)); + assert_param(IS_FSMC_SETUP_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_SetupTime)); + assert_param(IS_FSMC_WAIT_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_WaitSetupTime)); + assert_param(IS_FSMC_HOLD_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HoldSetupTime)); + assert_param(IS_FSMC_HIZ_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HiZSetupTime)); + + /* Set the PCR4 register value according to FSMC_PCCARDInitStruct parameters */ + FSMC_Bank4->PCR4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_Waitfeature | + FSMC_MemoryDataWidth_16b | + (FSMC_PCCARDInitStruct->FSMC_TCLRSetupTime << 9) | + (FSMC_PCCARDInitStruct->FSMC_TARSetupTime << 13); + + /* Set PMEM4 register value according to FSMC_CommonSpaceTimingStructure parameters */ + FSMC_Bank4->PMEM4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime | + (FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime << 8) | + (FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime << 16)| + (FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime << 24); + + /* Set PATT4 register value according to FSMC_AttributeSpaceTimingStructure parameters */ + FSMC_Bank4->PATT4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime | + (FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime << 8) | + (FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime << 16)| + (FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime << 24); + + /* Set PIO4 register value according to FSMC_IOSpaceTimingStructure parameters */ + FSMC_Bank4->PIO4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_SetupTime | + (FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_WaitSetupTime << 8) | + (FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HoldSetupTime << 16)| + (FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HiZSetupTime << 24); +} + +/** + * @brief Fills each FSMC_NORSRAMInitStruct member with its default value. + * @param FSMC_NORSRAMInitStruct: pointer to a FSMC_NORSRAMInitTypeDef + * structure which will be initialized. + * @retval None + */ +void FSMC_NORSRAMStructInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct) +{ + /* Reset NOR/SRAM Init structure parameters values */ + FSMC_NORSRAMInitStruct->FSMC_Bank = FSMC_Bank1_NORSRAM1; + FSMC_NORSRAMInitStruct->FSMC_DataAddressMux = FSMC_DataAddressMux_Enable; + FSMC_NORSRAMInitStruct->FSMC_MemoryType = FSMC_MemoryType_SRAM; + FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b; + FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; + FSMC_NORSRAMInitStruct->FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; + FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; + FSMC_NORSRAMInitStruct->FSMC_WrapMode = FSMC_WrapMode_Disable; + FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; + FSMC_NORSRAMInitStruct->FSMC_WriteOperation = FSMC_WriteOperation_Enable; + FSMC_NORSRAMInitStruct->FSMC_WaitSignal = FSMC_WaitSignal_Enable; + FSMC_NORSRAMInitStruct->FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; + FSMC_NORSRAMInitStruct->FSMC_WriteBurst = FSMC_WriteBurst_Disable; + FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime = 0xF; + FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime = 0xF; + FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime = 0xFF; + FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration = 0xF; + FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision = 0xF; + FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency = 0xF; + FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode = FSMC_AccessMode_A; + FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime = 0xF; + FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime = 0xF; + FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime = 0xFF; + FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_BusTurnAroundDuration = 0xF; + FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision = 0xF; + FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency = 0xF; + FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode = FSMC_AccessMode_A; +} + +/** + * @brief Fills each FSMC_NANDInitStruct member with its default value. + * @param FSMC_NANDInitStruct: pointer to a FSMC_NANDInitTypeDef + * structure which will be initialized. + * @retval None + */ +void FSMC_NANDStructInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct) +{ + /* Reset NAND Init structure parameters values */ + FSMC_NANDInitStruct->FSMC_Bank = FSMC_Bank2_NAND; + FSMC_NANDInitStruct->FSMC_Waitfeature = FSMC_Waitfeature_Disable; + FSMC_NANDInitStruct->FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b; + FSMC_NANDInitStruct->FSMC_ECC = FSMC_ECC_Disable; + FSMC_NANDInitStruct->FSMC_ECCPageSize = FSMC_ECCPageSize_256Bytes; + FSMC_NANDInitStruct->FSMC_TCLRSetupTime = 0x0; + FSMC_NANDInitStruct->FSMC_TARSetupTime = 0x0; + FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime = 0xFC; + FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC; + FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC; + FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC; + FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime = 0xFC; + FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC; + FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC; + FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC; +} + +/** + * @brief Fills each FSMC_PCCARDInitStruct member with its default value. + * @param FSMC_PCCARDInitStruct: pointer to a FSMC_PCCARDInitTypeDef + * structure which will be initialized. + * @retval None + */ +void FSMC_PCCARDStructInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct) +{ + /* Reset PCCARD Init structure parameters values */ + FSMC_PCCARDInitStruct->FSMC_Waitfeature = FSMC_Waitfeature_Disable; + FSMC_PCCARDInitStruct->FSMC_TCLRSetupTime = 0x0; + FSMC_PCCARDInitStruct->FSMC_TARSetupTime = 0x0; + FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime = 0xFC; + FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC; + FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC; + FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC; + FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime = 0xFC; + FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC; + FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC; + FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC; + FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_SetupTime = 0xFC; + FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC; + FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC; + FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC; +} + +/** + * @brief Enables or disables the specified NOR/SRAM Memory Bank. + * @param FSMC_Bank: specifies the FSMC Bank to be used + * This parameter can be one of the following values: + * @arg FSMC_Bank1_NORSRAM1: FSMC Bank1 NOR/SRAM1 + * @arg FSMC_Bank1_NORSRAM2: FSMC Bank1 NOR/SRAM2 + * @arg FSMC_Bank1_NORSRAM3: FSMC Bank1 NOR/SRAM3 + * @arg FSMC_Bank1_NORSRAM4: FSMC Bank1 NOR/SRAM4 + * @param NewState: new state of the FSMC_Bank. This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void FSMC_NORSRAMCmd(uint32_t FSMC_Bank, FunctionalState NewState) +{ + assert_param(IS_FSMC_NORSRAM_BANK(FSMC_Bank)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the selected NOR/SRAM Bank by setting the PBKEN bit in the BCRx register */ + FSMC_Bank1->BTCR[FSMC_Bank] |= BCR_MBKEN_Set; + } + else + { + /* Disable the selected NOR/SRAM Bank by clearing the PBKEN bit in the BCRx register */ + FSMC_Bank1->BTCR[FSMC_Bank] &= BCR_MBKEN_Reset; + } +} + +/** + * @brief Enables or disables the specified NAND Memory Bank. + * @param FSMC_Bank: specifies the FSMC Bank to be used + * This parameter can be one of the following values: + * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND + * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND + * @param NewState: new state of the FSMC_Bank. This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void FSMC_NANDCmd(uint32_t FSMC_Bank, FunctionalState NewState) +{ + assert_param(IS_FSMC_NAND_BANK(FSMC_Bank)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the selected NAND Bank by setting the PBKEN bit in the PCRx register */ + if(FSMC_Bank == FSMC_Bank2_NAND) + { + FSMC_Bank2->PCR2 |= PCR_PBKEN_Set; + } + else + { + FSMC_Bank3->PCR3 |= PCR_PBKEN_Set; + } + } + else + { + /* Disable the selected NAND Bank by clearing the PBKEN bit in the PCRx register */ + if(FSMC_Bank == FSMC_Bank2_NAND) + { + FSMC_Bank2->PCR2 &= PCR_PBKEN_Reset; + } + else + { + FSMC_Bank3->PCR3 &= PCR_PBKEN_Reset; + } + } +} + +/** + * @brief Enables or disables the PCCARD Memory Bank. + * @param NewState: new state of the PCCARD Memory Bank. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void FSMC_PCCARDCmd(FunctionalState NewState) +{ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the PCCARD Bank by setting the PBKEN bit in the PCR4 register */ + FSMC_Bank4->PCR4 |= PCR_PBKEN_Set; + } + else + { + /* Disable the PCCARD Bank by clearing the PBKEN bit in the PCR4 register */ + FSMC_Bank4->PCR4 &= PCR_PBKEN_Reset; + } +} + +/** + * @brief Enables or disables the FSMC NAND ECC feature. + * @param FSMC_Bank: specifies the FSMC Bank to be used + * This parameter can be one of the following values: + * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND + * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND + * @param NewState: new state of the FSMC NAND ECC feature. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void FSMC_NANDECCCmd(uint32_t FSMC_Bank, FunctionalState NewState) +{ + assert_param(IS_FSMC_NAND_BANK(FSMC_Bank)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the selected NAND Bank ECC function by setting the ECCEN bit in the PCRx register */ + if(FSMC_Bank == FSMC_Bank2_NAND) + { + FSMC_Bank2->PCR2 |= PCR_ECCEN_Set; + } + else + { + FSMC_Bank3->PCR3 |= PCR_ECCEN_Set; + } + } + else + { + /* Disable the selected NAND Bank ECC function by clearing the ECCEN bit in the PCRx register */ + if(FSMC_Bank == FSMC_Bank2_NAND) + { + FSMC_Bank2->PCR2 &= PCR_ECCEN_Reset; + } + else + { + FSMC_Bank3->PCR3 &= PCR_ECCEN_Reset; + } + } +} + +/** + * @brief Returns the error correction code register value. + * @param FSMC_Bank: specifies the FSMC Bank to be used + * This parameter can be one of the following values: + * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND + * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND + * @retval The Error Correction Code (ECC) value. + */ +uint32_t FSMC_GetECC(uint32_t FSMC_Bank) +{ + uint32_t eccval = 0x00000000; + + if(FSMC_Bank == FSMC_Bank2_NAND) + { + /* Get the ECCR2 register value */ + eccval = FSMC_Bank2->ECCR2; + } + else + { + /* Get the ECCR3 register value */ + eccval = FSMC_Bank3->ECCR3; + } + /* Return the error correction code value */ + return(eccval); +} + +/** + * @brief Enables or disables the specified FSMC interrupts. + * @param FSMC_Bank: specifies the FSMC Bank to be used + * This parameter can be one of the following values: + * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND + * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND + * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD + * @param FSMC_IT: specifies the FSMC interrupt sources to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg FSMC_IT_RisingEdge: Rising edge detection interrupt. + * @arg FSMC_IT_Level: Level edge detection interrupt. + * @arg FSMC_IT_FallingEdge: Falling edge detection interrupt. + * @param NewState: new state of the specified FSMC interrupts. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void FSMC_ITConfig(uint32_t FSMC_Bank, uint32_t FSMC_IT, FunctionalState NewState) +{ + assert_param(IS_FSMC_IT_BANK(FSMC_Bank)); + assert_param(IS_FSMC_IT(FSMC_IT)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the selected FSMC_Bank2 interrupts */ + if(FSMC_Bank == FSMC_Bank2_NAND) + { + FSMC_Bank2->SR2 |= FSMC_IT; + } + /* Enable the selected FSMC_Bank3 interrupts */ + else if (FSMC_Bank == FSMC_Bank3_NAND) + { + FSMC_Bank3->SR3 |= FSMC_IT; + } + /* Enable the selected FSMC_Bank4 interrupts */ + else + { + FSMC_Bank4->SR4 |= FSMC_IT; + } + } + else + { + /* Disable the selected FSMC_Bank2 interrupts */ + if(FSMC_Bank == FSMC_Bank2_NAND) + { + + FSMC_Bank2->SR2 &= (uint32_t)~FSMC_IT; + } + /* Disable the selected FSMC_Bank3 interrupts */ + else if (FSMC_Bank == FSMC_Bank3_NAND) + { + FSMC_Bank3->SR3 &= (uint32_t)~FSMC_IT; + } + /* Disable the selected FSMC_Bank4 interrupts */ + else + { + FSMC_Bank4->SR4 &= (uint32_t)~FSMC_IT; + } + } +} + +/** + * @brief Checks whether the specified FSMC flag is set or not. + * @param FSMC_Bank: specifies the FSMC Bank to be used + * This parameter can be one of the following values: + * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND + * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND + * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD + * @param FSMC_FLAG: specifies the flag to check. + * This parameter can be one of the following values: + * @arg FSMC_FLAG_RisingEdge: Rising egde detection Flag. + * @arg FSMC_FLAG_Level: Level detection Flag. + * @arg FSMC_FLAG_FallingEdge: Falling egde detection Flag. + * @arg FSMC_FLAG_FEMPT: Fifo empty Flag. + * @retval The new state of FSMC_FLAG (SET or RESET). + */ +FlagStatus FSMC_GetFlagStatus(uint32_t FSMC_Bank, uint32_t FSMC_FLAG) +{ + FlagStatus bitstatus = RESET; + uint32_t tmpsr = 0x00000000; + + /* Check the parameters */ + assert_param(IS_FSMC_GETFLAG_BANK(FSMC_Bank)); + assert_param(IS_FSMC_GET_FLAG(FSMC_FLAG)); + + if(FSMC_Bank == FSMC_Bank2_NAND) + { + tmpsr = FSMC_Bank2->SR2; + } + else if(FSMC_Bank == FSMC_Bank3_NAND) + { + tmpsr = FSMC_Bank3->SR3; + } + /* FSMC_Bank4_PCCARD*/ + else + { + tmpsr = FSMC_Bank4->SR4; + } + + /* Get the flag status */ + if ((tmpsr & FSMC_FLAG) != (uint16_t)RESET ) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + /* Return the flag status */ + return bitstatus; +} + +/** + * @brief Clears the FSMC's pending flags. + * @param FSMC_Bank: specifies the FSMC Bank to be used + * This parameter can be one of the following values: + * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND + * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND + * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD + * @param FSMC_FLAG: specifies the flag to clear. + * This parameter can be any combination of the following values: + * @arg FSMC_FLAG_RisingEdge: Rising egde detection Flag. + * @arg FSMC_FLAG_Level: Level detection Flag. + * @arg FSMC_FLAG_FallingEdge: Falling egde detection Flag. + * @retval None + */ +void FSMC_ClearFlag(uint32_t FSMC_Bank, uint32_t FSMC_FLAG) +{ + /* Check the parameters */ + assert_param(IS_FSMC_GETFLAG_BANK(FSMC_Bank)); + assert_param(IS_FSMC_CLEAR_FLAG(FSMC_FLAG)) ; + + if(FSMC_Bank == FSMC_Bank2_NAND) + { + FSMC_Bank2->SR2 &= ~FSMC_FLAG; + } + else if(FSMC_Bank == FSMC_Bank3_NAND) + { + FSMC_Bank3->SR3 &= ~FSMC_FLAG; + } + /* FSMC_Bank4_PCCARD*/ + else + { + FSMC_Bank4->SR4 &= ~FSMC_FLAG; + } +} + +/** + * @brief Checks whether the specified FSMC interrupt has occurred or not. + * @param FSMC_Bank: specifies the FSMC Bank to be used + * This parameter can be one of the following values: + * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND + * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND + * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD + * @param FSMC_IT: specifies the FSMC interrupt source to check. + * This parameter can be one of the following values: + * @arg FSMC_IT_RisingEdge: Rising edge detection interrupt. + * @arg FSMC_IT_Level: Level edge detection interrupt. + * @arg FSMC_IT_FallingEdge: Falling edge detection interrupt. + * @retval The new state of FSMC_IT (SET or RESET). + */ +ITStatus FSMC_GetITStatus(uint32_t FSMC_Bank, uint32_t FSMC_IT) +{ + ITStatus bitstatus = RESET; + uint32_t tmpsr = 0x0, itstatus = 0x0, itenable = 0x0; + + /* Check the parameters */ + assert_param(IS_FSMC_IT_BANK(FSMC_Bank)); + assert_param(IS_FSMC_GET_IT(FSMC_IT)); + + if(FSMC_Bank == FSMC_Bank2_NAND) + { + tmpsr = FSMC_Bank2->SR2; + } + else if(FSMC_Bank == FSMC_Bank3_NAND) + { + tmpsr = FSMC_Bank3->SR3; + } + /* FSMC_Bank4_PCCARD*/ + else + { + tmpsr = FSMC_Bank4->SR4; + } + + itstatus = tmpsr & FSMC_IT; + + itenable = tmpsr & (FSMC_IT >> 3); + if ((itstatus != (uint32_t)RESET) && (itenable != (uint32_t)RESET)) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + return bitstatus; +} + +/** + * @brief Clears the FSMC's interrupt pending bits. + * @param FSMC_Bank: specifies the FSMC Bank to be used + * This parameter can be one of the following values: + * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND + * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND + * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD + * @param FSMC_IT: specifies the interrupt pending bit to clear. + * This parameter can be any combination of the following values: + * @arg FSMC_IT_RisingEdge: Rising edge detection interrupt. + * @arg FSMC_IT_Level: Level edge detection interrupt. + * @arg FSMC_IT_FallingEdge: Falling edge detection interrupt. + * @retval None + */ +void FSMC_ClearITPendingBit(uint32_t FSMC_Bank, uint32_t FSMC_IT) +{ + /* Check the parameters */ + assert_param(IS_FSMC_IT_BANK(FSMC_Bank)); + assert_param(IS_FSMC_IT(FSMC_IT)); + + if(FSMC_Bank == FSMC_Bank2_NAND) + { + FSMC_Bank2->SR2 &= ~(FSMC_IT >> 3); + } + else if(FSMC_Bank == FSMC_Bank3_NAND) + { + FSMC_Bank3->SR3 &= ~(FSMC_IT >> 3); + } + /* FSMC_Bank4_PCCARD*/ + else + { + FSMC_Bank4->SR4 &= ~(FSMC_IT >> 3); + } +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_gpio.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_gpio.c new file mode 100755 index 0000000..93dbcd7 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_gpio.c @@ -0,0 +1,650 @@ +/** + ****************************************************************************** + * @file stm32f10x_gpio.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the GPIO firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_gpio.h" +#include "stm32f10x_rcc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup GPIO + * @brief GPIO driver modules + * @{ + */ + +/** @defgroup GPIO_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup GPIO_Private_Defines + * @{ + */ + +/* ------------ RCC registers bit address in the alias region ----------------*/ +#define AFIO_OFFSET (AFIO_BASE - PERIPH_BASE) + +/* --- EVENTCR Register -----*/ + +/* Alias word address of EVOE bit */ +#define EVCR_OFFSET (AFIO_OFFSET + 0x00) +#define EVOE_BitNumber ((uint8_t)0x07) +#define EVCR_EVOE_BB (PERIPH_BB_BASE + (EVCR_OFFSET * 32) + (EVOE_BitNumber * 4)) + + +/* --- MAPR Register ---*/ +/* Alias word address of MII_RMII_SEL bit */ +#define MAPR_OFFSET (AFIO_OFFSET + 0x04) +#define MII_RMII_SEL_BitNumber ((u8)0x17) +#define MAPR_MII_RMII_SEL_BB (PERIPH_BB_BASE + (MAPR_OFFSET * 32) + (MII_RMII_SEL_BitNumber * 4)) + + +#define EVCR_PORTPINCONFIG_MASK ((uint16_t)0xFF80) +#define LSB_MASK ((uint16_t)0xFFFF) +#define DBGAFR_POSITION_MASK ((uint32_t)0x000F0000) +#define DBGAFR_SWJCFG_MASK ((uint32_t)0xF0FFFFFF) +#define DBGAFR_LOCATION_MASK ((uint32_t)0x00200000) +#define DBGAFR_NUMBITS_MASK ((uint32_t)0x00100000) +/** + * @} + */ + +/** @defgroup GPIO_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup GPIO_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup GPIO_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup GPIO_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the GPIOx peripheral registers to their default reset values. + * @param GPIOx: where x can be (A..G) to select the GPIO peripheral. + * @retval None + */ +void GPIO_DeInit(GPIO_TypeDef* GPIOx) +{ + /* Check the parameters */ + assert_param(IS_GPIO_ALL_PERIPH(GPIOx)); + + if (GPIOx == GPIOA) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOA, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOA, DISABLE); + } + else if (GPIOx == GPIOB) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOB, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOB, DISABLE); + } + else if (GPIOx == GPIOC) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOC, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOC, DISABLE); + } + else if (GPIOx == GPIOD) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOD, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOD, DISABLE); + } + else if (GPIOx == GPIOE) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOE, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOE, DISABLE); + } + else if (GPIOx == GPIOF) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOF, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOF, DISABLE); + } + else + { + if (GPIOx == GPIOG) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOG, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOG, DISABLE); + } + } +} + +/** + * @brief Deinitializes the Alternate Functions (remap, event control + * and EXTI configuration) registers to their default reset values. + * @param None + * @retval None + */ +void GPIO_AFIODeInit(void) +{ + RCC_APB2PeriphResetCmd(RCC_APB2Periph_AFIO, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_AFIO, DISABLE); +} + +/** + * @brief Initializes the GPIOx peripheral according to the specified + * parameters in the GPIO_InitStruct. + * @param GPIOx: where x can be (A..G) to select the GPIO peripheral. + * @param GPIO_InitStruct: pointer to a GPIO_InitTypeDef structure that + * contains the configuration information for the specified GPIO peripheral. + * @retval None + */ +void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct) +{ + uint32_t currentmode = 0x00, currentpin = 0x00, pinpos = 0x00, pos = 0x00; + uint32_t tmpreg = 0x00, pinmask = 0x00; + /* Check the parameters */ + assert_param(IS_GPIO_ALL_PERIPH(GPIOx)); + assert_param(IS_GPIO_MODE(GPIO_InitStruct->GPIO_Mode)); + assert_param(IS_GPIO_PIN(GPIO_InitStruct->GPIO_Pin)); + +/*---------------------------- GPIO Mode Configuration -----------------------*/ + currentmode = ((uint32_t)GPIO_InitStruct->GPIO_Mode) & ((uint32_t)0x0F); + if ((((uint32_t)GPIO_InitStruct->GPIO_Mode) & ((uint32_t)0x10)) != 0x00) + { + /* Check the parameters */ + assert_param(IS_GPIO_SPEED(GPIO_InitStruct->GPIO_Speed)); + /* Output mode */ + currentmode |= (uint32_t)GPIO_InitStruct->GPIO_Speed; + } +/*---------------------------- GPIO CRL Configuration ------------------------*/ + /* Configure the eight low port pins */ + if (((uint32_t)GPIO_InitStruct->GPIO_Pin & ((uint32_t)0x00FF)) != 0x00) + { + tmpreg = GPIOx->CRL; + for (pinpos = 0x00; pinpos < 0x08; pinpos++) + { + pos = ((uint32_t)0x01) << pinpos; + /* Get the port pins position */ + currentpin = (GPIO_InitStruct->GPIO_Pin) & pos; + if (currentpin == pos) + { + pos = pinpos << 2; + /* Clear the corresponding low control register bits */ + pinmask = ((uint32_t)0x0F) << pos; + tmpreg &= ~pinmask; + /* Write the mode configuration in the corresponding bits */ + tmpreg |= (currentmode << pos); + /* Reset the corresponding ODR bit */ + if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPD) + { + GPIOx->BRR = (((uint32_t)0x01) << pinpos); + } + else + { + /* Set the corresponding ODR bit */ + if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPU) + { + GPIOx->BSRR = (((uint32_t)0x01) << pinpos); + } + } + } + } + GPIOx->CRL = tmpreg; + } +/*---------------------------- GPIO CRH Configuration ------------------------*/ + /* Configure the eight high port pins */ + if (GPIO_InitStruct->GPIO_Pin > 0x00FF) + { + tmpreg = GPIOx->CRH; + for (pinpos = 0x00; pinpos < 0x08; pinpos++) + { + pos = (((uint32_t)0x01) << (pinpos + 0x08)); + /* Get the port pins position */ + currentpin = ((GPIO_InitStruct->GPIO_Pin) & pos); + if (currentpin == pos) + { + pos = pinpos << 2; + /* Clear the corresponding high control register bits */ + pinmask = ((uint32_t)0x0F) << pos; + tmpreg &= ~pinmask; + /* Write the mode configuration in the corresponding bits */ + tmpreg |= (currentmode << pos); + /* Reset the corresponding ODR bit */ + if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPD) + { + GPIOx->BRR = (((uint32_t)0x01) << (pinpos + 0x08)); + } + /* Set the corresponding ODR bit */ + if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPU) + { + GPIOx->BSRR = (((uint32_t)0x01) << (pinpos + 0x08)); + } + } + } + GPIOx->CRH = tmpreg; + } +} + +/** + * @brief Fills each GPIO_InitStruct member with its default value. + * @param GPIO_InitStruct : pointer to a GPIO_InitTypeDef structure which will + * be initialized. + * @retval None + */ +void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct) +{ + /* Reset GPIO init structure parameters values */ + GPIO_InitStruct->GPIO_Pin = GPIO_Pin_All; + GPIO_InitStruct->GPIO_Speed = GPIO_Speed_2MHz; + GPIO_InitStruct->GPIO_Mode = GPIO_Mode_IN_FLOATING; +} + +/** + * @brief Reads the specified input port pin. + * @param GPIOx: where x can be (A..G) to select the GPIO peripheral. + * @param GPIO_Pin: specifies the port bit to read. + * This parameter can be GPIO_Pin_x where x can be (0..15). + * @retval The input port pin value. + */ +uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) +{ + uint8_t bitstatus = 0x00; + + /* Check the parameters */ + assert_param(IS_GPIO_ALL_PERIPH(GPIOx)); + assert_param(IS_GET_GPIO_PIN(GPIO_Pin)); + + if ((GPIOx->IDR & GPIO_Pin) != (uint32_t)Bit_RESET) + { + bitstatus = (uint8_t)Bit_SET; + } + else + { + bitstatus = (uint8_t)Bit_RESET; + } + return bitstatus; +} + +/** + * @brief Reads the specified GPIO input data port. + * @param GPIOx: where x can be (A..G) to select the GPIO peripheral. + * @retval GPIO input data port value. + */ +uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx) +{ + /* Check the parameters */ + assert_param(IS_GPIO_ALL_PERIPH(GPIOx)); + + return ((uint16_t)GPIOx->IDR); +} + +/** + * @brief Reads the specified output data port bit. + * @param GPIOx: where x can be (A..G) to select the GPIO peripheral. + * @param GPIO_Pin: specifies the port bit to read. + * This parameter can be GPIO_Pin_x where x can be (0..15). + * @retval The output port pin value. + */ +uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) +{ + uint8_t bitstatus = 0x00; + /* Check the parameters */ + assert_param(IS_GPIO_ALL_PERIPH(GPIOx)); + assert_param(IS_GET_GPIO_PIN(GPIO_Pin)); + + if ((GPIOx->ODR & GPIO_Pin) != (uint32_t)Bit_RESET) + { + bitstatus = (uint8_t)Bit_SET; + } + else + { + bitstatus = (uint8_t)Bit_RESET; + } + return bitstatus; +} + +/** + * @brief Reads the specified GPIO output data port. + * @param GPIOx: where x can be (A..G) to select the GPIO peripheral. + * @retval GPIO output data port value. + */ +uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx) +{ + /* Check the parameters */ + assert_param(IS_GPIO_ALL_PERIPH(GPIOx)); + + return ((uint16_t)GPIOx->ODR); +} + +/** + * @brief Sets the selected data port bits. + * @param GPIOx: where x can be (A..G) to select the GPIO peripheral. + * @param GPIO_Pin: specifies the port bits to be written. + * This parameter can be any combination of GPIO_Pin_x where x can be (0..15). + * @retval None + */ +void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) +{ + /* Check the parameters */ + assert_param(IS_GPIO_ALL_PERIPH(GPIOx)); + assert_param(IS_GPIO_PIN(GPIO_Pin)); + + GPIOx->BSRR = GPIO_Pin; +} + +/** + * @brief Clears the selected data port bits. + * @param GPIOx: where x can be (A..G) to select the GPIO peripheral. + * @param GPIO_Pin: specifies the port bits to be written. + * This parameter can be any combination of GPIO_Pin_x where x can be (0..15). + * @retval None + */ +void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) +{ + /* Check the parameters */ + assert_param(IS_GPIO_ALL_PERIPH(GPIOx)); + assert_param(IS_GPIO_PIN(GPIO_Pin)); + + GPIOx->BRR = GPIO_Pin; +} + +/** + * @brief Sets or clears the selected data port bit. + * @param GPIOx: where x can be (A..G) to select the GPIO peripheral. + * @param GPIO_Pin: specifies the port bit to be written. + * This parameter can be one of GPIO_Pin_x where x can be (0..15). + * @param BitVal: specifies the value to be written to the selected bit. + * This parameter can be one of the BitAction enum values: + * @arg Bit_RESET: to clear the port pin + * @arg Bit_SET: to set the port pin + * @retval None + */ +void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal) +{ + /* Check the parameters */ + assert_param(IS_GPIO_ALL_PERIPH(GPIOx)); + assert_param(IS_GET_GPIO_PIN(GPIO_Pin)); + assert_param(IS_GPIO_BIT_ACTION(BitVal)); + + if (BitVal != Bit_RESET) + { + GPIOx->BSRR = GPIO_Pin; + } + else + { + GPIOx->BRR = GPIO_Pin; + } +} + +/** + * @brief Writes data to the specified GPIO data port. + * @param GPIOx: where x can be (A..G) to select the GPIO peripheral. + * @param PortVal: specifies the value to be written to the port output data register. + * @retval None + */ +void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal) +{ + /* Check the parameters */ + assert_param(IS_GPIO_ALL_PERIPH(GPIOx)); + + GPIOx->ODR = PortVal; +} + +/** + * @brief Locks GPIO Pins configuration registers. + * @param GPIOx: where x can be (A..G) to select the GPIO peripheral. + * @param GPIO_Pin: specifies the port bit to be written. + * This parameter can be any combination of GPIO_Pin_x where x can be (0..15). + * @retval None + */ +void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) +{ + uint32_t tmp = 0x00010000; + + /* Check the parameters */ + assert_param(IS_GPIO_ALL_PERIPH(GPIOx)); + assert_param(IS_GPIO_PIN(GPIO_Pin)); + + tmp |= GPIO_Pin; + /* Set LCKK bit */ + GPIOx->LCKR = tmp; + /* Reset LCKK bit */ + GPIOx->LCKR = GPIO_Pin; + /* Set LCKK bit */ + GPIOx->LCKR = tmp; + /* Read LCKK bit*/ + tmp = GPIOx->LCKR; + /* Read LCKK bit*/ + tmp = GPIOx->LCKR; +} + +/** + * @brief Selects the GPIO pin used as Event output. + * @param GPIO_PortSource: selects the GPIO port to be used as source + * for Event output. + * This parameter can be GPIO_PortSourceGPIOx where x can be (A..E). + * @param GPIO_PinSource: specifies the pin for the Event output. + * This parameter can be GPIO_PinSourcex where x can be (0..15). + * @retval None + */ +void GPIO_EventOutputConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource) +{ + uint32_t tmpreg = 0x00; + /* Check the parameters */ + assert_param(IS_GPIO_EVENTOUT_PORT_SOURCE(GPIO_PortSource)); + assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource)); + + tmpreg = AFIO->EVCR; + /* Clear the PORT[6:4] and PIN[3:0] bits */ + tmpreg &= EVCR_PORTPINCONFIG_MASK; + tmpreg |= (uint32_t)GPIO_PortSource << 0x04; + tmpreg |= GPIO_PinSource; + AFIO->EVCR = tmpreg; +} + +/** + * @brief Enables or disables the Event Output. + * @param NewState: new state of the Event output. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void GPIO_EventOutputCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + *(__IO uint32_t *) EVCR_EVOE_BB = (uint32_t)NewState; +} + +/** + * @brief Changes the mapping of the specified pin. + * @param GPIO_Remap: selects the pin to remap. + * This parameter can be one of the following values: + * @arg GPIO_Remap_SPI1 : SPI1 Alternate Function mapping + * @arg GPIO_Remap_I2C1 : I2C1 Alternate Function mapping + * @arg GPIO_Remap_USART1 : USART1 Alternate Function mapping + * @arg GPIO_Remap_USART2 : USART2 Alternate Function mapping + * @arg GPIO_PartialRemap_USART3 : USART3 Partial Alternate Function mapping + * @arg GPIO_FullRemap_USART3 : USART3 Full Alternate Function mapping + * @arg GPIO_PartialRemap_TIM1 : TIM1 Partial Alternate Function mapping + * @arg GPIO_FullRemap_TIM1 : TIM1 Full Alternate Function mapping + * @arg GPIO_PartialRemap1_TIM2 : TIM2 Partial1 Alternate Function mapping + * @arg GPIO_PartialRemap2_TIM2 : TIM2 Partial2 Alternate Function mapping + * @arg GPIO_FullRemap_TIM2 : TIM2 Full Alternate Function mapping + * @arg GPIO_PartialRemap_TIM3 : TIM3 Partial Alternate Function mapping + * @arg GPIO_FullRemap_TIM3 : TIM3 Full Alternate Function mapping + * @arg GPIO_Remap_TIM4 : TIM4 Alternate Function mapping + * @arg GPIO_Remap1_CAN1 : CAN1 Alternate Function mapping + * @arg GPIO_Remap2_CAN1 : CAN1 Alternate Function mapping + * @arg GPIO_Remap_PD01 : PD01 Alternate Function mapping + * @arg GPIO_Remap_TIM5CH4_LSI : LSI connected to TIM5 Channel4 input capture for calibration + * @arg GPIO_Remap_ADC1_ETRGINJ : ADC1 External Trigger Injected Conversion remapping + * @arg GPIO_Remap_ADC1_ETRGREG : ADC1 External Trigger Regular Conversion remapping + * @arg GPIO_Remap_ADC2_ETRGINJ : ADC2 External Trigger Injected Conversion remapping + * @arg GPIO_Remap_ADC2_ETRGREG : ADC2 External Trigger Regular Conversion remapping + * @arg GPIO_Remap_ETH : Ethernet remapping (only for Connectivity line devices) + * @arg GPIO_Remap_CAN2 : CAN2 remapping (only for Connectivity line devices) + * @arg GPIO_Remap_SWJ_NoJTRST : Full SWJ Enabled (JTAG-DP + SW-DP) but without JTRST + * @arg GPIO_Remap_SWJ_JTAGDisable : JTAG-DP Disabled and SW-DP Enabled + * @arg GPIO_Remap_SWJ_Disable : Full SWJ Disabled (JTAG-DP + SW-DP) + * @arg GPIO_Remap_SPI3 : SPI3/I2S3 Alternate Function mapping (only for Connectivity line devices) + * When the SPI3/I2S3 is remapped using this function, the SWJ is configured + * to Full SWJ Enabled (JTAG-DP + SW-DP) but without JTRST. + * @arg GPIO_Remap_TIM2ITR1_PTP_SOF : Ethernet PTP output or USB OTG SOF (Start of Frame) connected + * to TIM2 Internal Trigger 1 for calibration (only for Connectivity line devices) + * If the GPIO_Remap_TIM2ITR1_PTP_SOF is enabled the TIM2 ITR1 is connected to + * Ethernet PTP output. When Reset TIM2 ITR1 is connected to USB OTG SOF output. + * @arg GPIO_Remap_PTP_PPS : Ethernet MAC PPS_PTS output on PB05 (only for Connectivity line devices) + * @arg GPIO_Remap_TIM15 : TIM15 Alternate Function mapping (only for Value line devices) + * @arg GPIO_Remap_TIM16 : TIM16 Alternate Function mapping (only for Value line devices) + * @arg GPIO_Remap_TIM17 : TIM17 Alternate Function mapping (only for Value line devices) + * @arg GPIO_Remap_CEC : CEC Alternate Function mapping (only for Value line devices) + * @arg GPIO_Remap_TIM1_DMA : TIM1 DMA requests mapping (only for Value line devices) + * @arg GPIO_Remap_TIM9 : TIM9 Alternate Function mapping (only for XL-density devices) + * @arg GPIO_Remap_TIM10 : TIM10 Alternate Function mapping (only for XL-density devices) + * @arg GPIO_Remap_TIM11 : TIM11 Alternate Function mapping (only for XL-density devices) + * @arg GPIO_Remap_TIM13 : TIM13 Alternate Function mapping (only for High density Value line and XL-density devices) + * @arg GPIO_Remap_TIM14 : TIM14 Alternate Function mapping (only for High density Value line and XL-density devices) + * @arg GPIO_Remap_FSMC_NADV : FSMC_NADV Alternate Function mapping (only for High density Value line and XL-density devices) + * @arg GPIO_Remap_TIM67_DAC_DMA : TIM6/TIM7 and DAC DMA requests remapping (only for High density Value line devices) + * @arg GPIO_Remap_TIM12 : TIM12 Alternate Function mapping (only for High density Value line devices) + * @arg GPIO_Remap_MISC : Miscellaneous Remap (DMA2 Channel5 Position and DAC Trigger remapping, + * only for High density Value line devices) + * @param NewState: new state of the port pin remapping. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void GPIO_PinRemapConfig(uint32_t GPIO_Remap, FunctionalState NewState) +{ + uint32_t tmp = 0x00, tmp1 = 0x00, tmpreg = 0x00, tmpmask = 0x00; + + /* Check the parameters */ + assert_param(IS_GPIO_REMAP(GPIO_Remap)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if((GPIO_Remap & 0x80000000) == 0x80000000) + { + tmpreg = AFIO->MAPR2; + } + else + { + tmpreg = AFIO->MAPR; + } + + tmpmask = (GPIO_Remap & DBGAFR_POSITION_MASK) >> 0x10; + tmp = GPIO_Remap & LSB_MASK; + + if ((GPIO_Remap & (DBGAFR_LOCATION_MASK | DBGAFR_NUMBITS_MASK)) == (DBGAFR_LOCATION_MASK | DBGAFR_NUMBITS_MASK)) + { + tmpreg &= DBGAFR_SWJCFG_MASK; + AFIO->MAPR &= DBGAFR_SWJCFG_MASK; + } + else if ((GPIO_Remap & DBGAFR_NUMBITS_MASK) == DBGAFR_NUMBITS_MASK) + { + tmp1 = ((uint32_t)0x03) << tmpmask; + tmpreg &= ~tmp1; + tmpreg |= ~DBGAFR_SWJCFG_MASK; + } + else + { + tmpreg &= ~(tmp << ((GPIO_Remap >> 0x15)*0x10)); + tmpreg |= ~DBGAFR_SWJCFG_MASK; + } + + if (NewState != DISABLE) + { + tmpreg |= (tmp << ((GPIO_Remap >> 0x15)*0x10)); + } + + if((GPIO_Remap & 0x80000000) == 0x80000000) + { + AFIO->MAPR2 = tmpreg; + } + else + { + AFIO->MAPR = tmpreg; + } +} + +/** + * @brief Selects the GPIO pin used as EXTI Line. + * @param GPIO_PortSource: selects the GPIO port to be used as source for EXTI lines. + * This parameter can be GPIO_PortSourceGPIOx where x can be (A..G). + * @param GPIO_PinSource: specifies the EXTI line to be configured. + * This parameter can be GPIO_PinSourcex where x can be (0..15). + * @retval None + */ +void GPIO_EXTILineConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource) +{ + uint32_t tmp = 0x00; + /* Check the parameters */ + assert_param(IS_GPIO_EXTI_PORT_SOURCE(GPIO_PortSource)); + assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource)); + + tmp = ((uint32_t)0x0F) << (0x04 * (GPIO_PinSource & (uint8_t)0x03)); + AFIO->EXTICR[GPIO_PinSource >> 0x02] &= ~tmp; + AFIO->EXTICR[GPIO_PinSource >> 0x02] |= (((uint32_t)GPIO_PortSource) << (0x04 * (GPIO_PinSource & (uint8_t)0x03))); +} + +/** + * @brief Selects the Ethernet media interface. + * @note This function applies only to STM32 Connectivity line devices. + * @param GPIO_ETH_MediaInterface: specifies the Media Interface mode. + * This parameter can be one of the following values: + * @arg GPIO_ETH_MediaInterface_MII: MII mode + * @arg GPIO_ETH_MediaInterface_RMII: RMII mode + * @retval None + */ +void GPIO_ETH_MediaInterfaceConfig(uint32_t GPIO_ETH_MediaInterface) +{ + assert_param(IS_GPIO_ETH_MEDIA_INTERFACE(GPIO_ETH_MediaInterface)); + + /* Configure MII_RMII selection bit */ + *(__IO uint32_t *) MAPR_MII_RMII_SEL_BB = GPIO_ETH_MediaInterface; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_i2c.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_i2c.c new file mode 100755 index 0000000..8896726 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_i2c.c @@ -0,0 +1,1331 @@ +/** + ****************************************************************************** + * @file stm32f10x_i2c.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the I2C firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_i2c.h" +#include "stm32f10x_rcc.h" + + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup I2C + * @brief I2C driver modules + * @{ + */ + +/** @defgroup I2C_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup I2C_Private_Defines + * @{ + */ + +/* I2C SPE mask */ +#define CR1_PE_Set ((uint16_t)0x0001) +#define CR1_PE_Reset ((uint16_t)0xFFFE) + +/* I2C START mask */ +#define CR1_START_Set ((uint16_t)0x0100) +#define CR1_START_Reset ((uint16_t)0xFEFF) + +/* I2C STOP mask */ +#define CR1_STOP_Set ((uint16_t)0x0200) +#define CR1_STOP_Reset ((uint16_t)0xFDFF) + +/* I2C ACK mask */ +#define CR1_ACK_Set ((uint16_t)0x0400) +#define CR1_ACK_Reset ((uint16_t)0xFBFF) + +/* I2C ENGC mask */ +#define CR1_ENGC_Set ((uint16_t)0x0040) +#define CR1_ENGC_Reset ((uint16_t)0xFFBF) + +/* I2C SWRST mask */ +#define CR1_SWRST_Set ((uint16_t)0x8000) +#define CR1_SWRST_Reset ((uint16_t)0x7FFF) + +/* I2C PEC mask */ +#define CR1_PEC_Set ((uint16_t)0x1000) +#define CR1_PEC_Reset ((uint16_t)0xEFFF) + +/* I2C ENPEC mask */ +#define CR1_ENPEC_Set ((uint16_t)0x0020) +#define CR1_ENPEC_Reset ((uint16_t)0xFFDF) + +/* I2C ENARP mask */ +#define CR1_ENARP_Set ((uint16_t)0x0010) +#define CR1_ENARP_Reset ((uint16_t)0xFFEF) + +/* I2C NOSTRETCH mask */ +#define CR1_NOSTRETCH_Set ((uint16_t)0x0080) +#define CR1_NOSTRETCH_Reset ((uint16_t)0xFF7F) + +/* I2C registers Masks */ +#define CR1_CLEAR_Mask ((uint16_t)0xFBF5) + +/* I2C DMAEN mask */ +#define CR2_DMAEN_Set ((uint16_t)0x0800) +#define CR2_DMAEN_Reset ((uint16_t)0xF7FF) + +/* I2C LAST mask */ +#define CR2_LAST_Set ((uint16_t)0x1000) +#define CR2_LAST_Reset ((uint16_t)0xEFFF) + +/* I2C FREQ mask */ +#define CR2_FREQ_Reset ((uint16_t)0xFFC0) + +/* I2C ADD0 mask */ +#define OAR1_ADD0_Set ((uint16_t)0x0001) +#define OAR1_ADD0_Reset ((uint16_t)0xFFFE) + +/* I2C ENDUAL mask */ +#define OAR2_ENDUAL_Set ((uint16_t)0x0001) +#define OAR2_ENDUAL_Reset ((uint16_t)0xFFFE) + +/* I2C ADD2 mask */ +#define OAR2_ADD2_Reset ((uint16_t)0xFF01) + +/* I2C F/S mask */ +#define CCR_FS_Set ((uint16_t)0x8000) + +/* I2C CCR mask */ +#define CCR_CCR_Set ((uint16_t)0x0FFF) + +/* I2C FLAG mask */ +#define FLAG_Mask ((uint32_t)0x00FFFFFF) + +/* I2C Interrupt Enable mask */ +#define ITEN_Mask ((uint32_t)0x07000000) + +/** + * @} + */ + +/** @defgroup I2C_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup I2C_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup I2C_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup I2C_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the I2Cx peripheral registers to their default reset values. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @retval None + */ +void I2C_DeInit(I2C_TypeDef* I2Cx) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + + if (I2Cx == I2C1) + { + /* Enable I2C1 reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE); + /* Release I2C1 from reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE); + } + else + { + /* Enable I2C2 reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, ENABLE); + /* Release I2C2 from reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, DISABLE); + } +} + +/** + * @brief Initializes the I2Cx peripheral according to the specified + * parameters in the I2C_InitStruct. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param I2C_InitStruct: pointer to a I2C_InitTypeDef structure that + * contains the configuration information for the specified I2C peripheral. + * @retval None + */ +void I2C_Init(I2C_TypeDef* I2Cx, I2C_InitTypeDef* I2C_InitStruct) +{ + uint16_t tmpreg = 0, freqrange = 0; + uint16_t result = 0x04; + uint32_t pclk1 = 8000000; + RCC_ClocksTypeDef rcc_clocks; + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_I2C_CLOCK_SPEED(I2C_InitStruct->I2C_ClockSpeed)); + assert_param(IS_I2C_MODE(I2C_InitStruct->I2C_Mode)); + assert_param(IS_I2C_DUTY_CYCLE(I2C_InitStruct->I2C_DutyCycle)); + assert_param(IS_I2C_OWN_ADDRESS1(I2C_InitStruct->I2C_OwnAddress1)); + assert_param(IS_I2C_ACK_STATE(I2C_InitStruct->I2C_Ack)); + assert_param(IS_I2C_ACKNOWLEDGE_ADDRESS(I2C_InitStruct->I2C_AcknowledgedAddress)); + +/*---------------------------- I2Cx CR2 Configuration ------------------------*/ + /* Get the I2Cx CR2 value */ + tmpreg = I2Cx->CR2; + /* Clear frequency FREQ[5:0] bits */ + tmpreg &= CR2_FREQ_Reset; + /* Get pclk1 frequency value */ + RCC_GetClocksFreq(&rcc_clocks); + pclk1 = rcc_clocks.PCLK1_Frequency; + /* Set frequency bits depending on pclk1 value */ + freqrange = (uint16_t)(pclk1 / 1000000); + tmpreg |= freqrange; + /* Write to I2Cx CR2 */ + I2Cx->CR2 = tmpreg; + +/*---------------------------- I2Cx CCR Configuration ------------------------*/ + /* Disable the selected I2C peripheral to configure TRISE */ + I2Cx->CR1 &= CR1_PE_Reset; + /* Reset tmpreg value */ + /* Clear F/S, DUTY and CCR[11:0] bits */ + tmpreg = 0; + + /* Configure speed in standard mode */ + if (I2C_InitStruct->I2C_ClockSpeed <= 100000) + { + /* Standard mode speed calculate */ + result = (uint16_t)(pclk1 / (I2C_InitStruct->I2C_ClockSpeed << 1)); + /* Test if CCR value is under 0x4*/ + if (result < 0x04) + { + /* Set minimum allowed value */ + result = 0x04; + } + /* Set speed value for standard mode */ + tmpreg |= result; + /* Set Maximum Rise Time for standard mode */ + I2Cx->TRISE = freqrange + 1; + } + /* Configure speed in fast mode */ + else /*(I2C_InitStruct->I2C_ClockSpeed <= 400000)*/ + { + if (I2C_InitStruct->I2C_DutyCycle == I2C_DutyCycle_2) + { + /* Fast mode speed calculate: Tlow/Thigh = 2 */ + result = (uint16_t)(pclk1 / (I2C_InitStruct->I2C_ClockSpeed * 3)); + } + else /*I2C_InitStruct->I2C_DutyCycle == I2C_DutyCycle_16_9*/ + { + /* Fast mode speed calculate: Tlow/Thigh = 16/9 */ + result = (uint16_t)(pclk1 / (I2C_InitStruct->I2C_ClockSpeed * 25)); + /* Set DUTY bit */ + result |= I2C_DutyCycle_16_9; + } + + /* Test if CCR value is under 0x1*/ + if ((result & CCR_CCR_Set) == 0) + { + /* Set minimum allowed value */ + result |= (uint16_t)0x0001; + } + /* Set speed value and set F/S bit for fast mode */ + tmpreg |= (uint16_t)(result | CCR_FS_Set); + /* Set Maximum Rise Time for fast mode */ + I2Cx->TRISE = (uint16_t)(((freqrange * (uint16_t)300) / (uint16_t)1000) + (uint16_t)1); + } + + /* Write to I2Cx CCR */ + I2Cx->CCR = tmpreg; + /* Enable the selected I2C peripheral */ + I2Cx->CR1 |= CR1_PE_Set; + +/*---------------------------- I2Cx CR1 Configuration ------------------------*/ + /* Get the I2Cx CR1 value */ + tmpreg = I2Cx->CR1; + /* Clear ACK, SMBTYPE and SMBUS bits */ + tmpreg &= CR1_CLEAR_Mask; + /* Configure I2Cx: mode and acknowledgement */ + /* Set SMBTYPE and SMBUS bits according to I2C_Mode value */ + /* Set ACK bit according to I2C_Ack value */ + tmpreg |= (uint16_t)((uint32_t)I2C_InitStruct->I2C_Mode | I2C_InitStruct->I2C_Ack); + /* Write to I2Cx CR1 */ + I2Cx->CR1 = tmpreg; + +/*---------------------------- I2Cx OAR1 Configuration -----------------------*/ + /* Set I2Cx Own Address1 and acknowledged address */ + I2Cx->OAR1 = (I2C_InitStruct->I2C_AcknowledgedAddress | I2C_InitStruct->I2C_OwnAddress1); +} + +/** + * @brief Fills each I2C_InitStruct member with its default value. + * @param I2C_InitStruct: pointer to an I2C_InitTypeDef structure which will be initialized. + * @retval None + */ +void I2C_StructInit(I2C_InitTypeDef* I2C_InitStruct) +{ +/*---------------- Reset I2C init structure parameters values ----------------*/ + /* initialize the I2C_ClockSpeed member */ + I2C_InitStruct->I2C_ClockSpeed = 5000; + /* Initialize the I2C_Mode member */ + I2C_InitStruct->I2C_Mode = I2C_Mode_I2C; + /* Initialize the I2C_DutyCycle member */ + I2C_InitStruct->I2C_DutyCycle = I2C_DutyCycle_2; + /* Initialize the I2C_OwnAddress1 member */ + I2C_InitStruct->I2C_OwnAddress1 = 0; + /* Initialize the I2C_Ack member */ + I2C_InitStruct->I2C_Ack = I2C_Ack_Disable; + /* Initialize the I2C_AcknowledgedAddress member */ + I2C_InitStruct->I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; +} + +/** + * @brief Enables or disables the specified I2C peripheral. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param NewState: new state of the I2Cx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void I2C_Cmd(I2C_TypeDef* I2Cx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected I2C peripheral */ + I2Cx->CR1 |= CR1_PE_Set; + } + else + { + /* Disable the selected I2C peripheral */ + I2Cx->CR1 &= CR1_PE_Reset; + } +} + +/** + * @brief Enables or disables the specified I2C DMA requests. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param NewState: new state of the I2C DMA transfer. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void I2C_DMACmd(I2C_TypeDef* I2Cx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected I2C DMA requests */ + I2Cx->CR2 |= CR2_DMAEN_Set; + } + else + { + /* Disable the selected I2C DMA requests */ + I2Cx->CR2 &= CR2_DMAEN_Reset; + } +} + +/** + * @brief Specifies if the next DMA transfer will be the last one. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param NewState: new state of the I2C DMA last transfer. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void I2C_DMALastTransferCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Next DMA transfer is the last transfer */ + I2Cx->CR2 |= CR2_LAST_Set; + } + else + { + /* Next DMA transfer is not the last transfer */ + I2Cx->CR2 &= CR2_LAST_Reset; + } +} + +/** + * @brief Generates I2Cx communication START condition. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param NewState: new state of the I2C START condition generation. + * This parameter can be: ENABLE or DISABLE. + * @retval None. + */ +void I2C_GenerateSTART(I2C_TypeDef* I2Cx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Generate a START condition */ + I2Cx->CR1 |= CR1_START_Set; + } + else + { + /* Disable the START condition generation */ + I2Cx->CR1 &= CR1_START_Reset; + } +} + +/** + * @brief Generates I2Cx communication STOP condition. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param NewState: new state of the I2C STOP condition generation. + * This parameter can be: ENABLE or DISABLE. + * @retval None. + */ +void I2C_GenerateSTOP(I2C_TypeDef* I2Cx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Generate a STOP condition */ + I2Cx->CR1 |= CR1_STOP_Set; + } + else + { + /* Disable the STOP condition generation */ + I2Cx->CR1 &= CR1_STOP_Reset; + } +} + +/** + * @brief Enables or disables the specified I2C acknowledge feature. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param NewState: new state of the I2C Acknowledgement. + * This parameter can be: ENABLE or DISABLE. + * @retval None. + */ +void I2C_AcknowledgeConfig(I2C_TypeDef* I2Cx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the acknowledgement */ + I2Cx->CR1 |= CR1_ACK_Set; + } + else + { + /* Disable the acknowledgement */ + I2Cx->CR1 &= CR1_ACK_Reset; + } +} + +/** + * @brief Configures the specified I2C own address2. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param Address: specifies the 7bit I2C own address2. + * @retval None. + */ +void I2C_OwnAddress2Config(I2C_TypeDef* I2Cx, uint8_t Address) +{ + uint16_t tmpreg = 0; + + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + + /* Get the old register value */ + tmpreg = I2Cx->OAR2; + + /* Reset I2Cx Own address2 bit [7:1] */ + tmpreg &= OAR2_ADD2_Reset; + + /* Set I2Cx Own address2 */ + tmpreg |= (uint16_t)((uint16_t)Address & (uint16_t)0x00FE); + + /* Store the new register value */ + I2Cx->OAR2 = tmpreg; +} + +/** + * @brief Enables or disables the specified I2C dual addressing mode. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param NewState: new state of the I2C dual addressing mode. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void I2C_DualAddressCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable dual addressing mode */ + I2Cx->OAR2 |= OAR2_ENDUAL_Set; + } + else + { + /* Disable dual addressing mode */ + I2Cx->OAR2 &= OAR2_ENDUAL_Reset; + } +} + +/** + * @brief Enables or disables the specified I2C general call feature. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param NewState: new state of the I2C General call. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void I2C_GeneralCallCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable generall call */ + I2Cx->CR1 |= CR1_ENGC_Set; + } + else + { + /* Disable generall call */ + I2Cx->CR1 &= CR1_ENGC_Reset; + } +} + +/** + * @brief Enables or disables the specified I2C interrupts. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param I2C_IT: specifies the I2C interrupts sources to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg I2C_IT_BUF: Buffer interrupt mask + * @arg I2C_IT_EVT: Event interrupt mask + * @arg I2C_IT_ERR: Error interrupt mask + * @param NewState: new state of the specified I2C interrupts. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void I2C_ITConfig(I2C_TypeDef* I2Cx, uint16_t I2C_IT, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + assert_param(IS_I2C_CONFIG_IT(I2C_IT)); + + if (NewState != DISABLE) + { + /* Enable the selected I2C interrupts */ + I2Cx->CR2 |= I2C_IT; + } + else + { + /* Disable the selected I2C interrupts */ + I2Cx->CR2 &= (uint16_t)~I2C_IT; + } +} + +/** + * @brief Sends a data byte through the I2Cx peripheral. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param Data: Byte to be transmitted.. + * @retval None + */ +void I2C_SendData(I2C_TypeDef* I2Cx, uint8_t Data) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + /* Write in the DR register the data to be sent */ + I2Cx->DR = Data; +} + +/** + * @brief Returns the most recent received data by the I2Cx peripheral. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @retval The value of the received data. + */ +uint8_t I2C_ReceiveData(I2C_TypeDef* I2Cx) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + /* Return the data in the DR register */ + return (uint8_t)I2Cx->DR; +} + +/** + * @brief Transmits the address byte to select the slave device. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param Address: specifies the slave address which will be transmitted + * @param I2C_Direction: specifies whether the I2C device will be a + * Transmitter or a Receiver. This parameter can be one of the following values + * @arg I2C_Direction_Transmitter: Transmitter mode + * @arg I2C_Direction_Receiver: Receiver mode + * @retval None. + */ +void I2C_Send7bitAddress(I2C_TypeDef* I2Cx, uint8_t Address, uint8_t I2C_Direction) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_I2C_DIRECTION(I2C_Direction)); + /* Test on the direction to set/reset the read/write bit */ + if (I2C_Direction != I2C_Direction_Transmitter) + { + /* Set the address bit0 for read */ + Address |= OAR1_ADD0_Set; + } + else + { + /* Reset the address bit0 for write */ + Address &= OAR1_ADD0_Reset; + } + /* Send the address */ + I2Cx->DR = Address; +} + +/** + * @brief Reads the specified I2C register and returns its value. + * @param I2C_Register: specifies the register to read. + * This parameter can be one of the following values: + * @arg I2C_Register_CR1: CR1 register. + * @arg I2C_Register_CR2: CR2 register. + * @arg I2C_Register_OAR1: OAR1 register. + * @arg I2C_Register_OAR2: OAR2 register. + * @arg I2C_Register_DR: DR register. + * @arg I2C_Register_SR1: SR1 register. + * @arg I2C_Register_SR2: SR2 register. + * @arg I2C_Register_CCR: CCR register. + * @arg I2C_Register_TRISE: TRISE register. + * @retval The value of the read register. + */ +uint16_t I2C_ReadRegister(I2C_TypeDef* I2Cx, uint8_t I2C_Register) +{ + __IO uint32_t tmp = 0; + + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_I2C_REGISTER(I2C_Register)); + + tmp = (uint32_t) I2Cx; + tmp += I2C_Register; + + /* Return the selected register value */ + return (*(__IO uint16_t *) tmp); +} + +/** + * @brief Enables or disables the specified I2C software reset. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param NewState: new state of the I2C software reset. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void I2C_SoftwareResetCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Peripheral under reset */ + I2Cx->CR1 |= CR1_SWRST_Set; + } + else + { + /* Peripheral not under reset */ + I2Cx->CR1 &= CR1_SWRST_Reset; + } +} + +/** + * @brief Selects the specified I2C NACK position in master receiver mode. + * This function is useful in I2C Master Receiver mode when the number + * of data to be received is equal to 2. In this case, this function + * should be called (with parameter I2C_NACKPosition_Next) before data + * reception starts,as described in the 2-byte reception procedure + * recommended in Reference Manual in Section: Master receiver. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param I2C_NACKPosition: specifies the NACK position. + * This parameter can be one of the following values: + * @arg I2C_NACKPosition_Next: indicates that the next byte will be the last + * received byte. + * @arg I2C_NACKPosition_Current: indicates that current byte is the last + * received byte. + * + * @note This function configures the same bit (POS) as I2C_PECPositionConfig() + * but is intended to be used in I2C mode while I2C_PECPositionConfig() + * is intended to used in SMBUS mode. + * + * @retval None + */ +void I2C_NACKPositionConfig(I2C_TypeDef* I2Cx, uint16_t I2C_NACKPosition) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_I2C_NACK_POSITION(I2C_NACKPosition)); + + /* Check the input parameter */ + if (I2C_NACKPosition == I2C_NACKPosition_Next) + { + /* Next byte in shift register is the last received byte */ + I2Cx->CR1 |= I2C_NACKPosition_Next; + } + else + { + /* Current byte in shift register is the last received byte */ + I2Cx->CR1 &= I2C_NACKPosition_Current; + } +} + +/** + * @brief Drives the SMBusAlert pin high or low for the specified I2C. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param I2C_SMBusAlert: specifies SMBAlert pin level. + * This parameter can be one of the following values: + * @arg I2C_SMBusAlert_Low: SMBAlert pin driven low + * @arg I2C_SMBusAlert_High: SMBAlert pin driven high + * @retval None + */ +void I2C_SMBusAlertConfig(I2C_TypeDef* I2Cx, uint16_t I2C_SMBusAlert) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_I2C_SMBUS_ALERT(I2C_SMBusAlert)); + if (I2C_SMBusAlert == I2C_SMBusAlert_Low) + { + /* Drive the SMBusAlert pin Low */ + I2Cx->CR1 |= I2C_SMBusAlert_Low; + } + else + { + /* Drive the SMBusAlert pin High */ + I2Cx->CR1 &= I2C_SMBusAlert_High; + } +} + +/** + * @brief Enables or disables the specified I2C PEC transfer. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param NewState: new state of the I2C PEC transmission. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void I2C_TransmitPEC(I2C_TypeDef* I2Cx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected I2C PEC transmission */ + I2Cx->CR1 |= CR1_PEC_Set; + } + else + { + /* Disable the selected I2C PEC transmission */ + I2Cx->CR1 &= CR1_PEC_Reset; + } +} + +/** + * @brief Selects the specified I2C PEC position. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param I2C_PECPosition: specifies the PEC position. + * This parameter can be one of the following values: + * @arg I2C_PECPosition_Next: indicates that the next byte is PEC + * @arg I2C_PECPosition_Current: indicates that current byte is PEC + * + * @note This function configures the same bit (POS) as I2C_NACKPositionConfig() + * but is intended to be used in SMBUS mode while I2C_NACKPositionConfig() + * is intended to used in I2C mode. + * + * @retval None + */ +void I2C_PECPositionConfig(I2C_TypeDef* I2Cx, uint16_t I2C_PECPosition) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_I2C_PEC_POSITION(I2C_PECPosition)); + if (I2C_PECPosition == I2C_PECPosition_Next) + { + /* Next byte in shift register is PEC */ + I2Cx->CR1 |= I2C_PECPosition_Next; + } + else + { + /* Current byte in shift register is PEC */ + I2Cx->CR1 &= I2C_PECPosition_Current; + } +} + +/** + * @brief Enables or disables the PEC value calculation of the transferred bytes. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param NewState: new state of the I2Cx PEC value calculation. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void I2C_CalculatePEC(I2C_TypeDef* I2Cx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected I2C PEC calculation */ + I2Cx->CR1 |= CR1_ENPEC_Set; + } + else + { + /* Disable the selected I2C PEC calculation */ + I2Cx->CR1 &= CR1_ENPEC_Reset; + } +} + +/** + * @brief Returns the PEC value for the specified I2C. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @retval The PEC value. + */ +uint8_t I2C_GetPEC(I2C_TypeDef* I2Cx) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + /* Return the selected I2C PEC value */ + return ((I2Cx->SR2) >> 8); +} + +/** + * @brief Enables or disables the specified I2C ARP. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param NewState: new state of the I2Cx ARP. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void I2C_ARPCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected I2C ARP */ + I2Cx->CR1 |= CR1_ENARP_Set; + } + else + { + /* Disable the selected I2C ARP */ + I2Cx->CR1 &= CR1_ENARP_Reset; + } +} + +/** + * @brief Enables or disables the specified I2C Clock stretching. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param NewState: new state of the I2Cx Clock stretching. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void I2C_StretchClockCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState == DISABLE) + { + /* Enable the selected I2C Clock stretching */ + I2Cx->CR1 |= CR1_NOSTRETCH_Set; + } + else + { + /* Disable the selected I2C Clock stretching */ + I2Cx->CR1 &= CR1_NOSTRETCH_Reset; + } +} + +/** + * @brief Selects the specified I2C fast mode duty cycle. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param I2C_DutyCycle: specifies the fast mode duty cycle. + * This parameter can be one of the following values: + * @arg I2C_DutyCycle_2: I2C fast mode Tlow/Thigh = 2 + * @arg I2C_DutyCycle_16_9: I2C fast mode Tlow/Thigh = 16/9 + * @retval None + */ +void I2C_FastModeDutyCycleConfig(I2C_TypeDef* I2Cx, uint16_t I2C_DutyCycle) +{ + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_I2C_DUTY_CYCLE(I2C_DutyCycle)); + if (I2C_DutyCycle != I2C_DutyCycle_16_9) + { + /* I2C fast mode Tlow/Thigh=2 */ + I2Cx->CCR &= I2C_DutyCycle_2; + } + else + { + /* I2C fast mode Tlow/Thigh=16/9 */ + I2Cx->CCR |= I2C_DutyCycle_16_9; + } +} + + + +/** + * @brief + **************************************************************************************** + * + * I2C State Monitoring Functions + * + **************************************************************************************** + * This I2C driver provides three different ways for I2C state monitoring + * depending on the application requirements and constraints: + * + * + * 1) Basic state monitoring: + * Using I2C_CheckEvent() function: + * It compares the status registers (SR1 and SR2) content to a given event + * (can be the combination of one or more flags). + * It returns SUCCESS if the current status includes the given flags + * and returns ERROR if one or more flags are missing in the current status. + * - When to use: + * - This function is suitable for most applications as well as for startup + * activity since the events are fully described in the product reference manual + * (RM0008). + * - It is also suitable for users who need to define their own events. + * - Limitations: + * - If an error occurs (ie. error flags are set besides to the monitored flags), + * the I2C_CheckEvent() function may return SUCCESS despite the communication + * hold or corrupted real state. + * In this case, it is advised to use error interrupts to monitor the error + * events and handle them in the interrupt IRQ handler. + * + * @note + * For error management, it is advised to use the following functions: + * - I2C_ITConfig() to configure and enable the error interrupts (I2C_IT_ERR). + * - I2Cx_ER_IRQHandler() which is called when the error interrupt occurs. + * Where x is the peripheral instance (I2C1, I2C2 ...) + * - I2C_GetFlagStatus() or I2C_GetITStatus() to be called into I2Cx_ER_IRQHandler() + * in order to determine which error occured. + * - I2C_ClearFlag() or I2C_ClearITPendingBit() and/or I2C_SoftwareResetCmd() + * and/or I2C_GenerateStop() in order to clear the error flag and source, + * and return to correct communication status. + * + * + * 2) Advanced state monitoring: + * Using the function I2C_GetLastEvent() which returns the image of both status + * registers in a single word (uint32_t) (Status Register 2 value is shifted left + * by 16 bits and concatenated to Status Register 1). + * - When to use: + * - This function is suitable for the same applications above but it allows to + * overcome the mentioned limitation of I2C_GetFlagStatus() function. + * The returned value could be compared to events already defined in the + * library (stm32f10x_i2c.h) or to custom values defined by user. + * - This function is suitable when multiple flags are monitored at the same time. + * - At the opposite of I2C_CheckEvent() function, this function allows user to + * choose when an event is accepted (when all events flags are set and no + * other flags are set or just when the needed flags are set like + * I2C_CheckEvent() function). + * - Limitations: + * - User may need to define his own events. + * - Same remark concerning the error management is applicable for this + * function if user decides to check only regular communication flags (and + * ignores error flags). + * + * + * 3) Flag-based state monitoring: + * Using the function I2C_GetFlagStatus() which simply returns the status of + * one single flag (ie. I2C_FLAG_RXNE ...). + * - When to use: + * - This function could be used for specific applications or in debug phase. + * - It is suitable when only one flag checking is needed (most I2C events + * are monitored through multiple flags). + * - Limitations: + * - When calling this function, the Status register is accessed. Some flags are + * cleared when the status register is accessed. So checking the status + * of one Flag, may clear other ones. + * - Function may need to be called twice or more in order to monitor one + * single event. + * + * For detailed description of Events, please refer to section I2C_Events in + * stm32f10x_i2c.h file. + * + */ + +/** + * + * 1) Basic state monitoring + ******************************************************************************* + */ + +/** + * @brief Checks whether the last I2Cx Event is equal to the one passed + * as parameter. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param I2C_EVENT: specifies the event to be checked. + * This parameter can be one of the following values: + * @arg I2C_EVENT_SLAVE_TRANSMITTER_ADDRESS_MATCHED : EV1 + * @arg I2C_EVENT_SLAVE_RECEIVER_ADDRESS_MATCHED : EV1 + * @arg I2C_EVENT_SLAVE_TRANSMITTER_SECONDADDRESS_MATCHED : EV1 + * @arg I2C_EVENT_SLAVE_RECEIVER_SECONDADDRESS_MATCHED : EV1 + * @arg I2C_EVENT_SLAVE_GENERALCALLADDRESS_MATCHED : EV1 + * @arg I2C_EVENT_SLAVE_BYTE_RECEIVED : EV2 + * @arg (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_DUALF) : EV2 + * @arg (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_GENCALL) : EV2 + * @arg I2C_EVENT_SLAVE_BYTE_TRANSMITTED : EV3 + * @arg (I2C_EVENT_SLAVE_BYTE_TRANSMITTED | I2C_FLAG_DUALF) : EV3 + * @arg (I2C_EVENT_SLAVE_BYTE_TRANSMITTED | I2C_FLAG_GENCALL) : EV3 + * @arg I2C_EVENT_SLAVE_ACK_FAILURE : EV3_2 + * @arg I2C_EVENT_SLAVE_STOP_DETECTED : EV4 + * @arg I2C_EVENT_MASTER_MODE_SELECT : EV5 + * @arg I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED : EV6 + * @arg I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED : EV6 + * @arg I2C_EVENT_MASTER_BYTE_RECEIVED : EV7 + * @arg I2C_EVENT_MASTER_BYTE_TRANSMITTING : EV8 + * @arg I2C_EVENT_MASTER_BYTE_TRANSMITTED : EV8_2 + * @arg I2C_EVENT_MASTER_MODE_ADDRESS10 : EV9 + * + * @note: For detailed description of Events, please refer to section + * I2C_Events in stm32f10x_i2c.h file. + * + * @retval An ErrorStatus enumeration value: + * - SUCCESS: Last event is equal to the I2C_EVENT + * - ERROR: Last event is different from the I2C_EVENT + */ +ErrorStatus I2C_CheckEvent(I2C_TypeDef* I2Cx, uint32_t I2C_EVENT) +{ + uint32_t lastevent = 0; + uint32_t flag1 = 0, flag2 = 0; + ErrorStatus status = ERROR; + + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_I2C_EVENT(I2C_EVENT)); + + /* Read the I2Cx status register */ + flag1 = I2Cx->SR1; + flag2 = I2Cx->SR2; + flag2 = flag2 << 16; + + /* Get the last event value from I2C status register */ + lastevent = (flag1 | flag2) & FLAG_Mask; + + /* Check whether the last event contains the I2C_EVENT */ + if ((lastevent & I2C_EVENT) == I2C_EVENT) + { + /* SUCCESS: last event is equal to I2C_EVENT */ + status = SUCCESS; + } + else + { + /* ERROR: last event is different from I2C_EVENT */ + status = ERROR; + } + /* Return status */ + return status; +} + +/** + * + * 2) Advanced state monitoring + ******************************************************************************* + */ + +/** + * @brief Returns the last I2Cx Event. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * + * @note: For detailed description of Events, please refer to section + * I2C_Events in stm32f10x_i2c.h file. + * + * @retval The last event + */ +uint32_t I2C_GetLastEvent(I2C_TypeDef* I2Cx) +{ + uint32_t lastevent = 0; + uint32_t flag1 = 0, flag2 = 0; + + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + + /* Read the I2Cx status register */ + flag1 = I2Cx->SR1; + flag2 = I2Cx->SR2; + flag2 = flag2 << 16; + + /* Get the last event value from I2C status register */ + lastevent = (flag1 | flag2) & FLAG_Mask; + + /* Return status */ + return lastevent; +} + +/** + * + * 3) Flag-based state monitoring + ******************************************************************************* + */ + +/** + * @brief Checks whether the specified I2C flag is set or not. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param I2C_FLAG: specifies the flag to check. + * This parameter can be one of the following values: + * @arg I2C_FLAG_DUALF: Dual flag (Slave mode) + * @arg I2C_FLAG_SMBHOST: SMBus host header (Slave mode) + * @arg I2C_FLAG_SMBDEFAULT: SMBus default header (Slave mode) + * @arg I2C_FLAG_GENCALL: General call header flag (Slave mode) + * @arg I2C_FLAG_TRA: Transmitter/Receiver flag + * @arg I2C_FLAG_BUSY: Bus busy flag + * @arg I2C_FLAG_MSL: Master/Slave flag + * @arg I2C_FLAG_SMBALERT: SMBus Alert flag + * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow error flag + * @arg I2C_FLAG_PECERR: PEC error in reception flag + * @arg I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode) + * @arg I2C_FLAG_AF: Acknowledge failure flag + * @arg I2C_FLAG_ARLO: Arbitration lost flag (Master mode) + * @arg I2C_FLAG_BERR: Bus error flag + * @arg I2C_FLAG_TXE: Data register empty flag (Transmitter) + * @arg I2C_FLAG_RXNE: Data register not empty (Receiver) flag + * @arg I2C_FLAG_STOPF: Stop detection flag (Slave mode) + * @arg I2C_FLAG_ADD10: 10-bit header sent flag (Master mode) + * @arg I2C_FLAG_BTF: Byte transfer finished flag + * @arg I2C_FLAG_ADDR: Address sent flag (Master mode) "ADSL" + * Address matched flag (Slave mode)"ENDA" + * @arg I2C_FLAG_SB: Start bit flag (Master mode) + * @retval The new state of I2C_FLAG (SET or RESET). + */ +FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG) +{ + FlagStatus bitstatus = RESET; + __IO uint32_t i2creg = 0, i2cxbase = 0; + + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_I2C_GET_FLAG(I2C_FLAG)); + + /* Get the I2Cx peripheral base address */ + i2cxbase = (uint32_t)I2Cx; + + /* Read flag register index */ + i2creg = I2C_FLAG >> 28; + + /* Get bit[23:0] of the flag */ + I2C_FLAG &= FLAG_Mask; + + if(i2creg != 0) + { + /* Get the I2Cx SR1 register address */ + i2cxbase += 0x14; + } + else + { + /* Flag in I2Cx SR2 Register */ + I2C_FLAG = (uint32_t)(I2C_FLAG >> 16); + /* Get the I2Cx SR2 register address */ + i2cxbase += 0x18; + } + + if(((*(__IO uint32_t *)i2cxbase) & I2C_FLAG) != (uint32_t)RESET) + { + /* I2C_FLAG is set */ + bitstatus = SET; + } + else + { + /* I2C_FLAG is reset */ + bitstatus = RESET; + } + + /* Return the I2C_FLAG status */ + return bitstatus; +} + + + +/** + * @brief Clears the I2Cx's pending flags. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param I2C_FLAG: specifies the flag to clear. + * This parameter can be any combination of the following values: + * @arg I2C_FLAG_SMBALERT: SMBus Alert flag + * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow error flag + * @arg I2C_FLAG_PECERR: PEC error in reception flag + * @arg I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode) + * @arg I2C_FLAG_AF: Acknowledge failure flag + * @arg I2C_FLAG_ARLO: Arbitration lost flag (Master mode) + * @arg I2C_FLAG_BERR: Bus error flag + * + * @note + * - STOPF (STOP detection) is cleared by software sequence: a read operation + * to I2C_SR1 register (I2C_GetFlagStatus()) followed by a write operation + * to I2C_CR1 register (I2C_Cmd() to re-enable the I2C peripheral). + * - ADD10 (10-bit header sent) is cleared by software sequence: a read + * operation to I2C_SR1 (I2C_GetFlagStatus()) followed by writing the + * second byte of the address in DR register. + * - BTF (Byte Transfer Finished) is cleared by software sequence: a read + * operation to I2C_SR1 register (I2C_GetFlagStatus()) followed by a + * read/write to I2C_DR register (I2C_SendData()). + * - ADDR (Address sent) is cleared by software sequence: a read operation to + * I2C_SR1 register (I2C_GetFlagStatus()) followed by a read operation to + * I2C_SR2 register ((void)(I2Cx->SR2)). + * - SB (Start Bit) is cleared software sequence: a read operation to I2C_SR1 + * register (I2C_GetFlagStatus()) followed by a write operation to I2C_DR + * register (I2C_SendData()). + * @retval None + */ +void I2C_ClearFlag(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG) +{ + uint32_t flagpos = 0; + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_I2C_CLEAR_FLAG(I2C_FLAG)); + /* Get the I2C flag position */ + flagpos = I2C_FLAG & FLAG_Mask; + /* Clear the selected I2C flag */ + I2Cx->SR1 = (uint16_t)~flagpos; +} + +/** + * @brief Checks whether the specified I2C interrupt has occurred or not. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param I2C_IT: specifies the interrupt source to check. + * This parameter can be one of the following values: + * @arg I2C_IT_SMBALERT: SMBus Alert flag + * @arg I2C_IT_TIMEOUT: Timeout or Tlow error flag + * @arg I2C_IT_PECERR: PEC error in reception flag + * @arg I2C_IT_OVR: Overrun/Underrun flag (Slave mode) + * @arg I2C_IT_AF: Acknowledge failure flag + * @arg I2C_IT_ARLO: Arbitration lost flag (Master mode) + * @arg I2C_IT_BERR: Bus error flag + * @arg I2C_IT_TXE: Data register empty flag (Transmitter) + * @arg I2C_IT_RXNE: Data register not empty (Receiver) flag + * @arg I2C_IT_STOPF: Stop detection flag (Slave mode) + * @arg I2C_IT_ADD10: 10-bit header sent flag (Master mode) + * @arg I2C_IT_BTF: Byte transfer finished flag + * @arg I2C_IT_ADDR: Address sent flag (Master mode) "ADSL" + * Address matched flag (Slave mode)"ENDAD" + * @arg I2C_IT_SB: Start bit flag (Master mode) + * @retval The new state of I2C_IT (SET or RESET). + */ +ITStatus I2C_GetITStatus(I2C_TypeDef* I2Cx, uint32_t I2C_IT) +{ + ITStatus bitstatus = RESET; + uint32_t enablestatus = 0; + + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_I2C_GET_IT(I2C_IT)); + + /* Check if the interrupt source is enabled or not */ + enablestatus = (uint32_t)(((I2C_IT & ITEN_Mask) >> 16) & (I2Cx->CR2)) ; + + /* Get bit[23:0] of the flag */ + I2C_IT &= FLAG_Mask; + + /* Check the status of the specified I2C flag */ + if (((I2Cx->SR1 & I2C_IT) != (uint32_t)RESET) && enablestatus) + { + /* I2C_IT is set */ + bitstatus = SET; + } + else + { + /* I2C_IT is reset */ + bitstatus = RESET; + } + /* Return the I2C_IT status */ + return bitstatus; +} + +/** + * @brief Clears the I2Cxs interrupt pending bits. + * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. + * @param I2C_IT: specifies the interrupt pending bit to clear. + * This parameter can be any combination of the following values: + * @arg I2C_IT_SMBALERT: SMBus Alert interrupt + * @arg I2C_IT_TIMEOUT: Timeout or Tlow error interrupt + * @arg I2C_IT_PECERR: PEC error in reception interrupt + * @arg I2C_IT_OVR: Overrun/Underrun interrupt (Slave mode) + * @arg I2C_IT_AF: Acknowledge failure interrupt + * @arg I2C_IT_ARLO: Arbitration lost interrupt (Master mode) + * @arg I2C_IT_BERR: Bus error interrupt + * + * @note + * - STOPF (STOP detection) is cleared by software sequence: a read operation + * to I2C_SR1 register (I2C_GetITStatus()) followed by a write operation to + * I2C_CR1 register (I2C_Cmd() to re-enable the I2C peripheral). + * - ADD10 (10-bit header sent) is cleared by software sequence: a read + * operation to I2C_SR1 (I2C_GetITStatus()) followed by writing the second + * byte of the address in I2C_DR register. + * - BTF (Byte Transfer Finished) is cleared by software sequence: a read + * operation to I2C_SR1 register (I2C_GetITStatus()) followed by a + * read/write to I2C_DR register (I2C_SendData()). + * - ADDR (Address sent) is cleared by software sequence: a read operation to + * I2C_SR1 register (I2C_GetITStatus()) followed by a read operation to + * I2C_SR2 register ((void)(I2Cx->SR2)). + * - SB (Start Bit) is cleared by software sequence: a read operation to + * I2C_SR1 register (I2C_GetITStatus()) followed by a write operation to + * I2C_DR register (I2C_SendData()). + * @retval None + */ +void I2C_ClearITPendingBit(I2C_TypeDef* I2Cx, uint32_t I2C_IT) +{ + uint32_t flagpos = 0; + /* Check the parameters */ + assert_param(IS_I2C_ALL_PERIPH(I2Cx)); + assert_param(IS_I2C_CLEAR_IT(I2C_IT)); + /* Get the I2C flag position */ + flagpos = I2C_IT & FLAG_Mask; + /* Clear the selected I2C flag */ + I2Cx->SR1 = (uint16_t)~flagpos; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_iwdg.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_iwdg.c new file mode 100755 index 0000000..9d3b0e8 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_iwdg.c @@ -0,0 +1,190 @@ +/** + ****************************************************************************** + * @file stm32f10x_iwdg.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the IWDG firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_iwdg.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup IWDG + * @brief IWDG driver modules + * @{ + */ + +/** @defgroup IWDG_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup IWDG_Private_Defines + * @{ + */ + +/* ---------------------- IWDG registers bit mask ----------------------------*/ + +/* KR register bit mask */ +#define KR_KEY_Reload ((uint16_t)0xAAAA) +#define KR_KEY_Enable ((uint16_t)0xCCCC) + +/** + * @} + */ + +/** @defgroup IWDG_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup IWDG_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup IWDG_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup IWDG_Private_Functions + * @{ + */ + +/** + * @brief Enables or disables write access to IWDG_PR and IWDG_RLR registers. + * @param IWDG_WriteAccess: new state of write access to IWDG_PR and IWDG_RLR registers. + * This parameter can be one of the following values: + * @arg IWDG_WriteAccess_Enable: Enable write access to IWDG_PR and IWDG_RLR registers + * @arg IWDG_WriteAccess_Disable: Disable write access to IWDG_PR and IWDG_RLR registers + * @retval None + */ +void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess) +{ + /* Check the parameters */ + assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess)); + IWDG->KR = IWDG_WriteAccess; +} + +/** + * @brief Sets IWDG Prescaler value. + * @param IWDG_Prescaler: specifies the IWDG Prescaler value. + * This parameter can be one of the following values: + * @arg IWDG_Prescaler_4: IWDG prescaler set to 4 + * @arg IWDG_Prescaler_8: IWDG prescaler set to 8 + * @arg IWDG_Prescaler_16: IWDG prescaler set to 16 + * @arg IWDG_Prescaler_32: IWDG prescaler set to 32 + * @arg IWDG_Prescaler_64: IWDG prescaler set to 64 + * @arg IWDG_Prescaler_128: IWDG prescaler set to 128 + * @arg IWDG_Prescaler_256: IWDG prescaler set to 256 + * @retval None + */ +void IWDG_SetPrescaler(uint8_t IWDG_Prescaler) +{ + /* Check the parameters */ + assert_param(IS_IWDG_PRESCALER(IWDG_Prescaler)); + IWDG->PR = IWDG_Prescaler; +} + +/** + * @brief Sets IWDG Reload value. + * @param Reload: specifies the IWDG Reload value. + * This parameter must be a number between 0 and 0x0FFF. + * @retval None + */ +void IWDG_SetReload(uint16_t Reload) +{ + /* Check the parameters */ + assert_param(IS_IWDG_RELOAD(Reload)); + IWDG->RLR = Reload; +} + +/** + * @brief Reloads IWDG counter with value defined in the reload register + * (write access to IWDG_PR and IWDG_RLR registers disabled). + * @param None + * @retval None + */ +void IWDG_ReloadCounter(void) +{ + IWDG->KR = KR_KEY_Reload; +} + +/** + * @brief Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled). + * @param None + * @retval None + */ +void IWDG_Enable(void) +{ + IWDG->KR = KR_KEY_Enable; +} + +/** + * @brief Checks whether the specified IWDG flag is set or not. + * @param IWDG_FLAG: specifies the flag to check. + * This parameter can be one of the following values: + * @arg IWDG_FLAG_PVU: Prescaler Value Update on going + * @arg IWDG_FLAG_RVU: Reload Value Update on going + * @retval The new state of IWDG_FLAG (SET or RESET). + */ +FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG) +{ + FlagStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_IWDG_FLAG(IWDG_FLAG)); + if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + /* Return the flag status */ + return bitstatus; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_pwr.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_pwr.c new file mode 100755 index 0000000..147bf0f --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_pwr.c @@ -0,0 +1,307 @@ +/** + ****************************************************************************** + * @file stm32f10x_pwr.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the PWR firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_pwr.h" +#include "stm32f10x_rcc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup PWR + * @brief PWR driver modules + * @{ + */ + +/** @defgroup PWR_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup PWR_Private_Defines + * @{ + */ + +/* --------- PWR registers bit address in the alias region ---------- */ +#define PWR_OFFSET (PWR_BASE - PERIPH_BASE) + +/* --- CR Register ---*/ + +/* Alias word address of DBP bit */ +#define CR_OFFSET (PWR_OFFSET + 0x00) +#define DBP_BitNumber 0x08 +#define CR_DBP_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (DBP_BitNumber * 4)) + +/* Alias word address of PVDE bit */ +#define PVDE_BitNumber 0x04 +#define CR_PVDE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PVDE_BitNumber * 4)) + +/* --- CSR Register ---*/ + +/* Alias word address of EWUP bit */ +#define CSR_OFFSET (PWR_OFFSET + 0x04) +#define EWUP_BitNumber 0x08 +#define CSR_EWUP_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (EWUP_BitNumber * 4)) + +/* ------------------ PWR registers bit mask ------------------------ */ + +/* CR register bit mask */ +#define CR_DS_MASK ((uint32_t)0xFFFFFFFC) +#define CR_PLS_MASK ((uint32_t)0xFFFFFF1F) + + +/** + * @} + */ + +/** @defgroup PWR_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup PWR_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup PWR_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup PWR_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the PWR peripheral registers to their default reset values. + * @param None + * @retval None + */ +void PWR_DeInit(void) +{ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, ENABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, DISABLE); +} + +/** + * @brief Enables or disables access to the RTC and backup registers. + * @param NewState: new state of the access to the RTC and backup registers. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void PWR_BackupAccessCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + *(__IO uint32_t *) CR_DBP_BB = (uint32_t)NewState; +} + +/** + * @brief Enables or disables the Power Voltage Detector(PVD). + * @param NewState: new state of the PVD. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void PWR_PVDCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)NewState; +} + +/** + * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD). + * @param PWR_PVDLevel: specifies the PVD detection level + * This parameter can be one of the following values: + * @arg PWR_PVDLevel_2V2: PVD detection level set to 2.2V + * @arg PWR_PVDLevel_2V3: PVD detection level set to 2.3V + * @arg PWR_PVDLevel_2V4: PVD detection level set to 2.4V + * @arg PWR_PVDLevel_2V5: PVD detection level set to 2.5V + * @arg PWR_PVDLevel_2V6: PVD detection level set to 2.6V + * @arg PWR_PVDLevel_2V7: PVD detection level set to 2.7V + * @arg PWR_PVDLevel_2V8: PVD detection level set to 2.8V + * @arg PWR_PVDLevel_2V9: PVD detection level set to 2.9V + * @retval None + */ +void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel) +{ + uint32_t tmpreg = 0; + /* Check the parameters */ + assert_param(IS_PWR_PVD_LEVEL(PWR_PVDLevel)); + tmpreg = PWR->CR; + /* Clear PLS[7:5] bits */ + tmpreg &= CR_PLS_MASK; + /* Set PLS[7:5] bits according to PWR_PVDLevel value */ + tmpreg |= PWR_PVDLevel; + /* Store the new value */ + PWR->CR = tmpreg; +} + +/** + * @brief Enables or disables the WakeUp Pin functionality. + * @param NewState: new state of the WakeUp Pin functionality. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void PWR_WakeUpPinCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + *(__IO uint32_t *) CSR_EWUP_BB = (uint32_t)NewState; +} + +/** + * @brief Enters STOP mode. + * @param PWR_Regulator: specifies the regulator state in STOP mode. + * This parameter can be one of the following values: + * @arg PWR_Regulator_ON: STOP mode with regulator ON + * @arg PWR_Regulator_LowPower: STOP mode with regulator in low power mode + * @param PWR_STOPEntry: specifies if STOP mode in entered with WFI or WFE instruction. + * This parameter can be one of the following values: + * @arg PWR_STOPEntry_WFI: enter STOP mode with WFI instruction + * @arg PWR_STOPEntry_WFE: enter STOP mode with WFE instruction + * @retval None + */ +void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry) +{ + uint32_t tmpreg = 0; + /* Check the parameters */ + assert_param(IS_PWR_REGULATOR(PWR_Regulator)); + assert_param(IS_PWR_STOP_ENTRY(PWR_STOPEntry)); + + /* Select the regulator state in STOP mode ---------------------------------*/ + tmpreg = PWR->CR; + /* Clear PDDS and LPDS bits */ + tmpreg &= CR_DS_MASK; + /* Set LPDS bit according to PWR_Regulator value */ + tmpreg |= PWR_Regulator; + /* Store the new value */ + PWR->CR = tmpreg; + /* Set SLEEPDEEP bit of Cortex System Control Register */ + SCB->SCR |= SCB_SCR_SLEEPDEEP; + + /* Select STOP mode entry --------------------------------------------------*/ + if(PWR_STOPEntry == PWR_STOPEntry_WFI) + { + /* Request Wait For Interrupt */ + __WFI(); + } + else + { + /* Request Wait For Event */ + __WFE(); + } + + /* Reset SLEEPDEEP bit of Cortex System Control Register */ + SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP); +} + +/** + * @brief Enters STANDBY mode. + * @param None + * @retval None + */ +void PWR_EnterSTANDBYMode(void) +{ + /* Clear Wake-up flag */ + PWR->CR |= PWR_CR_CWUF; + /* Select STANDBY mode */ + PWR->CR |= PWR_CR_PDDS; + /* Set SLEEPDEEP bit of Cortex System Control Register */ + SCB->SCR |= SCB_SCR_SLEEPDEEP; +/* This option is used to ensure that store operations are completed */ +#if defined ( __CC_ARM ) + __force_stores(); +#endif + /* Request Wait For Interrupt */ + __WFI(); +} + +/** + * @brief Checks whether the specified PWR flag is set or not. + * @param PWR_FLAG: specifies the flag to check. + * This parameter can be one of the following values: + * @arg PWR_FLAG_WU: Wake Up flag + * @arg PWR_FLAG_SB: StandBy flag + * @arg PWR_FLAG_PVDO: PVD Output + * @retval The new state of PWR_FLAG (SET or RESET). + */ +FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG) +{ + FlagStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_PWR_GET_FLAG(PWR_FLAG)); + + if ((PWR->CSR & PWR_FLAG) != (uint32_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + /* Return the flag status */ + return bitstatus; +} + +/** + * @brief Clears the PWR's pending flags. + * @param PWR_FLAG: specifies the flag to clear. + * This parameter can be one of the following values: + * @arg PWR_FLAG_WU: Wake Up flag + * @arg PWR_FLAG_SB: StandBy flag + * @retval None + */ +void PWR_ClearFlag(uint32_t PWR_FLAG) +{ + /* Check the parameters */ + assert_param(IS_PWR_CLEAR_FLAG(PWR_FLAG)); + + PWR->CR |= PWR_FLAG << 2; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_rcc.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_rcc.c new file mode 100755 index 0000000..4b2ec1f --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_rcc.c @@ -0,0 +1,1470 @@ +/** + ****************************************************************************** + * @file stm32f10x_rcc.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the RCC firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_rcc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup RCC + * @brief RCC driver modules + * @{ + */ + +/** @defgroup RCC_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup RCC_Private_Defines + * @{ + */ + +/* ------------ RCC registers bit address in the alias region ----------- */ +#define RCC_OFFSET (RCC_BASE - PERIPH_BASE) + +/* --- CR Register ---*/ + +/* Alias word address of HSION bit */ +#define CR_OFFSET (RCC_OFFSET + 0x00) +#define HSION_BitNumber 0x00 +#define CR_HSION_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (HSION_BitNumber * 4)) + +/* Alias word address of PLLON bit */ +#define PLLON_BitNumber 0x18 +#define CR_PLLON_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PLLON_BitNumber * 4)) + +#ifdef STM32F10X_CL + /* Alias word address of PLL2ON bit */ + #define PLL2ON_BitNumber 0x1A + #define CR_PLL2ON_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PLL2ON_BitNumber * 4)) + + /* Alias word address of PLL3ON bit */ + #define PLL3ON_BitNumber 0x1C + #define CR_PLL3ON_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PLL3ON_BitNumber * 4)) +#endif /* STM32F10X_CL */ + +/* Alias word address of CSSON bit */ +#define CSSON_BitNumber 0x13 +#define CR_CSSON_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (CSSON_BitNumber * 4)) + +/* --- CFGR Register ---*/ + +/* Alias word address of USBPRE bit */ +#define CFGR_OFFSET (RCC_OFFSET + 0x04) + +#ifndef STM32F10X_CL + #define USBPRE_BitNumber 0x16 + #define CFGR_USBPRE_BB (PERIPH_BB_BASE + (CFGR_OFFSET * 32) + (USBPRE_BitNumber * 4)) +#else + #define OTGFSPRE_BitNumber 0x16 + #define CFGR_OTGFSPRE_BB (PERIPH_BB_BASE + (CFGR_OFFSET * 32) + (OTGFSPRE_BitNumber * 4)) +#endif /* STM32F10X_CL */ + +/* --- BDCR Register ---*/ + +/* Alias word address of RTCEN bit */ +#define BDCR_OFFSET (RCC_OFFSET + 0x20) +#define RTCEN_BitNumber 0x0F +#define BDCR_RTCEN_BB (PERIPH_BB_BASE + (BDCR_OFFSET * 32) + (RTCEN_BitNumber * 4)) + +/* Alias word address of BDRST bit */ +#define BDRST_BitNumber 0x10 +#define BDCR_BDRST_BB (PERIPH_BB_BASE + (BDCR_OFFSET * 32) + (BDRST_BitNumber * 4)) + +/* --- CSR Register ---*/ + +/* Alias word address of LSION bit */ +#define CSR_OFFSET (RCC_OFFSET + 0x24) +#define LSION_BitNumber 0x00 +#define CSR_LSION_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (LSION_BitNumber * 4)) + +#ifdef STM32F10X_CL +/* --- CFGR2 Register ---*/ + + /* Alias word address of I2S2SRC bit */ + #define CFGR2_OFFSET (RCC_OFFSET + 0x2C) + #define I2S2SRC_BitNumber 0x11 + #define CFGR2_I2S2SRC_BB (PERIPH_BB_BASE + (CFGR2_OFFSET * 32) + (I2S2SRC_BitNumber * 4)) + + /* Alias word address of I2S3SRC bit */ + #define I2S3SRC_BitNumber 0x12 + #define CFGR2_I2S3SRC_BB (PERIPH_BB_BASE + (CFGR2_OFFSET * 32) + (I2S3SRC_BitNumber * 4)) +#endif /* STM32F10X_CL */ + +/* ---------------------- RCC registers bit mask ------------------------ */ + +/* CR register bit mask */ +#define CR_HSEBYP_Reset ((uint32_t)0xFFFBFFFF) +#define CR_HSEBYP_Set ((uint32_t)0x00040000) +#define CR_HSEON_Reset ((uint32_t)0xFFFEFFFF) +#define CR_HSEON_Set ((uint32_t)0x00010000) +#define CR_HSITRIM_Mask ((uint32_t)0xFFFFFF07) + +/* CFGR register bit mask */ +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) || defined (STM32F10X_CL) + #define CFGR_PLL_Mask ((uint32_t)0xFFC2FFFF) +#else + #define CFGR_PLL_Mask ((uint32_t)0xFFC0FFFF) +#endif /* STM32F10X_CL */ + +#define CFGR_PLLMull_Mask ((uint32_t)0x003C0000) +#define CFGR_PLLSRC_Mask ((uint32_t)0x00010000) +#define CFGR_PLLXTPRE_Mask ((uint32_t)0x00020000) +#define CFGR_SWS_Mask ((uint32_t)0x0000000C) +#define CFGR_SW_Mask ((uint32_t)0xFFFFFFFC) +#define CFGR_HPRE_Reset_Mask ((uint32_t)0xFFFFFF0F) +#define CFGR_HPRE_Set_Mask ((uint32_t)0x000000F0) +#define CFGR_PPRE1_Reset_Mask ((uint32_t)0xFFFFF8FF) +#define CFGR_PPRE1_Set_Mask ((uint32_t)0x00000700) +#define CFGR_PPRE2_Reset_Mask ((uint32_t)0xFFFFC7FF) +#define CFGR_PPRE2_Set_Mask ((uint32_t)0x00003800) +#define CFGR_ADCPRE_Reset_Mask ((uint32_t)0xFFFF3FFF) +#define CFGR_ADCPRE_Set_Mask ((uint32_t)0x0000C000) + +/* CSR register bit mask */ +#define CSR_RMVF_Set ((uint32_t)0x01000000) + +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) || defined (STM32F10X_CL) +/* CFGR2 register bit mask */ + #define CFGR2_PREDIV1SRC ((uint32_t)0x00010000) + #define CFGR2_PREDIV1 ((uint32_t)0x0000000F) +#endif +#ifdef STM32F10X_CL + #define CFGR2_PREDIV2 ((uint32_t)0x000000F0) + #define CFGR2_PLL2MUL ((uint32_t)0x00000F00) + #define CFGR2_PLL3MUL ((uint32_t)0x0000F000) +#endif /* STM32F10X_CL */ + +/* RCC Flag Mask */ +#define FLAG_Mask ((uint8_t)0x1F) + +/* CIR register byte 2 (Bits[15:8]) base address */ +#define CIR_BYTE2_ADDRESS ((uint32_t)0x40021009) + +/* CIR register byte 3 (Bits[23:16]) base address */ +#define CIR_BYTE3_ADDRESS ((uint32_t)0x4002100A) + +/* CFGR register byte 4 (Bits[31:24]) base address */ +#define CFGR_BYTE4_ADDRESS ((uint32_t)0x40021007) + +/* BDCR register base address */ +#define BDCR_ADDRESS (PERIPH_BASE + BDCR_OFFSET) + +/** + * @} + */ + +/** @defgroup RCC_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup RCC_Private_Variables + * @{ + */ + +static __I uint8_t APBAHBPrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9}; +static __I uint8_t ADCPrescTable[4] = {2, 4, 6, 8}; + +/** + * @} + */ + +/** @defgroup RCC_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup RCC_Private_Functions + * @{ + */ + +/** + * @brief Resets the RCC clock configuration to the default reset state. + * @param None + * @retval None + */ +void RCC_DeInit(void) +{ + /* Set HSION bit */ + RCC->CR |= (uint32_t)0x00000001; + + /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ +#ifndef STM32F10X_CL + RCC->CFGR &= (uint32_t)0xF8FF0000; +#else + RCC->CFGR &= (uint32_t)0xF0FF0000; +#endif /* STM32F10X_CL */ + + /* Reset HSEON, CSSON and PLLON bits */ + RCC->CR &= (uint32_t)0xFEF6FFFF; + + /* Reset HSEBYP bit */ + RCC->CR &= (uint32_t)0xFFFBFFFF; + + /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ + RCC->CFGR &= (uint32_t)0xFF80FFFF; + +#ifdef STM32F10X_CL + /* Reset PLL2ON and PLL3ON bits */ + RCC->CR &= (uint32_t)0xEBFFFFFF; + + /* Disable all interrupts and clear pending bits */ + RCC->CIR = 0x00FF0000; + + /* Reset CFGR2 register */ + RCC->CFGR2 = 0x00000000; +#elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) + /* Disable all interrupts and clear pending bits */ + RCC->CIR = 0x009F0000; + + /* Reset CFGR2 register */ + RCC->CFGR2 = 0x00000000; +#else + /* Disable all interrupts and clear pending bits */ + RCC->CIR = 0x009F0000; +#endif /* STM32F10X_CL */ + +} + +/** + * @brief Configures the External High Speed oscillator (HSE). + * @note HSE can not be stopped if it is used directly or through the PLL as system clock. + * @param RCC_HSE: specifies the new state of the HSE. + * This parameter can be one of the following values: + * @arg RCC_HSE_OFF: HSE oscillator OFF + * @arg RCC_HSE_ON: HSE oscillator ON + * @arg RCC_HSE_Bypass: HSE oscillator bypassed with external clock + * @retval None + */ +void RCC_HSEConfig(uint32_t RCC_HSE) +{ + /* Check the parameters */ + assert_param(IS_RCC_HSE(RCC_HSE)); + /* Reset HSEON and HSEBYP bits before configuring the HSE ------------------*/ + /* Reset HSEON bit */ + RCC->CR &= CR_HSEON_Reset; + /* Reset HSEBYP bit */ + RCC->CR &= CR_HSEBYP_Reset; + /* Configure HSE (RCC_HSE_OFF is already covered by the code section above) */ + switch(RCC_HSE) + { + case RCC_HSE_ON: + /* Set HSEON bit */ + RCC->CR |= CR_HSEON_Set; + break; + + case RCC_HSE_Bypass: + /* Set HSEBYP and HSEON bits */ + RCC->CR |= CR_HSEBYP_Set | CR_HSEON_Set; + break; + + default: + break; + } +} + +/** + * @brief Waits for HSE start-up. + * @param None + * @retval An ErrorStatus enumuration value: + * - SUCCESS: HSE oscillator is stable and ready to use + * - ERROR: HSE oscillator not yet ready + */ +ErrorStatus RCC_WaitForHSEStartUp(void) +{ + __IO uint32_t StartUpCounter = 0; + ErrorStatus status = ERROR; + FlagStatus HSEStatus = RESET; + + /* Wait till HSE is ready and if Time out is reached exit */ + do + { + HSEStatus = RCC_GetFlagStatus(RCC_FLAG_HSERDY); + StartUpCounter++; + } while((StartUpCounter != HSE_STARTUP_TIMEOUT) && (HSEStatus == RESET)); + + if (RCC_GetFlagStatus(RCC_FLAG_HSERDY) != RESET) + { + status = SUCCESS; + } + else + { + status = ERROR; + } + return (status); +} + +/** + * @brief Adjusts the Internal High Speed oscillator (HSI) calibration value. + * @param HSICalibrationValue: specifies the calibration trimming value. + * This parameter must be a number between 0 and 0x1F. + * @retval None + */ +void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue) +{ + uint32_t tmpreg = 0; + /* Check the parameters */ + assert_param(IS_RCC_CALIBRATION_VALUE(HSICalibrationValue)); + tmpreg = RCC->CR; + /* Clear HSITRIM[4:0] bits */ + tmpreg &= CR_HSITRIM_Mask; + /* Set the HSITRIM[4:0] bits according to HSICalibrationValue value */ + tmpreg |= (uint32_t)HSICalibrationValue << 3; + /* Store the new value */ + RCC->CR = tmpreg; +} + +/** + * @brief Enables or disables the Internal High Speed oscillator (HSI). + * @note HSI can not be stopped if it is used directly or through the PLL as system clock. + * @param NewState: new state of the HSI. This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RCC_HSICmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + *(__IO uint32_t *) CR_HSION_BB = (uint32_t)NewState; +} + +/** + * @brief Configures the PLL clock source and multiplication factor. + * @note This function must be used only when the PLL is disabled. + * @param RCC_PLLSource: specifies the PLL entry clock source. + * For @b STM32_Connectivity_line_devices or @b STM32_Value_line_devices, + * this parameter can be one of the following values: + * @arg RCC_PLLSource_HSI_Div2: HSI oscillator clock divided by 2 selected as PLL clock entry + * @arg RCC_PLLSource_PREDIV1: PREDIV1 clock selected as PLL clock entry + * For @b other_STM32_devices, this parameter can be one of the following values: + * @arg RCC_PLLSource_HSI_Div2: HSI oscillator clock divided by 2 selected as PLL clock entry + * @arg RCC_PLLSource_HSE_Div1: HSE oscillator clock selected as PLL clock entry + * @arg RCC_PLLSource_HSE_Div2: HSE oscillator clock divided by 2 selected as PLL clock entry + * @param RCC_PLLMul: specifies the PLL multiplication factor. + * For @b STM32_Connectivity_line_devices, this parameter can be RCC_PLLMul_x where x:{[4,9], 6_5} + * For @b other_STM32_devices, this parameter can be RCC_PLLMul_x where x:[2,16] + * @retval None + */ +void RCC_PLLConfig(uint32_t RCC_PLLSource, uint32_t RCC_PLLMul) +{ + uint32_t tmpreg = 0; + + /* Check the parameters */ + assert_param(IS_RCC_PLL_SOURCE(RCC_PLLSource)); + assert_param(IS_RCC_PLL_MUL(RCC_PLLMul)); + + tmpreg = RCC->CFGR; + /* Clear PLLSRC, PLLXTPRE and PLLMUL[3:0] bits */ + tmpreg &= CFGR_PLL_Mask; + /* Set the PLL configuration bits */ + tmpreg |= RCC_PLLSource | RCC_PLLMul; + /* Store the new value */ + RCC->CFGR = tmpreg; +} + +/** + * @brief Enables or disables the PLL. + * @note The PLL can not be disabled if it is used as system clock. + * @param NewState: new state of the PLL. This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RCC_PLLCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + *(__IO uint32_t *) CR_PLLON_BB = (uint32_t)NewState; +} + +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) || defined (STM32F10X_CL) +/** + * @brief Configures the PREDIV1 division factor. + * @note + * - This function must be used only when the PLL is disabled. + * - This function applies only to STM32 Connectivity line and Value line + * devices. + * @param RCC_PREDIV1_Source: specifies the PREDIV1 clock source. + * This parameter can be one of the following values: + * @arg RCC_PREDIV1_Source_HSE: HSE selected as PREDIV1 clock + * @arg RCC_PREDIV1_Source_PLL2: PLL2 selected as PREDIV1 clock + * @note + * For @b STM32_Value_line_devices this parameter is always RCC_PREDIV1_Source_HSE + * @param RCC_PREDIV1_Div: specifies the PREDIV1 clock division factor. + * This parameter can be RCC_PREDIV1_Divx where x:[1,16] + * @retval None + */ +void RCC_PREDIV1Config(uint32_t RCC_PREDIV1_Source, uint32_t RCC_PREDIV1_Div) +{ + uint32_t tmpreg = 0; + + /* Check the parameters */ + assert_param(IS_RCC_PREDIV1_SOURCE(RCC_PREDIV1_Source)); + assert_param(IS_RCC_PREDIV1(RCC_PREDIV1_Div)); + + tmpreg = RCC->CFGR2; + /* Clear PREDIV1[3:0] and PREDIV1SRC bits */ + tmpreg &= ~(CFGR2_PREDIV1 | CFGR2_PREDIV1SRC); + /* Set the PREDIV1 clock source and division factor */ + tmpreg |= RCC_PREDIV1_Source | RCC_PREDIV1_Div ; + /* Store the new value */ + RCC->CFGR2 = tmpreg; +} +#endif + +#ifdef STM32F10X_CL +/** + * @brief Configures the PREDIV2 division factor. + * @note + * - This function must be used only when both PLL2 and PLL3 are disabled. + * - This function applies only to STM32 Connectivity line devices. + * @param RCC_PREDIV2_Div: specifies the PREDIV2 clock division factor. + * This parameter can be RCC_PREDIV2_Divx where x:[1,16] + * @retval None + */ +void RCC_PREDIV2Config(uint32_t RCC_PREDIV2_Div) +{ + uint32_t tmpreg = 0; + + /* Check the parameters */ + assert_param(IS_RCC_PREDIV2(RCC_PREDIV2_Div)); + + tmpreg = RCC->CFGR2; + /* Clear PREDIV2[3:0] bits */ + tmpreg &= ~CFGR2_PREDIV2; + /* Set the PREDIV2 division factor */ + tmpreg |= RCC_PREDIV2_Div; + /* Store the new value */ + RCC->CFGR2 = tmpreg; +} + +/** + * @brief Configures the PLL2 multiplication factor. + * @note + * - This function must be used only when the PLL2 is disabled. + * - This function applies only to STM32 Connectivity line devices. + * @param RCC_PLL2Mul: specifies the PLL2 multiplication factor. + * This parameter can be RCC_PLL2Mul_x where x:{[8,14], 16, 20} + * @retval None + */ +void RCC_PLL2Config(uint32_t RCC_PLL2Mul) +{ + uint32_t tmpreg = 0; + + /* Check the parameters */ + assert_param(IS_RCC_PLL2_MUL(RCC_PLL2Mul)); + + tmpreg = RCC->CFGR2; + /* Clear PLL2Mul[3:0] bits */ + tmpreg &= ~CFGR2_PLL2MUL; + /* Set the PLL2 configuration bits */ + tmpreg |= RCC_PLL2Mul; + /* Store the new value */ + RCC->CFGR2 = tmpreg; +} + + +/** + * @brief Enables or disables the PLL2. + * @note + * - The PLL2 can not be disabled if it is used indirectly as system clock + * (i.e. it is used as PLL clock entry that is used as System clock). + * - This function applies only to STM32 Connectivity line devices. + * @param NewState: new state of the PLL2. This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RCC_PLL2Cmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + *(__IO uint32_t *) CR_PLL2ON_BB = (uint32_t)NewState; +} + + +/** + * @brief Configures the PLL3 multiplication factor. + * @note + * - This function must be used only when the PLL3 is disabled. + * - This function applies only to STM32 Connectivity line devices. + * @param RCC_PLL3Mul: specifies the PLL3 multiplication factor. + * This parameter can be RCC_PLL3Mul_x where x:{[8,14], 16, 20} + * @retval None + */ +void RCC_PLL3Config(uint32_t RCC_PLL3Mul) +{ + uint32_t tmpreg = 0; + + /* Check the parameters */ + assert_param(IS_RCC_PLL3_MUL(RCC_PLL3Mul)); + + tmpreg = RCC->CFGR2; + /* Clear PLL3Mul[3:0] bits */ + tmpreg &= ~CFGR2_PLL3MUL; + /* Set the PLL3 configuration bits */ + tmpreg |= RCC_PLL3Mul; + /* Store the new value */ + RCC->CFGR2 = tmpreg; +} + + +/** + * @brief Enables or disables the PLL3. + * @note This function applies only to STM32 Connectivity line devices. + * @param NewState: new state of the PLL3. This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RCC_PLL3Cmd(FunctionalState NewState) +{ + /* Check the parameters */ + + assert_param(IS_FUNCTIONAL_STATE(NewState)); + *(__IO uint32_t *) CR_PLL3ON_BB = (uint32_t)NewState; +} +#endif /* STM32F10X_CL */ + +/** + * @brief Configures the system clock (SYSCLK). + * @param RCC_SYSCLKSource: specifies the clock source used as system clock. + * This parameter can be one of the following values: + * @arg RCC_SYSCLKSource_HSI: HSI selected as system clock + * @arg RCC_SYSCLKSource_HSE: HSE selected as system clock + * @arg RCC_SYSCLKSource_PLLCLK: PLL selected as system clock + * @retval None + */ +void RCC_SYSCLKConfig(uint32_t RCC_SYSCLKSource) +{ + uint32_t tmpreg = 0; + /* Check the parameters */ + assert_param(IS_RCC_SYSCLK_SOURCE(RCC_SYSCLKSource)); + tmpreg = RCC->CFGR; + /* Clear SW[1:0] bits */ + tmpreg &= CFGR_SW_Mask; + /* Set SW[1:0] bits according to RCC_SYSCLKSource value */ + tmpreg |= RCC_SYSCLKSource; + /* Store the new value */ + RCC->CFGR = tmpreg; +} + +/** + * @brief Returns the clock source used as system clock. + * @param None + * @retval The clock source used as system clock. The returned value can + * be one of the following: + * - 0x00: HSI used as system clock + * - 0x04: HSE used as system clock + * - 0x08: PLL used as system clock + */ +uint8_t RCC_GetSYSCLKSource(void) +{ + return ((uint8_t)(RCC->CFGR & CFGR_SWS_Mask)); +} + +/** + * @brief Configures the AHB clock (HCLK). + * @param RCC_SYSCLK: defines the AHB clock divider. This clock is derived from + * the system clock (SYSCLK). + * This parameter can be one of the following values: + * @arg RCC_SYSCLK_Div1: AHB clock = SYSCLK + * @arg RCC_SYSCLK_Div2: AHB clock = SYSCLK/2 + * @arg RCC_SYSCLK_Div4: AHB clock = SYSCLK/4 + * @arg RCC_SYSCLK_Div8: AHB clock = SYSCLK/8 + * @arg RCC_SYSCLK_Div16: AHB clock = SYSCLK/16 + * @arg RCC_SYSCLK_Div64: AHB clock = SYSCLK/64 + * @arg RCC_SYSCLK_Div128: AHB clock = SYSCLK/128 + * @arg RCC_SYSCLK_Div256: AHB clock = SYSCLK/256 + * @arg RCC_SYSCLK_Div512: AHB clock = SYSCLK/512 + * @retval None + */ +void RCC_HCLKConfig(uint32_t RCC_SYSCLK) +{ + uint32_t tmpreg = 0; + /* Check the parameters */ + assert_param(IS_RCC_HCLK(RCC_SYSCLK)); + tmpreg = RCC->CFGR; + /* Clear HPRE[3:0] bits */ + tmpreg &= CFGR_HPRE_Reset_Mask; + /* Set HPRE[3:0] bits according to RCC_SYSCLK value */ + tmpreg |= RCC_SYSCLK; + /* Store the new value */ + RCC->CFGR = tmpreg; +} + +/** + * @brief Configures the Low Speed APB clock (PCLK1). + * @param RCC_HCLK: defines the APB1 clock divider. This clock is derived from + * the AHB clock (HCLK). + * This parameter can be one of the following values: + * @arg RCC_HCLK_Div1: APB1 clock = HCLK + * @arg RCC_HCLK_Div2: APB1 clock = HCLK/2 + * @arg RCC_HCLK_Div4: APB1 clock = HCLK/4 + * @arg RCC_HCLK_Div8: APB1 clock = HCLK/8 + * @arg RCC_HCLK_Div16: APB1 clock = HCLK/16 + * @retval None + */ +void RCC_PCLK1Config(uint32_t RCC_HCLK) +{ + uint32_t tmpreg = 0; + /* Check the parameters */ + assert_param(IS_RCC_PCLK(RCC_HCLK)); + tmpreg = RCC->CFGR; + /* Clear PPRE1[2:0] bits */ + tmpreg &= CFGR_PPRE1_Reset_Mask; + /* Set PPRE1[2:0] bits according to RCC_HCLK value */ + tmpreg |= RCC_HCLK; + /* Store the new value */ + RCC->CFGR = tmpreg; +} + +/** + * @brief Configures the High Speed APB clock (PCLK2). + * @param RCC_HCLK: defines the APB2 clock divider. This clock is derived from + * the AHB clock (HCLK). + * This parameter can be one of the following values: + * @arg RCC_HCLK_Div1: APB2 clock = HCLK + * @arg RCC_HCLK_Div2: APB2 clock = HCLK/2 + * @arg RCC_HCLK_Div4: APB2 clock = HCLK/4 + * @arg RCC_HCLK_Div8: APB2 clock = HCLK/8 + * @arg RCC_HCLK_Div16: APB2 clock = HCLK/16 + * @retval None + */ +void RCC_PCLK2Config(uint32_t RCC_HCLK) +{ + uint32_t tmpreg = 0; + /* Check the parameters */ + assert_param(IS_RCC_PCLK(RCC_HCLK)); + tmpreg = RCC->CFGR; + /* Clear PPRE2[2:0] bits */ + tmpreg &= CFGR_PPRE2_Reset_Mask; + /* Set PPRE2[2:0] bits according to RCC_HCLK value */ + tmpreg |= RCC_HCLK << 3; + /* Store the new value */ + RCC->CFGR = tmpreg; +} + +/** + * @brief Enables or disables the specified RCC interrupts. + * @param RCC_IT: specifies the RCC interrupt sources to be enabled or disabled. + * + * For @b STM32_Connectivity_line_devices, this parameter can be any combination + * of the following values + * @arg RCC_IT_LSIRDY: LSI ready interrupt + * @arg RCC_IT_LSERDY: LSE ready interrupt + * @arg RCC_IT_HSIRDY: HSI ready interrupt + * @arg RCC_IT_HSERDY: HSE ready interrupt + * @arg RCC_IT_PLLRDY: PLL ready interrupt + * @arg RCC_IT_PLL2RDY: PLL2 ready interrupt + * @arg RCC_IT_PLL3RDY: PLL3 ready interrupt + * + * For @b other_STM32_devices, this parameter can be any combination of the + * following values + * @arg RCC_IT_LSIRDY: LSI ready interrupt + * @arg RCC_IT_LSERDY: LSE ready interrupt + * @arg RCC_IT_HSIRDY: HSI ready interrupt + * @arg RCC_IT_HSERDY: HSE ready interrupt + * @arg RCC_IT_PLLRDY: PLL ready interrupt + * + * @param NewState: new state of the specified RCC interrupts. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RCC_ITConfig(uint8_t RCC_IT, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_RCC_IT(RCC_IT)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Perform Byte access to RCC_CIR bits to enable the selected interrupts */ + *(__IO uint8_t *) CIR_BYTE2_ADDRESS |= RCC_IT; + } + else + { + /* Perform Byte access to RCC_CIR bits to disable the selected interrupts */ + *(__IO uint8_t *) CIR_BYTE2_ADDRESS &= (uint8_t)~RCC_IT; + } +} + +#ifndef STM32F10X_CL +/** + * @brief Configures the USB clock (USBCLK). + * @param RCC_USBCLKSource: specifies the USB clock source. This clock is + * derived from the PLL output. + * This parameter can be one of the following values: + * @arg RCC_USBCLKSource_PLLCLK_1Div5: PLL clock divided by 1,5 selected as USB + * clock source + * @arg RCC_USBCLKSource_PLLCLK_Div1: PLL clock selected as USB clock source + * @retval None + */ +void RCC_USBCLKConfig(uint32_t RCC_USBCLKSource) +{ + /* Check the parameters */ + assert_param(IS_RCC_USBCLK_SOURCE(RCC_USBCLKSource)); + + *(__IO uint32_t *) CFGR_USBPRE_BB = RCC_USBCLKSource; +} +#else +/** + * @brief Configures the USB OTG FS clock (OTGFSCLK). + * This function applies only to STM32 Connectivity line devices. + * @param RCC_OTGFSCLKSource: specifies the USB OTG FS clock source. + * This clock is derived from the PLL output. + * This parameter can be one of the following values: + * @arg RCC_OTGFSCLKSource_PLLVCO_Div3: PLL VCO clock divided by 2 selected as USB OTG FS clock source + * @arg RCC_OTGFSCLKSource_PLLVCO_Div2: PLL VCO clock divided by 2 selected as USB OTG FS clock source + * @retval None + */ +void RCC_OTGFSCLKConfig(uint32_t RCC_OTGFSCLKSource) +{ + /* Check the parameters */ + assert_param(IS_RCC_OTGFSCLK_SOURCE(RCC_OTGFSCLKSource)); + + *(__IO uint32_t *) CFGR_OTGFSPRE_BB = RCC_OTGFSCLKSource; +} +#endif /* STM32F10X_CL */ + +/** + * @brief Configures the ADC clock (ADCCLK). + * @param RCC_PCLK2: defines the ADC clock divider. This clock is derived from + * the APB2 clock (PCLK2). + * This parameter can be one of the following values: + * @arg RCC_PCLK2_Div2: ADC clock = PCLK2/2 + * @arg RCC_PCLK2_Div4: ADC clock = PCLK2/4 + * @arg RCC_PCLK2_Div6: ADC clock = PCLK2/6 + * @arg RCC_PCLK2_Div8: ADC clock = PCLK2/8 + * @retval None + */ +void RCC_ADCCLKConfig(uint32_t RCC_PCLK2) +{ + uint32_t tmpreg = 0; + /* Check the parameters */ + assert_param(IS_RCC_ADCCLK(RCC_PCLK2)); + tmpreg = RCC->CFGR; + /* Clear ADCPRE[1:0] bits */ + tmpreg &= CFGR_ADCPRE_Reset_Mask; + /* Set ADCPRE[1:0] bits according to RCC_PCLK2 value */ + tmpreg |= RCC_PCLK2; + /* Store the new value */ + RCC->CFGR = tmpreg; +} + +#ifdef STM32F10X_CL +/** + * @brief Configures the I2S2 clock source(I2S2CLK). + * @note + * - This function must be called before enabling I2S2 APB clock. + * - This function applies only to STM32 Connectivity line devices. + * @param RCC_I2S2CLKSource: specifies the I2S2 clock source. + * This parameter can be one of the following values: + * @arg RCC_I2S2CLKSource_SYSCLK: system clock selected as I2S2 clock entry + * @arg RCC_I2S2CLKSource_PLL3_VCO: PLL3 VCO clock selected as I2S2 clock entry + * @retval None + */ +void RCC_I2S2CLKConfig(uint32_t RCC_I2S2CLKSource) +{ + /* Check the parameters */ + assert_param(IS_RCC_I2S2CLK_SOURCE(RCC_I2S2CLKSource)); + + *(__IO uint32_t *) CFGR2_I2S2SRC_BB = RCC_I2S2CLKSource; +} + +/** + * @brief Configures the I2S3 clock source(I2S2CLK). + * @note + * - This function must be called before enabling I2S3 APB clock. + * - This function applies only to STM32 Connectivity line devices. + * @param RCC_I2S3CLKSource: specifies the I2S3 clock source. + * This parameter can be one of the following values: + * @arg RCC_I2S3CLKSource_SYSCLK: system clock selected as I2S3 clock entry + * @arg RCC_I2S3CLKSource_PLL3_VCO: PLL3 VCO clock selected as I2S3 clock entry + * @retval None + */ +void RCC_I2S3CLKConfig(uint32_t RCC_I2S3CLKSource) +{ + /* Check the parameters */ + assert_param(IS_RCC_I2S3CLK_SOURCE(RCC_I2S3CLKSource)); + + *(__IO uint32_t *) CFGR2_I2S3SRC_BB = RCC_I2S3CLKSource; +} +#endif /* STM32F10X_CL */ + +/** + * @brief Configures the External Low Speed oscillator (LSE). + * @param RCC_LSE: specifies the new state of the LSE. + * This parameter can be one of the following values: + * @arg RCC_LSE_OFF: LSE oscillator OFF + * @arg RCC_LSE_ON: LSE oscillator ON + * @arg RCC_LSE_Bypass: LSE oscillator bypassed with external clock + * @retval None + */ +void RCC_LSEConfig(uint8_t RCC_LSE) +{ + /* Check the parameters */ + assert_param(IS_RCC_LSE(RCC_LSE)); + /* Reset LSEON and LSEBYP bits before configuring the LSE ------------------*/ + /* Reset LSEON bit */ + *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_OFF; + /* Reset LSEBYP bit */ + *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_OFF; + /* Configure LSE (RCC_LSE_OFF is already covered by the code section above) */ + switch(RCC_LSE) + { + case RCC_LSE_ON: + /* Set LSEON bit */ + *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_ON; + break; + + case RCC_LSE_Bypass: + /* Set LSEBYP and LSEON bits */ + *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_Bypass | RCC_LSE_ON; + break; + + default: + break; + } +} + +/** + * @brief Enables or disables the Internal Low Speed oscillator (LSI). + * @note LSI can not be disabled if the IWDG is running. + * @param NewState: new state of the LSI. This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RCC_LSICmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + *(__IO uint32_t *) CSR_LSION_BB = (uint32_t)NewState; +} + +/** + * @brief Configures the RTC clock (RTCCLK). + * @note Once the RTC clock is selected it can't be changed unless the Backup domain is reset. + * @param RCC_RTCCLKSource: specifies the RTC clock source. + * This parameter can be one of the following values: + * @arg RCC_RTCCLKSource_LSE: LSE selected as RTC clock + * @arg RCC_RTCCLKSource_LSI: LSI selected as RTC clock + * @arg RCC_RTCCLKSource_HSE_Div128: HSE clock divided by 128 selected as RTC clock + * @retval None + */ +void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource) +{ + /* Check the parameters */ + assert_param(IS_RCC_RTCCLK_SOURCE(RCC_RTCCLKSource)); + /* Select the RTC clock source */ + RCC->BDCR |= RCC_RTCCLKSource; +} + +/** + * @brief Enables or disables the RTC clock. + * @note This function must be used only after the RTC clock was selected using the RCC_RTCCLKConfig function. + * @param NewState: new state of the RTC clock. This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RCC_RTCCLKCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + *(__IO uint32_t *) BDCR_RTCEN_BB = (uint32_t)NewState; +} + +/** + * @brief Returns the frequencies of different on chip clocks. + * @param RCC_Clocks: pointer to a RCC_ClocksTypeDef structure which will hold + * the clocks frequencies. + * @note The result of this function could be not correct when using + * fractional value for HSE crystal. + * @retval None + */ +void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks) +{ + uint32_t tmp = 0, pllmull = 0, pllsource = 0, presc = 0; + +#ifdef STM32F10X_CL + uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0; +#endif /* STM32F10X_CL */ + +#if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) + uint32_t prediv1factor = 0; +#endif + + /* Get SYSCLK source -------------------------------------------------------*/ + tmp = RCC->CFGR & CFGR_SWS_Mask; + + switch (tmp) + { + case 0x00: /* HSI used as system clock */ + RCC_Clocks->SYSCLK_Frequency = HSI_VALUE; + break; + case 0x04: /* HSE used as system clock */ + RCC_Clocks->SYSCLK_Frequency = HSE_VALUE; + break; + case 0x08: /* PLL used as system clock */ + + /* Get PLL clock source and multiplication factor ----------------------*/ + pllmull = RCC->CFGR & CFGR_PLLMull_Mask; + pllsource = RCC->CFGR & CFGR_PLLSRC_Mask; + +#ifndef STM32F10X_CL + pllmull = ( pllmull >> 18) + 2; + + if (pllsource == 0x00) + {/* HSI oscillator clock divided by 2 selected as PLL clock entry */ + RCC_Clocks->SYSCLK_Frequency = (HSI_VALUE >> 1) * pllmull; + } + else + { + #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) + prediv1factor = (RCC->CFGR2 & CFGR2_PREDIV1) + 1; + /* HSE oscillator clock selected as PREDIV1 clock entry */ + RCC_Clocks->SYSCLK_Frequency = (HSE_VALUE / prediv1factor) * pllmull; + #else + /* HSE selected as PLL clock entry */ + if ((RCC->CFGR & CFGR_PLLXTPRE_Mask) != (uint32_t)RESET) + {/* HSE oscillator clock divided by 2 */ + RCC_Clocks->SYSCLK_Frequency = (HSE_VALUE >> 1) * pllmull; + } + else + { + RCC_Clocks->SYSCLK_Frequency = HSE_VALUE * pllmull; + } + #endif + } +#else + pllmull = pllmull >> 18; + + if (pllmull != 0x0D) + { + pllmull += 2; + } + else + { /* PLL multiplication factor = PLL input clock * 6.5 */ + pllmull = 13 / 2; + } + + if (pllsource == 0x00) + {/* HSI oscillator clock divided by 2 selected as PLL clock entry */ + RCC_Clocks->SYSCLK_Frequency = (HSI_VALUE >> 1) * pllmull; + } + else + {/* PREDIV1 selected as PLL clock entry */ + + /* Get PREDIV1 clock source and division factor */ + prediv1source = RCC->CFGR2 & CFGR2_PREDIV1SRC; + prediv1factor = (RCC->CFGR2 & CFGR2_PREDIV1) + 1; + + if (prediv1source == 0) + { /* HSE oscillator clock selected as PREDIV1 clock entry */ + RCC_Clocks->SYSCLK_Frequency = (HSE_VALUE / prediv1factor) * pllmull; + } + else + {/* PLL2 clock selected as PREDIV1 clock entry */ + + /* Get PREDIV2 division factor and PLL2 multiplication factor */ + prediv2factor = ((RCC->CFGR2 & CFGR2_PREDIV2) >> 4) + 1; + pll2mull = ((RCC->CFGR2 & CFGR2_PLL2MUL) >> 8 ) + 2; + RCC_Clocks->SYSCLK_Frequency = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull; + } + } +#endif /* STM32F10X_CL */ + break; + + default: + RCC_Clocks->SYSCLK_Frequency = HSI_VALUE; + break; + } + + /* Compute HCLK, PCLK1, PCLK2 and ADCCLK clocks frequencies ----------------*/ + /* Get HCLK prescaler */ + tmp = RCC->CFGR & CFGR_HPRE_Set_Mask; + tmp = tmp >> 4; + presc = APBAHBPrescTable[tmp]; + /* HCLK clock frequency */ + RCC_Clocks->HCLK_Frequency = RCC_Clocks->SYSCLK_Frequency >> presc; + /* Get PCLK1 prescaler */ + tmp = RCC->CFGR & CFGR_PPRE1_Set_Mask; + tmp = tmp >> 8; + presc = APBAHBPrescTable[tmp]; + /* PCLK1 clock frequency */ + RCC_Clocks->PCLK1_Frequency = RCC_Clocks->HCLK_Frequency >> presc; + /* Get PCLK2 prescaler */ + tmp = RCC->CFGR & CFGR_PPRE2_Set_Mask; + tmp = tmp >> 11; + presc = APBAHBPrescTable[tmp]; + /* PCLK2 clock frequency */ + RCC_Clocks->PCLK2_Frequency = RCC_Clocks->HCLK_Frequency >> presc; + /* Get ADCCLK prescaler */ + tmp = RCC->CFGR & CFGR_ADCPRE_Set_Mask; + tmp = tmp >> 14; + presc = ADCPrescTable[tmp]; + /* ADCCLK clock frequency */ + RCC_Clocks->ADCCLK_Frequency = RCC_Clocks->PCLK2_Frequency / presc; +} + +/** + * @brief Enables or disables the AHB peripheral clock. + * @param RCC_AHBPeriph: specifies the AHB peripheral to gates its clock. + * + * For @b STM32_Connectivity_line_devices, this parameter can be any combination + * of the following values: + * @arg RCC_AHBPeriph_DMA1 + * @arg RCC_AHBPeriph_DMA2 + * @arg RCC_AHBPeriph_SRAM + * @arg RCC_AHBPeriph_FLITF + * @arg RCC_AHBPeriph_CRC + * @arg RCC_AHBPeriph_OTG_FS + * @arg RCC_AHBPeriph_ETH_MAC + * @arg RCC_AHBPeriph_ETH_MAC_Tx + * @arg RCC_AHBPeriph_ETH_MAC_Rx + * + * For @b other_STM32_devices, this parameter can be any combination of the + * following values: + * @arg RCC_AHBPeriph_DMA1 + * @arg RCC_AHBPeriph_DMA2 + * @arg RCC_AHBPeriph_SRAM + * @arg RCC_AHBPeriph_FLITF + * @arg RCC_AHBPeriph_CRC + * @arg RCC_AHBPeriph_FSMC + * @arg RCC_AHBPeriph_SDIO + * + * @note SRAM and FLITF clock can be disabled only during sleep mode. + * @param NewState: new state of the specified peripheral clock. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RCC_AHBPeriphClockCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_RCC_AHB_PERIPH(RCC_AHBPeriph)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + RCC->AHBENR |= RCC_AHBPeriph; + } + else + { + RCC->AHBENR &= ~RCC_AHBPeriph; + } +} + +/** + * @brief Enables or disables the High Speed APB (APB2) peripheral clock. + * @param RCC_APB2Periph: specifies the APB2 peripheral to gates its clock. + * This parameter can be any combination of the following values: + * @arg RCC_APB2Periph_AFIO, RCC_APB2Periph_GPIOA, RCC_APB2Periph_GPIOB, + * RCC_APB2Periph_GPIOC, RCC_APB2Periph_GPIOD, RCC_APB2Periph_GPIOE, + * RCC_APB2Periph_GPIOF, RCC_APB2Periph_GPIOG, RCC_APB2Periph_ADC1, + * RCC_APB2Periph_ADC2, RCC_APB2Periph_TIM1, RCC_APB2Periph_SPI1, + * RCC_APB2Periph_TIM8, RCC_APB2Periph_USART1, RCC_APB2Periph_ADC3, + * RCC_APB2Periph_TIM15, RCC_APB2Periph_TIM16, RCC_APB2Periph_TIM17, + * RCC_APB2Periph_TIM9, RCC_APB2Periph_TIM10, RCC_APB2Periph_TIM11 + * @param NewState: new state of the specified peripheral clock. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + RCC->APB2ENR |= RCC_APB2Periph; + } + else + { + RCC->APB2ENR &= ~RCC_APB2Periph; + } +} + +/** + * @brief Enables or disables the Low Speed APB (APB1) peripheral clock. + * @param RCC_APB1Periph: specifies the APB1 peripheral to gates its clock. + * This parameter can be any combination of the following values: + * @arg RCC_APB1Periph_TIM2, RCC_APB1Periph_TIM3, RCC_APB1Periph_TIM4, + * RCC_APB1Periph_TIM5, RCC_APB1Periph_TIM6, RCC_APB1Periph_TIM7, + * RCC_APB1Periph_WWDG, RCC_APB1Periph_SPI2, RCC_APB1Periph_SPI3, + * RCC_APB1Periph_USART2, RCC_APB1Periph_USART3, RCC_APB1Periph_USART4, + * RCC_APB1Periph_USART5, RCC_APB1Periph_I2C1, RCC_APB1Periph_I2C2, + * RCC_APB1Periph_USB, RCC_APB1Periph_CAN1, RCC_APB1Periph_BKP, + * RCC_APB1Periph_PWR, RCC_APB1Periph_DAC, RCC_APB1Periph_CEC, + * RCC_APB1Periph_TIM12, RCC_APB1Periph_TIM13, RCC_APB1Periph_TIM14 + * @param NewState: new state of the specified peripheral clock. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + RCC->APB1ENR |= RCC_APB1Periph; + } + else + { + RCC->APB1ENR &= ~RCC_APB1Periph; + } +} + +#ifdef STM32F10X_CL +/** + * @brief Forces or releases AHB peripheral reset. + * @note This function applies only to STM32 Connectivity line devices. + * @param RCC_AHBPeriph: specifies the AHB peripheral to reset. + * This parameter can be any combination of the following values: + * @arg RCC_AHBPeriph_OTG_FS + * @arg RCC_AHBPeriph_ETH_MAC + * @param NewState: new state of the specified peripheral reset. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RCC_AHBPeriphResetCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_RCC_AHB_PERIPH_RESET(RCC_AHBPeriph)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + RCC->AHBRSTR |= RCC_AHBPeriph; + } + else + { + RCC->AHBRSTR &= ~RCC_AHBPeriph; + } +} +#endif /* STM32F10X_CL */ + +/** + * @brief Forces or releases High Speed APB (APB2) peripheral reset. + * @param RCC_APB2Periph: specifies the APB2 peripheral to reset. + * This parameter can be any combination of the following values: + * @arg RCC_APB2Periph_AFIO, RCC_APB2Periph_GPIOA, RCC_APB2Periph_GPIOB, + * RCC_APB2Periph_GPIOC, RCC_APB2Periph_GPIOD, RCC_APB2Periph_GPIOE, + * RCC_APB2Periph_GPIOF, RCC_APB2Periph_GPIOG, RCC_APB2Periph_ADC1, + * RCC_APB2Periph_ADC2, RCC_APB2Periph_TIM1, RCC_APB2Periph_SPI1, + * RCC_APB2Periph_TIM8, RCC_APB2Periph_USART1, RCC_APB2Periph_ADC3, + * RCC_APB2Periph_TIM15, RCC_APB2Periph_TIM16, RCC_APB2Periph_TIM17, + * RCC_APB2Periph_TIM9, RCC_APB2Periph_TIM10, RCC_APB2Periph_TIM11 + * @param NewState: new state of the specified peripheral reset. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + RCC->APB2RSTR |= RCC_APB2Periph; + } + else + { + RCC->APB2RSTR &= ~RCC_APB2Periph; + } +} + +/** + * @brief Forces or releases Low Speed APB (APB1) peripheral reset. + * @param RCC_APB1Periph: specifies the APB1 peripheral to reset. + * This parameter can be any combination of the following values: + * @arg RCC_APB1Periph_TIM2, RCC_APB1Periph_TIM3, RCC_APB1Periph_TIM4, + * RCC_APB1Periph_TIM5, RCC_APB1Periph_TIM6, RCC_APB1Periph_TIM7, + * RCC_APB1Periph_WWDG, RCC_APB1Periph_SPI2, RCC_APB1Periph_SPI3, + * RCC_APB1Periph_USART2, RCC_APB1Periph_USART3, RCC_APB1Periph_USART4, + * RCC_APB1Periph_USART5, RCC_APB1Periph_I2C1, RCC_APB1Periph_I2C2, + * RCC_APB1Periph_USB, RCC_APB1Periph_CAN1, RCC_APB1Periph_BKP, + * RCC_APB1Periph_PWR, RCC_APB1Periph_DAC, RCC_APB1Periph_CEC, + * RCC_APB1Periph_TIM12, RCC_APB1Periph_TIM13, RCC_APB1Periph_TIM14 + * @param NewState: new state of the specified peripheral clock. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + RCC->APB1RSTR |= RCC_APB1Periph; + } + else + { + RCC->APB1RSTR &= ~RCC_APB1Periph; + } +} + +/** + * @brief Forces or releases the Backup domain reset. + * @param NewState: new state of the Backup domain reset. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RCC_BackupResetCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + *(__IO uint32_t *) BDCR_BDRST_BB = (uint32_t)NewState; +} + +/** + * @brief Enables or disables the Clock Security System. + * @param NewState: new state of the Clock Security System.. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RCC_ClockSecuritySystemCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + *(__IO uint32_t *) CR_CSSON_BB = (uint32_t)NewState; +} + +/** + * @brief Selects the clock source to output on MCO pin. + * @param RCC_MCO: specifies the clock source to output. + * + * For @b STM32_Connectivity_line_devices, this parameter can be one of the + * following values: + * @arg RCC_MCO_NoClock: No clock selected + * @arg RCC_MCO_SYSCLK: System clock selected + * @arg RCC_MCO_HSI: HSI oscillator clock selected + * @arg RCC_MCO_HSE: HSE oscillator clock selected + * @arg RCC_MCO_PLLCLK_Div2: PLL clock divided by 2 selected + * @arg RCC_MCO_PLL2CLK: PLL2 clock selected + * @arg RCC_MCO_PLL3CLK_Div2: PLL3 clock divided by 2 selected + * @arg RCC_MCO_XT1: External 3-25 MHz oscillator clock selected + * @arg RCC_MCO_PLL3CLK: PLL3 clock selected + * + * For @b other_STM32_devices, this parameter can be one of the following values: + * @arg RCC_MCO_NoClock: No clock selected + * @arg RCC_MCO_SYSCLK: System clock selected + * @arg RCC_MCO_HSI: HSI oscillator clock selected + * @arg RCC_MCO_HSE: HSE oscillator clock selected + * @arg RCC_MCO_PLLCLK_Div2: PLL clock divided by 2 selected + * + * @retval None + */ +void RCC_MCOConfig(uint8_t RCC_MCO) +{ + /* Check the parameters */ + assert_param(IS_RCC_MCO(RCC_MCO)); + + /* Perform Byte access to MCO bits to select the MCO source */ + *(__IO uint8_t *) CFGR_BYTE4_ADDRESS = RCC_MCO; +} + +/** + * @brief Checks whether the specified RCC flag is set or not. + * @param RCC_FLAG: specifies the flag to check. + * + * For @b STM32_Connectivity_line_devices, this parameter can be one of the + * following values: + * @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready + * @arg RCC_FLAG_HSERDY: HSE oscillator clock ready + * @arg RCC_FLAG_PLLRDY: PLL clock ready + * @arg RCC_FLAG_PLL2RDY: PLL2 clock ready + * @arg RCC_FLAG_PLL3RDY: PLL3 clock ready + * @arg RCC_FLAG_LSERDY: LSE oscillator clock ready + * @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready + * @arg RCC_FLAG_PINRST: Pin reset + * @arg RCC_FLAG_PORRST: POR/PDR reset + * @arg RCC_FLAG_SFTRST: Software reset + * @arg RCC_FLAG_IWDGRST: Independent Watchdog reset + * @arg RCC_FLAG_WWDGRST: Window Watchdog reset + * @arg RCC_FLAG_LPWRRST: Low Power reset + * + * For @b other_STM32_devices, this parameter can be one of the following values: + * @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready + * @arg RCC_FLAG_HSERDY: HSE oscillator clock ready + * @arg RCC_FLAG_PLLRDY: PLL clock ready + * @arg RCC_FLAG_LSERDY: LSE oscillator clock ready + * @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready + * @arg RCC_FLAG_PINRST: Pin reset + * @arg RCC_FLAG_PORRST: POR/PDR reset + * @arg RCC_FLAG_SFTRST: Software reset + * @arg RCC_FLAG_IWDGRST: Independent Watchdog reset + * @arg RCC_FLAG_WWDGRST: Window Watchdog reset + * @arg RCC_FLAG_LPWRRST: Low Power reset + * + * @retval The new state of RCC_FLAG (SET or RESET). + */ +FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG) +{ + uint32_t tmp = 0; + uint32_t statusreg = 0; + FlagStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_RCC_FLAG(RCC_FLAG)); + + /* Get the RCC register index */ + tmp = RCC_FLAG >> 5; + if (tmp == 1) /* The flag to check is in CR register */ + { + statusreg = RCC->CR; + } + else if (tmp == 2) /* The flag to check is in BDCR register */ + { + statusreg = RCC->BDCR; + } + else /* The flag to check is in CSR register */ + { + statusreg = RCC->CSR; + } + + /* Get the flag position */ + tmp = RCC_FLAG & FLAG_Mask; + if ((statusreg & ((uint32_t)1 << tmp)) != (uint32_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + + /* Return the flag status */ + return bitstatus; +} + +/** + * @brief Clears the RCC reset flags. + * @note The reset flags are: RCC_FLAG_PINRST, RCC_FLAG_PORRST, RCC_FLAG_SFTRST, + * RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST, RCC_FLAG_LPWRRST + * @param None + * @retval None + */ +void RCC_ClearFlag(void) +{ + /* Set RMVF bit to clear the reset flags */ + RCC->CSR |= CSR_RMVF_Set; +} + +/** + * @brief Checks whether the specified RCC interrupt has occurred or not. + * @param RCC_IT: specifies the RCC interrupt source to check. + * + * For @b STM32_Connectivity_line_devices, this parameter can be one of the + * following values: + * @arg RCC_IT_LSIRDY: LSI ready interrupt + * @arg RCC_IT_LSERDY: LSE ready interrupt + * @arg RCC_IT_HSIRDY: HSI ready interrupt + * @arg RCC_IT_HSERDY: HSE ready interrupt + * @arg RCC_IT_PLLRDY: PLL ready interrupt + * @arg RCC_IT_PLL2RDY: PLL2 ready interrupt + * @arg RCC_IT_PLL3RDY: PLL3 ready interrupt + * @arg RCC_IT_CSS: Clock Security System interrupt + * + * For @b other_STM32_devices, this parameter can be one of the following values: + * @arg RCC_IT_LSIRDY: LSI ready interrupt + * @arg RCC_IT_LSERDY: LSE ready interrupt + * @arg RCC_IT_HSIRDY: HSI ready interrupt + * @arg RCC_IT_HSERDY: HSE ready interrupt + * @arg RCC_IT_PLLRDY: PLL ready interrupt + * @arg RCC_IT_CSS: Clock Security System interrupt + * + * @retval The new state of RCC_IT (SET or RESET). + */ +ITStatus RCC_GetITStatus(uint8_t RCC_IT) +{ + ITStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_RCC_GET_IT(RCC_IT)); + + /* Check the status of the specified RCC interrupt */ + if ((RCC->CIR & RCC_IT) != (uint32_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + + /* Return the RCC_IT status */ + return bitstatus; +} + +/** + * @brief Clears the RCC's interrupt pending bits. + * @param RCC_IT: specifies the interrupt pending bit to clear. + * + * For @b STM32_Connectivity_line_devices, this parameter can be any combination + * of the following values: + * @arg RCC_IT_LSIRDY: LSI ready interrupt + * @arg RCC_IT_LSERDY: LSE ready interrupt + * @arg RCC_IT_HSIRDY: HSI ready interrupt + * @arg RCC_IT_HSERDY: HSE ready interrupt + * @arg RCC_IT_PLLRDY: PLL ready interrupt + * @arg RCC_IT_PLL2RDY: PLL2 ready interrupt + * @arg RCC_IT_PLL3RDY: PLL3 ready interrupt + * @arg RCC_IT_CSS: Clock Security System interrupt + * + * For @b other_STM32_devices, this parameter can be any combination of the + * following values: + * @arg RCC_IT_LSIRDY: LSI ready interrupt + * @arg RCC_IT_LSERDY: LSE ready interrupt + * @arg RCC_IT_HSIRDY: HSI ready interrupt + * @arg RCC_IT_HSERDY: HSE ready interrupt + * @arg RCC_IT_PLLRDY: PLL ready interrupt + * + * @arg RCC_IT_CSS: Clock Security System interrupt + * @retval None + */ +void RCC_ClearITPendingBit(uint8_t RCC_IT) +{ + /* Check the parameters */ + assert_param(IS_RCC_CLEAR_IT(RCC_IT)); + + /* Perform Byte access to RCC_CIR[23:16] bits to clear the selected interrupt + pending bits */ + *(__IO uint8_t *) CIR_BYTE3_ADDRESS = RCC_IT; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_rtc.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_rtc.c new file mode 100755 index 0000000..f798d2b --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_rtc.c @@ -0,0 +1,339 @@ +/** + ****************************************************************************** + * @file stm32f10x_rtc.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the RTC firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_rtc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup RTC + * @brief RTC driver modules + * @{ + */ + +/** @defgroup RTC_Private_TypesDefinitions + * @{ + */ +/** + * @} + */ + +/** @defgroup RTC_Private_Defines + * @{ + */ +#define RTC_LSB_MASK ((uint32_t)0x0000FFFF) /*!< RTC LSB Mask */ +#define PRLH_MSB_MASK ((uint32_t)0x000F0000) /*!< RTC Prescaler MSB Mask */ + +/** + * @} + */ + +/** @defgroup RTC_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup RTC_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup RTC_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup RTC_Private_Functions + * @{ + */ + +/** + * @brief Enables or disables the specified RTC interrupts. + * @param RTC_IT: specifies the RTC interrupts sources to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg RTC_IT_OW: Overflow interrupt + * @arg RTC_IT_ALR: Alarm interrupt + * @arg RTC_IT_SEC: Second interrupt + * @param NewState: new state of the specified RTC interrupts. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_RTC_IT(RTC_IT)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + RTC->CRH |= RTC_IT; + } + else + { + RTC->CRH &= (uint16_t)~RTC_IT; + } +} + +/** + * @brief Enters the RTC configuration mode. + * @param None + * @retval None + */ +void RTC_EnterConfigMode(void) +{ + /* Set the CNF flag to enter in the Configuration Mode */ + RTC->CRL |= RTC_CRL_CNF; +} + +/** + * @brief Exits from the RTC configuration mode. + * @param None + * @retval None + */ +void RTC_ExitConfigMode(void) +{ + /* Reset the CNF flag to exit from the Configuration Mode */ + RTC->CRL &= (uint16_t)~((uint16_t)RTC_CRL_CNF); +} + +/** + * @brief Gets the RTC counter value. + * @param None + * @retval RTC counter value. + */ +uint32_t RTC_GetCounter(void) +{ + uint16_t tmp = 0; + tmp = RTC->CNTL; + return (((uint32_t)RTC->CNTH << 16 ) | tmp) ; +} + +/** + * @brief Sets the RTC counter value. + * @param CounterValue: RTC counter new value. + * @retval None + */ +void RTC_SetCounter(uint32_t CounterValue) +{ + RTC_EnterConfigMode(); + /* Set RTC COUNTER MSB word */ + RTC->CNTH = CounterValue >> 16; + /* Set RTC COUNTER LSB word */ + RTC->CNTL = (CounterValue & RTC_LSB_MASK); + RTC_ExitConfigMode(); +} + +/** + * @brief Sets the RTC prescaler value. + * @param PrescalerValue: RTC prescaler new value. + * @retval None + */ +void RTC_SetPrescaler(uint32_t PrescalerValue) +{ + /* Check the parameters */ + assert_param(IS_RTC_PRESCALER(PrescalerValue)); + + RTC_EnterConfigMode(); + /* Set RTC PRESCALER MSB word */ + RTC->PRLH = (PrescalerValue & PRLH_MSB_MASK) >> 16; + /* Set RTC PRESCALER LSB word */ + RTC->PRLL = (PrescalerValue & RTC_LSB_MASK); + RTC_ExitConfigMode(); +} + +/** + * @brief Sets the RTC alarm value. + * @param AlarmValue: RTC alarm new value. + * @retval None + */ +void RTC_SetAlarm(uint32_t AlarmValue) +{ + RTC_EnterConfigMode(); + /* Set the ALARM MSB word */ + RTC->ALRH = AlarmValue >> 16; + /* Set the ALARM LSB word */ + RTC->ALRL = (AlarmValue & RTC_LSB_MASK); + RTC_ExitConfigMode(); +} + +/** + * @brief Gets the RTC divider value. + * @param None + * @retval RTC Divider value. + */ +uint32_t RTC_GetDivider(void) +{ + uint32_t tmp = 0x00; + tmp = ((uint32_t)RTC->DIVH & (uint32_t)0x000F) << 16; + tmp |= RTC->DIVL; + return tmp; +} + +/** + * @brief Waits until last write operation on RTC registers has finished. + * @note This function must be called before any write to RTC registers. + * @param None + * @retval None + */ +void RTC_WaitForLastTask(void) +{ + /* Loop until RTOFF flag is set */ + while ((RTC->CRL & RTC_FLAG_RTOFF) == (uint16_t)RESET) + { + } +} + +/** + * @brief Waits until the RTC registers (RTC_CNT, RTC_ALR and RTC_PRL) + * are synchronized with RTC APB clock. + * @note This function must be called before any read operation after an APB reset + * or an APB clock stop. + * @param None + * @retval None + */ +void RTC_WaitForSynchro(void) +{ + /* Clear RSF flag */ + RTC->CRL &= (uint16_t)~RTC_FLAG_RSF; + /* Loop until RSF flag is set */ + while ((RTC->CRL & RTC_FLAG_RSF) == (uint16_t)RESET) + { + } +} + +/** + * @brief Checks whether the specified RTC flag is set or not. + * @param RTC_FLAG: specifies the flag to check. + * This parameter can be one the following values: + * @arg RTC_FLAG_RTOFF: RTC Operation OFF flag + * @arg RTC_FLAG_RSF: Registers Synchronized flag + * @arg RTC_FLAG_OW: Overflow flag + * @arg RTC_FLAG_ALR: Alarm flag + * @arg RTC_FLAG_SEC: Second flag + * @retval The new state of RTC_FLAG (SET or RESET). + */ +FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG) +{ + FlagStatus bitstatus = RESET; + + /* Check the parameters */ + assert_param(IS_RTC_GET_FLAG(RTC_FLAG)); + + if ((RTC->CRL & RTC_FLAG) != (uint16_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + return bitstatus; +} + +/** + * @brief Clears the RTC's pending flags. + * @param RTC_FLAG: specifies the flag to clear. + * This parameter can be any combination of the following values: + * @arg RTC_FLAG_RSF: Registers Synchronized flag. This flag is cleared only after + * an APB reset or an APB Clock stop. + * @arg RTC_FLAG_OW: Overflow flag + * @arg RTC_FLAG_ALR: Alarm flag + * @arg RTC_FLAG_SEC: Second flag + * @retval None + */ +void RTC_ClearFlag(uint16_t RTC_FLAG) +{ + /* Check the parameters */ + assert_param(IS_RTC_CLEAR_FLAG(RTC_FLAG)); + + /* Clear the corresponding RTC flag */ + RTC->CRL &= (uint16_t)~RTC_FLAG; +} + +/** + * @brief Checks whether the specified RTC interrupt has occurred or not. + * @param RTC_IT: specifies the RTC interrupts sources to check. + * This parameter can be one of the following values: + * @arg RTC_IT_OW: Overflow interrupt + * @arg RTC_IT_ALR: Alarm interrupt + * @arg RTC_IT_SEC: Second interrupt + * @retval The new state of the RTC_IT (SET or RESET). + */ +ITStatus RTC_GetITStatus(uint16_t RTC_IT) +{ + ITStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_RTC_GET_IT(RTC_IT)); + + bitstatus = (ITStatus)(RTC->CRL & RTC_IT); + if (((RTC->CRH & RTC_IT) != (uint16_t)RESET) && (bitstatus != (uint16_t)RESET)) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + return bitstatus; +} + +/** + * @brief Clears the RTC's interrupt pending bits. + * @param RTC_IT: specifies the interrupt pending bit to clear. + * This parameter can be any combination of the following values: + * @arg RTC_IT_OW: Overflow interrupt + * @arg RTC_IT_ALR: Alarm interrupt + * @arg RTC_IT_SEC: Second interrupt + * @retval None + */ +void RTC_ClearITPendingBit(uint16_t RTC_IT) +{ + /* Check the parameters */ + assert_param(IS_RTC_IT(RTC_IT)); + + /* Clear the corresponding RTC pending bit */ + RTC->CRL &= (uint16_t)~RTC_IT; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_sdio.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_sdio.c new file mode 100755 index 0000000..d1870ce --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_sdio.c @@ -0,0 +1,799 @@ +/** + ****************************************************************************** + * @file stm32f10x_sdio.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the SDIO firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_sdio.h" +#include "stm32f10x_rcc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup SDIO + * @brief SDIO driver modules + * @{ + */ + +/** @defgroup SDIO_Private_TypesDefinitions + * @{ + */ + +/* ------------ SDIO registers bit address in the alias region ----------- */ +#define SDIO_OFFSET (SDIO_BASE - PERIPH_BASE) + +/* --- CLKCR Register ---*/ + +/* Alias word address of CLKEN bit */ +#define CLKCR_OFFSET (SDIO_OFFSET + 0x04) +#define CLKEN_BitNumber 0x08 +#define CLKCR_CLKEN_BB (PERIPH_BB_BASE + (CLKCR_OFFSET * 32) + (CLKEN_BitNumber * 4)) + +/* --- CMD Register ---*/ + +/* Alias word address of SDIOSUSPEND bit */ +#define CMD_OFFSET (SDIO_OFFSET + 0x0C) +#define SDIOSUSPEND_BitNumber 0x0B +#define CMD_SDIOSUSPEND_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (SDIOSUSPEND_BitNumber * 4)) + +/* Alias word address of ENCMDCOMPL bit */ +#define ENCMDCOMPL_BitNumber 0x0C +#define CMD_ENCMDCOMPL_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (ENCMDCOMPL_BitNumber * 4)) + +/* Alias word address of NIEN bit */ +#define NIEN_BitNumber 0x0D +#define CMD_NIEN_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (NIEN_BitNumber * 4)) + +/* Alias word address of ATACMD bit */ +#define ATACMD_BitNumber 0x0E +#define CMD_ATACMD_BB (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (ATACMD_BitNumber * 4)) + +/* --- DCTRL Register ---*/ + +/* Alias word address of DMAEN bit */ +#define DCTRL_OFFSET (SDIO_OFFSET + 0x2C) +#define DMAEN_BitNumber 0x03 +#define DCTRL_DMAEN_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (DMAEN_BitNumber * 4)) + +/* Alias word address of RWSTART bit */ +#define RWSTART_BitNumber 0x08 +#define DCTRL_RWSTART_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWSTART_BitNumber * 4)) + +/* Alias word address of RWSTOP bit */ +#define RWSTOP_BitNumber 0x09 +#define DCTRL_RWSTOP_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWSTOP_BitNumber * 4)) + +/* Alias word address of RWMOD bit */ +#define RWMOD_BitNumber 0x0A +#define DCTRL_RWMOD_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWMOD_BitNumber * 4)) + +/* Alias word address of SDIOEN bit */ +#define SDIOEN_BitNumber 0x0B +#define DCTRL_SDIOEN_BB (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (SDIOEN_BitNumber * 4)) + +/* ---------------------- SDIO registers bit mask ------------------------ */ + +/* --- CLKCR Register ---*/ + +/* CLKCR register clear mask */ +#define CLKCR_CLEAR_MASK ((uint32_t)0xFFFF8100) + +/* --- PWRCTRL Register ---*/ + +/* SDIO PWRCTRL Mask */ +#define PWR_PWRCTRL_MASK ((uint32_t)0xFFFFFFFC) + +/* --- DCTRL Register ---*/ + +/* SDIO DCTRL Clear Mask */ +#define DCTRL_CLEAR_MASK ((uint32_t)0xFFFFFF08) + +/* --- CMD Register ---*/ + +/* CMD Register clear mask */ +#define CMD_CLEAR_MASK ((uint32_t)0xFFFFF800) + +/* SDIO RESP Registers Address */ +#define SDIO_RESP_ADDR ((uint32_t)(SDIO_BASE + 0x14)) + +/** + * @} + */ + +/** @defgroup SDIO_Private_Defines + * @{ + */ + +/** + * @} + */ + +/** @defgroup SDIO_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup SDIO_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup SDIO_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup SDIO_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the SDIO peripheral registers to their default reset values. + * @param None + * @retval None + */ +void SDIO_DeInit(void) +{ + SDIO->POWER = 0x00000000; + SDIO->CLKCR = 0x00000000; + SDIO->ARG = 0x00000000; + SDIO->CMD = 0x00000000; + SDIO->DTIMER = 0x00000000; + SDIO->DLEN = 0x00000000; + SDIO->DCTRL = 0x00000000; + SDIO->ICR = 0x00C007FF; + SDIO->MASK = 0x00000000; +} + +/** + * @brief Initializes the SDIO peripheral according to the specified + * parameters in the SDIO_InitStruct. + * @param SDIO_InitStruct : pointer to a SDIO_InitTypeDef structure + * that contains the configuration information for the SDIO peripheral. + * @retval None + */ +void SDIO_Init(SDIO_InitTypeDef* SDIO_InitStruct) +{ + uint32_t tmpreg = 0; + + /* Check the parameters */ + assert_param(IS_SDIO_CLOCK_EDGE(SDIO_InitStruct->SDIO_ClockEdge)); + assert_param(IS_SDIO_CLOCK_BYPASS(SDIO_InitStruct->SDIO_ClockBypass)); + assert_param(IS_SDIO_CLOCK_POWER_SAVE(SDIO_InitStruct->SDIO_ClockPowerSave)); + assert_param(IS_SDIO_BUS_WIDE(SDIO_InitStruct->SDIO_BusWide)); + assert_param(IS_SDIO_HARDWARE_FLOW_CONTROL(SDIO_InitStruct->SDIO_HardwareFlowControl)); + +/*---------------------------- SDIO CLKCR Configuration ------------------------*/ + /* Get the SDIO CLKCR value */ + tmpreg = SDIO->CLKCR; + + /* Clear CLKDIV, PWRSAV, BYPASS, WIDBUS, NEGEDGE, HWFC_EN bits */ + tmpreg &= CLKCR_CLEAR_MASK; + + /* Set CLKDIV bits according to SDIO_ClockDiv value */ + /* Set PWRSAV bit according to SDIO_ClockPowerSave value */ + /* Set BYPASS bit according to SDIO_ClockBypass value */ + /* Set WIDBUS bits according to SDIO_BusWide value */ + /* Set NEGEDGE bits according to SDIO_ClockEdge value */ + /* Set HWFC_EN bits according to SDIO_HardwareFlowControl value */ + tmpreg |= (SDIO_InitStruct->SDIO_ClockDiv | SDIO_InitStruct->SDIO_ClockPowerSave | + SDIO_InitStruct->SDIO_ClockBypass | SDIO_InitStruct->SDIO_BusWide | + SDIO_InitStruct->SDIO_ClockEdge | SDIO_InitStruct->SDIO_HardwareFlowControl); + + /* Write to SDIO CLKCR */ + SDIO->CLKCR = tmpreg; +} + +/** + * @brief Fills each SDIO_InitStruct member with its default value. + * @param SDIO_InitStruct: pointer to an SDIO_InitTypeDef structure which + * will be initialized. + * @retval None + */ +void SDIO_StructInit(SDIO_InitTypeDef* SDIO_InitStruct) +{ + /* SDIO_InitStruct members default value */ + SDIO_InitStruct->SDIO_ClockDiv = 0x00; + SDIO_InitStruct->SDIO_ClockEdge = SDIO_ClockEdge_Rising; + SDIO_InitStruct->SDIO_ClockBypass = SDIO_ClockBypass_Disable; + SDIO_InitStruct->SDIO_ClockPowerSave = SDIO_ClockPowerSave_Disable; + SDIO_InitStruct->SDIO_BusWide = SDIO_BusWide_1b; + SDIO_InitStruct->SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable; +} + +/** + * @brief Enables or disables the SDIO Clock. + * @param NewState: new state of the SDIO Clock. This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void SDIO_ClockCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + *(__IO uint32_t *) CLKCR_CLKEN_BB = (uint32_t)NewState; +} + +/** + * @brief Sets the power status of the controller. + * @param SDIO_PowerState: new state of the Power state. + * This parameter can be one of the following values: + * @arg SDIO_PowerState_OFF + * @arg SDIO_PowerState_ON + * @retval None + */ +void SDIO_SetPowerState(uint32_t SDIO_PowerState) +{ + /* Check the parameters */ + assert_param(IS_SDIO_POWER_STATE(SDIO_PowerState)); + + SDIO->POWER &= PWR_PWRCTRL_MASK; + SDIO->POWER |= SDIO_PowerState; +} + +/** + * @brief Gets the power status of the controller. + * @param None + * @retval Power status of the controller. The returned value can + * be one of the following: + * - 0x00: Power OFF + * - 0x02: Power UP + * - 0x03: Power ON + */ +uint32_t SDIO_GetPowerState(void) +{ + return (SDIO->POWER & (~PWR_PWRCTRL_MASK)); +} + +/** + * @brief Enables or disables the SDIO interrupts. + * @param SDIO_IT: specifies the SDIO interrupt sources to be enabled or disabled. + * This parameter can be one or a combination of the following values: + * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt + * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt + * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt + * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt + * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt + * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt + * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt + * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt + * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt + * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide + * bus mode interrupt + * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt + * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt + * @arg SDIO_IT_TXACT: Data transmit in progress interrupt + * @arg SDIO_IT_RXACT: Data receive in progress interrupt + * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt + * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt + * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt + * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt + * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt + * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt + * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt + * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt + * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt + * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt + * @param NewState: new state of the specified SDIO interrupts. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void SDIO_ITConfig(uint32_t SDIO_IT, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_SDIO_IT(SDIO_IT)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the SDIO interrupts */ + SDIO->MASK |= SDIO_IT; + } + else + { + /* Disable the SDIO interrupts */ + SDIO->MASK &= ~SDIO_IT; + } +} + +/** + * @brief Enables or disables the SDIO DMA request. + * @param NewState: new state of the selected SDIO DMA request. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void SDIO_DMACmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + *(__IO uint32_t *) DCTRL_DMAEN_BB = (uint32_t)NewState; +} + +/** + * @brief Initializes the SDIO Command according to the specified + * parameters in the SDIO_CmdInitStruct and send the command. + * @param SDIO_CmdInitStruct : pointer to a SDIO_CmdInitTypeDef + * structure that contains the configuration information for the SDIO command. + * @retval None + */ +void SDIO_SendCommand(SDIO_CmdInitTypeDef *SDIO_CmdInitStruct) +{ + uint32_t tmpreg = 0; + + /* Check the parameters */ + assert_param(IS_SDIO_CMD_INDEX(SDIO_CmdInitStruct->SDIO_CmdIndex)); + assert_param(IS_SDIO_RESPONSE(SDIO_CmdInitStruct->SDIO_Response)); + assert_param(IS_SDIO_WAIT(SDIO_CmdInitStruct->SDIO_Wait)); + assert_param(IS_SDIO_CPSM(SDIO_CmdInitStruct->SDIO_CPSM)); + +/*---------------------------- SDIO ARG Configuration ------------------------*/ + /* Set the SDIO Argument value */ + SDIO->ARG = SDIO_CmdInitStruct->SDIO_Argument; + +/*---------------------------- SDIO CMD Configuration ------------------------*/ + /* Get the SDIO CMD value */ + tmpreg = SDIO->CMD; + /* Clear CMDINDEX, WAITRESP, WAITINT, WAITPEND, CPSMEN bits */ + tmpreg &= CMD_CLEAR_MASK; + /* Set CMDINDEX bits according to SDIO_CmdIndex value */ + /* Set WAITRESP bits according to SDIO_Response value */ + /* Set WAITINT and WAITPEND bits according to SDIO_Wait value */ + /* Set CPSMEN bits according to SDIO_CPSM value */ + tmpreg |= (uint32_t)SDIO_CmdInitStruct->SDIO_CmdIndex | SDIO_CmdInitStruct->SDIO_Response + | SDIO_CmdInitStruct->SDIO_Wait | SDIO_CmdInitStruct->SDIO_CPSM; + + /* Write to SDIO CMD */ + SDIO->CMD = tmpreg; +} + +/** + * @brief Fills each SDIO_CmdInitStruct member with its default value. + * @param SDIO_CmdInitStruct: pointer to an SDIO_CmdInitTypeDef + * structure which will be initialized. + * @retval None + */ +void SDIO_CmdStructInit(SDIO_CmdInitTypeDef* SDIO_CmdInitStruct) +{ + /* SDIO_CmdInitStruct members default value */ + SDIO_CmdInitStruct->SDIO_Argument = 0x00; + SDIO_CmdInitStruct->SDIO_CmdIndex = 0x00; + SDIO_CmdInitStruct->SDIO_Response = SDIO_Response_No; + SDIO_CmdInitStruct->SDIO_Wait = SDIO_Wait_No; + SDIO_CmdInitStruct->SDIO_CPSM = SDIO_CPSM_Disable; +} + +/** + * @brief Returns command index of last command for which response received. + * @param None + * @retval Returns the command index of the last command response received. + */ +uint8_t SDIO_GetCommandResponse(void) +{ + return (uint8_t)(SDIO->RESPCMD); +} + +/** + * @brief Returns response received from the card for the last command. + * @param SDIO_RESP: Specifies the SDIO response register. + * This parameter can be one of the following values: + * @arg SDIO_RESP1: Response Register 1 + * @arg SDIO_RESP2: Response Register 2 + * @arg SDIO_RESP3: Response Register 3 + * @arg SDIO_RESP4: Response Register 4 + * @retval The Corresponding response register value. + */ +uint32_t SDIO_GetResponse(uint32_t SDIO_RESP) +{ + __IO uint32_t tmp = 0; + + /* Check the parameters */ + assert_param(IS_SDIO_RESP(SDIO_RESP)); + + tmp = SDIO_RESP_ADDR + SDIO_RESP; + + return (*(__IO uint32_t *) tmp); +} + +/** + * @brief Initializes the SDIO data path according to the specified + * parameters in the SDIO_DataInitStruct. + * @param SDIO_DataInitStruct : pointer to a SDIO_DataInitTypeDef structure that + * contains the configuration information for the SDIO command. + * @retval None + */ +void SDIO_DataConfig(SDIO_DataInitTypeDef* SDIO_DataInitStruct) +{ + uint32_t tmpreg = 0; + + /* Check the parameters */ + assert_param(IS_SDIO_DATA_LENGTH(SDIO_DataInitStruct->SDIO_DataLength)); + assert_param(IS_SDIO_BLOCK_SIZE(SDIO_DataInitStruct->SDIO_DataBlockSize)); + assert_param(IS_SDIO_TRANSFER_DIR(SDIO_DataInitStruct->SDIO_TransferDir)); + assert_param(IS_SDIO_TRANSFER_MODE(SDIO_DataInitStruct->SDIO_TransferMode)); + assert_param(IS_SDIO_DPSM(SDIO_DataInitStruct->SDIO_DPSM)); + +/*---------------------------- SDIO DTIMER Configuration ---------------------*/ + /* Set the SDIO Data TimeOut value */ + SDIO->DTIMER = SDIO_DataInitStruct->SDIO_DataTimeOut; + +/*---------------------------- SDIO DLEN Configuration -----------------------*/ + /* Set the SDIO DataLength value */ + SDIO->DLEN = SDIO_DataInitStruct->SDIO_DataLength; + +/*---------------------------- SDIO DCTRL Configuration ----------------------*/ + /* Get the SDIO DCTRL value */ + tmpreg = SDIO->DCTRL; + /* Clear DEN, DTMODE, DTDIR and DBCKSIZE bits */ + tmpreg &= DCTRL_CLEAR_MASK; + /* Set DEN bit according to SDIO_DPSM value */ + /* Set DTMODE bit according to SDIO_TransferMode value */ + /* Set DTDIR bit according to SDIO_TransferDir value */ + /* Set DBCKSIZE bits according to SDIO_DataBlockSize value */ + tmpreg |= (uint32_t)SDIO_DataInitStruct->SDIO_DataBlockSize | SDIO_DataInitStruct->SDIO_TransferDir + | SDIO_DataInitStruct->SDIO_TransferMode | SDIO_DataInitStruct->SDIO_DPSM; + + /* Write to SDIO DCTRL */ + SDIO->DCTRL = tmpreg; +} + +/** + * @brief Fills each SDIO_DataInitStruct member with its default value. + * @param SDIO_DataInitStruct: pointer to an SDIO_DataInitTypeDef structure which + * will be initialized. + * @retval None + */ +void SDIO_DataStructInit(SDIO_DataInitTypeDef* SDIO_DataInitStruct) +{ + /* SDIO_DataInitStruct members default value */ + SDIO_DataInitStruct->SDIO_DataTimeOut = 0xFFFFFFFF; + SDIO_DataInitStruct->SDIO_DataLength = 0x00; + SDIO_DataInitStruct->SDIO_DataBlockSize = SDIO_DataBlockSize_1b; + SDIO_DataInitStruct->SDIO_TransferDir = SDIO_TransferDir_ToCard; + SDIO_DataInitStruct->SDIO_TransferMode = SDIO_TransferMode_Block; + SDIO_DataInitStruct->SDIO_DPSM = SDIO_DPSM_Disable; +} + +/** + * @brief Returns number of remaining data bytes to be transferred. + * @param None + * @retval Number of remaining data bytes to be transferred + */ +uint32_t SDIO_GetDataCounter(void) +{ + return SDIO->DCOUNT; +} + +/** + * @brief Read one data word from Rx FIFO. + * @param None + * @retval Data received + */ +uint32_t SDIO_ReadData(void) +{ + return SDIO->FIFO; +} + +/** + * @brief Write one data word to Tx FIFO. + * @param Data: 32-bit data word to write. + * @retval None + */ +void SDIO_WriteData(uint32_t Data) +{ + SDIO->FIFO = Data; +} + +/** + * @brief Returns the number of words left to be written to or read from FIFO. + * @param None + * @retval Remaining number of words. + */ +uint32_t SDIO_GetFIFOCount(void) +{ + return SDIO->FIFOCNT; +} + +/** + * @brief Starts the SD I/O Read Wait operation. + * @param NewState: new state of the Start SDIO Read Wait operation. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void SDIO_StartSDIOReadWait(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + *(__IO uint32_t *) DCTRL_RWSTART_BB = (uint32_t) NewState; +} + +/** + * @brief Stops the SD I/O Read Wait operation. + * @param NewState: new state of the Stop SDIO Read Wait operation. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void SDIO_StopSDIOReadWait(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + *(__IO uint32_t *) DCTRL_RWSTOP_BB = (uint32_t) NewState; +} + +/** + * @brief Sets one of the two options of inserting read wait interval. + * @param SDIO_ReadWaitMode: SD I/O Read Wait operation mode. + * This parameter can be: + * @arg SDIO_ReadWaitMode_CLK: Read Wait control by stopping SDIOCLK + * @arg SDIO_ReadWaitMode_DATA2: Read Wait control using SDIO_DATA2 + * @retval None + */ +void SDIO_SetSDIOReadWaitMode(uint32_t SDIO_ReadWaitMode) +{ + /* Check the parameters */ + assert_param(IS_SDIO_READWAIT_MODE(SDIO_ReadWaitMode)); + + *(__IO uint32_t *) DCTRL_RWMOD_BB = SDIO_ReadWaitMode; +} + +/** + * @brief Enables or disables the SD I/O Mode Operation. + * @param NewState: new state of SDIO specific operation. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void SDIO_SetSDIOOperation(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + *(__IO uint32_t *) DCTRL_SDIOEN_BB = (uint32_t)NewState; +} + +/** + * @brief Enables or disables the SD I/O Mode suspend command sending. + * @param NewState: new state of the SD I/O Mode suspend command. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void SDIO_SendSDIOSuspendCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + *(__IO uint32_t *) CMD_SDIOSUSPEND_BB = (uint32_t)NewState; +} + +/** + * @brief Enables or disables the command completion signal. + * @param NewState: new state of command completion signal. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void SDIO_CommandCompletionCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + *(__IO uint32_t *) CMD_ENCMDCOMPL_BB = (uint32_t)NewState; +} + +/** + * @brief Enables or disables the CE-ATA interrupt. + * @param NewState: new state of CE-ATA interrupt. This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void SDIO_CEATAITCmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + *(__IO uint32_t *) CMD_NIEN_BB = (uint32_t)((~((uint32_t)NewState)) & ((uint32_t)0x1)); +} + +/** + * @brief Sends CE-ATA command (CMD61). + * @param NewState: new state of CE-ATA command. This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void SDIO_SendCEATACmd(FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + *(__IO uint32_t *) CMD_ATACMD_BB = (uint32_t)NewState; +} + +/** + * @brief Checks whether the specified SDIO flag is set or not. + * @param SDIO_FLAG: specifies the flag to check. + * This parameter can be one of the following values: + * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) + * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) + * @arg SDIO_FLAG_CTIMEOUT: Command response timeout + * @arg SDIO_FLAG_DTIMEOUT: Data timeout + * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error + * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error + * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) + * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) + * @arg SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero) + * @arg SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide + * bus mode. + * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) + * @arg SDIO_FLAG_CMDACT: Command transfer in progress + * @arg SDIO_FLAG_TXACT: Data transmit in progress + * @arg SDIO_FLAG_RXACT: Data receive in progress + * @arg SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty + * @arg SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full + * @arg SDIO_FLAG_TXFIFOF: Transmit FIFO full + * @arg SDIO_FLAG_RXFIFOF: Receive FIFO full + * @arg SDIO_FLAG_TXFIFOE: Transmit FIFO empty + * @arg SDIO_FLAG_RXFIFOE: Receive FIFO empty + * @arg SDIO_FLAG_TXDAVL: Data available in transmit FIFO + * @arg SDIO_FLAG_RXDAVL: Data available in receive FIFO + * @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received + * @arg SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61 + * @retval The new state of SDIO_FLAG (SET or RESET). + */ +FlagStatus SDIO_GetFlagStatus(uint32_t SDIO_FLAG) +{ + FlagStatus bitstatus = RESET; + + /* Check the parameters */ + assert_param(IS_SDIO_FLAG(SDIO_FLAG)); + + if ((SDIO->STA & SDIO_FLAG) != (uint32_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + return bitstatus; +} + +/** + * @brief Clears the SDIO's pending flags. + * @param SDIO_FLAG: specifies the flag to clear. + * This parameter can be one or a combination of the following values: + * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) + * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) + * @arg SDIO_FLAG_CTIMEOUT: Command response timeout + * @arg SDIO_FLAG_DTIMEOUT: Data timeout + * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error + * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error + * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) + * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) + * @arg SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero) + * @arg SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide + * bus mode + * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) + * @arg SDIO_FLAG_SDIOIT: SD I/O interrupt received + * @arg SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61 + * @retval None + */ +void SDIO_ClearFlag(uint32_t SDIO_FLAG) +{ + /* Check the parameters */ + assert_param(IS_SDIO_CLEAR_FLAG(SDIO_FLAG)); + + SDIO->ICR = SDIO_FLAG; +} + +/** + * @brief Checks whether the specified SDIO interrupt has occurred or not. + * @param SDIO_IT: specifies the SDIO interrupt source to check. + * This parameter can be one of the following values: + * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt + * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt + * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt + * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt + * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt + * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt + * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt + * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt + * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt + * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide + * bus mode interrupt + * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt + * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt + * @arg SDIO_IT_TXACT: Data transmit in progress interrupt + * @arg SDIO_IT_RXACT: Data receive in progress interrupt + * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt + * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt + * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt + * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt + * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt + * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt + * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt + * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt + * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt + * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt + * @retval The new state of SDIO_IT (SET or RESET). + */ +ITStatus SDIO_GetITStatus(uint32_t SDIO_IT) +{ + ITStatus bitstatus = RESET; + + /* Check the parameters */ + assert_param(IS_SDIO_GET_IT(SDIO_IT)); + if ((SDIO->STA & SDIO_IT) != (uint32_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + return bitstatus; +} + +/** + * @brief Clears the SDIO's interrupt pending bits. + * @param SDIO_IT: specifies the interrupt pending bit to clear. + * This parameter can be one or a combination of the following values: + * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt + * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt + * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt + * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt + * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt + * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt + * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt + * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt + * @arg SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt + * @arg SDIO_IT_STBITERR: Start bit not detected on all data signals in wide + * bus mode interrupt + * @arg SDIO_IT_SDIOIT: SD I/O interrupt received interrupt + * @arg SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 + * @retval None + */ +void SDIO_ClearITPendingBit(uint32_t SDIO_IT) +{ + /* Check the parameters */ + assert_param(IS_SDIO_CLEAR_IT(SDIO_IT)); + + SDIO->ICR = SDIO_IT; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_spi.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_spi.c new file mode 100755 index 0000000..51a9cce --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_spi.c @@ -0,0 +1,908 @@ +/** + ****************************************************************************** + * @file stm32f10x_spi.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the SPI firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_spi.h" +#include "stm32f10x_rcc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup SPI + * @brief SPI driver modules + * @{ + */ + +/** @defgroup SPI_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + + +/** @defgroup SPI_Private_Defines + * @{ + */ + +/* SPI SPE mask */ +#define CR1_SPE_Set ((uint16_t)0x0040) +#define CR1_SPE_Reset ((uint16_t)0xFFBF) + +/* I2S I2SE mask */ +#define I2SCFGR_I2SE_Set ((uint16_t)0x0400) +#define I2SCFGR_I2SE_Reset ((uint16_t)0xFBFF) + +/* SPI CRCNext mask */ +#define CR1_CRCNext_Set ((uint16_t)0x1000) + +/* SPI CRCEN mask */ +#define CR1_CRCEN_Set ((uint16_t)0x2000) +#define CR1_CRCEN_Reset ((uint16_t)0xDFFF) + +/* SPI SSOE mask */ +#define CR2_SSOE_Set ((uint16_t)0x0004) +#define CR2_SSOE_Reset ((uint16_t)0xFFFB) + +/* SPI registers Masks */ +#define CR1_CLEAR_Mask ((uint16_t)0x3040) +#define I2SCFGR_CLEAR_Mask ((uint16_t)0xF040) + +/* SPI or I2S mode selection masks */ +#define SPI_Mode_Select ((uint16_t)0xF7FF) +#define I2S_Mode_Select ((uint16_t)0x0800) + +/* I2S clock source selection masks */ +#define I2S2_CLOCK_SRC ((uint32_t)(0x00020000)) +#define I2S3_CLOCK_SRC ((uint32_t)(0x00040000)) +#define I2S_MUL_MASK ((uint32_t)(0x0000F000)) +#define I2S_DIV_MASK ((uint32_t)(0x000000F0)) + +/** + * @} + */ + +/** @defgroup SPI_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup SPI_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup SPI_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup SPI_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the SPIx peripheral registers to their default + * reset values (Affects also the I2Ss). + * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral. + * @retval None + */ +void SPI_I2S_DeInit(SPI_TypeDef* SPIx) +{ + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + + if (SPIx == SPI1) + { + /* Enable SPI1 reset state */ + RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE); + /* Release SPI1 from reset state */ + RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE); + } + else if (SPIx == SPI2) + { + /* Enable SPI2 reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, ENABLE); + /* Release SPI2 from reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, DISABLE); + } + else + { + if (SPIx == SPI3) + { + /* Enable SPI3 reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, ENABLE); + /* Release SPI3 from reset state */ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, DISABLE); + } + } +} + +/** + * @brief Initializes the SPIx peripheral according to the specified + * parameters in the SPI_InitStruct. + * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral. + * @param SPI_InitStruct: pointer to a SPI_InitTypeDef structure that + * contains the configuration information for the specified SPI peripheral. + * @retval None + */ +void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct) +{ + uint16_t tmpreg = 0; + + /* check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + + /* Check the SPI parameters */ + assert_param(IS_SPI_DIRECTION_MODE(SPI_InitStruct->SPI_Direction)); + assert_param(IS_SPI_MODE(SPI_InitStruct->SPI_Mode)); + assert_param(IS_SPI_DATASIZE(SPI_InitStruct->SPI_DataSize)); + assert_param(IS_SPI_CPOL(SPI_InitStruct->SPI_CPOL)); + assert_param(IS_SPI_CPHA(SPI_InitStruct->SPI_CPHA)); + assert_param(IS_SPI_NSS(SPI_InitStruct->SPI_NSS)); + assert_param(IS_SPI_BAUDRATE_PRESCALER(SPI_InitStruct->SPI_BaudRatePrescaler)); + assert_param(IS_SPI_FIRST_BIT(SPI_InitStruct->SPI_FirstBit)); + assert_param(IS_SPI_CRC_POLYNOMIAL(SPI_InitStruct->SPI_CRCPolynomial)); + +/*---------------------------- SPIx CR1 Configuration ------------------------*/ + /* Get the SPIx CR1 value */ + tmpreg = SPIx->CR1; + /* Clear BIDIMode, BIDIOE, RxONLY, SSM, SSI, LSBFirst, BR, MSTR, CPOL and CPHA bits */ + tmpreg &= CR1_CLEAR_Mask; + /* Configure SPIx: direction, NSS management, first transmitted bit, BaudRate prescaler + master/salve mode, CPOL and CPHA */ + /* Set BIDImode, BIDIOE and RxONLY bits according to SPI_Direction value */ + /* Set SSM, SSI and MSTR bits according to SPI_Mode and SPI_NSS values */ + /* Set LSBFirst bit according to SPI_FirstBit value */ + /* Set BR bits according to SPI_BaudRatePrescaler value */ + /* Set CPOL bit according to SPI_CPOL value */ + /* Set CPHA bit according to SPI_CPHA value */ + tmpreg |= (uint16_t)((uint32_t)SPI_InitStruct->SPI_Direction | SPI_InitStruct->SPI_Mode | + SPI_InitStruct->SPI_DataSize | SPI_InitStruct->SPI_CPOL | + SPI_InitStruct->SPI_CPHA | SPI_InitStruct->SPI_NSS | + SPI_InitStruct->SPI_BaudRatePrescaler | SPI_InitStruct->SPI_FirstBit); + /* Write to SPIx CR1 */ + SPIx->CR1 = tmpreg; + + /* Activate the SPI mode (Reset I2SMOD bit in I2SCFGR register) */ + SPIx->I2SCFGR &= SPI_Mode_Select; + +/*---------------------------- SPIx CRCPOLY Configuration --------------------*/ + /* Write to SPIx CRCPOLY */ + SPIx->CRCPR = SPI_InitStruct->SPI_CRCPolynomial; +} + +/** + * @brief Initializes the SPIx peripheral according to the specified + * parameters in the I2S_InitStruct. + * @param SPIx: where x can be 2 or 3 to select the SPI peripheral + * (configured in I2S mode). + * @param I2S_InitStruct: pointer to an I2S_InitTypeDef structure that + * contains the configuration information for the specified SPI peripheral + * configured in I2S mode. + * @note + * The function calculates the optimal prescaler needed to obtain the most + * accurate audio frequency (depending on the I2S clock source, the PLL values + * and the product configuration). But in case the prescaler value is greater + * than 511, the default value (0x02) will be configured instead. * + * @retval None + */ +void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct) +{ + uint16_t tmpreg = 0, i2sdiv = 2, i2sodd = 0, packetlength = 1; + uint32_t tmp = 0; + RCC_ClocksTypeDef RCC_Clocks; + uint32_t sourceclock = 0; + + /* Check the I2S parameters */ + assert_param(IS_SPI_23_PERIPH(SPIx)); + assert_param(IS_I2S_MODE(I2S_InitStruct->I2S_Mode)); + assert_param(IS_I2S_STANDARD(I2S_InitStruct->I2S_Standard)); + assert_param(IS_I2S_DATA_FORMAT(I2S_InitStruct->I2S_DataFormat)); + assert_param(IS_I2S_MCLK_OUTPUT(I2S_InitStruct->I2S_MCLKOutput)); + assert_param(IS_I2S_AUDIO_FREQ(I2S_InitStruct->I2S_AudioFreq)); + assert_param(IS_I2S_CPOL(I2S_InitStruct->I2S_CPOL)); + +/*----------------------- SPIx I2SCFGR & I2SPR Configuration -----------------*/ + /* Clear I2SMOD, I2SE, I2SCFG, PCMSYNC, I2SSTD, CKPOL, DATLEN and CHLEN bits */ + SPIx->I2SCFGR &= I2SCFGR_CLEAR_Mask; + SPIx->I2SPR = 0x0002; + + /* Get the I2SCFGR register value */ + tmpreg = SPIx->I2SCFGR; + + /* If the default value has to be written, reinitialize i2sdiv and i2sodd*/ + if(I2S_InitStruct->I2S_AudioFreq == I2S_AudioFreq_Default) + { + i2sodd = (uint16_t)0; + i2sdiv = (uint16_t)2; + } + /* If the requested audio frequency is not the default, compute the prescaler */ + else + { + /* Check the frame length (For the Prescaler computing) */ + if(I2S_InitStruct->I2S_DataFormat == I2S_DataFormat_16b) + { + /* Packet length is 16 bits */ + packetlength = 1; + } + else + { + /* Packet length is 32 bits */ + packetlength = 2; + } + + /* Get the I2S clock source mask depending on the peripheral number */ + if(((uint32_t)SPIx) == SPI2_BASE) + { + /* The mask is relative to I2S2 */ + tmp = I2S2_CLOCK_SRC; + } + else + { + /* The mask is relative to I2S3 */ + tmp = I2S3_CLOCK_SRC; + } + + /* Check the I2S clock source configuration depending on the Device: + Only Connectivity line devices have the PLL3 VCO clock */ +#ifdef STM32F10X_CL + if((RCC->CFGR2 & tmp) != 0) + { + /* Get the configuration bits of RCC PLL3 multiplier */ + tmp = (uint32_t)((RCC->CFGR2 & I2S_MUL_MASK) >> 12); + + /* Get the value of the PLL3 multiplier */ + if((tmp > 5) && (tmp < 15)) + { + /* Multiplier is between 8 and 14 (value 15 is forbidden) */ + tmp += 2; + } + else + { + if (tmp == 15) + { + /* Multiplier is 20 */ + tmp = 20; + } + } + /* Get the PREDIV2 value */ + sourceclock = (uint32_t)(((RCC->CFGR2 & I2S_DIV_MASK) >> 4) + 1); + + /* Calculate the Source Clock frequency based on PLL3 and PREDIV2 values */ + sourceclock = (uint32_t) ((HSE_Value / sourceclock) * tmp * 2); + } + else + { + /* I2S Clock source is System clock: Get System Clock frequency */ + RCC_GetClocksFreq(&RCC_Clocks); + + /* Get the source clock value: based on System Clock value */ + sourceclock = RCC_Clocks.SYSCLK_Frequency; + } +#else /* STM32F10X_HD */ + /* I2S Clock source is System clock: Get System Clock frequency */ + RCC_GetClocksFreq(&RCC_Clocks); + + /* Get the source clock value: based on System Clock value */ + sourceclock = RCC_Clocks.SYSCLK_Frequency; +#endif /* STM32F10X_CL */ + + /* Compute the Real divider depending on the MCLK output state with a floating point */ + if(I2S_InitStruct->I2S_MCLKOutput == I2S_MCLKOutput_Enable) + { + /* MCLK output is enabled */ + tmp = (uint16_t)(((((sourceclock / 256) * 10) / I2S_InitStruct->I2S_AudioFreq)) + 5); + } + else + { + /* MCLK output is disabled */ + tmp = (uint16_t)(((((sourceclock / (32 * packetlength)) *10 ) / I2S_InitStruct->I2S_AudioFreq)) + 5); + } + + /* Remove the floating point */ + tmp = tmp / 10; + + /* Check the parity of the divider */ + i2sodd = (uint16_t)(tmp & (uint16_t)0x0001); + + /* Compute the i2sdiv prescaler */ + i2sdiv = (uint16_t)((tmp - i2sodd) / 2); + + /* Get the Mask for the Odd bit (SPI_I2SPR[8]) register */ + i2sodd = (uint16_t) (i2sodd << 8); + } + + /* Test if the divider is 1 or 0 or greater than 0xFF */ + if ((i2sdiv < 2) || (i2sdiv > 0xFF)) + { + /* Set the default values */ + i2sdiv = 2; + i2sodd = 0; + } + + /* Write to SPIx I2SPR register the computed value */ + SPIx->I2SPR = (uint16_t)(i2sdiv | (uint16_t)(i2sodd | (uint16_t)I2S_InitStruct->I2S_MCLKOutput)); + + /* Configure the I2S with the SPI_InitStruct values */ + tmpreg |= (uint16_t)(I2S_Mode_Select | (uint16_t)(I2S_InitStruct->I2S_Mode | \ + (uint16_t)(I2S_InitStruct->I2S_Standard | (uint16_t)(I2S_InitStruct->I2S_DataFormat | \ + (uint16_t)I2S_InitStruct->I2S_CPOL)))); + + /* Write to SPIx I2SCFGR */ + SPIx->I2SCFGR = tmpreg; +} + +/** + * @brief Fills each SPI_InitStruct member with its default value. + * @param SPI_InitStruct : pointer to a SPI_InitTypeDef structure which will be initialized. + * @retval None + */ +void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct) +{ +/*--------------- Reset SPI init structure parameters values -----------------*/ + /* Initialize the SPI_Direction member */ + SPI_InitStruct->SPI_Direction = SPI_Direction_2Lines_FullDuplex; + /* initialize the SPI_Mode member */ + SPI_InitStruct->SPI_Mode = SPI_Mode_Slave; + /* initialize the SPI_DataSize member */ + SPI_InitStruct->SPI_DataSize = SPI_DataSize_8b; + /* Initialize the SPI_CPOL member */ + SPI_InitStruct->SPI_CPOL = SPI_CPOL_Low; + /* Initialize the SPI_CPHA member */ + SPI_InitStruct->SPI_CPHA = SPI_CPHA_1Edge; + /* Initialize the SPI_NSS member */ + SPI_InitStruct->SPI_NSS = SPI_NSS_Hard; + /* Initialize the SPI_BaudRatePrescaler member */ + SPI_InitStruct->SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2; + /* Initialize the SPI_FirstBit member */ + SPI_InitStruct->SPI_FirstBit = SPI_FirstBit_MSB; + /* Initialize the SPI_CRCPolynomial member */ + SPI_InitStruct->SPI_CRCPolynomial = 7; +} + +/** + * @brief Fills each I2S_InitStruct member with its default value. + * @param I2S_InitStruct : pointer to a I2S_InitTypeDef structure which will be initialized. + * @retval None + */ +void I2S_StructInit(I2S_InitTypeDef* I2S_InitStruct) +{ +/*--------------- Reset I2S init structure parameters values -----------------*/ + /* Initialize the I2S_Mode member */ + I2S_InitStruct->I2S_Mode = I2S_Mode_SlaveTx; + + /* Initialize the I2S_Standard member */ + I2S_InitStruct->I2S_Standard = I2S_Standard_Phillips; + + /* Initialize the I2S_DataFormat member */ + I2S_InitStruct->I2S_DataFormat = I2S_DataFormat_16b; + + /* Initialize the I2S_MCLKOutput member */ + I2S_InitStruct->I2S_MCLKOutput = I2S_MCLKOutput_Disable; + + /* Initialize the I2S_AudioFreq member */ + I2S_InitStruct->I2S_AudioFreq = I2S_AudioFreq_Default; + + /* Initialize the I2S_CPOL member */ + I2S_InitStruct->I2S_CPOL = I2S_CPOL_Low; +} + +/** + * @brief Enables or disables the specified SPI peripheral. + * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral. + * @param NewState: new state of the SPIx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected SPI peripheral */ + SPIx->CR1 |= CR1_SPE_Set; + } + else + { + /* Disable the selected SPI peripheral */ + SPIx->CR1 &= CR1_SPE_Reset; + } +} + +/** + * @brief Enables or disables the specified SPI peripheral (in I2S mode). + * @param SPIx: where x can be 2 or 3 to select the SPI peripheral. + * @param NewState: new state of the SPIx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void I2S_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_SPI_23_PERIPH(SPIx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected SPI peripheral (in I2S mode) */ + SPIx->I2SCFGR |= I2SCFGR_I2SE_Set; + } + else + { + /* Disable the selected SPI peripheral (in I2S mode) */ + SPIx->I2SCFGR &= I2SCFGR_I2SE_Reset; + } +} + +/** + * @brief Enables or disables the specified SPI/I2S interrupts. + * @param SPIx: where x can be + * - 1, 2 or 3 in SPI mode + * - 2 or 3 in I2S mode + * @param SPI_I2S_IT: specifies the SPI/I2S interrupt source to be enabled or disabled. + * This parameter can be one of the following values: + * @arg SPI_I2S_IT_TXE: Tx buffer empty interrupt mask + * @arg SPI_I2S_IT_RXNE: Rx buffer not empty interrupt mask + * @arg SPI_I2S_IT_ERR: Error interrupt mask + * @param NewState: new state of the specified SPI/I2S interrupt. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState) +{ + uint16_t itpos = 0, itmask = 0 ; + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + assert_param(IS_SPI_I2S_CONFIG_IT(SPI_I2S_IT)); + + /* Get the SPI/I2S IT index */ + itpos = SPI_I2S_IT >> 4; + + /* Set the IT mask */ + itmask = (uint16_t)1 << (uint16_t)itpos; + + if (NewState != DISABLE) + { + /* Enable the selected SPI/I2S interrupt */ + SPIx->CR2 |= itmask; + } + else + { + /* Disable the selected SPI/I2S interrupt */ + SPIx->CR2 &= (uint16_t)~itmask; + } +} + +/** + * @brief Enables or disables the SPIx/I2Sx DMA interface. + * @param SPIx: where x can be + * - 1, 2 or 3 in SPI mode + * - 2 or 3 in I2S mode + * @param SPI_I2S_DMAReq: specifies the SPI/I2S DMA transfer request to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg SPI_I2S_DMAReq_Tx: Tx buffer DMA transfer request + * @arg SPI_I2S_DMAReq_Rx: Rx buffer DMA transfer request + * @param NewState: new state of the selected SPI/I2S DMA transfer request. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + assert_param(IS_SPI_I2S_DMAREQ(SPI_I2S_DMAReq)); + if (NewState != DISABLE) + { + /* Enable the selected SPI/I2S DMA requests */ + SPIx->CR2 |= SPI_I2S_DMAReq; + } + else + { + /* Disable the selected SPI/I2S DMA requests */ + SPIx->CR2 &= (uint16_t)~SPI_I2S_DMAReq; + } +} + +/** + * @brief Transmits a Data through the SPIx/I2Sx peripheral. + * @param SPIx: where x can be + * - 1, 2 or 3 in SPI mode + * - 2 or 3 in I2S mode + * @param Data : Data to be transmitted. + * @retval None + */ +void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data) +{ + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + + /* Write in the DR register the data to be sent */ + SPIx->DR = Data; +} + +/** + * @brief Returns the most recent received data by the SPIx/I2Sx peripheral. + * @param SPIx: where x can be + * - 1, 2 or 3 in SPI mode + * - 2 or 3 in I2S mode + * @retval The value of the received data. + */ +uint16_t SPI_I2S_ReceiveData(SPI_TypeDef* SPIx) +{ + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + + /* Return the data in the DR register */ + return SPIx->DR; +} + +/** + * @brief Configures internally by software the NSS pin for the selected SPI. + * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral. + * @param SPI_NSSInternalSoft: specifies the SPI NSS internal state. + * This parameter can be one of the following values: + * @arg SPI_NSSInternalSoft_Set: Set NSS pin internally + * @arg SPI_NSSInternalSoft_Reset: Reset NSS pin internally + * @retval None + */ +void SPI_NSSInternalSoftwareConfig(SPI_TypeDef* SPIx, uint16_t SPI_NSSInternalSoft) +{ + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + assert_param(IS_SPI_NSS_INTERNAL(SPI_NSSInternalSoft)); + if (SPI_NSSInternalSoft != SPI_NSSInternalSoft_Reset) + { + /* Set NSS pin internally by software */ + SPIx->CR1 |= SPI_NSSInternalSoft_Set; + } + else + { + /* Reset NSS pin internally by software */ + SPIx->CR1 &= SPI_NSSInternalSoft_Reset; + } +} + +/** + * @brief Enables or disables the SS output for the selected SPI. + * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral. + * @param NewState: new state of the SPIx SS output. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void SPI_SSOutputCmd(SPI_TypeDef* SPIx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected SPI SS output */ + SPIx->CR2 |= CR2_SSOE_Set; + } + else + { + /* Disable the selected SPI SS output */ + SPIx->CR2 &= CR2_SSOE_Reset; + } +} + +/** + * @brief Configures the data size for the selected SPI. + * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral. + * @param SPI_DataSize: specifies the SPI data size. + * This parameter can be one of the following values: + * @arg SPI_DataSize_16b: Set data frame format to 16bit + * @arg SPI_DataSize_8b: Set data frame format to 8bit + * @retval None + */ +void SPI_DataSizeConfig(SPI_TypeDef* SPIx, uint16_t SPI_DataSize) +{ + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + assert_param(IS_SPI_DATASIZE(SPI_DataSize)); + /* Clear DFF bit */ + SPIx->CR1 &= (uint16_t)~SPI_DataSize_16b; + /* Set new DFF bit value */ + SPIx->CR1 |= SPI_DataSize; +} + +/** + * @brief Transmit the SPIx CRC value. + * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral. + * @retval None + */ +void SPI_TransmitCRC(SPI_TypeDef* SPIx) +{ + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + + /* Enable the selected SPI CRC transmission */ + SPIx->CR1 |= CR1_CRCNext_Set; +} + +/** + * @brief Enables or disables the CRC value calculation of the transferred bytes. + * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral. + * @param NewState: new state of the SPIx CRC value calculation. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the selected SPI CRC calculation */ + SPIx->CR1 |= CR1_CRCEN_Set; + } + else + { + /* Disable the selected SPI CRC calculation */ + SPIx->CR1 &= CR1_CRCEN_Reset; + } +} + +/** + * @brief Returns the transmit or the receive CRC register value for the specified SPI. + * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral. + * @param SPI_CRC: specifies the CRC register to be read. + * This parameter can be one of the following values: + * @arg SPI_CRC_Tx: Selects Tx CRC register + * @arg SPI_CRC_Rx: Selects Rx CRC register + * @retval The selected CRC register value.. + */ +uint16_t SPI_GetCRC(SPI_TypeDef* SPIx, uint8_t SPI_CRC) +{ + uint16_t crcreg = 0; + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + assert_param(IS_SPI_CRC(SPI_CRC)); + if (SPI_CRC != SPI_CRC_Rx) + { + /* Get the Tx CRC register */ + crcreg = SPIx->TXCRCR; + } + else + { + /* Get the Rx CRC register */ + crcreg = SPIx->RXCRCR; + } + /* Return the selected CRC register */ + return crcreg; +} + +/** + * @brief Returns the CRC Polynomial register value for the specified SPI. + * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral. + * @retval The CRC Polynomial register value. + */ +uint16_t SPI_GetCRCPolynomial(SPI_TypeDef* SPIx) +{ + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + + /* Return the CRC polynomial register */ + return SPIx->CRCPR; +} + +/** + * @brief Selects the data transfer direction in bi-directional mode for the specified SPI. + * @param SPIx: where x can be 1, 2 or 3 to select the SPI peripheral. + * @param SPI_Direction: specifies the data transfer direction in bi-directional mode. + * This parameter can be one of the following values: + * @arg SPI_Direction_Tx: Selects Tx transmission direction + * @arg SPI_Direction_Rx: Selects Rx receive direction + * @retval None + */ +void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, uint16_t SPI_Direction) +{ + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + assert_param(IS_SPI_DIRECTION(SPI_Direction)); + if (SPI_Direction == SPI_Direction_Tx) + { + /* Set the Tx only mode */ + SPIx->CR1 |= SPI_Direction_Tx; + } + else + { + /* Set the Rx only mode */ + SPIx->CR1 &= SPI_Direction_Rx; + } +} + +/** + * @brief Checks whether the specified SPI/I2S flag is set or not. + * @param SPIx: where x can be + * - 1, 2 or 3 in SPI mode + * - 2 or 3 in I2S mode + * @param SPI_I2S_FLAG: specifies the SPI/I2S flag to check. + * This parameter can be one of the following values: + * @arg SPI_I2S_FLAG_TXE: Transmit buffer empty flag. + * @arg SPI_I2S_FLAG_RXNE: Receive buffer not empty flag. + * @arg SPI_I2S_FLAG_BSY: Busy flag. + * @arg SPI_I2S_FLAG_OVR: Overrun flag. + * @arg SPI_FLAG_MODF: Mode Fault flag. + * @arg SPI_FLAG_CRCERR: CRC Error flag. + * @arg I2S_FLAG_UDR: Underrun Error flag. + * @arg I2S_FLAG_CHSIDE: Channel Side flag. + * @retval The new state of SPI_I2S_FLAG (SET or RESET). + */ +FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG) +{ + FlagStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + assert_param(IS_SPI_I2S_GET_FLAG(SPI_I2S_FLAG)); + /* Check the status of the specified SPI/I2S flag */ + if ((SPIx->SR & SPI_I2S_FLAG) != (uint16_t)RESET) + { + /* SPI_I2S_FLAG is set */ + bitstatus = SET; + } + else + { + /* SPI_I2S_FLAG is reset */ + bitstatus = RESET; + } + /* Return the SPI_I2S_FLAG status */ + return bitstatus; +} + +/** + * @brief Clears the SPIx CRC Error (CRCERR) flag. + * @param SPIx: where x can be + * - 1, 2 or 3 in SPI mode + * @param SPI_I2S_FLAG: specifies the SPI flag to clear. + * This function clears only CRCERR flag. + * @note + * - OVR (OverRun error) flag is cleared by software sequence: a read + * operation to SPI_DR register (SPI_I2S_ReceiveData()) followed by a read + * operation to SPI_SR register (SPI_I2S_GetFlagStatus()). + * - UDR (UnderRun error) flag is cleared by a read operation to + * SPI_SR register (SPI_I2S_GetFlagStatus()). + * - MODF (Mode Fault) flag is cleared by software sequence: a read/write + * operation to SPI_SR register (SPI_I2S_GetFlagStatus()) followed by a + * write operation to SPI_CR1 register (SPI_Cmd() to enable the SPI). + * @retval None + */ +void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG) +{ + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + assert_param(IS_SPI_I2S_CLEAR_FLAG(SPI_I2S_FLAG)); + + /* Clear the selected SPI CRC Error (CRCERR) flag */ + SPIx->SR = (uint16_t)~SPI_I2S_FLAG; +} + +/** + * @brief Checks whether the specified SPI/I2S interrupt has occurred or not. + * @param SPIx: where x can be + * - 1, 2 or 3 in SPI mode + * - 2 or 3 in I2S mode + * @param SPI_I2S_IT: specifies the SPI/I2S interrupt source to check. + * This parameter can be one of the following values: + * @arg SPI_I2S_IT_TXE: Transmit buffer empty interrupt. + * @arg SPI_I2S_IT_RXNE: Receive buffer not empty interrupt. + * @arg SPI_I2S_IT_OVR: Overrun interrupt. + * @arg SPI_IT_MODF: Mode Fault interrupt. + * @arg SPI_IT_CRCERR: CRC Error interrupt. + * @arg I2S_IT_UDR: Underrun Error interrupt. + * @retval The new state of SPI_I2S_IT (SET or RESET). + */ +ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT) +{ + ITStatus bitstatus = RESET; + uint16_t itpos = 0, itmask = 0, enablestatus = 0; + + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + assert_param(IS_SPI_I2S_GET_IT(SPI_I2S_IT)); + + /* Get the SPI/I2S IT index */ + itpos = 0x01 << (SPI_I2S_IT & 0x0F); + + /* Get the SPI/I2S IT mask */ + itmask = SPI_I2S_IT >> 4; + + /* Set the IT mask */ + itmask = 0x01 << itmask; + + /* Get the SPI_I2S_IT enable bit status */ + enablestatus = (SPIx->CR2 & itmask) ; + + /* Check the status of the specified SPI/I2S interrupt */ + if (((SPIx->SR & itpos) != (uint16_t)RESET) && enablestatus) + { + /* SPI_I2S_IT is set */ + bitstatus = SET; + } + else + { + /* SPI_I2S_IT is reset */ + bitstatus = RESET; + } + /* Return the SPI_I2S_IT status */ + return bitstatus; +} + +/** + * @brief Clears the SPIx CRC Error (CRCERR) interrupt pending bit. + * @param SPIx: where x can be + * - 1, 2 or 3 in SPI mode + * @param SPI_I2S_IT: specifies the SPI interrupt pending bit to clear. + * This function clears only CRCERR interrupt pending bit. + * @note + * - OVR (OverRun Error) interrupt pending bit is cleared by software + * sequence: a read operation to SPI_DR register (SPI_I2S_ReceiveData()) + * followed by a read operation to SPI_SR register (SPI_I2S_GetITStatus()). + * - UDR (UnderRun Error) interrupt pending bit is cleared by a read + * operation to SPI_SR register (SPI_I2S_GetITStatus()). + * - MODF (Mode Fault) interrupt pending bit is cleared by software sequence: + * a read/write operation to SPI_SR register (SPI_I2S_GetITStatus()) + * followed by a write operation to SPI_CR1 register (SPI_Cmd() to enable + * the SPI). + * @retval None + */ +void SPI_I2S_ClearITPendingBit(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT) +{ + uint16_t itpos = 0; + /* Check the parameters */ + assert_param(IS_SPI_ALL_PERIPH(SPIx)); + assert_param(IS_SPI_I2S_CLEAR_IT(SPI_I2S_IT)); + + /* Get the SPI IT index */ + itpos = 0x01 << (SPI_I2S_IT & 0x0F); + + /* Clear the selected SPI CRC Error (CRCERR) interrupt pending bit */ + SPIx->SR = (uint16_t)~itpos; +} +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_tim.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_tim.c new file mode 100755 index 0000000..81c8484 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_tim.c @@ -0,0 +1,2890 @@ +/** + ****************************************************************************** + * @file stm32f10x_tim.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the TIM firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_tim.h" +#include "stm32f10x_rcc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup TIM + * @brief TIM driver modules + * @{ + */ + +/** @defgroup TIM_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup TIM_Private_Defines + * @{ + */ + +/* ---------------------- TIM registers bit mask ------------------------ */ +#define SMCR_ETR_Mask ((uint16_t)0x00FF) +#define CCMR_Offset ((uint16_t)0x0018) +#define CCER_CCE_Set ((uint16_t)0x0001) +#define CCER_CCNE_Set ((uint16_t)0x0004) + +/** + * @} + */ + +/** @defgroup TIM_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup TIM_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup TIM_Private_FunctionPrototypes + * @{ + */ + +static void TI1_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, + uint16_t TIM_ICFilter); +static void TI2_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, + uint16_t TIM_ICFilter); +static void TI3_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, + uint16_t TIM_ICFilter); +static void TI4_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, + uint16_t TIM_ICFilter); +/** + * @} + */ + +/** @defgroup TIM_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup TIM_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup TIM_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup TIM_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the TIMx peripheral registers to their default reset values. + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @retval None + */ +void TIM_DeInit(TIM_TypeDef* TIMx) +{ + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + + if (TIMx == TIM1) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM1, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM1, DISABLE); + } + else if (TIMx == TIM2) + { + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2, ENABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2, DISABLE); + } + else if (TIMx == TIM3) + { + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM3, ENABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM3, DISABLE); + } + else if (TIMx == TIM4) + { + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM4, ENABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM4, DISABLE); + } + else if (TIMx == TIM5) + { + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM5, ENABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM5, DISABLE); + } + else if (TIMx == TIM6) + { + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM6, ENABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM6, DISABLE); + } + else if (TIMx == TIM7) + { + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM7, ENABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM7, DISABLE); + } + else if (TIMx == TIM8) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM8, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM8, DISABLE); + } + else if (TIMx == TIM9) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM9, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM9, DISABLE); + } + else if (TIMx == TIM10) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM10, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM10, DISABLE); + } + else if (TIMx == TIM11) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM11, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM11, DISABLE); + } + else if (TIMx == TIM12) + { + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM12, ENABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM12, DISABLE); + } + else if (TIMx == TIM13) + { + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM13, ENABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM13, DISABLE); + } + else if (TIMx == TIM14) + { + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM14, ENABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM14, DISABLE); + } + else if (TIMx == TIM15) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM15, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM15, DISABLE); + } + else if (TIMx == TIM16) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM16, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM16, DISABLE); + } + else + { + if (TIMx == TIM17) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM17, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM17, DISABLE); + } + } +} + +/** + * @brief Initializes the TIMx Time Base Unit peripheral according to + * the specified parameters in the TIM_TimeBaseInitStruct. + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @param TIM_TimeBaseInitStruct: pointer to a TIM_TimeBaseInitTypeDef + * structure that contains the configuration information for the + * specified TIM peripheral. + * @retval None + */ +void TIM_TimeBaseInit(TIM_TypeDef* TIMx, TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct) +{ + uint16_t tmpcr1 = 0; + + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + assert_param(IS_TIM_COUNTER_MODE(TIM_TimeBaseInitStruct->TIM_CounterMode)); + assert_param(IS_TIM_CKD_DIV(TIM_TimeBaseInitStruct->TIM_ClockDivision)); + + tmpcr1 = TIMx->CR1; + + if((TIMx == TIM1) || (TIMx == TIM8)|| (TIMx == TIM2) || (TIMx == TIM3)|| + (TIMx == TIM4) || (TIMx == TIM5)) + { + /* Select the Counter Mode */ + tmpcr1 &= (uint16_t)(~((uint16_t)(TIM_CR1_DIR | TIM_CR1_CMS))); + tmpcr1 |= (uint32_t)TIM_TimeBaseInitStruct->TIM_CounterMode; + } + + if((TIMx != TIM6) && (TIMx != TIM7)) + { + /* Set the clock division */ + tmpcr1 &= (uint16_t)(~((uint16_t)TIM_CR1_CKD)); + tmpcr1 |= (uint32_t)TIM_TimeBaseInitStruct->TIM_ClockDivision; + } + + TIMx->CR1 = tmpcr1; + + /* Set the Autoreload value */ + TIMx->ARR = TIM_TimeBaseInitStruct->TIM_Period ; + + /* Set the Prescaler value */ + TIMx->PSC = TIM_TimeBaseInitStruct->TIM_Prescaler; + + if ((TIMx == TIM1) || (TIMx == TIM8)|| (TIMx == TIM15)|| (TIMx == TIM16) || (TIMx == TIM17)) + { + /* Set the Repetition Counter value */ + TIMx->RCR = TIM_TimeBaseInitStruct->TIM_RepetitionCounter; + } + + /* Generate an update event to reload the Prescaler and the Repetition counter + values immediately */ + TIMx->EGR = TIM_PSCReloadMode_Immediate; +} + +/** + * @brief Initializes the TIMx Channel1 according to the specified + * parameters in the TIM_OCInitStruct. + * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral. + * @param TIM_OCInitStruct: pointer to a TIM_OCInitTypeDef structure + * that contains the configuration information for the specified TIM peripheral. + * @retval None + */ +void TIM_OC1Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct) +{ + uint16_t tmpccmrx = 0, tmpccer = 0, tmpcr2 = 0; + + /* Check the parameters */ + assert_param(IS_TIM_LIST8_PERIPH(TIMx)); + assert_param(IS_TIM_OC_MODE(TIM_OCInitStruct->TIM_OCMode)); + assert_param(IS_TIM_OUTPUT_STATE(TIM_OCInitStruct->TIM_OutputState)); + assert_param(IS_TIM_OC_POLARITY(TIM_OCInitStruct->TIM_OCPolarity)); + /* Disable the Channel 1: Reset the CC1E Bit */ + TIMx->CCER &= (uint16_t)(~(uint16_t)TIM_CCER_CC1E); + /* Get the TIMx CCER register value */ + tmpccer = TIMx->CCER; + /* Get the TIMx CR2 register value */ + tmpcr2 = TIMx->CR2; + + /* Get the TIMx CCMR1 register value */ + tmpccmrx = TIMx->CCMR1; + + /* Reset the Output Compare Mode Bits */ + tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR1_OC1M)); + tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR1_CC1S)); + + /* Select the Output Compare Mode */ + tmpccmrx |= TIM_OCInitStruct->TIM_OCMode; + + /* Reset the Output Polarity level */ + tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC1P)); + /* Set the Output Compare Polarity */ + tmpccer |= TIM_OCInitStruct->TIM_OCPolarity; + + /* Set the Output State */ + tmpccer |= TIM_OCInitStruct->TIM_OutputState; + + if((TIMx == TIM1) || (TIMx == TIM8)|| (TIMx == TIM15)|| + (TIMx == TIM16)|| (TIMx == TIM17)) + { + assert_param(IS_TIM_OUTPUTN_STATE(TIM_OCInitStruct->TIM_OutputNState)); + assert_param(IS_TIM_OCN_POLARITY(TIM_OCInitStruct->TIM_OCNPolarity)); + assert_param(IS_TIM_OCNIDLE_STATE(TIM_OCInitStruct->TIM_OCNIdleState)); + assert_param(IS_TIM_OCIDLE_STATE(TIM_OCInitStruct->TIM_OCIdleState)); + + /* Reset the Output N Polarity level */ + tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC1NP)); + /* Set the Output N Polarity */ + tmpccer |= TIM_OCInitStruct->TIM_OCNPolarity; + + /* Reset the Output N State */ + tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC1NE)); + /* Set the Output N State */ + tmpccer |= TIM_OCInitStruct->TIM_OutputNState; + + /* Reset the Output Compare and Output Compare N IDLE State */ + tmpcr2 &= (uint16_t)(~((uint16_t)TIM_CR2_OIS1)); + tmpcr2 &= (uint16_t)(~((uint16_t)TIM_CR2_OIS1N)); + + /* Set the Output Idle state */ + tmpcr2 |= TIM_OCInitStruct->TIM_OCIdleState; + /* Set the Output N Idle state */ + tmpcr2 |= TIM_OCInitStruct->TIM_OCNIdleState; + } + /* Write to TIMx CR2 */ + TIMx->CR2 = tmpcr2; + + /* Write to TIMx CCMR1 */ + TIMx->CCMR1 = tmpccmrx; + + /* Set the Capture Compare Register value */ + TIMx->CCR1 = TIM_OCInitStruct->TIM_Pulse; + + /* Write to TIMx CCER */ + TIMx->CCER = tmpccer; +} + +/** + * @brief Initializes the TIMx Channel2 according to the specified + * parameters in the TIM_OCInitStruct. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select + * the TIM peripheral. + * @param TIM_OCInitStruct: pointer to a TIM_OCInitTypeDef structure + * that contains the configuration information for the specified TIM peripheral. + * @retval None + */ +void TIM_OC2Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct) +{ + uint16_t tmpccmrx = 0, tmpccer = 0, tmpcr2 = 0; + + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + assert_param(IS_TIM_OC_MODE(TIM_OCInitStruct->TIM_OCMode)); + assert_param(IS_TIM_OUTPUT_STATE(TIM_OCInitStruct->TIM_OutputState)); + assert_param(IS_TIM_OC_POLARITY(TIM_OCInitStruct->TIM_OCPolarity)); + /* Disable the Channel 2: Reset the CC2E Bit */ + TIMx->CCER &= (uint16_t)(~((uint16_t)TIM_CCER_CC2E)); + + /* Get the TIMx CCER register value */ + tmpccer = TIMx->CCER; + /* Get the TIMx CR2 register value */ + tmpcr2 = TIMx->CR2; + + /* Get the TIMx CCMR1 register value */ + tmpccmrx = TIMx->CCMR1; + + /* Reset the Output Compare mode and Capture/Compare selection Bits */ + tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR1_OC2M)); + tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR1_CC2S)); + + /* Select the Output Compare Mode */ + tmpccmrx |= (uint16_t)(TIM_OCInitStruct->TIM_OCMode << 8); + + /* Reset the Output Polarity level */ + tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC2P)); + /* Set the Output Compare Polarity */ + tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OCPolarity << 4); + + /* Set the Output State */ + tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OutputState << 4); + + if((TIMx == TIM1) || (TIMx == TIM8)) + { + assert_param(IS_TIM_OUTPUTN_STATE(TIM_OCInitStruct->TIM_OutputNState)); + assert_param(IS_TIM_OCN_POLARITY(TIM_OCInitStruct->TIM_OCNPolarity)); + assert_param(IS_TIM_OCNIDLE_STATE(TIM_OCInitStruct->TIM_OCNIdleState)); + assert_param(IS_TIM_OCIDLE_STATE(TIM_OCInitStruct->TIM_OCIdleState)); + + /* Reset the Output N Polarity level */ + tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC2NP)); + /* Set the Output N Polarity */ + tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OCNPolarity << 4); + + /* Reset the Output N State */ + tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC2NE)); + /* Set the Output N State */ + tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OutputNState << 4); + + /* Reset the Output Compare and Output Compare N IDLE State */ + tmpcr2 &= (uint16_t)(~((uint16_t)TIM_CR2_OIS2)); + tmpcr2 &= (uint16_t)(~((uint16_t)TIM_CR2_OIS2N)); + + /* Set the Output Idle state */ + tmpcr2 |= (uint16_t)(TIM_OCInitStruct->TIM_OCIdleState << 2); + /* Set the Output N Idle state */ + tmpcr2 |= (uint16_t)(TIM_OCInitStruct->TIM_OCNIdleState << 2); + } + /* Write to TIMx CR2 */ + TIMx->CR2 = tmpcr2; + + /* Write to TIMx CCMR1 */ + TIMx->CCMR1 = tmpccmrx; + + /* Set the Capture Compare Register value */ + TIMx->CCR2 = TIM_OCInitStruct->TIM_Pulse; + + /* Write to TIMx CCER */ + TIMx->CCER = tmpccer; +} + +/** + * @brief Initializes the TIMx Channel3 according to the specified + * parameters in the TIM_OCInitStruct. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_OCInitStruct: pointer to a TIM_OCInitTypeDef structure + * that contains the configuration information for the specified TIM peripheral. + * @retval None + */ +void TIM_OC3Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct) +{ + uint16_t tmpccmrx = 0, tmpccer = 0, tmpcr2 = 0; + + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_OC_MODE(TIM_OCInitStruct->TIM_OCMode)); + assert_param(IS_TIM_OUTPUT_STATE(TIM_OCInitStruct->TIM_OutputState)); + assert_param(IS_TIM_OC_POLARITY(TIM_OCInitStruct->TIM_OCPolarity)); + /* Disable the Channel 2: Reset the CC2E Bit */ + TIMx->CCER &= (uint16_t)(~((uint16_t)TIM_CCER_CC3E)); + + /* Get the TIMx CCER register value */ + tmpccer = TIMx->CCER; + /* Get the TIMx CR2 register value */ + tmpcr2 = TIMx->CR2; + + /* Get the TIMx CCMR2 register value */ + tmpccmrx = TIMx->CCMR2; + + /* Reset the Output Compare mode and Capture/Compare selection Bits */ + tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR2_OC3M)); + tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR2_CC3S)); + /* Select the Output Compare Mode */ + tmpccmrx |= TIM_OCInitStruct->TIM_OCMode; + + /* Reset the Output Polarity level */ + tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC3P)); + /* Set the Output Compare Polarity */ + tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OCPolarity << 8); + + /* Set the Output State */ + tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OutputState << 8); + + if((TIMx == TIM1) || (TIMx == TIM8)) + { + assert_param(IS_TIM_OUTPUTN_STATE(TIM_OCInitStruct->TIM_OutputNState)); + assert_param(IS_TIM_OCN_POLARITY(TIM_OCInitStruct->TIM_OCNPolarity)); + assert_param(IS_TIM_OCNIDLE_STATE(TIM_OCInitStruct->TIM_OCNIdleState)); + assert_param(IS_TIM_OCIDLE_STATE(TIM_OCInitStruct->TIM_OCIdleState)); + + /* Reset the Output N Polarity level */ + tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC3NP)); + /* Set the Output N Polarity */ + tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OCNPolarity << 8); + /* Reset the Output N State */ + tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC3NE)); + + /* Set the Output N State */ + tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OutputNState << 8); + /* Reset the Output Compare and Output Compare N IDLE State */ + tmpcr2 &= (uint16_t)(~((uint16_t)TIM_CR2_OIS3)); + tmpcr2 &= (uint16_t)(~((uint16_t)TIM_CR2_OIS3N)); + /* Set the Output Idle state */ + tmpcr2 |= (uint16_t)(TIM_OCInitStruct->TIM_OCIdleState << 4); + /* Set the Output N Idle state */ + tmpcr2 |= (uint16_t)(TIM_OCInitStruct->TIM_OCNIdleState << 4); + } + /* Write to TIMx CR2 */ + TIMx->CR2 = tmpcr2; + + /* Write to TIMx CCMR2 */ + TIMx->CCMR2 = tmpccmrx; + + /* Set the Capture Compare Register value */ + TIMx->CCR3 = TIM_OCInitStruct->TIM_Pulse; + + /* Write to TIMx CCER */ + TIMx->CCER = tmpccer; +} + +/** + * @brief Initializes the TIMx Channel4 according to the specified + * parameters in the TIM_OCInitStruct. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_OCInitStruct: pointer to a TIM_OCInitTypeDef structure + * that contains the configuration information for the specified TIM peripheral. + * @retval None + */ +void TIM_OC4Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct) +{ + uint16_t tmpccmrx = 0, tmpccer = 0, tmpcr2 = 0; + + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_OC_MODE(TIM_OCInitStruct->TIM_OCMode)); + assert_param(IS_TIM_OUTPUT_STATE(TIM_OCInitStruct->TIM_OutputState)); + assert_param(IS_TIM_OC_POLARITY(TIM_OCInitStruct->TIM_OCPolarity)); + /* Disable the Channel 2: Reset the CC4E Bit */ + TIMx->CCER &= (uint16_t)(~((uint16_t)TIM_CCER_CC4E)); + + /* Get the TIMx CCER register value */ + tmpccer = TIMx->CCER; + /* Get the TIMx CR2 register value */ + tmpcr2 = TIMx->CR2; + + /* Get the TIMx CCMR2 register value */ + tmpccmrx = TIMx->CCMR2; + + /* Reset the Output Compare mode and Capture/Compare selection Bits */ + tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR2_OC4M)); + tmpccmrx &= (uint16_t)(~((uint16_t)TIM_CCMR2_CC4S)); + + /* Select the Output Compare Mode */ + tmpccmrx |= (uint16_t)(TIM_OCInitStruct->TIM_OCMode << 8); + + /* Reset the Output Polarity level */ + tmpccer &= (uint16_t)(~((uint16_t)TIM_CCER_CC4P)); + /* Set the Output Compare Polarity */ + tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OCPolarity << 12); + + /* Set the Output State */ + tmpccer |= (uint16_t)(TIM_OCInitStruct->TIM_OutputState << 12); + + if((TIMx == TIM1) || (TIMx == TIM8)) + { + assert_param(IS_TIM_OCIDLE_STATE(TIM_OCInitStruct->TIM_OCIdleState)); + /* Reset the Output Compare IDLE State */ + tmpcr2 &= (uint16_t)(~((uint16_t)TIM_CR2_OIS4)); + /* Set the Output Idle state */ + tmpcr2 |= (uint16_t)(TIM_OCInitStruct->TIM_OCIdleState << 6); + } + /* Write to TIMx CR2 */ + TIMx->CR2 = tmpcr2; + + /* Write to TIMx CCMR2 */ + TIMx->CCMR2 = tmpccmrx; + + /* Set the Capture Compare Register value */ + TIMx->CCR4 = TIM_OCInitStruct->TIM_Pulse; + + /* Write to TIMx CCER */ + TIMx->CCER = tmpccer; +} + +/** + * @brief Initializes the TIM peripheral according to the specified + * parameters in the TIM_ICInitStruct. + * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral. + * @param TIM_ICInitStruct: pointer to a TIM_ICInitTypeDef structure + * that contains the configuration information for the specified TIM peripheral. + * @retval None + */ +void TIM_ICInit(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct) +{ + /* Check the parameters */ + assert_param(IS_TIM_CHANNEL(TIM_ICInitStruct->TIM_Channel)); + assert_param(IS_TIM_IC_SELECTION(TIM_ICInitStruct->TIM_ICSelection)); + assert_param(IS_TIM_IC_PRESCALER(TIM_ICInitStruct->TIM_ICPrescaler)); + assert_param(IS_TIM_IC_FILTER(TIM_ICInitStruct->TIM_ICFilter)); + + if((TIMx == TIM1) || (TIMx == TIM8) || (TIMx == TIM2) || (TIMx == TIM3) || + (TIMx == TIM4) ||(TIMx == TIM5)) + { + assert_param(IS_TIM_IC_POLARITY(TIM_ICInitStruct->TIM_ICPolarity)); + } + else + { + assert_param(IS_TIM_IC_POLARITY_LITE(TIM_ICInitStruct->TIM_ICPolarity)); + } + if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_1) + { + assert_param(IS_TIM_LIST8_PERIPH(TIMx)); + /* TI1 Configuration */ + TI1_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity, + TIM_ICInitStruct->TIM_ICSelection, + TIM_ICInitStruct->TIM_ICFilter); + /* Set the Input Capture Prescaler value */ + TIM_SetIC1Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler); + } + else if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_2) + { + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + /* TI2 Configuration */ + TI2_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity, + TIM_ICInitStruct->TIM_ICSelection, + TIM_ICInitStruct->TIM_ICFilter); + /* Set the Input Capture Prescaler value */ + TIM_SetIC2Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler); + } + else if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_3) + { + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + /* TI3 Configuration */ + TI3_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity, + TIM_ICInitStruct->TIM_ICSelection, + TIM_ICInitStruct->TIM_ICFilter); + /* Set the Input Capture Prescaler value */ + TIM_SetIC3Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler); + } + else + { + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + /* TI4 Configuration */ + TI4_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity, + TIM_ICInitStruct->TIM_ICSelection, + TIM_ICInitStruct->TIM_ICFilter); + /* Set the Input Capture Prescaler value */ + TIM_SetIC4Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler); + } +} + +/** + * @brief Configures the TIM peripheral according to the specified + * parameters in the TIM_ICInitStruct to measure an external PWM signal. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral. + * @param TIM_ICInitStruct: pointer to a TIM_ICInitTypeDef structure + * that contains the configuration information for the specified TIM peripheral. + * @retval None + */ +void TIM_PWMIConfig(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct) +{ + uint16_t icoppositepolarity = TIM_ICPolarity_Rising; + uint16_t icoppositeselection = TIM_ICSelection_DirectTI; + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + /* Select the Opposite Input Polarity */ + if (TIM_ICInitStruct->TIM_ICPolarity == TIM_ICPolarity_Rising) + { + icoppositepolarity = TIM_ICPolarity_Falling; + } + else + { + icoppositepolarity = TIM_ICPolarity_Rising; + } + /* Select the Opposite Input */ + if (TIM_ICInitStruct->TIM_ICSelection == TIM_ICSelection_DirectTI) + { + icoppositeselection = TIM_ICSelection_IndirectTI; + } + else + { + icoppositeselection = TIM_ICSelection_DirectTI; + } + if (TIM_ICInitStruct->TIM_Channel == TIM_Channel_1) + { + /* TI1 Configuration */ + TI1_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity, TIM_ICInitStruct->TIM_ICSelection, + TIM_ICInitStruct->TIM_ICFilter); + /* Set the Input Capture Prescaler value */ + TIM_SetIC1Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler); + /* TI2 Configuration */ + TI2_Config(TIMx, icoppositepolarity, icoppositeselection, TIM_ICInitStruct->TIM_ICFilter); + /* Set the Input Capture Prescaler value */ + TIM_SetIC2Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler); + } + else + { + /* TI2 Configuration */ + TI2_Config(TIMx, TIM_ICInitStruct->TIM_ICPolarity, TIM_ICInitStruct->TIM_ICSelection, + TIM_ICInitStruct->TIM_ICFilter); + /* Set the Input Capture Prescaler value */ + TIM_SetIC2Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler); + /* TI1 Configuration */ + TI1_Config(TIMx, icoppositepolarity, icoppositeselection, TIM_ICInitStruct->TIM_ICFilter); + /* Set the Input Capture Prescaler value */ + TIM_SetIC1Prescaler(TIMx, TIM_ICInitStruct->TIM_ICPrescaler); + } +} + +/** + * @brief Configures the: Break feature, dead time, Lock level, the OSSI, + * the OSSR State and the AOE(automatic output enable). + * @param TIMx: where x can be 1 or 8 to select the TIM + * @param TIM_BDTRInitStruct: pointer to a TIM_BDTRInitTypeDef structure that + * contains the BDTR Register configuration information for the TIM peripheral. + * @retval None + */ +void TIM_BDTRConfig(TIM_TypeDef* TIMx, TIM_BDTRInitTypeDef *TIM_BDTRInitStruct) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST2_PERIPH(TIMx)); + assert_param(IS_TIM_OSSR_STATE(TIM_BDTRInitStruct->TIM_OSSRState)); + assert_param(IS_TIM_OSSI_STATE(TIM_BDTRInitStruct->TIM_OSSIState)); + assert_param(IS_TIM_LOCK_LEVEL(TIM_BDTRInitStruct->TIM_LOCKLevel)); + assert_param(IS_TIM_BREAK_STATE(TIM_BDTRInitStruct->TIM_Break)); + assert_param(IS_TIM_BREAK_POLARITY(TIM_BDTRInitStruct->TIM_BreakPolarity)); + assert_param(IS_TIM_AUTOMATIC_OUTPUT_STATE(TIM_BDTRInitStruct->TIM_AutomaticOutput)); + /* Set the Lock level, the Break enable Bit and the Ploarity, the OSSR State, + the OSSI State, the dead time value and the Automatic Output Enable Bit */ + TIMx->BDTR = (uint32_t)TIM_BDTRInitStruct->TIM_OSSRState | TIM_BDTRInitStruct->TIM_OSSIState | + TIM_BDTRInitStruct->TIM_LOCKLevel | TIM_BDTRInitStruct->TIM_DeadTime | + TIM_BDTRInitStruct->TIM_Break | TIM_BDTRInitStruct->TIM_BreakPolarity | + TIM_BDTRInitStruct->TIM_AutomaticOutput; +} + +/** + * @brief Fills each TIM_TimeBaseInitStruct member with its default value. + * @param TIM_TimeBaseInitStruct : pointer to a TIM_TimeBaseInitTypeDef + * structure which will be initialized. + * @retval None + */ +void TIM_TimeBaseStructInit(TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct) +{ + /* Set the default configuration */ + TIM_TimeBaseInitStruct->TIM_Period = 0xFFFF; + TIM_TimeBaseInitStruct->TIM_Prescaler = 0x0000; + TIM_TimeBaseInitStruct->TIM_ClockDivision = TIM_CKD_DIV1; + TIM_TimeBaseInitStruct->TIM_CounterMode = TIM_CounterMode_Up; + TIM_TimeBaseInitStruct->TIM_RepetitionCounter = 0x0000; +} + +/** + * @brief Fills each TIM_OCInitStruct member with its default value. + * @param TIM_OCInitStruct : pointer to a TIM_OCInitTypeDef structure which will + * be initialized. + * @retval None + */ +void TIM_OCStructInit(TIM_OCInitTypeDef* TIM_OCInitStruct) +{ + /* Set the default configuration */ + TIM_OCInitStruct->TIM_OCMode = TIM_OCMode_Timing; + TIM_OCInitStruct->TIM_OutputState = TIM_OutputState_Disable; + TIM_OCInitStruct->TIM_OutputNState = TIM_OutputNState_Disable; + TIM_OCInitStruct->TIM_Pulse = 0x0000; + TIM_OCInitStruct->TIM_OCPolarity = TIM_OCPolarity_High; + TIM_OCInitStruct->TIM_OCNPolarity = TIM_OCPolarity_High; + TIM_OCInitStruct->TIM_OCIdleState = TIM_OCIdleState_Reset; + TIM_OCInitStruct->TIM_OCNIdleState = TIM_OCNIdleState_Reset; +} + +/** + * @brief Fills each TIM_ICInitStruct member with its default value. + * @param TIM_ICInitStruct: pointer to a TIM_ICInitTypeDef structure which will + * be initialized. + * @retval None + */ +void TIM_ICStructInit(TIM_ICInitTypeDef* TIM_ICInitStruct) +{ + /* Set the default configuration */ + TIM_ICInitStruct->TIM_Channel = TIM_Channel_1; + TIM_ICInitStruct->TIM_ICPolarity = TIM_ICPolarity_Rising; + TIM_ICInitStruct->TIM_ICSelection = TIM_ICSelection_DirectTI; + TIM_ICInitStruct->TIM_ICPrescaler = TIM_ICPSC_DIV1; + TIM_ICInitStruct->TIM_ICFilter = 0x00; +} + +/** + * @brief Fills each TIM_BDTRInitStruct member with its default value. + * @param TIM_BDTRInitStruct: pointer to a TIM_BDTRInitTypeDef structure which + * will be initialized. + * @retval None + */ +void TIM_BDTRStructInit(TIM_BDTRInitTypeDef* TIM_BDTRInitStruct) +{ + /* Set the default configuration */ + TIM_BDTRInitStruct->TIM_OSSRState = TIM_OSSRState_Disable; + TIM_BDTRInitStruct->TIM_OSSIState = TIM_OSSIState_Disable; + TIM_BDTRInitStruct->TIM_LOCKLevel = TIM_LOCKLevel_OFF; + TIM_BDTRInitStruct->TIM_DeadTime = 0x00; + TIM_BDTRInitStruct->TIM_Break = TIM_Break_Disable; + TIM_BDTRInitStruct->TIM_BreakPolarity = TIM_BreakPolarity_Low; + TIM_BDTRInitStruct->TIM_AutomaticOutput = TIM_AutomaticOutput_Disable; +} + +/** + * @brief Enables or disables the specified TIM peripheral. + * @param TIMx: where x can be 1 to 17 to select the TIMx peripheral. + * @param NewState: new state of the TIMx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void TIM_Cmd(TIM_TypeDef* TIMx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the TIM Counter */ + TIMx->CR1 |= TIM_CR1_CEN; + } + else + { + /* Disable the TIM Counter */ + TIMx->CR1 &= (uint16_t)(~((uint16_t)TIM_CR1_CEN)); + } +} + +/** + * @brief Enables or disables the TIM peripheral Main Outputs. + * @param TIMx: where x can be 1, 8, 15, 16 or 17 to select the TIMx peripheral. + * @param NewState: new state of the TIM peripheral Main Outputs. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void TIM_CtrlPWMOutputs(TIM_TypeDef* TIMx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST2_PERIPH(TIMx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the TIM Main Output */ + TIMx->BDTR |= TIM_BDTR_MOE; + } + else + { + /* Disable the TIM Main Output */ + TIMx->BDTR &= (uint16_t)(~((uint16_t)TIM_BDTR_MOE)); + } +} + +/** + * @brief Enables or disables the specified TIM interrupts. + * @param TIMx: where x can be 1 to 17 to select the TIMx peripheral. + * @param TIM_IT: specifies the TIM interrupts sources to be enabled or disabled. + * This parameter can be any combination of the following values: + * @arg TIM_IT_Update: TIM update Interrupt source + * @arg TIM_IT_CC1: TIM Capture Compare 1 Interrupt source + * @arg TIM_IT_CC2: TIM Capture Compare 2 Interrupt source + * @arg TIM_IT_CC3: TIM Capture Compare 3 Interrupt source + * @arg TIM_IT_CC4: TIM Capture Compare 4 Interrupt source + * @arg TIM_IT_COM: TIM Commutation Interrupt source + * @arg TIM_IT_Trigger: TIM Trigger Interrupt source + * @arg TIM_IT_Break: TIM Break Interrupt source + * @note + * - TIM6 and TIM7 can only generate an update interrupt. + * - TIM9, TIM12 and TIM15 can have only TIM_IT_Update, TIM_IT_CC1, + * TIM_IT_CC2 or TIM_IT_Trigger. + * - TIM10, TIM11, TIM13, TIM14, TIM16 and TIM17 can have TIM_IT_Update or TIM_IT_CC1. + * - TIM_IT_Break is used only with TIM1, TIM8 and TIM15. + * - TIM_IT_COM is used only with TIM1, TIM8, TIM15, TIM16 and TIM17. + * @param NewState: new state of the TIM interrupts. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void TIM_ITConfig(TIM_TypeDef* TIMx, uint16_t TIM_IT, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + assert_param(IS_TIM_IT(TIM_IT)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the Interrupt sources */ + TIMx->DIER |= TIM_IT; + } + else + { + /* Disable the Interrupt sources */ + TIMx->DIER &= (uint16_t)~TIM_IT; + } +} + +/** + * @brief Configures the TIMx event to be generate by software. + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @param TIM_EventSource: specifies the event source. + * This parameter can be one or more of the following values: + * @arg TIM_EventSource_Update: Timer update Event source + * @arg TIM_EventSource_CC1: Timer Capture Compare 1 Event source + * @arg TIM_EventSource_CC2: Timer Capture Compare 2 Event source + * @arg TIM_EventSource_CC3: Timer Capture Compare 3 Event source + * @arg TIM_EventSource_CC4: Timer Capture Compare 4 Event source + * @arg TIM_EventSource_COM: Timer COM event source + * @arg TIM_EventSource_Trigger: Timer Trigger Event source + * @arg TIM_EventSource_Break: Timer Break event source + * @note + * - TIM6 and TIM7 can only generate an update event. + * - TIM_EventSource_COM and TIM_EventSource_Break are used only with TIM1 and TIM8. + * @retval None + */ +void TIM_GenerateEvent(TIM_TypeDef* TIMx, uint16_t TIM_EventSource) +{ + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + assert_param(IS_TIM_EVENT_SOURCE(TIM_EventSource)); + + /* Set the event sources */ + TIMx->EGR = TIM_EventSource; +} + +/** + * @brief Configures the TIMx's DMA interface. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 15, 16 or 17 to select + * the TIM peripheral. + * @param TIM_DMABase: DMA Base address. + * This parameter can be one of the following values: + * @arg TIM_DMABase_CR, TIM_DMABase_CR2, TIM_DMABase_SMCR, + * TIM_DMABase_DIER, TIM1_DMABase_SR, TIM_DMABase_EGR, + * TIM_DMABase_CCMR1, TIM_DMABase_CCMR2, TIM_DMABase_CCER, + * TIM_DMABase_CNT, TIM_DMABase_PSC, TIM_DMABase_ARR, + * TIM_DMABase_RCR, TIM_DMABase_CCR1, TIM_DMABase_CCR2, + * TIM_DMABase_CCR3, TIM_DMABase_CCR4, TIM_DMABase_BDTR, + * TIM_DMABase_DCR. + * @param TIM_DMABurstLength: DMA Burst length. + * This parameter can be one value between: + * TIM_DMABurstLength_1Transfer and TIM_DMABurstLength_18Transfers. + * @retval None + */ +void TIM_DMAConfig(TIM_TypeDef* TIMx, uint16_t TIM_DMABase, uint16_t TIM_DMABurstLength) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST4_PERIPH(TIMx)); + assert_param(IS_TIM_DMA_BASE(TIM_DMABase)); + assert_param(IS_TIM_DMA_LENGTH(TIM_DMABurstLength)); + /* Set the DMA Base and the DMA Burst Length */ + TIMx->DCR = TIM_DMABase | TIM_DMABurstLength; +} + +/** + * @brief Enables or disables the TIMx's DMA Requests. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 6, 7, 8, 15, 16 or 17 + * to select the TIM peripheral. + * @param TIM_DMASource: specifies the DMA Request sources. + * This parameter can be any combination of the following values: + * @arg TIM_DMA_Update: TIM update Interrupt source + * @arg TIM_DMA_CC1: TIM Capture Compare 1 DMA source + * @arg TIM_DMA_CC2: TIM Capture Compare 2 DMA source + * @arg TIM_DMA_CC3: TIM Capture Compare 3 DMA source + * @arg TIM_DMA_CC4: TIM Capture Compare 4 DMA source + * @arg TIM_DMA_COM: TIM Commutation DMA source + * @arg TIM_DMA_Trigger: TIM Trigger DMA source + * @param NewState: new state of the DMA Request sources. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void TIM_DMACmd(TIM_TypeDef* TIMx, uint16_t TIM_DMASource, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST9_PERIPH(TIMx)); + assert_param(IS_TIM_DMA_SOURCE(TIM_DMASource)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the DMA sources */ + TIMx->DIER |= TIM_DMASource; + } + else + { + /* Disable the DMA sources */ + TIMx->DIER &= (uint16_t)~TIM_DMASource; + } +} + +/** + * @brief Configures the TIMx internal Clock + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 + * to select the TIM peripheral. + * @retval None + */ +void TIM_InternalClockConfig(TIM_TypeDef* TIMx) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + /* Disable slave mode to clock the prescaler directly with the internal clock */ + TIMx->SMCR &= (uint16_t)(~((uint16_t)TIM_SMCR_SMS)); +} + +/** + * @brief Configures the TIMx Internal Trigger as External Clock + * @param TIMx: where x can be 1, 2, 3, 4, 5, 9, 12 or 15 to select the TIM peripheral. + * @param TIM_ITRSource: Trigger source. + * This parameter can be one of the following values: + * @param TIM_TS_ITR0: Internal Trigger 0 + * @param TIM_TS_ITR1: Internal Trigger 1 + * @param TIM_TS_ITR2: Internal Trigger 2 + * @param TIM_TS_ITR3: Internal Trigger 3 + * @retval None + */ +void TIM_ITRxExternalClockConfig(TIM_TypeDef* TIMx, uint16_t TIM_InputTriggerSource) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + assert_param(IS_TIM_INTERNAL_TRIGGER_SELECTION(TIM_InputTriggerSource)); + /* Select the Internal Trigger */ + TIM_SelectInputTrigger(TIMx, TIM_InputTriggerSource); + /* Select the External clock mode1 */ + TIMx->SMCR |= TIM_SlaveMode_External1; +} + +/** + * @brief Configures the TIMx Trigger as External Clock + * @param TIMx: where x can be 1, 2, 3, 4, 5, 9, 12 or 15 to select the TIM peripheral. + * @param TIM_TIxExternalCLKSource: Trigger source. + * This parameter can be one of the following values: + * @arg TIM_TIxExternalCLK1Source_TI1ED: TI1 Edge Detector + * @arg TIM_TIxExternalCLK1Source_TI1: Filtered Timer Input 1 + * @arg TIM_TIxExternalCLK1Source_TI2: Filtered Timer Input 2 + * @param TIM_ICPolarity: specifies the TIx Polarity. + * This parameter can be one of the following values: + * @arg TIM_ICPolarity_Rising + * @arg TIM_ICPolarity_Falling + * @param ICFilter : specifies the filter value. + * This parameter must be a value between 0x0 and 0xF. + * @retval None + */ +void TIM_TIxExternalClockConfig(TIM_TypeDef* TIMx, uint16_t TIM_TIxExternalCLKSource, + uint16_t TIM_ICPolarity, uint16_t ICFilter) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + assert_param(IS_TIM_TIXCLK_SOURCE(TIM_TIxExternalCLKSource)); + assert_param(IS_TIM_IC_POLARITY(TIM_ICPolarity)); + assert_param(IS_TIM_IC_FILTER(ICFilter)); + /* Configure the Timer Input Clock Source */ + if (TIM_TIxExternalCLKSource == TIM_TIxExternalCLK1Source_TI2) + { + TI2_Config(TIMx, TIM_ICPolarity, TIM_ICSelection_DirectTI, ICFilter); + } + else + { + TI1_Config(TIMx, TIM_ICPolarity, TIM_ICSelection_DirectTI, ICFilter); + } + /* Select the Trigger source */ + TIM_SelectInputTrigger(TIMx, TIM_TIxExternalCLKSource); + /* Select the External clock mode1 */ + TIMx->SMCR |= TIM_SlaveMode_External1; +} + +/** + * @brief Configures the External clock Mode1 + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_ExtTRGPrescaler: The external Trigger Prescaler. + * This parameter can be one of the following values: + * @arg TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF. + * @arg TIM_ExtTRGPSC_DIV2: ETRP frequency divided by 2. + * @arg TIM_ExtTRGPSC_DIV4: ETRP frequency divided by 4. + * @arg TIM_ExtTRGPSC_DIV8: ETRP frequency divided by 8. + * @param TIM_ExtTRGPolarity: The external Trigger Polarity. + * This parameter can be one of the following values: + * @arg TIM_ExtTRGPolarity_Inverted: active low or falling edge active. + * @arg TIM_ExtTRGPolarity_NonInverted: active high or rising edge active. + * @param ExtTRGFilter: External Trigger Filter. + * This parameter must be a value between 0x00 and 0x0F + * @retval None + */ +void TIM_ETRClockMode1Config(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity, + uint16_t ExtTRGFilter) +{ + uint16_t tmpsmcr = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_EXT_PRESCALER(TIM_ExtTRGPrescaler)); + assert_param(IS_TIM_EXT_POLARITY(TIM_ExtTRGPolarity)); + assert_param(IS_TIM_EXT_FILTER(ExtTRGFilter)); + /* Configure the ETR Clock source */ + TIM_ETRConfig(TIMx, TIM_ExtTRGPrescaler, TIM_ExtTRGPolarity, ExtTRGFilter); + + /* Get the TIMx SMCR register value */ + tmpsmcr = TIMx->SMCR; + /* Reset the SMS Bits */ + tmpsmcr &= (uint16_t)(~((uint16_t)TIM_SMCR_SMS)); + /* Select the External clock mode1 */ + tmpsmcr |= TIM_SlaveMode_External1; + /* Select the Trigger selection : ETRF */ + tmpsmcr &= (uint16_t)(~((uint16_t)TIM_SMCR_TS)); + tmpsmcr |= TIM_TS_ETRF; + /* Write to TIMx SMCR */ + TIMx->SMCR = tmpsmcr; +} + +/** + * @brief Configures the External clock Mode2 + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_ExtTRGPrescaler: The external Trigger Prescaler. + * This parameter can be one of the following values: + * @arg TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF. + * @arg TIM_ExtTRGPSC_DIV2: ETRP frequency divided by 2. + * @arg TIM_ExtTRGPSC_DIV4: ETRP frequency divided by 4. + * @arg TIM_ExtTRGPSC_DIV8: ETRP frequency divided by 8. + * @param TIM_ExtTRGPolarity: The external Trigger Polarity. + * This parameter can be one of the following values: + * @arg TIM_ExtTRGPolarity_Inverted: active low or falling edge active. + * @arg TIM_ExtTRGPolarity_NonInverted: active high or rising edge active. + * @param ExtTRGFilter: External Trigger Filter. + * This parameter must be a value between 0x00 and 0x0F + * @retval None + */ +void TIM_ETRClockMode2Config(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, + uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_EXT_PRESCALER(TIM_ExtTRGPrescaler)); + assert_param(IS_TIM_EXT_POLARITY(TIM_ExtTRGPolarity)); + assert_param(IS_TIM_EXT_FILTER(ExtTRGFilter)); + /* Configure the ETR Clock source */ + TIM_ETRConfig(TIMx, TIM_ExtTRGPrescaler, TIM_ExtTRGPolarity, ExtTRGFilter); + /* Enable the External clock mode2 */ + TIMx->SMCR |= TIM_SMCR_ECE; +} + +/** + * @brief Configures the TIMx External Trigger (ETR). + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_ExtTRGPrescaler: The external Trigger Prescaler. + * This parameter can be one of the following values: + * @arg TIM_ExtTRGPSC_OFF: ETRP Prescaler OFF. + * @arg TIM_ExtTRGPSC_DIV2: ETRP frequency divided by 2. + * @arg TIM_ExtTRGPSC_DIV4: ETRP frequency divided by 4. + * @arg TIM_ExtTRGPSC_DIV8: ETRP frequency divided by 8. + * @param TIM_ExtTRGPolarity: The external Trigger Polarity. + * This parameter can be one of the following values: + * @arg TIM_ExtTRGPolarity_Inverted: active low or falling edge active. + * @arg TIM_ExtTRGPolarity_NonInverted: active high or rising edge active. + * @param ExtTRGFilter: External Trigger Filter. + * This parameter must be a value between 0x00 and 0x0F + * @retval None + */ +void TIM_ETRConfig(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity, + uint16_t ExtTRGFilter) +{ + uint16_t tmpsmcr = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_EXT_PRESCALER(TIM_ExtTRGPrescaler)); + assert_param(IS_TIM_EXT_POLARITY(TIM_ExtTRGPolarity)); + assert_param(IS_TIM_EXT_FILTER(ExtTRGFilter)); + tmpsmcr = TIMx->SMCR; + /* Reset the ETR Bits */ + tmpsmcr &= SMCR_ETR_Mask; + /* Set the Prescaler, the Filter value and the Polarity */ + tmpsmcr |= (uint16_t)(TIM_ExtTRGPrescaler | (uint16_t)(TIM_ExtTRGPolarity | (uint16_t)(ExtTRGFilter << (uint16_t)8))); + /* Write to TIMx SMCR */ + TIMx->SMCR = tmpsmcr; +} + +/** + * @brief Configures the TIMx Prescaler. + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @param Prescaler: specifies the Prescaler Register value + * @param TIM_PSCReloadMode: specifies the TIM Prescaler Reload mode + * This parameter can be one of the following values: + * @arg TIM_PSCReloadMode_Update: The Prescaler is loaded at the update event. + * @arg TIM_PSCReloadMode_Immediate: The Prescaler is loaded immediately. + * @retval None + */ +void TIM_PrescalerConfig(TIM_TypeDef* TIMx, uint16_t Prescaler, uint16_t TIM_PSCReloadMode) +{ + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + assert_param(IS_TIM_PRESCALER_RELOAD(TIM_PSCReloadMode)); + /* Set the Prescaler value */ + TIMx->PSC = Prescaler; + /* Set or reset the UG Bit */ + TIMx->EGR = TIM_PSCReloadMode; +} + +/** + * @brief Specifies the TIMx Counter Mode to be used. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_CounterMode: specifies the Counter Mode to be used + * This parameter can be one of the following values: + * @arg TIM_CounterMode_Up: TIM Up Counting Mode + * @arg TIM_CounterMode_Down: TIM Down Counting Mode + * @arg TIM_CounterMode_CenterAligned1: TIM Center Aligned Mode1 + * @arg TIM_CounterMode_CenterAligned2: TIM Center Aligned Mode2 + * @arg TIM_CounterMode_CenterAligned3: TIM Center Aligned Mode3 + * @retval None + */ +void TIM_CounterModeConfig(TIM_TypeDef* TIMx, uint16_t TIM_CounterMode) +{ + uint16_t tmpcr1 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_COUNTER_MODE(TIM_CounterMode)); + tmpcr1 = TIMx->CR1; + /* Reset the CMS and DIR Bits */ + tmpcr1 &= (uint16_t)(~((uint16_t)(TIM_CR1_DIR | TIM_CR1_CMS))); + /* Set the Counter Mode */ + tmpcr1 |= TIM_CounterMode; + /* Write to TIMx CR1 register */ + TIMx->CR1 = tmpcr1; +} + +/** + * @brief Selects the Input Trigger source + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral. + * @param TIM_InputTriggerSource: The Input Trigger source. + * This parameter can be one of the following values: + * @arg TIM_TS_ITR0: Internal Trigger 0 + * @arg TIM_TS_ITR1: Internal Trigger 1 + * @arg TIM_TS_ITR2: Internal Trigger 2 + * @arg TIM_TS_ITR3: Internal Trigger 3 + * @arg TIM_TS_TI1F_ED: TI1 Edge Detector + * @arg TIM_TS_TI1FP1: Filtered Timer Input 1 + * @arg TIM_TS_TI2FP2: Filtered Timer Input 2 + * @arg TIM_TS_ETRF: External Trigger input + * @retval None + */ +void TIM_SelectInputTrigger(TIM_TypeDef* TIMx, uint16_t TIM_InputTriggerSource) +{ + uint16_t tmpsmcr = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + assert_param(IS_TIM_TRIGGER_SELECTION(TIM_InputTriggerSource)); + /* Get the TIMx SMCR register value */ + tmpsmcr = TIMx->SMCR; + /* Reset the TS Bits */ + tmpsmcr &= (uint16_t)(~((uint16_t)TIM_SMCR_TS)); + /* Set the Input Trigger source */ + tmpsmcr |= TIM_InputTriggerSource; + /* Write to TIMx SMCR */ + TIMx->SMCR = tmpsmcr; +} + +/** + * @brief Configures the TIMx Encoder Interface. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_EncoderMode: specifies the TIMx Encoder Mode. + * This parameter can be one of the following values: + * @arg TIM_EncoderMode_TI1: Counter counts on TI1FP1 edge depending on TI2FP2 level. + * @arg TIM_EncoderMode_TI2: Counter counts on TI2FP2 edge depending on TI1FP1 level. + * @arg TIM_EncoderMode_TI12: Counter counts on both TI1FP1 and TI2FP2 edges depending + * on the level of the other input. + * @param TIM_IC1Polarity: specifies the IC1 Polarity + * This parameter can be one of the following values: + * @arg TIM_ICPolarity_Falling: IC Falling edge. + * @arg TIM_ICPolarity_Rising: IC Rising edge. + * @param TIM_IC2Polarity: specifies the IC2 Polarity + * This parameter can be one of the following values: + * @arg TIM_ICPolarity_Falling: IC Falling edge. + * @arg TIM_ICPolarity_Rising: IC Rising edge. + * @retval None + */ +void TIM_EncoderInterfaceConfig(TIM_TypeDef* TIMx, uint16_t TIM_EncoderMode, + uint16_t TIM_IC1Polarity, uint16_t TIM_IC2Polarity) +{ + uint16_t tmpsmcr = 0; + uint16_t tmpccmr1 = 0; + uint16_t tmpccer = 0; + + /* Check the parameters */ + assert_param(IS_TIM_LIST5_PERIPH(TIMx)); + assert_param(IS_TIM_ENCODER_MODE(TIM_EncoderMode)); + assert_param(IS_TIM_IC_POLARITY(TIM_IC1Polarity)); + assert_param(IS_TIM_IC_POLARITY(TIM_IC2Polarity)); + + /* Get the TIMx SMCR register value */ + tmpsmcr = TIMx->SMCR; + + /* Get the TIMx CCMR1 register value */ + tmpccmr1 = TIMx->CCMR1; + + /* Get the TIMx CCER register value */ + tmpccer = TIMx->CCER; + + /* Set the encoder Mode */ + tmpsmcr &= (uint16_t)(~((uint16_t)TIM_SMCR_SMS)); + tmpsmcr |= TIM_EncoderMode; + + /* Select the Capture Compare 1 and the Capture Compare 2 as input */ + tmpccmr1 &= (uint16_t)(((uint16_t)~((uint16_t)TIM_CCMR1_CC1S)) & (uint16_t)(~((uint16_t)TIM_CCMR1_CC2S))); + tmpccmr1 |= TIM_CCMR1_CC1S_0 | TIM_CCMR1_CC2S_0; + + /* Set the TI1 and the TI2 Polarities */ + tmpccer &= (uint16_t)(((uint16_t)~((uint16_t)TIM_CCER_CC1P)) & ((uint16_t)~((uint16_t)TIM_CCER_CC2P))); + tmpccer |= (uint16_t)(TIM_IC1Polarity | (uint16_t)(TIM_IC2Polarity << (uint16_t)4)); + + /* Write to TIMx SMCR */ + TIMx->SMCR = tmpsmcr; + /* Write to TIMx CCMR1 */ + TIMx->CCMR1 = tmpccmr1; + /* Write to TIMx CCER */ + TIMx->CCER = tmpccer; +} + +/** + * @brief Forces the TIMx output 1 waveform to active or inactive level. + * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral. + * @param TIM_ForcedAction: specifies the forced Action to be set to the output waveform. + * This parameter can be one of the following values: + * @arg TIM_ForcedAction_Active: Force active level on OC1REF + * @arg TIM_ForcedAction_InActive: Force inactive level on OC1REF. + * @retval None + */ +void TIM_ForcedOC1Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction) +{ + uint16_t tmpccmr1 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST8_PERIPH(TIMx)); + assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction)); + tmpccmr1 = TIMx->CCMR1; + /* Reset the OC1M Bits */ + tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC1M); + /* Configure The Forced output Mode */ + tmpccmr1 |= TIM_ForcedAction; + /* Write to TIMx CCMR1 register */ + TIMx->CCMR1 = tmpccmr1; +} + +/** + * @brief Forces the TIMx output 2 waveform to active or inactive level. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral. + * @param TIM_ForcedAction: specifies the forced Action to be set to the output waveform. + * This parameter can be one of the following values: + * @arg TIM_ForcedAction_Active: Force active level on OC2REF + * @arg TIM_ForcedAction_InActive: Force inactive level on OC2REF. + * @retval None + */ +void TIM_ForcedOC2Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction) +{ + uint16_t tmpccmr1 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction)); + tmpccmr1 = TIMx->CCMR1; + /* Reset the OC2M Bits */ + tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC2M); + /* Configure The Forced output Mode */ + tmpccmr1 |= (uint16_t)(TIM_ForcedAction << 8); + /* Write to TIMx CCMR1 register */ + TIMx->CCMR1 = tmpccmr1; +} + +/** + * @brief Forces the TIMx output 3 waveform to active or inactive level. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_ForcedAction: specifies the forced Action to be set to the output waveform. + * This parameter can be one of the following values: + * @arg TIM_ForcedAction_Active: Force active level on OC3REF + * @arg TIM_ForcedAction_InActive: Force inactive level on OC3REF. + * @retval None + */ +void TIM_ForcedOC3Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction) +{ + uint16_t tmpccmr2 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction)); + tmpccmr2 = TIMx->CCMR2; + /* Reset the OC1M Bits */ + tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC3M); + /* Configure The Forced output Mode */ + tmpccmr2 |= TIM_ForcedAction; + /* Write to TIMx CCMR2 register */ + TIMx->CCMR2 = tmpccmr2; +} + +/** + * @brief Forces the TIMx output 4 waveform to active or inactive level. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_ForcedAction: specifies the forced Action to be set to the output waveform. + * This parameter can be one of the following values: + * @arg TIM_ForcedAction_Active: Force active level on OC4REF + * @arg TIM_ForcedAction_InActive: Force inactive level on OC4REF. + * @retval None + */ +void TIM_ForcedOC4Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction) +{ + uint16_t tmpccmr2 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_FORCED_ACTION(TIM_ForcedAction)); + tmpccmr2 = TIMx->CCMR2; + /* Reset the OC2M Bits */ + tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC4M); + /* Configure The Forced output Mode */ + tmpccmr2 |= (uint16_t)(TIM_ForcedAction << 8); + /* Write to TIMx CCMR2 register */ + TIMx->CCMR2 = tmpccmr2; +} + +/** + * @brief Enables or disables TIMx peripheral Preload register on ARR. + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @param NewState: new state of the TIMx peripheral Preload register + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void TIM_ARRPreloadConfig(TIM_TypeDef* TIMx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Set the ARR Preload Bit */ + TIMx->CR1 |= TIM_CR1_ARPE; + } + else + { + /* Reset the ARR Preload Bit */ + TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_ARPE); + } +} + +/** + * @brief Selects the TIM peripheral Commutation event. + * @param TIMx: where x can be 1, 8, 15, 16 or 17 to select the TIMx peripheral + * @param NewState: new state of the Commutation event. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void TIM_SelectCOM(TIM_TypeDef* TIMx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST2_PERIPH(TIMx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Set the COM Bit */ + TIMx->CR2 |= TIM_CR2_CCUS; + } + else + { + /* Reset the COM Bit */ + TIMx->CR2 &= (uint16_t)~((uint16_t)TIM_CR2_CCUS); + } +} + +/** + * @brief Selects the TIMx peripheral Capture Compare DMA source. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 15, 16 or 17 to select + * the TIM peripheral. + * @param NewState: new state of the Capture Compare DMA source + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void TIM_SelectCCDMA(TIM_TypeDef* TIMx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST4_PERIPH(TIMx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Set the CCDS Bit */ + TIMx->CR2 |= TIM_CR2_CCDS; + } + else + { + /* Reset the CCDS Bit */ + TIMx->CR2 &= (uint16_t)~((uint16_t)TIM_CR2_CCDS); + } +} + +/** + * @brief Sets or Resets the TIM peripheral Capture Compare Preload Control bit. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8 or 15 + * to select the TIMx peripheral + * @param NewState: new state of the Capture Compare Preload Control bit + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void TIM_CCPreloadControl(TIM_TypeDef* TIMx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST5_PERIPH(TIMx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Set the CCPC Bit */ + TIMx->CR2 |= TIM_CR2_CCPC; + } + else + { + /* Reset the CCPC Bit */ + TIMx->CR2 &= (uint16_t)~((uint16_t)TIM_CR2_CCPC); + } +} + +/** + * @brief Enables or disables the TIMx peripheral Preload register on CCR1. + * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral. + * @param TIM_OCPreload: new state of the TIMx peripheral Preload register + * This parameter can be one of the following values: + * @arg TIM_OCPreload_Enable + * @arg TIM_OCPreload_Disable + * @retval None + */ +void TIM_OC1PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload) +{ + uint16_t tmpccmr1 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST8_PERIPH(TIMx)); + assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload)); + tmpccmr1 = TIMx->CCMR1; + /* Reset the OC1PE Bit */ + tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC1PE); + /* Enable or Disable the Output Compare Preload feature */ + tmpccmr1 |= TIM_OCPreload; + /* Write to TIMx CCMR1 register */ + TIMx->CCMR1 = tmpccmr1; +} + +/** + * @brief Enables or disables the TIMx peripheral Preload register on CCR2. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select + * the TIM peripheral. + * @param TIM_OCPreload: new state of the TIMx peripheral Preload register + * This parameter can be one of the following values: + * @arg TIM_OCPreload_Enable + * @arg TIM_OCPreload_Disable + * @retval None + */ +void TIM_OC2PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload) +{ + uint16_t tmpccmr1 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload)); + tmpccmr1 = TIMx->CCMR1; + /* Reset the OC2PE Bit */ + tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC2PE); + /* Enable or Disable the Output Compare Preload feature */ + tmpccmr1 |= (uint16_t)(TIM_OCPreload << 8); + /* Write to TIMx CCMR1 register */ + TIMx->CCMR1 = tmpccmr1; +} + +/** + * @brief Enables or disables the TIMx peripheral Preload register on CCR3. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_OCPreload: new state of the TIMx peripheral Preload register + * This parameter can be one of the following values: + * @arg TIM_OCPreload_Enable + * @arg TIM_OCPreload_Disable + * @retval None + */ +void TIM_OC3PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload) +{ + uint16_t tmpccmr2 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload)); + tmpccmr2 = TIMx->CCMR2; + /* Reset the OC3PE Bit */ + tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC3PE); + /* Enable or Disable the Output Compare Preload feature */ + tmpccmr2 |= TIM_OCPreload; + /* Write to TIMx CCMR2 register */ + TIMx->CCMR2 = tmpccmr2; +} + +/** + * @brief Enables or disables the TIMx peripheral Preload register on CCR4. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_OCPreload: new state of the TIMx peripheral Preload register + * This parameter can be one of the following values: + * @arg TIM_OCPreload_Enable + * @arg TIM_OCPreload_Disable + * @retval None + */ +void TIM_OC4PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload) +{ + uint16_t tmpccmr2 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload)); + tmpccmr2 = TIMx->CCMR2; + /* Reset the OC4PE Bit */ + tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC4PE); + /* Enable or Disable the Output Compare Preload feature */ + tmpccmr2 |= (uint16_t)(TIM_OCPreload << 8); + /* Write to TIMx CCMR2 register */ + TIMx->CCMR2 = tmpccmr2; +} + +/** + * @brief Configures the TIMx Output Compare 1 Fast feature. + * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral. + * @param TIM_OCFast: new state of the Output Compare Fast Enable Bit. + * This parameter can be one of the following values: + * @arg TIM_OCFast_Enable: TIM output compare fast enable + * @arg TIM_OCFast_Disable: TIM output compare fast disable + * @retval None + */ +void TIM_OC1FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast) +{ + uint16_t tmpccmr1 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST8_PERIPH(TIMx)); + assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast)); + /* Get the TIMx CCMR1 register value */ + tmpccmr1 = TIMx->CCMR1; + /* Reset the OC1FE Bit */ + tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC1FE); + /* Enable or Disable the Output Compare Fast Bit */ + tmpccmr1 |= TIM_OCFast; + /* Write to TIMx CCMR1 */ + TIMx->CCMR1 = tmpccmr1; +} + +/** + * @brief Configures the TIMx Output Compare 2 Fast feature. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select + * the TIM peripheral. + * @param TIM_OCFast: new state of the Output Compare Fast Enable Bit. + * This parameter can be one of the following values: + * @arg TIM_OCFast_Enable: TIM output compare fast enable + * @arg TIM_OCFast_Disable: TIM output compare fast disable + * @retval None + */ +void TIM_OC2FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast) +{ + uint16_t tmpccmr1 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast)); + /* Get the TIMx CCMR1 register value */ + tmpccmr1 = TIMx->CCMR1; + /* Reset the OC2FE Bit */ + tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC2FE); + /* Enable or Disable the Output Compare Fast Bit */ + tmpccmr1 |= (uint16_t)(TIM_OCFast << 8); + /* Write to TIMx CCMR1 */ + TIMx->CCMR1 = tmpccmr1; +} + +/** + * @brief Configures the TIMx Output Compare 3 Fast feature. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_OCFast: new state of the Output Compare Fast Enable Bit. + * This parameter can be one of the following values: + * @arg TIM_OCFast_Enable: TIM output compare fast enable + * @arg TIM_OCFast_Disable: TIM output compare fast disable + * @retval None + */ +void TIM_OC3FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast) +{ + uint16_t tmpccmr2 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast)); + /* Get the TIMx CCMR2 register value */ + tmpccmr2 = TIMx->CCMR2; + /* Reset the OC3FE Bit */ + tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC3FE); + /* Enable or Disable the Output Compare Fast Bit */ + tmpccmr2 |= TIM_OCFast; + /* Write to TIMx CCMR2 */ + TIMx->CCMR2 = tmpccmr2; +} + +/** + * @brief Configures the TIMx Output Compare 4 Fast feature. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_OCFast: new state of the Output Compare Fast Enable Bit. + * This parameter can be one of the following values: + * @arg TIM_OCFast_Enable: TIM output compare fast enable + * @arg TIM_OCFast_Disable: TIM output compare fast disable + * @retval None + */ +void TIM_OC4FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast) +{ + uint16_t tmpccmr2 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast)); + /* Get the TIMx CCMR2 register value */ + tmpccmr2 = TIMx->CCMR2; + /* Reset the OC4FE Bit */ + tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC4FE); + /* Enable or Disable the Output Compare Fast Bit */ + tmpccmr2 |= (uint16_t)(TIM_OCFast << 8); + /* Write to TIMx CCMR2 */ + TIMx->CCMR2 = tmpccmr2; +} + +/** + * @brief Clears or safeguards the OCREF1 signal on an external event + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_OCClear: new state of the Output Compare Clear Enable Bit. + * This parameter can be one of the following values: + * @arg TIM_OCClear_Enable: TIM Output clear enable + * @arg TIM_OCClear_Disable: TIM Output clear disable + * @retval None + */ +void TIM_ClearOC1Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear) +{ + uint16_t tmpccmr1 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear)); + + tmpccmr1 = TIMx->CCMR1; + + /* Reset the OC1CE Bit */ + tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC1CE); + /* Enable or Disable the Output Compare Clear Bit */ + tmpccmr1 |= TIM_OCClear; + /* Write to TIMx CCMR1 register */ + TIMx->CCMR1 = tmpccmr1; +} + +/** + * @brief Clears or safeguards the OCREF2 signal on an external event + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_OCClear: new state of the Output Compare Clear Enable Bit. + * This parameter can be one of the following values: + * @arg TIM_OCClear_Enable: TIM Output clear enable + * @arg TIM_OCClear_Disable: TIM Output clear disable + * @retval None + */ +void TIM_ClearOC2Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear) +{ + uint16_t tmpccmr1 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear)); + tmpccmr1 = TIMx->CCMR1; + /* Reset the OC2CE Bit */ + tmpccmr1 &= (uint16_t)~((uint16_t)TIM_CCMR1_OC2CE); + /* Enable or Disable the Output Compare Clear Bit */ + tmpccmr1 |= (uint16_t)(TIM_OCClear << 8); + /* Write to TIMx CCMR1 register */ + TIMx->CCMR1 = tmpccmr1; +} + +/** + * @brief Clears or safeguards the OCREF3 signal on an external event + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_OCClear: new state of the Output Compare Clear Enable Bit. + * This parameter can be one of the following values: + * @arg TIM_OCClear_Enable: TIM Output clear enable + * @arg TIM_OCClear_Disable: TIM Output clear disable + * @retval None + */ +void TIM_ClearOC3Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear) +{ + uint16_t tmpccmr2 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear)); + tmpccmr2 = TIMx->CCMR2; + /* Reset the OC3CE Bit */ + tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC3CE); + /* Enable or Disable the Output Compare Clear Bit */ + tmpccmr2 |= TIM_OCClear; + /* Write to TIMx CCMR2 register */ + TIMx->CCMR2 = tmpccmr2; +} + +/** + * @brief Clears or safeguards the OCREF4 signal on an external event + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_OCClear: new state of the Output Compare Clear Enable Bit. + * This parameter can be one of the following values: + * @arg TIM_OCClear_Enable: TIM Output clear enable + * @arg TIM_OCClear_Disable: TIM Output clear disable + * @retval None + */ +void TIM_ClearOC4Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear) +{ + uint16_t tmpccmr2 = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear)); + tmpccmr2 = TIMx->CCMR2; + /* Reset the OC4CE Bit */ + tmpccmr2 &= (uint16_t)~((uint16_t)TIM_CCMR2_OC4CE); + /* Enable or Disable the Output Compare Clear Bit */ + tmpccmr2 |= (uint16_t)(TIM_OCClear << 8); + /* Write to TIMx CCMR2 register */ + TIMx->CCMR2 = tmpccmr2; +} + +/** + * @brief Configures the TIMx channel 1 polarity. + * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral. + * @param TIM_OCPolarity: specifies the OC1 Polarity + * This parameter can be one of the following values: + * @arg TIM_OCPolarity_High: Output Compare active high + * @arg TIM_OCPolarity_Low: Output Compare active low + * @retval None + */ +void TIM_OC1PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity) +{ + uint16_t tmpccer = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST8_PERIPH(TIMx)); + assert_param(IS_TIM_OC_POLARITY(TIM_OCPolarity)); + tmpccer = TIMx->CCER; + /* Set or Reset the CC1P Bit */ + tmpccer &= (uint16_t)~((uint16_t)TIM_CCER_CC1P); + tmpccer |= TIM_OCPolarity; + /* Write to TIMx CCER register */ + TIMx->CCER = tmpccer; +} + +/** + * @brief Configures the TIMx Channel 1N polarity. + * @param TIMx: where x can be 1, 8, 15, 16 or 17 to select the TIM peripheral. + * @param TIM_OCNPolarity: specifies the OC1N Polarity + * This parameter can be one of the following values: + * @arg TIM_OCNPolarity_High: Output Compare active high + * @arg TIM_OCNPolarity_Low: Output Compare active low + * @retval None + */ +void TIM_OC1NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity) +{ + uint16_t tmpccer = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST2_PERIPH(TIMx)); + assert_param(IS_TIM_OCN_POLARITY(TIM_OCNPolarity)); + + tmpccer = TIMx->CCER; + /* Set or Reset the CC1NP Bit */ + tmpccer &= (uint16_t)~((uint16_t)TIM_CCER_CC1NP); + tmpccer |= TIM_OCNPolarity; + /* Write to TIMx CCER register */ + TIMx->CCER = tmpccer; +} + +/** + * @brief Configures the TIMx channel 2 polarity. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral. + * @param TIM_OCPolarity: specifies the OC2 Polarity + * This parameter can be one of the following values: + * @arg TIM_OCPolarity_High: Output Compare active high + * @arg TIM_OCPolarity_Low: Output Compare active low + * @retval None + */ +void TIM_OC2PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity) +{ + uint16_t tmpccer = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + assert_param(IS_TIM_OC_POLARITY(TIM_OCPolarity)); + tmpccer = TIMx->CCER; + /* Set or Reset the CC2P Bit */ + tmpccer &= (uint16_t)~((uint16_t)TIM_CCER_CC2P); + tmpccer |= (uint16_t)(TIM_OCPolarity << 4); + /* Write to TIMx CCER register */ + TIMx->CCER = tmpccer; +} + +/** + * @brief Configures the TIMx Channel 2N polarity. + * @param TIMx: where x can be 1 or 8 to select the TIM peripheral. + * @param TIM_OCNPolarity: specifies the OC2N Polarity + * This parameter can be one of the following values: + * @arg TIM_OCNPolarity_High: Output Compare active high + * @arg TIM_OCNPolarity_Low: Output Compare active low + * @retval None + */ +void TIM_OC2NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity) +{ + uint16_t tmpccer = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST1_PERIPH(TIMx)); + assert_param(IS_TIM_OCN_POLARITY(TIM_OCNPolarity)); + + tmpccer = TIMx->CCER; + /* Set or Reset the CC2NP Bit */ + tmpccer &= (uint16_t)~((uint16_t)TIM_CCER_CC2NP); + tmpccer |= (uint16_t)(TIM_OCNPolarity << 4); + /* Write to TIMx CCER register */ + TIMx->CCER = tmpccer; +} + +/** + * @brief Configures the TIMx channel 3 polarity. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_OCPolarity: specifies the OC3 Polarity + * This parameter can be one of the following values: + * @arg TIM_OCPolarity_High: Output Compare active high + * @arg TIM_OCPolarity_Low: Output Compare active low + * @retval None + */ +void TIM_OC3PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity) +{ + uint16_t tmpccer = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_OC_POLARITY(TIM_OCPolarity)); + tmpccer = TIMx->CCER; + /* Set or Reset the CC3P Bit */ + tmpccer &= (uint16_t)~((uint16_t)TIM_CCER_CC3P); + tmpccer |= (uint16_t)(TIM_OCPolarity << 8); + /* Write to TIMx CCER register */ + TIMx->CCER = tmpccer; +} + +/** + * @brief Configures the TIMx Channel 3N polarity. + * @param TIMx: where x can be 1 or 8 to select the TIM peripheral. + * @param TIM_OCNPolarity: specifies the OC3N Polarity + * This parameter can be one of the following values: + * @arg TIM_OCNPolarity_High: Output Compare active high + * @arg TIM_OCNPolarity_Low: Output Compare active low + * @retval None + */ +void TIM_OC3NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity) +{ + uint16_t tmpccer = 0; + + /* Check the parameters */ + assert_param(IS_TIM_LIST1_PERIPH(TIMx)); + assert_param(IS_TIM_OCN_POLARITY(TIM_OCNPolarity)); + + tmpccer = TIMx->CCER; + /* Set or Reset the CC3NP Bit */ + tmpccer &= (uint16_t)~((uint16_t)TIM_CCER_CC3NP); + tmpccer |= (uint16_t)(TIM_OCNPolarity << 8); + /* Write to TIMx CCER register */ + TIMx->CCER = tmpccer; +} + +/** + * @brief Configures the TIMx channel 4 polarity. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_OCPolarity: specifies the OC4 Polarity + * This parameter can be one of the following values: + * @arg TIM_OCPolarity_High: Output Compare active high + * @arg TIM_OCPolarity_Low: Output Compare active low + * @retval None + */ +void TIM_OC4PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity) +{ + uint16_t tmpccer = 0; + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_OC_POLARITY(TIM_OCPolarity)); + tmpccer = TIMx->CCER; + /* Set or Reset the CC4P Bit */ + tmpccer &= (uint16_t)~((uint16_t)TIM_CCER_CC4P); + tmpccer |= (uint16_t)(TIM_OCPolarity << 12); + /* Write to TIMx CCER register */ + TIMx->CCER = tmpccer; +} + +/** + * @brief Enables or disables the TIM Capture Compare Channel x. + * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral. + * @param TIM_Channel: specifies the TIM Channel + * This parameter can be one of the following values: + * @arg TIM_Channel_1: TIM Channel 1 + * @arg TIM_Channel_2: TIM Channel 2 + * @arg TIM_Channel_3: TIM Channel 3 + * @arg TIM_Channel_4: TIM Channel 4 + * @param TIM_CCx: specifies the TIM Channel CCxE bit new state. + * This parameter can be: TIM_CCx_Enable or TIM_CCx_Disable. + * @retval None + */ +void TIM_CCxCmd(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx) +{ + uint16_t tmp = 0; + + /* Check the parameters */ + assert_param(IS_TIM_LIST8_PERIPH(TIMx)); + assert_param(IS_TIM_CHANNEL(TIM_Channel)); + assert_param(IS_TIM_CCX(TIM_CCx)); + + tmp = CCER_CCE_Set << TIM_Channel; + + /* Reset the CCxE Bit */ + TIMx->CCER &= (uint16_t)~ tmp; + + /* Set or reset the CCxE Bit */ + TIMx->CCER |= (uint16_t)(TIM_CCx << TIM_Channel); +} + +/** + * @brief Enables or disables the TIM Capture Compare Channel xN. + * @param TIMx: where x can be 1, 8, 15, 16 or 17 to select the TIM peripheral. + * @param TIM_Channel: specifies the TIM Channel + * This parameter can be one of the following values: + * @arg TIM_Channel_1: TIM Channel 1 + * @arg TIM_Channel_2: TIM Channel 2 + * @arg TIM_Channel_3: TIM Channel 3 + * @param TIM_CCxN: specifies the TIM Channel CCxNE bit new state. + * This parameter can be: TIM_CCxN_Enable or TIM_CCxN_Disable. + * @retval None + */ +void TIM_CCxNCmd(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_CCxN) +{ + uint16_t tmp = 0; + + /* Check the parameters */ + assert_param(IS_TIM_LIST2_PERIPH(TIMx)); + assert_param(IS_TIM_COMPLEMENTARY_CHANNEL(TIM_Channel)); + assert_param(IS_TIM_CCXN(TIM_CCxN)); + + tmp = CCER_CCNE_Set << TIM_Channel; + + /* Reset the CCxNE Bit */ + TIMx->CCER &= (uint16_t) ~tmp; + + /* Set or reset the CCxNE Bit */ + TIMx->CCER |= (uint16_t)(TIM_CCxN << TIM_Channel); +} + +/** + * @brief Selects the TIM Output Compare Mode. + * @note This function disables the selected channel before changing the Output + * Compare Mode. + * User has to enable this channel using TIM_CCxCmd and TIM_CCxNCmd functions. + * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral. + * @param TIM_Channel: specifies the TIM Channel + * This parameter can be one of the following values: + * @arg TIM_Channel_1: TIM Channel 1 + * @arg TIM_Channel_2: TIM Channel 2 + * @arg TIM_Channel_3: TIM Channel 3 + * @arg TIM_Channel_4: TIM Channel 4 + * @param TIM_OCMode: specifies the TIM Output Compare Mode. + * This parameter can be one of the following values: + * @arg TIM_OCMode_Timing + * @arg TIM_OCMode_Active + * @arg TIM_OCMode_Toggle + * @arg TIM_OCMode_PWM1 + * @arg TIM_OCMode_PWM2 + * @arg TIM_ForcedAction_Active + * @arg TIM_ForcedAction_InActive + * @retval None + */ +void TIM_SelectOCxM(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_OCMode) +{ + uint32_t tmp = 0; + uint16_t tmp1 = 0; + + /* Check the parameters */ + assert_param(IS_TIM_LIST8_PERIPH(TIMx)); + assert_param(IS_TIM_CHANNEL(TIM_Channel)); + assert_param(IS_TIM_OCM(TIM_OCMode)); + + tmp = (uint32_t) TIMx; + tmp += CCMR_Offset; + + tmp1 = CCER_CCE_Set << (uint16_t)TIM_Channel; + + /* Disable the Channel: Reset the CCxE Bit */ + TIMx->CCER &= (uint16_t) ~tmp1; + + if((TIM_Channel == TIM_Channel_1) ||(TIM_Channel == TIM_Channel_3)) + { + tmp += (TIM_Channel>>1); + + /* Reset the OCxM bits in the CCMRx register */ + *(__IO uint32_t *) tmp &= (uint32_t)~((uint32_t)TIM_CCMR1_OC1M); + + /* Configure the OCxM bits in the CCMRx register */ + *(__IO uint32_t *) tmp |= TIM_OCMode; + } + else + { + tmp += (uint16_t)(TIM_Channel - (uint16_t)4)>> (uint16_t)1; + + /* Reset the OCxM bits in the CCMRx register */ + *(__IO uint32_t *) tmp &= (uint32_t)~((uint32_t)TIM_CCMR1_OC2M); + + /* Configure the OCxM bits in the CCMRx register */ + *(__IO uint32_t *) tmp |= (uint16_t)(TIM_OCMode << 8); + } +} + +/** + * @brief Enables or Disables the TIMx Update event. + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @param NewState: new state of the TIMx UDIS bit + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void TIM_UpdateDisableConfig(TIM_TypeDef* TIMx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Set the Update Disable Bit */ + TIMx->CR1 |= TIM_CR1_UDIS; + } + else + { + /* Reset the Update Disable Bit */ + TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_UDIS); + } +} + +/** + * @brief Configures the TIMx Update Request Interrupt source. + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @param TIM_UpdateSource: specifies the Update source. + * This parameter can be one of the following values: + * @arg TIM_UpdateSource_Regular: Source of update is the counter overflow/underflow + or the setting of UG bit, or an update generation + through the slave mode controller. + * @arg TIM_UpdateSource_Global: Source of update is counter overflow/underflow. + * @retval None + */ +void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource) +{ + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + assert_param(IS_TIM_UPDATE_SOURCE(TIM_UpdateSource)); + if (TIM_UpdateSource != TIM_UpdateSource_Global) + { + /* Set the URS Bit */ + TIMx->CR1 |= TIM_CR1_URS; + } + else + { + /* Reset the URS Bit */ + TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_URS); + } +} + +/** + * @brief Enables or disables the TIMx's Hall sensor interface. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param NewState: new state of the TIMx Hall sensor interface. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void TIM_SelectHallSensor(TIM_TypeDef* TIMx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Set the TI1S Bit */ + TIMx->CR2 |= TIM_CR2_TI1S; + } + else + { + /* Reset the TI1S Bit */ + TIMx->CR2 &= (uint16_t)~((uint16_t)TIM_CR2_TI1S); + } +} + +/** + * @brief Selects the TIMx's One Pulse Mode. + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @param TIM_OPMode: specifies the OPM Mode to be used. + * This parameter can be one of the following values: + * @arg TIM_OPMode_Single + * @arg TIM_OPMode_Repetitive + * @retval None + */ +void TIM_SelectOnePulseMode(TIM_TypeDef* TIMx, uint16_t TIM_OPMode) +{ + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + assert_param(IS_TIM_OPM_MODE(TIM_OPMode)); + /* Reset the OPM Bit */ + TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_OPM); + /* Configure the OPM Mode */ + TIMx->CR1 |= TIM_OPMode; +} + +/** + * @brief Selects the TIMx Trigger Output Mode. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 6, 7, 8, 9, 12 or 15 to select the TIM peripheral. + * @param TIM_TRGOSource: specifies the Trigger Output source. + * This paramter can be one of the following values: + * + * - For all TIMx + * @arg TIM_TRGOSource_Reset: The UG bit in the TIM_EGR register is used as the trigger output (TRGO). + * @arg TIM_TRGOSource_Enable: The Counter Enable CEN is used as the trigger output (TRGO). + * @arg TIM_TRGOSource_Update: The update event is selected as the trigger output (TRGO). + * + * - For all TIMx except TIM6 and TIM7 + * @arg TIM_TRGOSource_OC1: The trigger output sends a positive pulse when the CC1IF flag + * is to be set, as soon as a capture or compare match occurs (TRGO). + * @arg TIM_TRGOSource_OC1Ref: OC1REF signal is used as the trigger output (TRGO). + * @arg TIM_TRGOSource_OC2Ref: OC2REF signal is used as the trigger output (TRGO). + * @arg TIM_TRGOSource_OC3Ref: OC3REF signal is used as the trigger output (TRGO). + * @arg TIM_TRGOSource_OC4Ref: OC4REF signal is used as the trigger output (TRGO). + * + * @retval None + */ +void TIM_SelectOutputTrigger(TIM_TypeDef* TIMx, uint16_t TIM_TRGOSource) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST7_PERIPH(TIMx)); + assert_param(IS_TIM_TRGO_SOURCE(TIM_TRGOSource)); + /* Reset the MMS Bits */ + TIMx->CR2 &= (uint16_t)~((uint16_t)TIM_CR2_MMS); + /* Select the TRGO source */ + TIMx->CR2 |= TIM_TRGOSource; +} + +/** + * @brief Selects the TIMx Slave Mode. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral. + * @param TIM_SlaveMode: specifies the Timer Slave Mode. + * This parameter can be one of the following values: + * @arg TIM_SlaveMode_Reset: Rising edge of the selected trigger signal (TRGI) re-initializes + * the counter and triggers an update of the registers. + * @arg TIM_SlaveMode_Gated: The counter clock is enabled when the trigger signal (TRGI) is high. + * @arg TIM_SlaveMode_Trigger: The counter starts at a rising edge of the trigger TRGI. + * @arg TIM_SlaveMode_External1: Rising edges of the selected trigger (TRGI) clock the counter. + * @retval None + */ +void TIM_SelectSlaveMode(TIM_TypeDef* TIMx, uint16_t TIM_SlaveMode) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + assert_param(IS_TIM_SLAVE_MODE(TIM_SlaveMode)); + /* Reset the SMS Bits */ + TIMx->SMCR &= (uint16_t)~((uint16_t)TIM_SMCR_SMS); + /* Select the Slave Mode */ + TIMx->SMCR |= TIM_SlaveMode; +} + +/** + * @brief Sets or Resets the TIMx Master/Slave Mode. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral. + * @param TIM_MasterSlaveMode: specifies the Timer Master Slave Mode. + * This parameter can be one of the following values: + * @arg TIM_MasterSlaveMode_Enable: synchronization between the current timer + * and its slaves (through TRGO). + * @arg TIM_MasterSlaveMode_Disable: No action + * @retval None + */ +void TIM_SelectMasterSlaveMode(TIM_TypeDef* TIMx, uint16_t TIM_MasterSlaveMode) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + assert_param(IS_TIM_MSM_STATE(TIM_MasterSlaveMode)); + /* Reset the MSM Bit */ + TIMx->SMCR &= (uint16_t)~((uint16_t)TIM_SMCR_MSM); + + /* Set or Reset the MSM Bit */ + TIMx->SMCR |= TIM_MasterSlaveMode; +} + +/** + * @brief Sets the TIMx Counter Register value + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @param Counter: specifies the Counter register new value. + * @retval None + */ +void TIM_SetCounter(TIM_TypeDef* TIMx, uint16_t Counter) +{ + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + /* Set the Counter Register value */ + TIMx->CNT = Counter; +} + +/** + * @brief Sets the TIMx Autoreload Register value + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @param Autoreload: specifies the Autoreload register new value. + * @retval None + */ +void TIM_SetAutoreload(TIM_TypeDef* TIMx, uint16_t Autoreload) +{ + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + /* Set the Autoreload Register value */ + TIMx->ARR = Autoreload; +} + +/** + * @brief Sets the TIMx Capture Compare1 Register value + * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral. + * @param Compare1: specifies the Capture Compare1 register new value. + * @retval None + */ +void TIM_SetCompare1(TIM_TypeDef* TIMx, uint16_t Compare1) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST8_PERIPH(TIMx)); + /* Set the Capture Compare1 Register value */ + TIMx->CCR1 = Compare1; +} + +/** + * @brief Sets the TIMx Capture Compare2 Register value + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral. + * @param Compare2: specifies the Capture Compare2 register new value. + * @retval None + */ +void TIM_SetCompare2(TIM_TypeDef* TIMx, uint16_t Compare2) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + /* Set the Capture Compare2 Register value */ + TIMx->CCR2 = Compare2; +} + +/** + * @brief Sets the TIMx Capture Compare3 Register value + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param Compare3: specifies the Capture Compare3 register new value. + * @retval None + */ +void TIM_SetCompare3(TIM_TypeDef* TIMx, uint16_t Compare3) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + /* Set the Capture Compare3 Register value */ + TIMx->CCR3 = Compare3; +} + +/** + * @brief Sets the TIMx Capture Compare4 Register value + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param Compare4: specifies the Capture Compare4 register new value. + * @retval None + */ +void TIM_SetCompare4(TIM_TypeDef* TIMx, uint16_t Compare4) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + /* Set the Capture Compare4 Register value */ + TIMx->CCR4 = Compare4; +} + +/** + * @brief Sets the TIMx Input Capture 1 prescaler. + * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral. + * @param TIM_ICPSC: specifies the Input Capture1 prescaler new value. + * This parameter can be one of the following values: + * @arg TIM_ICPSC_DIV1: no prescaler + * @arg TIM_ICPSC_DIV2: capture is done once every 2 events + * @arg TIM_ICPSC_DIV4: capture is done once every 4 events + * @arg TIM_ICPSC_DIV8: capture is done once every 8 events + * @retval None + */ +void TIM_SetIC1Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST8_PERIPH(TIMx)); + assert_param(IS_TIM_IC_PRESCALER(TIM_ICPSC)); + /* Reset the IC1PSC Bits */ + TIMx->CCMR1 &= (uint16_t)~((uint16_t)TIM_CCMR1_IC1PSC); + /* Set the IC1PSC value */ + TIMx->CCMR1 |= TIM_ICPSC; +} + +/** + * @brief Sets the TIMx Input Capture 2 prescaler. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral. + * @param TIM_ICPSC: specifies the Input Capture2 prescaler new value. + * This parameter can be one of the following values: + * @arg TIM_ICPSC_DIV1: no prescaler + * @arg TIM_ICPSC_DIV2: capture is done once every 2 events + * @arg TIM_ICPSC_DIV4: capture is done once every 4 events + * @arg TIM_ICPSC_DIV8: capture is done once every 8 events + * @retval None + */ +void TIM_SetIC2Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + assert_param(IS_TIM_IC_PRESCALER(TIM_ICPSC)); + /* Reset the IC2PSC Bits */ + TIMx->CCMR1 &= (uint16_t)~((uint16_t)TIM_CCMR1_IC2PSC); + /* Set the IC2PSC value */ + TIMx->CCMR1 |= (uint16_t)(TIM_ICPSC << 8); +} + +/** + * @brief Sets the TIMx Input Capture 3 prescaler. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_ICPSC: specifies the Input Capture3 prescaler new value. + * This parameter can be one of the following values: + * @arg TIM_ICPSC_DIV1: no prescaler + * @arg TIM_ICPSC_DIV2: capture is done once every 2 events + * @arg TIM_ICPSC_DIV4: capture is done once every 4 events + * @arg TIM_ICPSC_DIV8: capture is done once every 8 events + * @retval None + */ +void TIM_SetIC3Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_IC_PRESCALER(TIM_ICPSC)); + /* Reset the IC3PSC Bits */ + TIMx->CCMR2 &= (uint16_t)~((uint16_t)TIM_CCMR2_IC3PSC); + /* Set the IC3PSC value */ + TIMx->CCMR2 |= TIM_ICPSC; +} + +/** + * @brief Sets the TIMx Input Capture 4 prescaler. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_ICPSC: specifies the Input Capture4 prescaler new value. + * This parameter can be one of the following values: + * @arg TIM_ICPSC_DIV1: no prescaler + * @arg TIM_ICPSC_DIV2: capture is done once every 2 events + * @arg TIM_ICPSC_DIV4: capture is done once every 4 events + * @arg TIM_ICPSC_DIV8: capture is done once every 8 events + * @retval None + */ +void TIM_SetIC4Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + assert_param(IS_TIM_IC_PRESCALER(TIM_ICPSC)); + /* Reset the IC4PSC Bits */ + TIMx->CCMR2 &= (uint16_t)~((uint16_t)TIM_CCMR2_IC4PSC); + /* Set the IC4PSC value */ + TIMx->CCMR2 |= (uint16_t)(TIM_ICPSC << 8); +} + +/** + * @brief Sets the TIMx Clock Division value. + * @param TIMx: where x can be 1 to 17 except 6 and 7 to select + * the TIM peripheral. + * @param TIM_CKD: specifies the clock division value. + * This parameter can be one of the following value: + * @arg TIM_CKD_DIV1: TDTS = Tck_tim + * @arg TIM_CKD_DIV2: TDTS = 2*Tck_tim + * @arg TIM_CKD_DIV4: TDTS = 4*Tck_tim + * @retval None + */ +void TIM_SetClockDivision(TIM_TypeDef* TIMx, uint16_t TIM_CKD) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST8_PERIPH(TIMx)); + assert_param(IS_TIM_CKD_DIV(TIM_CKD)); + /* Reset the CKD Bits */ + TIMx->CR1 &= (uint16_t)~((uint16_t)TIM_CR1_CKD); + /* Set the CKD value */ + TIMx->CR1 |= TIM_CKD; +} + +/** + * @brief Gets the TIMx Input Capture 1 value. + * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral. + * @retval Capture Compare 1 Register value. + */ +uint16_t TIM_GetCapture1(TIM_TypeDef* TIMx) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST8_PERIPH(TIMx)); + /* Get the Capture 1 Register value */ + return TIMx->CCR1; +} + +/** + * @brief Gets the TIMx Input Capture 2 value. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral. + * @retval Capture Compare 2 Register value. + */ +uint16_t TIM_GetCapture2(TIM_TypeDef* TIMx) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST6_PERIPH(TIMx)); + /* Get the Capture 2 Register value */ + return TIMx->CCR2; +} + +/** + * @brief Gets the TIMx Input Capture 3 value. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @retval Capture Compare 3 Register value. + */ +uint16_t TIM_GetCapture3(TIM_TypeDef* TIMx) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + /* Get the Capture 3 Register value */ + return TIMx->CCR3; +} + +/** + * @brief Gets the TIMx Input Capture 4 value. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @retval Capture Compare 4 Register value. + */ +uint16_t TIM_GetCapture4(TIM_TypeDef* TIMx) +{ + /* Check the parameters */ + assert_param(IS_TIM_LIST3_PERIPH(TIMx)); + /* Get the Capture 4 Register value */ + return TIMx->CCR4; +} + +/** + * @brief Gets the TIMx Counter value. + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @retval Counter Register value. + */ +uint16_t TIM_GetCounter(TIM_TypeDef* TIMx) +{ + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + /* Get the Counter Register value */ + return TIMx->CNT; +} + +/** + * @brief Gets the TIMx Prescaler value. + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @retval Prescaler Register value. + */ +uint16_t TIM_GetPrescaler(TIM_TypeDef* TIMx) +{ + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + /* Get the Prescaler Register value */ + return TIMx->PSC; +} + +/** + * @brief Checks whether the specified TIM flag is set or not. + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @param TIM_FLAG: specifies the flag to check. + * This parameter can be one of the following values: + * @arg TIM_FLAG_Update: TIM update Flag + * @arg TIM_FLAG_CC1: TIM Capture Compare 1 Flag + * @arg TIM_FLAG_CC2: TIM Capture Compare 2 Flag + * @arg TIM_FLAG_CC3: TIM Capture Compare 3 Flag + * @arg TIM_FLAG_CC4: TIM Capture Compare 4 Flag + * @arg TIM_FLAG_COM: TIM Commutation Flag + * @arg TIM_FLAG_Trigger: TIM Trigger Flag + * @arg TIM_FLAG_Break: TIM Break Flag + * @arg TIM_FLAG_CC1OF: TIM Capture Compare 1 overcapture Flag + * @arg TIM_FLAG_CC2OF: TIM Capture Compare 2 overcapture Flag + * @arg TIM_FLAG_CC3OF: TIM Capture Compare 3 overcapture Flag + * @arg TIM_FLAG_CC4OF: TIM Capture Compare 4 overcapture Flag + * @note + * - TIM6 and TIM7 can have only one update flag. + * - TIM9, TIM12 and TIM15 can have only TIM_FLAG_Update, TIM_FLAG_CC1, + * TIM_FLAG_CC2 or TIM_FLAG_Trigger. + * - TIM10, TIM11, TIM13, TIM14, TIM16 and TIM17 can have TIM_FLAG_Update or TIM_FLAG_CC1. + * - TIM_FLAG_Break is used only with TIM1, TIM8 and TIM15. + * - TIM_FLAG_COM is used only with TIM1, TIM8, TIM15, TIM16 and TIM17. + * @retval The new state of TIM_FLAG (SET or RESET). + */ +FlagStatus TIM_GetFlagStatus(TIM_TypeDef* TIMx, uint16_t TIM_FLAG) +{ + ITStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + assert_param(IS_TIM_GET_FLAG(TIM_FLAG)); + + if ((TIMx->SR & TIM_FLAG) != (uint16_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + return bitstatus; +} + +/** + * @brief Clears the TIMx's pending flags. + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @param TIM_FLAG: specifies the flag bit to clear. + * This parameter can be any combination of the following values: + * @arg TIM_FLAG_Update: TIM update Flag + * @arg TIM_FLAG_CC1: TIM Capture Compare 1 Flag + * @arg TIM_FLAG_CC2: TIM Capture Compare 2 Flag + * @arg TIM_FLAG_CC3: TIM Capture Compare 3 Flag + * @arg TIM_FLAG_CC4: TIM Capture Compare 4 Flag + * @arg TIM_FLAG_COM: TIM Commutation Flag + * @arg TIM_FLAG_Trigger: TIM Trigger Flag + * @arg TIM_FLAG_Break: TIM Break Flag + * @arg TIM_FLAG_CC1OF: TIM Capture Compare 1 overcapture Flag + * @arg TIM_FLAG_CC2OF: TIM Capture Compare 2 overcapture Flag + * @arg TIM_FLAG_CC3OF: TIM Capture Compare 3 overcapture Flag + * @arg TIM_FLAG_CC4OF: TIM Capture Compare 4 overcapture Flag + * @note + * - TIM6 and TIM7 can have only one update flag. + * - TIM9, TIM12 and TIM15 can have only TIM_FLAG_Update, TIM_FLAG_CC1, + * TIM_FLAG_CC2 or TIM_FLAG_Trigger. + * - TIM10, TIM11, TIM13, TIM14, TIM16 and TIM17 can have TIM_FLAG_Update or TIM_FLAG_CC1. + * - TIM_FLAG_Break is used only with TIM1, TIM8 and TIM15. + * - TIM_FLAG_COM is used only with TIM1, TIM8, TIM15, TIM16 and TIM17. + * @retval None + */ +void TIM_ClearFlag(TIM_TypeDef* TIMx, uint16_t TIM_FLAG) +{ + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + assert_param(IS_TIM_CLEAR_FLAG(TIM_FLAG)); + + /* Clear the flags */ + TIMx->SR = (uint16_t)~TIM_FLAG; +} + +/** + * @brief Checks whether the TIM interrupt has occurred or not. + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @param TIM_IT: specifies the TIM interrupt source to check. + * This parameter can be one of the following values: + * @arg TIM_IT_Update: TIM update Interrupt source + * @arg TIM_IT_CC1: TIM Capture Compare 1 Interrupt source + * @arg TIM_IT_CC2: TIM Capture Compare 2 Interrupt source + * @arg TIM_IT_CC3: TIM Capture Compare 3 Interrupt source + * @arg TIM_IT_CC4: TIM Capture Compare 4 Interrupt source + * @arg TIM_IT_COM: TIM Commutation Interrupt source + * @arg TIM_IT_Trigger: TIM Trigger Interrupt source + * @arg TIM_IT_Break: TIM Break Interrupt source + * @note + * - TIM6 and TIM7 can generate only an update interrupt. + * - TIM9, TIM12 and TIM15 can have only TIM_IT_Update, TIM_IT_CC1, + * TIM_IT_CC2 or TIM_IT_Trigger. + * - TIM10, TIM11, TIM13, TIM14, TIM16 and TIM17 can have TIM_IT_Update or TIM_IT_CC1. + * - TIM_IT_Break is used only with TIM1, TIM8 and TIM15. + * - TIM_IT_COM is used only with TIM1, TIM8, TIM15, TIM16 and TIM17. + * @retval The new state of the TIM_IT(SET or RESET). + */ +ITStatus TIM_GetITStatus(TIM_TypeDef* TIMx, uint16_t TIM_IT) +{ + ITStatus bitstatus = RESET; + uint16_t itstatus = 0x0, itenable = 0x0; + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + assert_param(IS_TIM_GET_IT(TIM_IT)); + + itstatus = TIMx->SR & TIM_IT; + + itenable = TIMx->DIER & TIM_IT; + if ((itstatus != (uint16_t)RESET) && (itenable != (uint16_t)RESET)) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + return bitstatus; +} + +/** + * @brief Clears the TIMx's interrupt pending bits. + * @param TIMx: where x can be 1 to 17 to select the TIM peripheral. + * @param TIM_IT: specifies the pending bit to clear. + * This parameter can be any combination of the following values: + * @arg TIM_IT_Update: TIM1 update Interrupt source + * @arg TIM_IT_CC1: TIM Capture Compare 1 Interrupt source + * @arg TIM_IT_CC2: TIM Capture Compare 2 Interrupt source + * @arg TIM_IT_CC3: TIM Capture Compare 3 Interrupt source + * @arg TIM_IT_CC4: TIM Capture Compare 4 Interrupt source + * @arg TIM_IT_COM: TIM Commutation Interrupt source + * @arg TIM_IT_Trigger: TIM Trigger Interrupt source + * @arg TIM_IT_Break: TIM Break Interrupt source + * @note + * - TIM6 and TIM7 can generate only an update interrupt. + * - TIM9, TIM12 and TIM15 can have only TIM_IT_Update, TIM_IT_CC1, + * TIM_IT_CC2 or TIM_IT_Trigger. + * - TIM10, TIM11, TIM13, TIM14, TIM16 and TIM17 can have TIM_IT_Update or TIM_IT_CC1. + * - TIM_IT_Break is used only with TIM1, TIM8 and TIM15. + * - TIM_IT_COM is used only with TIM1, TIM8, TIM15, TIM16 and TIM17. + * @retval None + */ +void TIM_ClearITPendingBit(TIM_TypeDef* TIMx, uint16_t TIM_IT) +{ + /* Check the parameters */ + assert_param(IS_TIM_ALL_PERIPH(TIMx)); + assert_param(IS_TIM_IT(TIM_IT)); + /* Clear the IT pending Bit */ + TIMx->SR = (uint16_t)~TIM_IT; +} + +/** + * @brief Configure the TI1 as Input. + * @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral. + * @param TIM_ICPolarity : The Input Polarity. + * This parameter can be one of the following values: + * @arg TIM_ICPolarity_Rising + * @arg TIM_ICPolarity_Falling + * @param TIM_ICSelection: specifies the input to be used. + * This parameter can be one of the following values: + * @arg TIM_ICSelection_DirectTI: TIM Input 1 is selected to be connected to IC1. + * @arg TIM_ICSelection_IndirectTI: TIM Input 1 is selected to be connected to IC2. + * @arg TIM_ICSelection_TRC: TIM Input 1 is selected to be connected to TRC. + * @param TIM_ICFilter: Specifies the Input Capture Filter. + * This parameter must be a value between 0x00 and 0x0F. + * @retval None + */ +static void TI1_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, + uint16_t TIM_ICFilter) +{ + uint16_t tmpccmr1 = 0, tmpccer = 0; + /* Disable the Channel 1: Reset the CC1E Bit */ + TIMx->CCER &= (uint16_t)~((uint16_t)TIM_CCER_CC1E); + tmpccmr1 = TIMx->CCMR1; + tmpccer = TIMx->CCER; + /* Select the Input and set the filter */ + tmpccmr1 &= (uint16_t)(((uint16_t)~((uint16_t)TIM_CCMR1_CC1S)) & ((uint16_t)~((uint16_t)TIM_CCMR1_IC1F))); + tmpccmr1 |= (uint16_t)(TIM_ICSelection | (uint16_t)(TIM_ICFilter << (uint16_t)4)); + + if((TIMx == TIM1) || (TIMx == TIM8) || (TIMx == TIM2) || (TIMx == TIM3) || + (TIMx == TIM4) ||(TIMx == TIM5)) + { + /* Select the Polarity and set the CC1E Bit */ + tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC1P)); + tmpccer |= (uint16_t)(TIM_ICPolarity | (uint16_t)TIM_CCER_CC1E); + } + else + { + /* Select the Polarity and set the CC1E Bit */ + tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC1P | TIM_CCER_CC1NP)); + tmpccer |= (uint16_t)(TIM_ICPolarity | (uint16_t)TIM_CCER_CC1E); + } + + /* Write to TIMx CCMR1 and CCER registers */ + TIMx->CCMR1 = tmpccmr1; + TIMx->CCER = tmpccer; +} + +/** + * @brief Configure the TI2 as Input. + * @param TIMx: where x can be 1, 2, 3, 4, 5, 8, 9, 12 or 15 to select the TIM peripheral. + * @param TIM_ICPolarity : The Input Polarity. + * This parameter can be one of the following values: + * @arg TIM_ICPolarity_Rising + * @arg TIM_ICPolarity_Falling + * @param TIM_ICSelection: specifies the input to be used. + * This parameter can be one of the following values: + * @arg TIM_ICSelection_DirectTI: TIM Input 2 is selected to be connected to IC2. + * @arg TIM_ICSelection_IndirectTI: TIM Input 2 is selected to be connected to IC1. + * @arg TIM_ICSelection_TRC: TIM Input 2 is selected to be connected to TRC. + * @param TIM_ICFilter: Specifies the Input Capture Filter. + * This parameter must be a value between 0x00 and 0x0F. + * @retval None + */ +static void TI2_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, + uint16_t TIM_ICFilter) +{ + uint16_t tmpccmr1 = 0, tmpccer = 0, tmp = 0; + /* Disable the Channel 2: Reset the CC2E Bit */ + TIMx->CCER &= (uint16_t)~((uint16_t)TIM_CCER_CC2E); + tmpccmr1 = TIMx->CCMR1; + tmpccer = TIMx->CCER; + tmp = (uint16_t)(TIM_ICPolarity << 4); + /* Select the Input and set the filter */ + tmpccmr1 &= (uint16_t)(((uint16_t)~((uint16_t)TIM_CCMR1_CC2S)) & ((uint16_t)~((uint16_t)TIM_CCMR1_IC2F))); + tmpccmr1 |= (uint16_t)(TIM_ICFilter << 12); + tmpccmr1 |= (uint16_t)(TIM_ICSelection << 8); + + if((TIMx == TIM1) || (TIMx == TIM8) || (TIMx == TIM2) || (TIMx == TIM3) || + (TIMx == TIM4) ||(TIMx == TIM5)) + { + /* Select the Polarity and set the CC2E Bit */ + tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC2P)); + tmpccer |= (uint16_t)(tmp | (uint16_t)TIM_CCER_CC2E); + } + else + { + /* Select the Polarity and set the CC2E Bit */ + tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC2P | TIM_CCER_CC2NP)); + tmpccer |= (uint16_t)(TIM_ICPolarity | (uint16_t)TIM_CCER_CC2E); + } + + /* Write to TIMx CCMR1 and CCER registers */ + TIMx->CCMR1 = tmpccmr1 ; + TIMx->CCER = tmpccer; +} + +/** + * @brief Configure the TI3 as Input. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_ICPolarity : The Input Polarity. + * This parameter can be one of the following values: + * @arg TIM_ICPolarity_Rising + * @arg TIM_ICPolarity_Falling + * @param TIM_ICSelection: specifies the input to be used. + * This parameter can be one of the following values: + * @arg TIM_ICSelection_DirectTI: TIM Input 3 is selected to be connected to IC3. + * @arg TIM_ICSelection_IndirectTI: TIM Input 3 is selected to be connected to IC4. + * @arg TIM_ICSelection_TRC: TIM Input 3 is selected to be connected to TRC. + * @param TIM_ICFilter: Specifies the Input Capture Filter. + * This parameter must be a value between 0x00 and 0x0F. + * @retval None + */ +static void TI3_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, + uint16_t TIM_ICFilter) +{ + uint16_t tmpccmr2 = 0, tmpccer = 0, tmp = 0; + /* Disable the Channel 3: Reset the CC3E Bit */ + TIMx->CCER &= (uint16_t)~((uint16_t)TIM_CCER_CC3E); + tmpccmr2 = TIMx->CCMR2; + tmpccer = TIMx->CCER; + tmp = (uint16_t)(TIM_ICPolarity << 8); + /* Select the Input and set the filter */ + tmpccmr2 &= (uint16_t)(((uint16_t)~((uint16_t)TIM_CCMR2_CC3S)) & ((uint16_t)~((uint16_t)TIM_CCMR2_IC3F))); + tmpccmr2 |= (uint16_t)(TIM_ICSelection | (uint16_t)(TIM_ICFilter << (uint16_t)4)); + + if((TIMx == TIM1) || (TIMx == TIM8) || (TIMx == TIM2) || (TIMx == TIM3) || + (TIMx == TIM4) ||(TIMx == TIM5)) + { + /* Select the Polarity and set the CC3E Bit */ + tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC3P)); + tmpccer |= (uint16_t)(tmp | (uint16_t)TIM_CCER_CC3E); + } + else + { + /* Select the Polarity and set the CC3E Bit */ + tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC3P | TIM_CCER_CC3NP)); + tmpccer |= (uint16_t)(TIM_ICPolarity | (uint16_t)TIM_CCER_CC3E); + } + + /* Write to TIMx CCMR2 and CCER registers */ + TIMx->CCMR2 = tmpccmr2; + TIMx->CCER = tmpccer; +} + +/** + * @brief Configure the TI4 as Input. + * @param TIMx: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral. + * @param TIM_ICPolarity : The Input Polarity. + * This parameter can be one of the following values: + * @arg TIM_ICPolarity_Rising + * @arg TIM_ICPolarity_Falling + * @param TIM_ICSelection: specifies the input to be used. + * This parameter can be one of the following values: + * @arg TIM_ICSelection_DirectTI: TIM Input 4 is selected to be connected to IC4. + * @arg TIM_ICSelection_IndirectTI: TIM Input 4 is selected to be connected to IC3. + * @arg TIM_ICSelection_TRC: TIM Input 4 is selected to be connected to TRC. + * @param TIM_ICFilter: Specifies the Input Capture Filter. + * This parameter must be a value between 0x00 and 0x0F. + * @retval None + */ +static void TI4_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, + uint16_t TIM_ICFilter) +{ + uint16_t tmpccmr2 = 0, tmpccer = 0, tmp = 0; + + /* Disable the Channel 4: Reset the CC4E Bit */ + TIMx->CCER &= (uint16_t)~((uint16_t)TIM_CCER_CC4E); + tmpccmr2 = TIMx->CCMR2; + tmpccer = TIMx->CCER; + tmp = (uint16_t)(TIM_ICPolarity << 12); + /* Select the Input and set the filter */ + tmpccmr2 &= (uint16_t)((uint16_t)(~(uint16_t)TIM_CCMR2_CC4S) & ((uint16_t)~((uint16_t)TIM_CCMR2_IC4F))); + tmpccmr2 |= (uint16_t)(TIM_ICSelection << 8); + tmpccmr2 |= (uint16_t)(TIM_ICFilter << 12); + + if((TIMx == TIM1) || (TIMx == TIM8) || (TIMx == TIM2) || (TIMx == TIM3) || + (TIMx == TIM4) ||(TIMx == TIM5)) + { + /* Select the Polarity and set the CC4E Bit */ + tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC4P)); + tmpccer |= (uint16_t)(tmp | (uint16_t)TIM_CCER_CC4E); + } + else + { + /* Select the Polarity and set the CC4E Bit */ + tmpccer &= (uint16_t)~((uint16_t)(TIM_CCER_CC3P | TIM_CCER_CC4NP)); + tmpccer |= (uint16_t)(TIM_ICPolarity | (uint16_t)TIM_CCER_CC4E); + } + /* Write to TIMx CCMR2 and CCER registers */ + TIMx->CCMR2 = tmpccmr2; + TIMx->CCER = tmpccer; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_usart.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_usart.c new file mode 100755 index 0000000..a3f16f1 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_usart.c @@ -0,0 +1,1058 @@ +/** + ****************************************************************************** + * @file stm32f10x_usart.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the USART firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_usart.h" +#include "stm32f10x_rcc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup USART + * @brief USART driver modules + * @{ + */ + +/** @defgroup USART_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup USART_Private_Defines + * @{ + */ + +#define CR1_UE_Set ((uint16_t)0x2000) /*!< USART Enable Mask */ +#define CR1_UE_Reset ((uint16_t)0xDFFF) /*!< USART Disable Mask */ + +#define CR1_WAKE_Mask ((uint16_t)0xF7FF) /*!< USART WakeUp Method Mask */ + +#define CR1_RWU_Set ((uint16_t)0x0002) /*!< USART mute mode Enable Mask */ +#define CR1_RWU_Reset ((uint16_t)0xFFFD) /*!< USART mute mode Enable Mask */ +#define CR1_SBK_Set ((uint16_t)0x0001) /*!< USART Break Character send Mask */ +#define CR1_CLEAR_Mask ((uint16_t)0xE9F3) /*!< USART CR1 Mask */ +#define CR2_Address_Mask ((uint16_t)0xFFF0) /*!< USART address Mask */ + +#define CR2_LINEN_Set ((uint16_t)0x4000) /*!< USART LIN Enable Mask */ +#define CR2_LINEN_Reset ((uint16_t)0xBFFF) /*!< USART LIN Disable Mask */ + +#define CR2_LBDL_Mask ((uint16_t)0xFFDF) /*!< USART LIN Break detection Mask */ +#define CR2_STOP_CLEAR_Mask ((uint16_t)0xCFFF) /*!< USART CR2 STOP Bits Mask */ +#define CR2_CLOCK_CLEAR_Mask ((uint16_t)0xF0FF) /*!< USART CR2 Clock Mask */ + +#define CR3_SCEN_Set ((uint16_t)0x0020) /*!< USART SC Enable Mask */ +#define CR3_SCEN_Reset ((uint16_t)0xFFDF) /*!< USART SC Disable Mask */ + +#define CR3_NACK_Set ((uint16_t)0x0010) /*!< USART SC NACK Enable Mask */ +#define CR3_NACK_Reset ((uint16_t)0xFFEF) /*!< USART SC NACK Disable Mask */ + +#define CR3_HDSEL_Set ((uint16_t)0x0008) /*!< USART Half-Duplex Enable Mask */ +#define CR3_HDSEL_Reset ((uint16_t)0xFFF7) /*!< USART Half-Duplex Disable Mask */ + +#define CR3_IRLP_Mask ((uint16_t)0xFFFB) /*!< USART IrDA LowPower mode Mask */ +#define CR3_CLEAR_Mask ((uint16_t)0xFCFF) /*!< USART CR3 Mask */ + +#define CR3_IREN_Set ((uint16_t)0x0002) /*!< USART IrDA Enable Mask */ +#define CR3_IREN_Reset ((uint16_t)0xFFFD) /*!< USART IrDA Disable Mask */ +#define GTPR_LSB_Mask ((uint16_t)0x00FF) /*!< Guard Time Register LSB Mask */ +#define GTPR_MSB_Mask ((uint16_t)0xFF00) /*!< Guard Time Register MSB Mask */ +#define IT_Mask ((uint16_t)0x001F) /*!< USART Interrupt Mask */ + +/* USART OverSampling-8 Mask */ +#define CR1_OVER8_Set ((u16)0x8000) /* USART OVER8 mode Enable Mask */ +#define CR1_OVER8_Reset ((u16)0x7FFF) /* USART OVER8 mode Disable Mask */ + +/* USART One Bit Sampling Mask */ +#define CR3_ONEBITE_Set ((u16)0x0800) /* USART ONEBITE mode Enable Mask */ +#define CR3_ONEBITE_Reset ((u16)0xF7FF) /* USART ONEBITE mode Disable Mask */ + +/** + * @} + */ + +/** @defgroup USART_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup USART_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup USART_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup USART_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the USARTx peripheral registers to their default reset values. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @retval None + */ +void USART_DeInit(USART_TypeDef* USARTx) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + + if (USARTx == USART1) + { + RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART1, ENABLE); + RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART1, DISABLE); + } + else if (USARTx == USART2) + { + RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART2, ENABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART2, DISABLE); + } + else if (USARTx == USART3) + { + RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART3, ENABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART3, DISABLE); + } + else if (USARTx == UART4) + { + RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART4, ENABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART4, DISABLE); + } + else + { + if (USARTx == UART5) + { + RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART5, ENABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART5, DISABLE); + } + } +} + +/** + * @brief Initializes the USARTx peripheral according to the specified + * parameters in the USART_InitStruct . + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param USART_InitStruct: pointer to a USART_InitTypeDef structure + * that contains the configuration information for the specified USART + * peripheral. + * @retval None + */ +void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct) +{ + uint32_t tmpreg = 0x00, apbclock = 0x00; + uint32_t integerdivider = 0x00; + uint32_t fractionaldivider = 0x00; + uint32_t usartxbase = 0; + RCC_ClocksTypeDef RCC_ClocksStatus; + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_USART_BAUDRATE(USART_InitStruct->USART_BaudRate)); + assert_param(IS_USART_WORD_LENGTH(USART_InitStruct->USART_WordLength)); + assert_param(IS_USART_STOPBITS(USART_InitStruct->USART_StopBits)); + assert_param(IS_USART_PARITY(USART_InitStruct->USART_Parity)); + assert_param(IS_USART_MODE(USART_InitStruct->USART_Mode)); + assert_param(IS_USART_HARDWARE_FLOW_CONTROL(USART_InitStruct->USART_HardwareFlowControl)); + /* The hardware flow control is available only for USART1, USART2 and USART3 */ + if (USART_InitStruct->USART_HardwareFlowControl != USART_HardwareFlowControl_None) + { + assert_param(IS_USART_123_PERIPH(USARTx)); + } + + usartxbase = (uint32_t)USARTx; + +/*---------------------------- USART CR2 Configuration -----------------------*/ + tmpreg = USARTx->CR2; + /* Clear STOP[13:12] bits */ + tmpreg &= CR2_STOP_CLEAR_Mask; + /* Configure the USART Stop Bits, Clock, CPOL, CPHA and LastBit ------------*/ + /* Set STOP[13:12] bits according to USART_StopBits value */ + tmpreg |= (uint32_t)USART_InitStruct->USART_StopBits; + + /* Write to USART CR2 */ + USARTx->CR2 = (uint16_t)tmpreg; + +/*---------------------------- USART CR1 Configuration -----------------------*/ + tmpreg = USARTx->CR1; + /* Clear M, PCE, PS, TE and RE bits */ + tmpreg &= CR1_CLEAR_Mask; + /* Configure the USART Word Length, Parity and mode ----------------------- */ + /* Set the M bits according to USART_WordLength value */ + /* Set PCE and PS bits according to USART_Parity value */ + /* Set TE and RE bits according to USART_Mode value */ + tmpreg |= (uint32_t)USART_InitStruct->USART_WordLength | USART_InitStruct->USART_Parity | + USART_InitStruct->USART_Mode; + /* Write to USART CR1 */ + USARTx->CR1 = (uint16_t)tmpreg; + +/*---------------------------- USART CR3 Configuration -----------------------*/ + tmpreg = USARTx->CR3; + /* Clear CTSE and RTSE bits */ + tmpreg &= CR3_CLEAR_Mask; + /* Configure the USART HFC -------------------------------------------------*/ + /* Set CTSE and RTSE bits according to USART_HardwareFlowControl value */ + tmpreg |= USART_InitStruct->USART_HardwareFlowControl; + /* Write to USART CR3 */ + USARTx->CR3 = (uint16_t)tmpreg; + +/*---------------------------- USART BRR Configuration -----------------------*/ + /* Configure the USART Baud Rate -------------------------------------------*/ + RCC_GetClocksFreq(&RCC_ClocksStatus); + if (usartxbase == USART1_BASE) + { + apbclock = RCC_ClocksStatus.PCLK2_Frequency; + } + else + { + apbclock = RCC_ClocksStatus.PCLK1_Frequency; + } + + /* Determine the integer part */ + if ((USARTx->CR1 & CR1_OVER8_Set) != 0) + { + /* Integer part computing in case Oversampling mode is 8 Samples */ + integerdivider = ((25 * apbclock) / (2 * (USART_InitStruct->USART_BaudRate))); + } + else /* if ((USARTx->CR1 & CR1_OVER8_Set) == 0) */ + { + /* Integer part computing in case Oversampling mode is 16 Samples */ + integerdivider = ((25 * apbclock) / (4 * (USART_InitStruct->USART_BaudRate))); + } + tmpreg = (integerdivider / 100) << 4; + + /* Determine the fractional part */ + fractionaldivider = integerdivider - (100 * (tmpreg >> 4)); + + /* Implement the fractional part in the register */ + if ((USARTx->CR1 & CR1_OVER8_Set) != 0) + { + tmpreg |= ((((fractionaldivider * 8) + 50) / 100)) & ((uint8_t)0x07); + } + else /* if ((USARTx->CR1 & CR1_OVER8_Set) == 0) */ + { + tmpreg |= ((((fractionaldivider * 16) + 50) / 100)) & ((uint8_t)0x0F); + } + + /* Write to USART BRR */ + USARTx->BRR = (uint16_t)tmpreg; +} + +/** + * @brief Fills each USART_InitStruct member with its default value. + * @param USART_InitStruct: pointer to a USART_InitTypeDef structure + * which will be initialized. + * @retval None + */ +void USART_StructInit(USART_InitTypeDef* USART_InitStruct) +{ + /* USART_InitStruct members default value */ + USART_InitStruct->USART_BaudRate = 9600; + USART_InitStruct->USART_WordLength = USART_WordLength_8b; + USART_InitStruct->USART_StopBits = USART_StopBits_1; + USART_InitStruct->USART_Parity = USART_Parity_No ; + USART_InitStruct->USART_Mode = USART_Mode_Rx | USART_Mode_Tx; + USART_InitStruct->USART_HardwareFlowControl = USART_HardwareFlowControl_None; +} + +/** + * @brief Initializes the USARTx peripheral Clock according to the + * specified parameters in the USART_ClockInitStruct . + * @param USARTx: where x can be 1, 2, 3 to select the USART peripheral. + * @param USART_ClockInitStruct: pointer to a USART_ClockInitTypeDef + * structure that contains the configuration information for the specified + * USART peripheral. + * @note The Smart Card and Synchronous modes are not available for UART4 and UART5. + * @retval None + */ +void USART_ClockInit(USART_TypeDef* USARTx, USART_ClockInitTypeDef* USART_ClockInitStruct) +{ + uint32_t tmpreg = 0x00; + /* Check the parameters */ + assert_param(IS_USART_123_PERIPH(USARTx)); + assert_param(IS_USART_CLOCK(USART_ClockInitStruct->USART_Clock)); + assert_param(IS_USART_CPOL(USART_ClockInitStruct->USART_CPOL)); + assert_param(IS_USART_CPHA(USART_ClockInitStruct->USART_CPHA)); + assert_param(IS_USART_LASTBIT(USART_ClockInitStruct->USART_LastBit)); + +/*---------------------------- USART CR2 Configuration -----------------------*/ + tmpreg = USARTx->CR2; + /* Clear CLKEN, CPOL, CPHA and LBCL bits */ + tmpreg &= CR2_CLOCK_CLEAR_Mask; + /* Configure the USART Clock, CPOL, CPHA and LastBit ------------*/ + /* Set CLKEN bit according to USART_Clock value */ + /* Set CPOL bit according to USART_CPOL value */ + /* Set CPHA bit according to USART_CPHA value */ + /* Set LBCL bit according to USART_LastBit value */ + tmpreg |= (uint32_t)USART_ClockInitStruct->USART_Clock | USART_ClockInitStruct->USART_CPOL | + USART_ClockInitStruct->USART_CPHA | USART_ClockInitStruct->USART_LastBit; + /* Write to USART CR2 */ + USARTx->CR2 = (uint16_t)tmpreg; +} + +/** + * @brief Fills each USART_ClockInitStruct member with its default value. + * @param USART_ClockInitStruct: pointer to a USART_ClockInitTypeDef + * structure which will be initialized. + * @retval None + */ +void USART_ClockStructInit(USART_ClockInitTypeDef* USART_ClockInitStruct) +{ + /* USART_ClockInitStruct members default value */ + USART_ClockInitStruct->USART_Clock = USART_Clock_Disable; + USART_ClockInitStruct->USART_CPOL = USART_CPOL_Low; + USART_ClockInitStruct->USART_CPHA = USART_CPHA_1Edge; + USART_ClockInitStruct->USART_LastBit = USART_LastBit_Disable; +} + +/** + * @brief Enables or disables the specified USART peripheral. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param NewState: new state of the USARTx peripheral. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the selected USART by setting the UE bit in the CR1 register */ + USARTx->CR1 |= CR1_UE_Set; + } + else + { + /* Disable the selected USART by clearing the UE bit in the CR1 register */ + USARTx->CR1 &= CR1_UE_Reset; + } +} + +/** + * @brief Enables or disables the specified USART interrupts. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param USART_IT: specifies the USART interrupt sources to be enabled or disabled. + * This parameter can be one of the following values: + * @arg USART_IT_CTS: CTS change interrupt (not available for UART4 and UART5) + * @arg USART_IT_LBD: LIN Break detection interrupt + * @arg USART_IT_TXE: Transmit Data Register empty interrupt + * @arg USART_IT_TC: Transmission complete interrupt + * @arg USART_IT_RXNE: Receive Data register not empty interrupt + * @arg USART_IT_IDLE: Idle line detection interrupt + * @arg USART_IT_PE: Parity Error interrupt + * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error) + * @param NewState: new state of the specified USARTx interrupts. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void USART_ITConfig(USART_TypeDef* USARTx, uint16_t USART_IT, FunctionalState NewState) +{ + uint32_t usartreg = 0x00, itpos = 0x00, itmask = 0x00; + uint32_t usartxbase = 0x00; + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_USART_CONFIG_IT(USART_IT)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + /* The CTS interrupt is not available for UART4 and UART5 */ + if (USART_IT == USART_IT_CTS) + { + assert_param(IS_USART_123_PERIPH(USARTx)); + } + + usartxbase = (uint32_t)USARTx; + + /* Get the USART register index */ + usartreg = (((uint8_t)USART_IT) >> 0x05); + + /* Get the interrupt position */ + itpos = USART_IT & IT_Mask; + itmask = (((uint32_t)0x01) << itpos); + + if (usartreg == 0x01) /* The IT is in CR1 register */ + { + usartxbase += 0x0C; + } + else if (usartreg == 0x02) /* The IT is in CR2 register */ + { + usartxbase += 0x10; + } + else /* The IT is in CR3 register */ + { + usartxbase += 0x14; + } + if (NewState != DISABLE) + { + *(__IO uint32_t*)usartxbase |= itmask; + } + else + { + *(__IO uint32_t*)usartxbase &= ~itmask; + } +} + +/** + * @brief Enables or disables the USARTs DMA interface. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param USART_DMAReq: specifies the DMA request. + * This parameter can be any combination of the following values: + * @arg USART_DMAReq_Tx: USART DMA transmit request + * @arg USART_DMAReq_Rx: USART DMA receive request + * @param NewState: new state of the DMA Request sources. + * This parameter can be: ENABLE or DISABLE. + * @note The DMA mode is not available for UART5 except in the STM32 + * High density value line devices(STM32F10X_HD_VL). + * @retval None + */ +void USART_DMACmd(USART_TypeDef* USARTx, uint16_t USART_DMAReq, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_USART_DMAREQ(USART_DMAReq)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the DMA transfer for selected requests by setting the DMAT and/or + DMAR bits in the USART CR3 register */ + USARTx->CR3 |= USART_DMAReq; + } + else + { + /* Disable the DMA transfer for selected requests by clearing the DMAT and/or + DMAR bits in the USART CR3 register */ + USARTx->CR3 &= (uint16_t)~USART_DMAReq; + } +} + +/** + * @brief Sets the address of the USART node. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param USART_Address: Indicates the address of the USART node. + * @retval None + */ +void USART_SetAddress(USART_TypeDef* USARTx, uint8_t USART_Address) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_USART_ADDRESS(USART_Address)); + + /* Clear the USART address */ + USARTx->CR2 &= CR2_Address_Mask; + /* Set the USART address node */ + USARTx->CR2 |= USART_Address; +} + +/** + * @brief Selects the USART WakeUp method. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param USART_WakeUp: specifies the USART wakeup method. + * This parameter can be one of the following values: + * @arg USART_WakeUp_IdleLine: WakeUp by an idle line detection + * @arg USART_WakeUp_AddressMark: WakeUp by an address mark + * @retval None + */ +void USART_WakeUpConfig(USART_TypeDef* USARTx, uint16_t USART_WakeUp) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_USART_WAKEUP(USART_WakeUp)); + + USARTx->CR1 &= CR1_WAKE_Mask; + USARTx->CR1 |= USART_WakeUp; +} + +/** + * @brief Determines if the USART is in mute mode or not. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param NewState: new state of the USART mute mode. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void USART_ReceiverWakeUpCmd(USART_TypeDef* USARTx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the USART mute mode by setting the RWU bit in the CR1 register */ + USARTx->CR1 |= CR1_RWU_Set; + } + else + { + /* Disable the USART mute mode by clearing the RWU bit in the CR1 register */ + USARTx->CR1 &= CR1_RWU_Reset; + } +} + +/** + * @brief Sets the USART LIN Break detection length. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param USART_LINBreakDetectLength: specifies the LIN break detection length. + * This parameter can be one of the following values: + * @arg USART_LINBreakDetectLength_10b: 10-bit break detection + * @arg USART_LINBreakDetectLength_11b: 11-bit break detection + * @retval None + */ +void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, uint16_t USART_LINBreakDetectLength) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_USART_LIN_BREAK_DETECT_LENGTH(USART_LINBreakDetectLength)); + + USARTx->CR2 &= CR2_LBDL_Mask; + USARTx->CR2 |= USART_LINBreakDetectLength; +} + +/** + * @brief Enables or disables the USARTs LIN mode. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param NewState: new state of the USART LIN mode. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the LIN mode by setting the LINEN bit in the CR2 register */ + USARTx->CR2 |= CR2_LINEN_Set; + } + else + { + /* Disable the LIN mode by clearing the LINEN bit in the CR2 register */ + USARTx->CR2 &= CR2_LINEN_Reset; + } +} + +/** + * @brief Transmits single data through the USARTx peripheral. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param Data: the data to transmit. + * @retval None + */ +void USART_SendData(USART_TypeDef* USARTx, uint16_t Data) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_USART_DATA(Data)); + + /* Transmit Data */ + USARTx->DR = (Data & (uint16_t)0x01FF); +} + +/** + * @brief Returns the most recent received data by the USARTx peripheral. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @retval The received data. + */ +uint16_t USART_ReceiveData(USART_TypeDef* USARTx) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + + /* Receive Data */ + return (uint16_t)(USARTx->DR & (uint16_t)0x01FF); +} + +/** + * @brief Transmits break characters. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @retval None + */ +void USART_SendBreak(USART_TypeDef* USARTx) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + + /* Send break characters */ + USARTx->CR1 |= CR1_SBK_Set; +} + +/** + * @brief Sets the specified USART guard time. + * @param USARTx: where x can be 1, 2 or 3 to select the USART peripheral. + * @param USART_GuardTime: specifies the guard time. + * @note The guard time bits are not available for UART4 and UART5. + * @retval None + */ +void USART_SetGuardTime(USART_TypeDef* USARTx, uint8_t USART_GuardTime) +{ + /* Check the parameters */ + assert_param(IS_USART_123_PERIPH(USARTx)); + + /* Clear the USART Guard time */ + USARTx->GTPR &= GTPR_LSB_Mask; + /* Set the USART guard time */ + USARTx->GTPR |= (uint16_t)((uint16_t)USART_GuardTime << 0x08); +} + +/** + * @brief Sets the system clock prescaler. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param USART_Prescaler: specifies the prescaler clock. + * @note The function is used for IrDA mode with UART4 and UART5. + * @retval None + */ +void USART_SetPrescaler(USART_TypeDef* USARTx, uint8_t USART_Prescaler) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + + /* Clear the USART prescaler */ + USARTx->GTPR &= GTPR_MSB_Mask; + /* Set the USART prescaler */ + USARTx->GTPR |= USART_Prescaler; +} + +/** + * @brief Enables or disables the USARTs Smart Card mode. + * @param USARTx: where x can be 1, 2 or 3 to select the USART peripheral. + * @param NewState: new state of the Smart Card mode. + * This parameter can be: ENABLE or DISABLE. + * @note The Smart Card mode is not available for UART4 and UART5. + * @retval None + */ +void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_USART_123_PERIPH(USARTx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the SC mode by setting the SCEN bit in the CR3 register */ + USARTx->CR3 |= CR3_SCEN_Set; + } + else + { + /* Disable the SC mode by clearing the SCEN bit in the CR3 register */ + USARTx->CR3 &= CR3_SCEN_Reset; + } +} + +/** + * @brief Enables or disables NACK transmission. + * @param USARTx: where x can be 1, 2 or 3 to select the USART peripheral. + * @param NewState: new state of the NACK transmission. + * This parameter can be: ENABLE or DISABLE. + * @note The Smart Card mode is not available for UART4 and UART5. + * @retval None + */ +void USART_SmartCardNACKCmd(USART_TypeDef* USARTx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_USART_123_PERIPH(USARTx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + if (NewState != DISABLE) + { + /* Enable the NACK transmission by setting the NACK bit in the CR3 register */ + USARTx->CR3 |= CR3_NACK_Set; + } + else + { + /* Disable the NACK transmission by clearing the NACK bit in the CR3 register */ + USARTx->CR3 &= CR3_NACK_Reset; + } +} + +/** + * @brief Enables or disables the USARTs Half Duplex communication. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param NewState: new state of the USART Communication. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the Half-Duplex mode by setting the HDSEL bit in the CR3 register */ + USARTx->CR3 |= CR3_HDSEL_Set; + } + else + { + /* Disable the Half-Duplex mode by clearing the HDSEL bit in the CR3 register */ + USARTx->CR3 &= CR3_HDSEL_Reset; + } +} + + +/** + * @brief Enables or disables the USART's 8x oversampling mode. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param NewState: new state of the USART one bit sampling method. + * This parameter can be: ENABLE or DISABLE. + * @note + * This function has to be called before calling USART_Init() + * function in order to have correct baudrate Divider value. + * @retval None + */ +void USART_OverSampling8Cmd(USART_TypeDef* USARTx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the 8x Oversampling mode by setting the OVER8 bit in the CR1 register */ + USARTx->CR1 |= CR1_OVER8_Set; + } + else + { + /* Disable the 8x Oversampling mode by clearing the OVER8 bit in the CR1 register */ + USARTx->CR1 &= CR1_OVER8_Reset; + } +} + +/** + * @brief Enables or disables the USART's one bit sampling method. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param NewState: new state of the USART one bit sampling method. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void USART_OneBitMethodCmd(USART_TypeDef* USARTx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the one bit method by setting the ONEBITE bit in the CR3 register */ + USARTx->CR3 |= CR3_ONEBITE_Set; + } + else + { + /* Disable tthe one bit method by clearing the ONEBITE bit in the CR3 register */ + USARTx->CR3 &= CR3_ONEBITE_Reset; + } +} + +/** + * @brief Configures the USART's IrDA interface. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param USART_IrDAMode: specifies the IrDA mode. + * This parameter can be one of the following values: + * @arg USART_IrDAMode_LowPower + * @arg USART_IrDAMode_Normal + * @retval None + */ +void USART_IrDAConfig(USART_TypeDef* USARTx, uint16_t USART_IrDAMode) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_USART_IRDA_MODE(USART_IrDAMode)); + + USARTx->CR3 &= CR3_IRLP_Mask; + USARTx->CR3 |= USART_IrDAMode; +} + +/** + * @brief Enables or disables the USART's IrDA interface. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param NewState: new state of the IrDA mode. + * This parameter can be: ENABLE or DISABLE. + * @retval None + */ +void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_FUNCTIONAL_STATE(NewState)); + + if (NewState != DISABLE) + { + /* Enable the IrDA mode by setting the IREN bit in the CR3 register */ + USARTx->CR3 |= CR3_IREN_Set; + } + else + { + /* Disable the IrDA mode by clearing the IREN bit in the CR3 register */ + USARTx->CR3 &= CR3_IREN_Reset; + } +} + +/** + * @brief Checks whether the specified USART flag is set or not. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param USART_FLAG: specifies the flag to check. + * This parameter can be one of the following values: + * @arg USART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5) + * @arg USART_FLAG_LBD: LIN Break detection flag + * @arg USART_FLAG_TXE: Transmit data register empty flag + * @arg USART_FLAG_TC: Transmission Complete flag + * @arg USART_FLAG_RXNE: Receive data register not empty flag + * @arg USART_FLAG_IDLE: Idle Line detection flag + * @arg USART_FLAG_ORE: OverRun Error flag + * @arg USART_FLAG_NE: Noise Error flag + * @arg USART_FLAG_FE: Framing Error flag + * @arg USART_FLAG_PE: Parity Error flag + * @retval The new state of USART_FLAG (SET or RESET). + */ +FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint16_t USART_FLAG) +{ + FlagStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_USART_FLAG(USART_FLAG)); + /* The CTS flag is not available for UART4 and UART5 */ + if (USART_FLAG == USART_FLAG_CTS) + { + assert_param(IS_USART_123_PERIPH(USARTx)); + } + + if ((USARTx->SR & USART_FLAG) != (uint16_t)RESET) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + return bitstatus; +} + +/** + * @brief Clears the USARTx's pending flags. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param USART_FLAG: specifies the flag to clear. + * This parameter can be any combination of the following values: + * @arg USART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5). + * @arg USART_FLAG_LBD: LIN Break detection flag. + * @arg USART_FLAG_TC: Transmission Complete flag. + * @arg USART_FLAG_RXNE: Receive data register not empty flag. + * + * @note + * - PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun + * error) and IDLE (Idle line detected) flags are cleared by software + * sequence: a read operation to USART_SR register (USART_GetFlagStatus()) + * followed by a read operation to USART_DR register (USART_ReceiveData()). + * - RXNE flag can be also cleared by a read to the USART_DR register + * (USART_ReceiveData()). + * - TC flag can be also cleared by software sequence: a read operation to + * USART_SR register (USART_GetFlagStatus()) followed by a write operation + * to USART_DR register (USART_SendData()). + * - TXE flag is cleared only by a write to the USART_DR register + * (USART_SendData()). + * @retval None + */ +void USART_ClearFlag(USART_TypeDef* USARTx, uint16_t USART_FLAG) +{ + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_USART_CLEAR_FLAG(USART_FLAG)); + /* The CTS flag is not available for UART4 and UART5 */ + if ((USART_FLAG & USART_FLAG_CTS) == USART_FLAG_CTS) + { + assert_param(IS_USART_123_PERIPH(USARTx)); + } + + USARTx->SR = (uint16_t)~USART_FLAG; +} + +/** + * @brief Checks whether the specified USART interrupt has occurred or not. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param USART_IT: specifies the USART interrupt source to check. + * This parameter can be one of the following values: + * @arg USART_IT_CTS: CTS change interrupt (not available for UART4 and UART5) + * @arg USART_IT_LBD: LIN Break detection interrupt + * @arg USART_IT_TXE: Tansmit Data Register empty interrupt + * @arg USART_IT_TC: Transmission complete interrupt + * @arg USART_IT_RXNE: Receive Data register not empty interrupt + * @arg USART_IT_IDLE: Idle line detection interrupt + * @arg USART_IT_ORE: OverRun Error interrupt + * @arg USART_IT_NE: Noise Error interrupt + * @arg USART_IT_FE: Framing Error interrupt + * @arg USART_IT_PE: Parity Error interrupt + * @retval The new state of USART_IT (SET or RESET). + */ +ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint16_t USART_IT) +{ + uint32_t bitpos = 0x00, itmask = 0x00, usartreg = 0x00; + ITStatus bitstatus = RESET; + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_USART_GET_IT(USART_IT)); + /* The CTS interrupt is not available for UART4 and UART5 */ + if (USART_IT == USART_IT_CTS) + { + assert_param(IS_USART_123_PERIPH(USARTx)); + } + + /* Get the USART register index */ + usartreg = (((uint8_t)USART_IT) >> 0x05); + /* Get the interrupt position */ + itmask = USART_IT & IT_Mask; + itmask = (uint32_t)0x01 << itmask; + + if (usartreg == 0x01) /* The IT is in CR1 register */ + { + itmask &= USARTx->CR1; + } + else if (usartreg == 0x02) /* The IT is in CR2 register */ + { + itmask &= USARTx->CR2; + } + else /* The IT is in CR3 register */ + { + itmask &= USARTx->CR3; + } + + bitpos = USART_IT >> 0x08; + bitpos = (uint32_t)0x01 << bitpos; + bitpos &= USARTx->SR; + if ((itmask != (uint16_t)RESET)&&(bitpos != (uint16_t)RESET)) + { + bitstatus = SET; + } + else + { + bitstatus = RESET; + } + + return bitstatus; +} + +/** + * @brief Clears the USARTx's interrupt pending bits. + * @param USARTx: Select the USART or the UART peripheral. + * This parameter can be one of the following values: + * USART1, USART2, USART3, UART4 or UART5. + * @param USART_IT: specifies the interrupt pending bit to clear. + * This parameter can be one of the following values: + * @arg USART_IT_CTS: CTS change interrupt (not available for UART4 and UART5) + * @arg USART_IT_LBD: LIN Break detection interrupt + * @arg USART_IT_TC: Transmission complete interrupt. + * @arg USART_IT_RXNE: Receive Data register not empty interrupt. + * + * @note + * - PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun + * error) and IDLE (Idle line detected) pending bits are cleared by + * software sequence: a read operation to USART_SR register + * (USART_GetITStatus()) followed by a read operation to USART_DR register + * (USART_ReceiveData()). + * - RXNE pending bit can be also cleared by a read to the USART_DR register + * (USART_ReceiveData()). + * - TC pending bit can be also cleared by software sequence: a read + * operation to USART_SR register (USART_GetITStatus()) followed by a write + * operation to USART_DR register (USART_SendData()). + * - TXE pending bit is cleared only by a write to the USART_DR register + * (USART_SendData()). + * @retval None + */ +void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint16_t USART_IT) +{ + uint16_t bitpos = 0x00, itmask = 0x00; + /* Check the parameters */ + assert_param(IS_USART_ALL_PERIPH(USARTx)); + assert_param(IS_USART_CLEAR_IT(USART_IT)); + /* The CTS interrupt is not available for UART4 and UART5 */ + if (USART_IT == USART_IT_CTS) + { + assert_param(IS_USART_123_PERIPH(USARTx)); + } + + bitpos = USART_IT >> 0x08; + itmask = ((uint16_t)0x01 << (uint16_t)bitpos); + USARTx->SR = (uint16_t)~itmask; +} +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_wwdg.c b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_wwdg.c new file mode 100755 index 0000000..77a7ce5 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/STM32F10x_FWLib/src/stm32f10x_wwdg.c @@ -0,0 +1,224 @@ +/** + ****************************************************************************** + * @file stm32f10x_wwdg.c + * @author MCD Application Team + * @version V3.5.0 + * @date 11-March-2011 + * @brief This file provides all the WWDG firmware functions. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_wwdg.h" +#include "stm32f10x_rcc.h" + +/** @addtogroup STM32F10x_StdPeriph_Driver + * @{ + */ + +/** @defgroup WWDG + * @brief WWDG driver modules + * @{ + */ + +/** @defgroup WWDG_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @defgroup WWDG_Private_Defines + * @{ + */ + +/* ----------- WWDG registers bit address in the alias region ----------- */ +#define WWDG_OFFSET (WWDG_BASE - PERIPH_BASE) + +/* Alias word address of EWI bit */ +#define CFR_OFFSET (WWDG_OFFSET + 0x04) +#define EWI_BitNumber 0x09 +#define CFR_EWI_BB (PERIPH_BB_BASE + (CFR_OFFSET * 32) + (EWI_BitNumber * 4)) + +/* --------------------- WWDG registers bit mask ------------------------ */ + +/* CR register bit mask */ +#define CR_WDGA_Set ((uint32_t)0x00000080) + +/* CFR register bit mask */ +#define CFR_WDGTB_Mask ((uint32_t)0xFFFFFE7F) +#define CFR_W_Mask ((uint32_t)0xFFFFFF80) +#define BIT_Mask ((uint8_t)0x7F) + +/** + * @} + */ + +/** @defgroup WWDG_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @defgroup WWDG_Private_Variables + * @{ + */ + +/** + * @} + */ + +/** @defgroup WWDG_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @defgroup WWDG_Private_Functions + * @{ + */ + +/** + * @brief Deinitializes the WWDG peripheral registers to their default reset values. + * @param None + * @retval None + */ +void WWDG_DeInit(void) +{ + RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, ENABLE); + RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, DISABLE); +} + +/** + * @brief Sets the WWDG Prescaler. + * @param WWDG_Prescaler: specifies the WWDG Prescaler. + * This parameter can be one of the following values: + * @arg WWDG_Prescaler_1: WWDG counter clock = (PCLK1/4096)/1 + * @arg WWDG_Prescaler_2: WWDG counter clock = (PCLK1/4096)/2 + * @arg WWDG_Prescaler_4: WWDG counter clock = (PCLK1/4096)/4 + * @arg WWDG_Prescaler_8: WWDG counter clock = (PCLK1/4096)/8 + * @retval None + */ +void WWDG_SetPrescaler(uint32_t WWDG_Prescaler) +{ + uint32_t tmpreg = 0; + /* Check the parameters */ + assert_param(IS_WWDG_PRESCALER(WWDG_Prescaler)); + /* Clear WDGTB[1:0] bits */ + tmpreg = WWDG->CFR & CFR_WDGTB_Mask; + /* Set WDGTB[1:0] bits according to WWDG_Prescaler value */ + tmpreg |= WWDG_Prescaler; + /* Store the new value */ + WWDG->CFR = tmpreg; +} + +/** + * @brief Sets the WWDG window value. + * @param WindowValue: specifies the window value to be compared to the downcounter. + * This parameter value must be lower than 0x80. + * @retval None + */ +void WWDG_SetWindowValue(uint8_t WindowValue) +{ + __IO uint32_t tmpreg = 0; + + /* Check the parameters */ + assert_param(IS_WWDG_WINDOW_VALUE(WindowValue)); + /* Clear W[6:0] bits */ + + tmpreg = WWDG->CFR & CFR_W_Mask; + + /* Set W[6:0] bits according to WindowValue value */ + tmpreg |= WindowValue & (uint32_t) BIT_Mask; + + /* Store the new value */ + WWDG->CFR = tmpreg; +} + +/** + * @brief Enables the WWDG Early Wakeup interrupt(EWI). + * @param None + * @retval None + */ +void WWDG_EnableIT(void) +{ + *(__IO uint32_t *) CFR_EWI_BB = (uint32_t)ENABLE; +} + +/** + * @brief Sets the WWDG counter value. + * @param Counter: specifies the watchdog counter value. + * This parameter must be a number between 0x40 and 0x7F. + * @retval None + */ +void WWDG_SetCounter(uint8_t Counter) +{ + /* Check the parameters */ + assert_param(IS_WWDG_COUNTER(Counter)); + /* Write to T[6:0] bits to configure the counter value, no need to do + a read-modify-write; writing a 0 to WDGA bit does nothing */ + WWDG->CR = Counter & BIT_Mask; +} + +/** + * @brief Enables WWDG and load the counter value. + * @param Counter: specifies the watchdog counter value. + * This parameter must be a number between 0x40 and 0x7F. + * @retval None + */ +void WWDG_Enable(uint8_t Counter) +{ + /* Check the parameters */ + assert_param(IS_WWDG_COUNTER(Counter)); + WWDG->CR = CR_WDGA_Set | Counter; +} + +/** + * @brief Checks whether the Early Wakeup interrupt flag is set or not. + * @param None + * @retval The new state of the Early Wakeup interrupt flag (SET or RESET) + */ +FlagStatus WWDG_GetFlagStatus(void) +{ + return (FlagStatus)(WWDG->SR); +} + +/** + * @brief Clears Early Wakeup interrupt flag. + * @param None + * @retval None + */ +void WWDG_ClearFlag(void) +{ + WWDG->SR = (uint32_t)RESET; +} + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/SYSTEM/debug/debug_conf.c b/STM32_4路称重_Git提交精简工程/src/SYSTEM/debug/debug_conf.c new file mode 100755 index 0000000..8a901fd --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/SYSTEM/debug/debug_conf.c @@ -0,0 +1,36 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ debug_output.c + * ӡϢ + * V1.0 + * XuZhongPing + * 2017/04/26 +*********************************************************************************/ +#include "debug_conf.h" + +//´,֧printf,Ҫѡuse MicroLIB +#if 1 +#pragma import(__use_no_semihosting) +//׼Ҫֺ֧ +struct __FILE +{ + int handle; +}; + +FILE __stdout; +//_sys_exit()Աʹðģʽ +_sys_exit(int x) +{ + x = x; +} + +//ضfputc +int fputc(int ch, FILE *f) +{ + while(USART_GetFlagStatus(UART5,USART_FLAG_TC)==RESET){}; + USART_SendData(UART5, (uint8_t)ch); + return ch; +} + +#endif + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/SYSTEM/debug/debug_conf.h b/STM32_4路称重_Git提交精简工程/src/SYSTEM/debug/debug_conf.h new file mode 100755 index 0000000..398e756 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/SYSTEM/debug/debug_conf.h @@ -0,0 +1,16 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ debug_output.h + * ӡϢͷļ + * V1.0 + * XuZhongPing + * 2017/04/26 +*********************************************************************************/ +#ifndef __DEBUG_OUTPUT_H +#define __DEBUG_OUTPUT_H + +#include "stm32f10x.h" +#include "stdio.h" + +#endif + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/SYSTEM/delay/delay.c b/STM32_4路称重_Git提交精简工程/src/SYSTEM/delay/delay.c new file mode 100755 index 0000000..2582b2d --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/SYSTEM/delay/delay.c @@ -0,0 +1,54 @@ +#include "delay.h" + +static u8 fac_us=0;//usʱ +static u16 fac_ms=0;//msʱ + +//ʼӳٺ +//ʹucosʱ,˺ʼucosʱӽ +//SYSTICKʱӹ̶ΪHCLKʱӵ1/8 +//SYSCLK:ϵͳʱ +void delay_init() +{ + SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8); //ѡⲿʱ HCLK/8 + fac_us=SystemCoreClock/8000000; //Ϊϵͳʱӵ1/8 + + fac_ms=(u16)fac_us*1000;//ucos,ÿmsҪsystickʱ +} + +//ʱnus +//nusΪҪʱus. +void delay_us(u32 nus) +{ + u32 temp; + SysTick->LOAD=nus*fac_us; //ʱ + SysTick->VAL=0x00; //ռ + SysTick->CTRL|=SysTick_CTRL_ENABLE_Msk ; //ʼ + do + { + temp=SysTick->CTRL; + } + while(temp&0x01&&!(temp&(1<<16)));//ȴʱ䵽 + SysTick->CTRL&=~SysTick_CTRL_ENABLE_Msk; //رռ + SysTick->VAL =0X00; //ռ +} +//ʱnms +//עnmsķΧ +//SysTick->LOADΪ24λĴ,,ʱΪ: +//nms<=0xffffff*8*1000/SYSCLK +//SYSCLKλΪHz,nmsλΪms +//72M,nms<=1864 +void delay_ms(u16 nms) +{ + u32 temp; + SysTick->LOAD=(u32)nms*fac_ms;//ʱ(SysTick->LOADΪ24bit) + SysTick->VAL =0x00; //ռ + SysTick->CTRL|=SysTick_CTRL_ENABLE_Msk ; //ʼ + do + { + temp=SysTick->CTRL; + } + while(temp&0x01&&!(temp&(1<<16)));//ȴʱ䵽 + SysTick->CTRL&=~SysTick_CTRL_ENABLE_Msk; //رռ + SysTick->VAL =0X00; //ռ +} + diff --git a/STM32_4路称重_Git提交精简工程/src/SYSTEM/delay/delay.h b/STM32_4路称重_Git提交精简工程/src/SYSTEM/delay/delay.h new file mode 100755 index 0000000..0f8145d --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/SYSTEM/delay/delay.h @@ -0,0 +1,10 @@ +#ifndef __DELAY_H +#define __DELAY_H +#include "stm32f10x.h" + +void delay_init(void); +void delay_ms(u16 nms); +void delay_us(u32 nus); + +#endif + diff --git a/STM32_4路称重_Git提交精简工程/src/USER/data_typedef.c b/STM32_4路称重_Git提交精简工程/src/USER/data_typedef.c new file mode 100755 index 0000000..fdf955b --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/data_typedef.c @@ -0,0 +1,371 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ DataProcessing.c + * ݴ + * V1.0 + * XuZhongPing + * 2017/03/05 +*********************************************************************************/ +#include "my_math.h" +#include "delay.h" +#include "data_typedef.h" +#include "gsm_gprs.h" +#include "gps.h" +#include "message.h" +#include "tcp_protocol.h" +#include "device.h" + +char VersionStr[17]; + +uint8_t deviceInitFlag = 0; //豸Ӳӿڳʼɱ־ +uint8_t swKeysVal = 0; +uint8_t adcDevInitOK = 0; +uint8_t synchronousOpenDoorMark = 1; //ͬű־1Ϊͬʱţ0Ϊţ + +uint16_t delayRandomTime = 0; //Ͽʱʱ + +uint8_t water; //ˮλ + +uint8_t optoSwitchStatus = 0; //翪״̬ +uint8_t switchKey1Status = 0; //ӽ״̬ +uint8_t switchKey2Status = 0; //ӽ״̬ +uint8_t dropOffPortMark1 = 0; +uint8_t dropOffPortMark2 = 0; + +uint8_t getRecycleClearDoorMark = 0; //Ӳȡ״̬ +uint8_t recycleClearDoorMark = 0; //״̬ + +uint8_t smokeAlarmStatus = 0; //״̬ + +uint8_t dropPortClosedStatus1 = 0; //Ͷſڹر״̬ +uint8_t dropPortClosedStatus2 = 0; + +uint8_t gpsConnectSta = 0; //GPSģӲ״̬ +uint8_t gpsStatus = 0; //GPSλ״̬ +uint8_t gpsEW = 0; //ȷ0->E-,W- +uint32_t gpsLon = 0; //ȣѷŴ1000000 +uint8_t gpsNS = 0; //γȷ0->N-,1->S-ϣ +uint32_t gpsLat = 0; //γȣѷŴ1000000 +uint8_t getGpsStatus = 0; //ȡGPSϢ + +uint8_t distance = 255; //· +uint8_t getDistance1 = 255; //ֵ +uint8_t getDistance2 = 255; +uint8_t getDistance3 = 255; +uint8_t getDistance4 = 255; +uint8_t updateDistanceMark = 0; + +uint8_t fullMarkLeft = 0; //Ͱװ־ +uint8_t fullMarkRight = 0; //Ͱװ־ + +uint8_t fullMark1 = 0; +uint8_t fullMark2 = 0; +uint8_t fullMark3 = 0; +uint8_t fullMark4 = 0; + +uint16_t getWeight1 = 0; //ȡõ +uint16_t getWeight2 = 0; +uint16_t getWeight3 = 0; +uint16_t getWeight4 = 0; + +uint16_t getWeightBefore1 = 0; //ȡõĵ1·Ͱǰ +uint16_t getWeightAfter1 = 0; //ȡõĵ1·Ͱź +uint16_t getWeightBefore2 = 0; +uint16_t getWeightAfter2 = 0; +uint16_t getWeightBefore3 = 0; +uint16_t getWeightAfter3 = 0; +uint16_t getWeightBefore4 = 0; +uint16_t getWeightAfter4 = 0; + +uint16_t weightChangeBefore_1 = 0; //仯ǰ +uint16_t weightChangeBefore_2 = 0; + +//쳣Ͷ +uint16_t exceptionWeight1 = 0; //⵽쳣Ͷ +uint16_t exceptionWeight2 = 0; +uint16_t exceptionWeight3 = 0; +uint16_t exceptionWeight4 = 0; + +uint16_t exceptionWeightBefore1 = 0; //ȡõĵ1·쳣Ͷǰ +uint16_t exceptionWeightAfter1 = 0; //ȡõĵ1·쳣Ͷ׺ +uint16_t exceptionWeightBefore2 = 0; +uint16_t exceptionWeightAfter2 = 0; +uint16_t exceptionWeightBefore3 = 0; +uint16_t exceptionWeightAfter3 = 0; +uint16_t exceptionWeightBefore4 = 0; +uint16_t exceptionWeightAfter4 = 0; + +uint16_t smallBottleCount = 0; //Сƿ +uint16_t bigBottleCount = 0; //ƿ +uint16_t cansCount = 0; // + +uint8_t getPutInType = 0; //յͶͣťICά롢룩 +uint8_t getDataLength = 0; //յϢ +uint8_t getDataBuf[256]; //յϢ + +uint8_t sendPutInType = 0; //ͶͣťICά롢룩 +uint8_t sendDataLength = 0; //Ϣij +uint8_t sendDataBuf[256]; //Ϣ + +uint8_t pcRequestOpenDoorMark = 0; //λͶſ +uint8_t openDoorNumber = 0; //򿪵Ͷڱ + +uint8_t rspPCDoorNumber = 0; //ӦλͶڱ +uint8_t rspPCWeightNumber = 0; //Ӧλ̱ +uint8_t rspPCDistanceNumber = 0; //Ӧλ +uint8_t rspPCTemperatureNumber = 0; //Ӧλ¶ȱ + +uint8_t pcRequestClooseDoorMark = 0; //λرͶſ + +//ûϢϴ +uint8_t collectorSendAuthType = 0; //ͶͣťICά롢룩 +uint8_t collectorSendDataLength = 0; //Ϣij +uint8_t collectorSendDataBuf[35]; //Ϣ + +uint8_t get_IC_ID[16]; //յIC +uint8_t send_IC_ID[16]; //Ҫ͵̨IC +uint8_t getCardNumberBit[32]; //ŷ17λʮ + + +//̨Ӧر +uint8_t userInfoQueryStatus = 0; //Ӻ̨ȡûϢ״̬ +uint8_t getUserInfoMark = 0; //ȡûϢ־ +uint8_t putInUploadSuccessMark = 0; //Ͷϴɹ־ +uint8_t getSetDistanceParamMark = 0; //ȡų́ +uint8_t getDeviceWorkStatusMark = 0; //ȡų́õ豸״̬־ + +uint8_t deviceStatus = 0; //豸״̬ + +uint8_t isAuth; //Ƿ֤ͨ +uint32_t userID; //ûID +uint32_t accountNum; //û˺ +uint8_t nickNameLength; //dzݳ +uint8_t nickName[64]; //dz +uint32_t capital = 0; //ʽ +uint32_t capitalAfter = 0; //ʽͶź +uint8_t residue; // +uint8_t businessNum[8]; //ˮ +uint16_t receiveBusinessNum; //̨صĽˮ +uint8_t isOutput; //ǷԳ + +uint8_t barcodeLength = 0; //άݳ +uint8_t barcode[32]; //ά + +// +uint8_t getBoxOpenAckMark = 0; //ȡų́ش״̬־ +uint8_t boxOpenAckStatus = 0; //̨ӦŴ򿪱־ + +//ͶŹõı +uint8_t putInProgress = 0; //ͶŽб־ +uint8_t isOpenDoor = 0; +uint8_t keyOpenDoorRequest = 0; // + +uint8_t isOpenDoorRequest_1 = 0; //ű־ +uint8_t isOpenDoorRequest_2 = 0; +uint8_t isOpenDoorRequest_3 = 0; +uint8_t isOpenDoorRequest_4 = 0; +uint8_t isOpenDoor_1 = 0; //ű־ +uint8_t isOpenDoor_2 = 0; +uint8_t isOpenDoor_3 = 0; +uint8_t isOpenDoor_4 = 0; + +uint8_t isCloseDoorMark_1 = 0; //ű־ +uint8_t isCloseDoorMark_2 = 0; +uint8_t isCloseDoorMark_3 = 0; +uint8_t isCloseDoorMark_4 = 0; + +uint8_t openDoorCtrlEndMark_1 = 0; //ſƽ־ +uint8_t openDoorCtrlEndMark_2 = 0; +uint8_t openDoorCtrlEndMark_3 = 0; +uint8_t openDoorCtrlEndMark_4 = 0; + +uint8_t putInEndMark = 0; //豸תƽ־ + +uint8_t delayCloseDoorStatus = 0; //յӳٹ +uint8_t delayCloseDoorStatus2 = 0; //յӳٹ + +uint8_t disablePutInMark = 0; //ֹͶɱ־ +uint8_t putInOKMark = 0; //Ͷɱ־ + +uint8_t getRemainingTimerStatus = 0; //ȡõʱʱ״̬ +uint8_t remainingTimer = 0; //ʣʱ + +uint8_t faceEntryFlag = 0; //¼־ + +uint8_t devChannel1FaultMark = 0; //ϱ־ +uint8_t devChannel2FaultMark = 0; //ϱ־ +uint8_t devChannel3FaultMark = 0; //ϱ־ +uint8_t devChannel4FaultMark = 0; //ϱ־ +uint8_t deviceFault = 0; //豸 +uint8_t faultLedFlashMark = 0; //ʱ˸־ +uint8_t faultCode_1 = 0; // +uint8_t faultCode_2 = 0; +uint8_t faultCode_3 = 0; +uint8_t faultCode_4 = 0; +uint8_t limitKeyExceptionMark = 0; //λ쳣־ +uint8_t displayFaultCode = 0; //ʾĹ + +uint8_t exitMark = 0; //˳־ + +uint8_t boxOpenRecordMark = 0; //ſż¼־־ǷѾʱά뿪ţ +uint8_t boxOpenMark = 0; //ȡʱά뿪ű־ +uint8_t boxOpenQRMark = 0; //ȡʱά뿪ű־ + +//豸ز +//ǰʹõIJ +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +uint8_t deviceType = FOUR_CLASSIFICATION; //豸ͣĬķࣩ +uint8_t devChannelNumbers = 4; //Ͷſͨ +uint8_t leftBarrelType = GLASS; //豸Ͱ +uint8_t rightBarrelType = METAL; //豸Ͱ + +uint8_t devChannel1Type = GLASS; //豸ͨ +uint8_t devChannel2Type = METAL; +uint8_t devChannel3Type = PLASTIC; +uint8_t devChannel4Type = PAPER; + +uint32_t password = 123321; //豸 +uint32_t customerID = 000000; //ͻţڿ˭Դţ + +uint8_t distance_L_DepthVal; //ͰͰȣͰĸ߶ȣ +uint8_t distance_L_MaxVal; //Ͱֵװߵֵ +uint8_t distance_L_AlarmPercent; //Ͱװٷֱ + +uint8_t distance_R_MaxVal; //Ͱֵװߵֵ +uint8_t distance_R_DepthVal; //ͰͰȣͰĸ߶ȣ +uint8_t distance_R_AlarmPercent; //Ͱװٷֱ + +//豸ͨ +uint8_t distanceParamAtStart = 0; //ʼ +uint8_t PerCentSetVal = 30; //ʼİٷֱֵ + +uint8_t devChannel1DisDepthVal = 100; //òͰȣͰĸ߶ȣ +uint8_t devChannel1DisMaxVal = 155; //òֵװߵֵ +uint8_t devChannel1DisAlarmPercent = 90; //òװٷֱ + +uint8_t devChannel2DisDepthVal = 100; +uint8_t devChannel2DisMaxVal = 155; +uint8_t devChannel2DisAlarmPercent = 90; + +uint8_t devChannel3DisDepthVal = 100; +uint8_t devChannel3DisMaxVal = 160; +uint8_t devChannel3DisAlarmPercent = 90; + +uint8_t devChannel4DisDepthVal = 100; +uint8_t devChannel4DisMaxVal = 160; +uint8_t devChannel4DisAlarmPercent = 90; + +uint8_t disableICCardFunStatus = 0; ///ͣáõICܿšܱ־λ1ͣùܣùܣĬù +uint8_t enableCleanQRCodeStatus = 0; ///ͣá˶ά뿪šܱ־λ1ùܣͣùܣĬͣù + +uint8_t deviceIdLength = 0; //豸ų +uint8_t deviceIdBuf[33] = {0}; //豸 + +uint8_t ipAddr0 = 255, ipAddr1 = 255, ipAddr2 = 255, ipAddr3 = 255; +uint16_t ipPort = 8080; + +//ȡõĴ޸ĺ󱣴IJflashȡͨάȡõĴʹõIJ +uint8_t setDeviceType = 0; //õ豸 +uint8_t setDevChannelNumbers = 0; //ʱȡõͶſͨ +uint8_t setDevChannel1Type = 0; //豸ͨ +uint8_t setDevChannel2Type = 0; +uint8_t setDevChannel3Type = 0; +uint8_t setDevChannel4Type = 0; + +uint32_t setPassword = 0; //Ҫõ豸 +uint32_t setCustomerID = 0; //ͻţڿ˭Դţ + +uint8_t setDevChannel1DisDepthVal = 0; //ͰȾ루Ͱĸ߶ȣ +uint8_t setDevChannel1DisMaxVal = 0; //ôװ߶Ⱦֵװߵֵ +uint8_t setDevChannel1DisAlarmPercent = 0;//뱨ٷֱ + +uint8_t setDevChannel2DisDepthVal = 0; +uint8_t setDevChannel2DisMaxVal = 0; +uint8_t setDevChannel2DisAlarmPercent = 0; + +uint8_t setDevChannel3DisDepthVal = 0; +uint8_t setDevChannel3DisMaxVal = 0; +uint8_t setDevChannel3DisAlarmPercent = 0; + +uint8_t setDevChannel4DisDepthVal = 0; +uint8_t setDevChannel4DisMaxVal = 0; +uint8_t setDevChannel4DisAlarmPercent = 0; + +uint8_t setDisableICCardFunStatus = 0; ///ͣáõICܿšܱ־λ1ͣùܣùܣ +uint8_t setEnableCleanQRCodeStatus = 0; ///ͣá˶ά뿪šܱ־λ1ùܣͣùܣ + +uint8_t setDeviceIdLength = 0; //õ豸ų +uint8_t setDeviceIdBuf[33]; //õ豸 + +uint8_t setIpAddr0 = 0, setIpAddr1 = 0, setIpAddr2 = 0, setIpAddr3 = 0; +uint16_t setIpPort = 0; + +//ûȡõIJ +uint8_t getDeviceType = 0; //ȡõ豸 +uint8_t getDevChannelNumbers = 0; //ʱȡõͶſͨ +uint8_t getDevChannel1Type = 0; //ȡõ豸ͨ +uint8_t getDevChannel2Type = 0; +uint8_t getDevChannel3Type = 0; +uint8_t getDevChannel4Type = 0; + +uint32_t getConfirmPassword = 0; //ȡȷ +uint32_t getPassword = 0; //ȡõ豸 +uint32_t getCustomerID = 0; //ȡõĿͻ + +uint8_t getDevChannel1DisDepthVal = 0; //ͰȾ루Ͱĸ߶ȣ +uint8_t getDevChannel1DisMaxVal = 0; //ôװ߶Ⱦֵװߵֵ +uint8_t getDevChannel1DisAlarmPercent = 0;//뱨ٷֱ + +uint8_t getDevChannel2DisDepthVal = 0; +uint8_t getDevChannel2DisMaxVal = 0; +uint8_t getDevChannel2DisAlarmPercent = 0; + +uint8_t getDevChannel3DisDepthVal = 0; +uint8_t getDevChannel3DisMaxVal = 0; +uint8_t getDevChannel3DisAlarmPercent = 0; + +uint8_t getDevChannel4DisDepthVal = 0; +uint8_t getDevChannel4DisMaxVal = 0; +uint8_t getDevChannel4DisAlarmPercent = 0; + +uint8_t getDisableICCardFunStatus = 0; //ȡ/ͣáõICܿšܱ־λ1ͣùܣùܣ +uint8_t getEnableCleanQRCodeStatus = 0; //ȡ/ͣá˶ά뿪šܱ־λ1ùܣͣùܣ + +uint8_t getDeviceIdLength = 0; //ȡõ豸ų +uint8_t getDeviceIdBuf[33]; //ȡõ豸 + +uint8_t getIpAddr0 = 0, getIpAddr1 = 0, getIpAddr2 = 0, getIpAddr3 = 0; +uint16_t getIpPort = 0; + +uint8_t getScaleNum = 0; //ȡУ׼̵ı + +//ȡز־ +uint8_t setParamSaveMark = 0; //òҪб־ +uint8_t setParamChangeMark = 0; //òб仯־ + +uint8_t getConfirmPasswordMark = 0; //ȡôȷ־ +uint8_t getPasswordMark = 0; //ȡҪõ־ +uint8_t getForceChangeMark = 0; //ȡǿ޸־ +uint8_t getDeviceTypeMark = 0; //ȡ豸ͱ־ +uint8_t getCustomerIDMark = 0; //ȡÿͻű־ + +uint8_t getDisableICCardFunMark = 0; //ȡ/ͣáõICܿšñ־ +uint8_t getEnableCleanQRCodeMark = 0; //ȡ/ͣá˶ά뿪šñ־ + +uint8_t getOverflowSetMark = 0; //ȡ־ + +uint8_t getScaleCalibrationMark = 0; //ȡóУ׼־ +uint8_t getBoxOpenMark = 0; //ȡʱά뿪ű־ + +uint8_t getDeviceParamResetMark = 0; //ȡûָ +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +uint8_t deviceWorkStatus = 1; //豸״̬ͣã +uint8_t deviceWorkStatusPre = 1; //豸״̬лǰ״̬ +uint8_t getDeviceWorkStatusVal = 0; //ȡų́õĹ״ֵ̬ + +uint8_t getMcu2SensorDataMark = 0; //ȡMCU2͵Ĵݱ־ + +uint16_t netStatus = 0; //״̬ +uint16_t devRunnigStatus = 0; //豸״̬ + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/data_typedef.h b/STM32_4路称重_Git提交精简工程/src/USER/data_typedef.h new file mode 100755 index 0000000..e5c56e2 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/data_typedef.h @@ -0,0 +1,412 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ data_typedef.h + * ݶ + * V1.0 + * XuZhongPing + * 2017/02/05 +*********************************************************************************/ +#ifndef __DATA_DEF_H +#define __DATA_DEF_H +#include "stdio.h" +#include "stdint.h" +#include "message.h" +#include "date_time.h" + +// 豸 +typedef enum +{ +// SINGLE_BARREL_660L = 1, +// DOUBLE_BARREL_480L = 2, +// DOUBLE_BARREL_BOTTLE_480L = 3, +// SINGLE_BARREL_480L = 4, + + SINGLE_CLASSIFICATION = 1, + DOUBLE_CLASSIFICATION = 2, + DOUBLE_CLASSIFICATION_BOTTLE = 3, + THREE_CLASSIFICATION = 4, + FOUR_CLASSIFICATION = 5, + +}deviceDefine; + +// ɻ +typedef enum +{ + PAPER = 1, //ֽ + PLASTIC = 3, // + GLASS = 4, // + METAL = 5, // + RECYCLED = 7, //ɻ + KITCHEN = 8, // + KITCHEN_1 = 81, //1 + KITCHEN_2 = 82, //2 + BIG_BOTTLE = 9, //ƿ + SMALL_BOTTLE = 10, //Сƿ + CANS = 11, // + BATTERY = 13, // + FABRIC = 14, //֯ + BOOK = 15, //鱾 + NEWSPAPER = 16, //ֽ + PLASTIC_2 = 17, //2 + OTHER = 18, // + HARMFUL = 30, //к + DRY_WASTES = 63, // + WET_WASTES = 64, //ʪ + PERISHABLE = 68, //׸ + +}trashType; + +extern char VersionStr[17]; + +extern uint8_t deviceInitFlag; //豸Ӳӿڳʼɱ־ +extern uint8_t swKeysVal; +extern uint8_t adcDevInitOK; +extern uint8_t synchronousOpenDoorMark; //ͬű־ + +extern uint16_t delayRandomTime; //Ͽʱʱ + +extern uint8_t water; //ˮλ + +extern uint8_t optoSwitchStatus; //翪״̬ +extern uint8_t switchKey1Status; //ӽ״̬ +extern uint8_t switchKey2Status; //ӽ״̬ +extern uint8_t dropOffPortMark1; +extern uint8_t dropOffPortMark2; + +extern uint8_t getRecycleClearDoorMark; //Ӳȡ״̬ +extern uint8_t recycleClearDoorMark; //״̬ + +extern uint8_t smokeAlarmStatus; //״̬ + +extern uint8_t dropPortClosedStatus1; //Ͷſڹر״̬ +extern uint8_t dropPortClosedStatus2; + +extern uint8_t gpsConnectSta; //GPSģӲ״̬ +extern uint8_t gpsStatus; //GPSλ״̬ +extern uint8_t gpsEW; //ȷ0->E-,W- +extern uint32_t gpsLon; //ȣѷŴ1000000 +extern uint8_t gpsNS; //γȷ0->N-,1->S-ϣ +extern uint32_t gpsLat; //γȣѷŴ1000000 +extern uint8_t getGpsStatus; //ȡGPSϢ + +extern uint8_t distance; // +extern uint8_t getDistance1; //ȡõĵ1· +extern uint8_t getDistance2; +extern uint8_t getDistance3; +extern uint8_t getDistance4; +extern uint8_t updateDistanceMark; + +extern uint8_t fullMarkLeft; //Ͱװ־ +extern uint8_t fullMarkRight; //Ͱװ־ + +extern uint8_t fullMark1; +extern uint8_t fullMark2; +extern uint8_t fullMark3; +extern uint8_t fullMark4; + +extern uint16_t weight; // +extern uint16_t getWeight1; //ȡõĵ1· +extern uint16_t getWeight2; +extern uint16_t getWeight3; +extern uint16_t getWeight4; + +extern uint16_t getWeightBefore1; //ȡõĵ1·Ͱǰ +extern uint16_t getWeightAfter1; +extern uint16_t getWeightBefore2; +extern uint16_t getWeightAfter2; +extern uint16_t getWeightBefore3; +extern uint16_t getWeightAfter3; +extern uint16_t getWeightBefore4; +extern uint16_t getWeightAfter4; + +extern uint16_t weightChangeBefore_1; //仯ǰ +extern uint16_t weightChangeBefore_2; + +//쳣Ͷ +extern uint16_t exceptionWeight1; //⵽쳣Ͷ +extern uint16_t exceptionWeight2; +extern uint16_t exceptionWeight3; +extern uint16_t exceptionWeight4; + +extern uint16_t exceptionWeightBefore1; //ȡõĵ1·쳣Ͷǰ +extern uint16_t exceptionWeightAfter1; //ȡõĵ1·쳣Ͷ׺ +extern uint16_t exceptionWeightBefore2; +extern uint16_t exceptionWeightAfter2; +extern uint16_t exceptionWeightBefore3; +extern uint16_t exceptionWeightAfter3; +extern uint16_t exceptionWeightBefore4; +extern uint16_t exceptionWeightAfter4; + +extern uint16_t smallBottleCount; //Сƿ +extern uint16_t bigBottleCount; //ƿ +extern uint16_t cansCount; // + +extern uint8_t getPutInType; //ȡõͶͣťICά롢룩 +extern uint8_t getDataLength; //ȡõϢ +extern uint8_t getDataBuf[256]; //ȡõϢ + +extern uint8_t sendPutInType; //ͶͣťICά롢룩 +extern uint8_t sendDataLength; //Ϣij +extern uint8_t sendDataBuf[256]; //Ϣ + +extern uint8_t pcRequestOpenDoorMark; //λͶſ +extern uint8_t openDoorNumber; //򿪵Ͷڱ + +extern uint8_t rspPCDoorNumber; //ӦλͶڱ +extern uint8_t rspPCWeightNumber; //Ӧλ̱ +extern uint8_t rspPCDistanceNumber; //Ӧλ +extern uint8_t rspPCTemperatureNumber; //Ӧλ¶ȱ + +extern uint8_t pcRequestClooseDoorMark; //λرͶſ + +//ûϢϴ +extern uint8_t collectorSendAuthType; //ͶͣťICά롢룩 +extern uint8_t collectorSendDataLength; //Ϣij +extern uint8_t collectorSendDataBuf[35]; //Ϣ + +extern uint8_t get_IC_ID[16]; //յIC +extern uint8_t send_IC_ID[16]; //Ҫ͵̨IC +extern uint8_t getCardNumberBit[32]; //ŷ17λʮ + + +//̨Ӧر +extern uint8_t userInfoQueryStatus; //Ӻ̨ȡûϢ״̬ +extern uint8_t getUserInfoMark; //ȡûϢ־ +extern uint8_t putInUploadSuccessMark; //Ͷϴɹ־ +extern uint8_t getSetDistanceParamMark; //ȡų́ +extern uint8_t getDeviceWorkStatusMark; //ȡų́õ豸״̬־ + +extern uint8_t deviceStatus; //豸״̬ +extern uint8_t isAuth; //Ƿ֤ͨ +extern uint8_t rewardDisplayType; //ʾʽ֣ +extern uint32_t userID; //ûID +extern uint32_t accountNum; //û˺ +extern uint8_t nickNameLength; //dzݳ +extern uint8_t nickName[64]; //dz +extern uint32_t capital; //ʽ +extern uint32_t capitalAfter; //ʽͶź +extern uint8_t residue; // +extern uint8_t businessNum[8]; //ˮ +extern uint16_t receiveBusinessNum; //̨صĽˮ +extern uint8_t isOutput; //ǷԳ +extern uint8_t barcodeLength; //άݳ +extern uint8_t barcode[32]; //ά + +// +extern uint8_t getBoxOpenAckMark; //ȡų́ش״̬־ +extern uint8_t boxOpenAckStatus; //̨ӦŴ򿪱־ + +//ͶŹõı +extern uint8_t putInProgress; //ͶŽб־ +extern uint8_t isOpenDoor; +extern uint8_t keyOpenDoorRequest; + +extern uint8_t isOpenDoorRequest_1; //յű־ +extern uint8_t isOpenDoorRequest_2; +extern uint8_t isOpenDoorRequest_3; +extern uint8_t isOpenDoorRequest_4; +extern uint8_t isOpenDoor_1; //յű־ +extern uint8_t isOpenDoor_2; +extern uint8_t isOpenDoor_3; +extern uint8_t isOpenDoor_4; + +extern uint8_t isCloseDoorMark_1; //ű־ +extern uint8_t isCloseDoorMark_2; +extern uint8_t isCloseDoorMark_3; +extern uint8_t isCloseDoorMark_4; + +extern uint8_t openDoorCtrlEndMark_1; //ſƽ־ +extern uint8_t openDoorCtrlEndMark_2; +extern uint8_t openDoorCtrlEndMark_3; +extern uint8_t openDoorCtrlEndMark_4; + + +extern uint8_t putInEndMark; //豸תƽ־ + +extern uint8_t delayCloseDoorStatus; //յӳٹ +extern uint8_t delayCloseDoorStatus2; //յӳٹ + +extern uint8_t disablePutInMark; //ֹͶɱ־ +extern uint8_t putInOKMark; //Ͷɱ־ + +extern uint8_t getRemainingTimerStatus; //ȡõʱʱ״̬ +extern uint8_t remainingTimer; //ʣʱ + +extern uint8_t faceEntryFlag; //¼־ + +extern uint8_t devChannel1FaultMark; //ϱ־ +extern uint8_t devChannel2FaultMark; //ϱ־ +extern uint8_t devChannel3FaultMark; //ϱ־ +extern uint8_t devChannel4FaultMark; //ϱ־ +extern uint8_t deviceFault; //豸 +extern uint8_t faultLedFlashMark; //ʱ˸־ +extern uint8_t faultCode_1; // +extern uint8_t faultCode_2; +extern uint8_t faultCode_3; +extern uint8_t faultCode_4; +extern uint8_t limitKeyExceptionMark; //λ쳣־ +extern uint8_t displayFaultCode; //ʾĹ + +extern uint8_t boxOpenRecordMark; //ſż¼־־ǷѾʱά뿪ţ +extern uint8_t boxOpenMark; //ȡʱά뿪ű־ +extern uint8_t boxOpenQRMark; //ȡʱά뿪ű־ + +extern uint8_t exitMark; //˳־ + +//豸ز +//ǰʹõIJ +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +extern uint8_t deviceType; //豸 +extern uint8_t devChannelNumbers; //豸ͶſͨͲʼֵ +extern uint8_t leftBarrelType; //豸Ͱ +extern uint8_t rightBarrelType; //豸Ͱ + +extern uint8_t devChannel1Type; //豸ͨ +extern uint8_t devChannel2Type; +extern uint8_t devChannel3Type; +extern uint8_t devChannel4Type; + +extern uint32_t password; //豸 +extern uint32_t customerID; //ͻţڿ˭Դţ + +extern uint8_t distance_L_DepthVal; //ͰͰȣͰĸ߶ȣ +extern uint8_t distance_L_MaxVal; //Ͱֵװߵֵ +extern uint8_t distance_L_AlarmPercent; //Ͱװٷֱ + +extern uint8_t distance_R_MaxVal; //Ͱֵװߵֵ +extern uint8_t distance_R_DepthVal; //ͰͰȣͰĸ߶ȣ +extern uint8_t distance_R_AlarmPercent; //Ͱװٷֱ + + +extern uint8_t distanceParamAtStart; //ʼ +extern uint8_t PerCentSetVal; //ʼİٷֱֵ + +extern uint8_t devChannel1DisDepthVal; //豸ͨ +extern uint8_t devChannel1DisMaxVal; +extern uint8_t devChannel1DisAlarmPercent; + +extern uint8_t devChannel2DisDepthVal; //豸ͨ +extern uint8_t devChannel2DisMaxVal; +extern uint8_t devChannel2DisAlarmPercent; + +extern uint8_t devChannel3DisDepthVal; //豸ͨ +extern uint8_t devChannel3DisMaxVal; +extern uint8_t devChannel3DisAlarmPercent; + +extern uint8_t devChannel4DisDepthVal; //豸ͨ +extern uint8_t devChannel4DisMaxVal; +extern uint8_t devChannel4DisAlarmPercent; + +extern uint8_t disableICCardFunStatus; ///ͣáõICܿš״̬1ͣùܣùܣ +extern uint8_t enableCleanQRCodeStatus; ///ͣá˶ά뿪š״̬1ùܣͣùܣ + +extern uint8_t deviceIdLength; //豸ų +extern uint8_t deviceIdBuf[33]; //豸 + +extern uint8_t ipAddr0, ipAddr1, ipAddr2, ipAddr3; //IPַ +extern uint16_t ipPort; + +//ȡõĴ޸ĺ󱣴IJflashȡͨάȡõĴʹõIJ +extern uint8_t setDeviceType; //õ豸 +extern uint8_t setDevChannelNumbers; //ʱȡõͶſͨ +extern uint8_t setDevChannel1Type; //豸ͨ +extern uint8_t setDevChannel2Type; +extern uint8_t setDevChannel3Type; +extern uint8_t setDevChannel4Type; + +extern uint32_t setPassword; //Ҫõ豸 +extern uint32_t setCustomerID; //ͻţڿ˭Դţ + +extern uint8_t setDevChannel1DisDepthVal; //ͰȾ루Ͱĸ߶ȣ +extern uint8_t setDevChannel1DisMaxVal; //ôװ߶Ⱦֵװߵֵ +extern uint8_t setDevChannel1DisAlarmPercent;//뱨ٷֱ + +extern uint8_t setDevChannel2DisDepthVal; +extern uint8_t setDevChannel2DisMaxVal; +extern uint8_t setDevChannel2DisAlarmPercent; + +extern uint8_t setDevChannel3DisDepthVal; +extern uint8_t setDevChannel3DisMaxVal; +extern uint8_t setDevChannel3DisAlarmPercent; + +extern uint8_t setDevChannel4DisDepthVal; +extern uint8_t setDevChannel4DisMaxVal; +extern uint8_t setDevChannel4DisAlarmPercent; + +extern uint8_t setDisableICCardFunStatus; ///ͣáõICܿš״̬1ͣùܣùܣ +extern uint8_t setEnableCleanQRCodeStatus; ///ͣá˶ά뿪š״̬1ùܣͣùܣ + +extern uint8_t setDeviceIdLength; //ȡõ豸ų +extern uint8_t setDeviceIdBuf[33]; //ȡõ豸 + +extern uint8_t setIpAddr0, setIpAddr1, setIpAddr2, setIpAddr3; +extern uint16_t setIpPort; + +//ûȡõIJ +extern uint8_t getDeviceType; //ȡõ豸 +extern uint8_t getDevChannelNumbers; //ʱȡõͶſͨ +extern uint8_t getDevChannel1Type; //ȡõ豸ͨ +extern uint8_t getDevChannel2Type; +extern uint8_t getDevChannel3Type; +extern uint8_t getDevChannel4Type; + +extern uint32_t getConfirmPassword; //ȡȷ +extern uint32_t getPassword; //ȡõ豸 +extern uint32_t getCustomerID; //ȡõĿͻ + +extern uint8_t getDevChannel1DisDepthVal; //ͰȾ루Ͱĸ߶ȣ +extern uint8_t getDevChannel1DisMaxVal; //ôװ߶Ⱦֵװߵֵ +extern uint8_t getDevChannel1DisAlarmPercent;//뱨ٷֱ + +extern uint8_t getDevChannel2DisDepthVal; +extern uint8_t getDevChannel2DisMaxVal; +extern uint8_t getDevChannel2DisAlarmPercent; + +extern uint8_t getDevChannel3DisDepthVal; +extern uint8_t getDevChannel3DisMaxVal; +extern uint8_t getDevChannel3DisAlarmPercent; + +extern uint8_t getDevChannel4DisDepthVal; +extern uint8_t getDevChannel4DisMaxVal; +extern uint8_t getDevChannel4DisAlarmPercent; + +extern uint8_t getDisableICCardFunStatus; //ȡ/ͣáõICܿš״̬1ͣùܣùܣ +extern uint8_t getEnableCleanQRCodeStatus;//ȡ/ͣá˶ά뿪š״̬1ùܣͣùܣ + +extern uint8_t getDeviceIdLength; //ȡõ豸ų +extern uint8_t getDeviceIdBuf[33]; //ȡõ豸 + +extern uint8_t getIpAddr0, getIpAddr1, getIpAddr2, getIpAddr3; +extern uint16_t getIpPort; + +extern uint8_t getScaleNum; //ȡУ׼̵ı + +//ȡز־ +extern uint8_t setParamSaveMark; //òҪб־ +extern uint8_t setParamChangeMark; //òб仯־ + +extern uint8_t getConfirmPasswordMark; //ȡôȷ־ +extern uint8_t getPasswordMark; //ȡҪõ־ +extern uint8_t getForceChangeMark; //ȡǿ޸־ +extern uint8_t getDeviceTypeMark; //ȡ豸ͱ־ +extern uint8_t getCustomerIDMark; //ȡÿͻű־ + +extern uint8_t getDisableICCardFunMark; //ȡ/ͣáõICܿšܱ־ +extern uint8_t getEnableCleanQRCodeMark; //ȡ/ͣá˶ά뿪šñ־ + +extern uint8_t getOverflowSetMark; //ȡ־ + +extern uint8_t getScaleCalibrationMark; //ȡóУ׼־ +extern uint8_t getBoxOpenMark; //ȡʱά뿪ű־ +extern uint8_t getDeviceParamResetMark; //ȡûָ +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +extern uint8_t deviceWorkStatus; //豸״̬ͣã +extern uint8_t deviceWorkStatusPre; //豸״̬лǰ״̬ +extern uint8_t getDeviceWorkStatusVal; //ȡų́õĹ״ֵ̬ + +extern uint8_t getMcu2SensorDataMark; //ȡMCU2͵Ĵݱ־ + +extern uint16_t netStatus; //״̬ +extern uint16_t devRunnigStatus; //豸״̬ + +#endif diff --git a/STM32_4路称重_Git提交精简工程/src/USER/date_time.c b/STM32_4路称重_Git提交精简工程/src/USER/date_time.c new file mode 100755 index 0000000..635b1a1 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/date_time.c @@ -0,0 +1,102 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ date_time.c + * ʱʱس + * V1.0 + * XuZhongPing + * 2021/02/05 +*********************************************************************************/ +#include "date_time.h" +#include "timer.h" + +my_time_t GMT_Time; //ʱ +my_time_t beijing_Time; //ʱ + +uint8_t systemTime[20]; //ϵͳʱʽΪYYYY-MM-DD hh:mm:ss +uint8_t getDateTimeMark = 0; //ȡʱʱ־ + +time_t timestamp_s = 0; //(s)Ϊλʱ + +struct tm* nowTime; + +/* +*********************************************************************** +* : UTC_To_Beijing +* ˵: ʱתʱ +* Σtime:תǰGMTʱ +* ֵ: ޣӰȫֱbeijing_Time +*********************************************************************** +*/ +void GMT_To_Beijing(my_time_t* time) +{ + struct tm stm; + struct tm dataTime; + time_t bj_timestamp_s; + + //GMTʱתʱ + stm.tm_year = GMT_Time.year-1900; + stm.tm_mon = GMT_Time.month-1; + stm.tm_mday = GMT_Time.day; + stm.tm_hour = GMT_Time.hour; + stm.tm_min = GMT_Time.minute; + stm.tm_sec = GMT_Time.second; + + timestamp_s = mktime(&stm); + + //UTCʱתʱ(ʱUTCʱ8Сʱ28800) + bj_timestamp_s = timestamp_s + 28800; + nowTime = localtime(&bj_timestamp_s); + + //ַʽ + strftime((char*)systemTime, 20, "%Y-%m-%d %H:%M:%S", nowTime); + printf("\r\nʱ䣺%s\r\n", (char*)systemTime); +} + +/* +*********************************************************************** +* : TimerTask +* ˵: ʱ +* Σ +* ֵ: +*********************************************************************** +*/ +void TimerTask(void) +{ + char buffer[128]; + static timer Timer_1S; + struct tm dataTime; + time_t bj_timestamp_s; + + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&Timer_1S, CLOCK_SECOND*1); + } + + + if(timer_expired(&Timer_1S)) + { + timer_restart(&Timer_1S); + + if(getDateTimeMark == 0) + { + printf("\r\nδʱ!\r\n"); + } + + timestamp_s++; + + bj_timestamp_s = timestamp_s + 28800; + nowTime = localtime(&bj_timestamp_s); + + strftime((char*)systemTime, 20, "%Y-%m-%d %H:%M:%S", nowTime); +// strftime(buffer, sizeof(buffer), "Now time: %Y-%m-%d %H:%M:%S", nowTime); +// printf("\r\n%s\r\n", buffer); + +// printf("\r\ntimestamp:%d\r\n", timestamp_s); +// printf("\r\ntimestamp_ms_h:%04X\r\n", timestamp_ms_H32); +// printf("\r\ntimestamp_ms_l:%08X\r\n", timestamp_ms_L32); + } +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/date_time.h b/STM32_4路称重_Git提交精简工程/src/USER/date_time.h new file mode 100755 index 0000000..b771b75 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/date_time.h @@ -0,0 +1,42 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ date_time.h + * ʱͷļ + * V1.0 + * XuZhongPing + * 2021/02/05 +*********************************************************************************/ +#ifndef __DATE_TIME_h +#define __DATE_TIME_h + +#include "stdint.h" +#include "stdio.h" +#include "string.h" +#include "time.h" + +typedef struct +{ + uint16_t year; + uint8_t month; + uint8_t day; + uint8_t hour; + uint8_t minute; + uint8_t second; +}my_time_t; + +extern my_time_t GMT_Time; //ʱ +extern my_time_t beijing_Time; //ʱ + +extern uint8_t systemTime[20]; //ϵͳʱʽΪYYYY-MM-DD hh:mm:ss +extern uint8_t getDateTimeMark; //ȡʱʱ־ + +extern time_t timestamp_s; //(s)Ϊλʱ + +extern struct tm* nowTime; + +void GMT_To_Beijing(my_time_t* time); +void GetPutInTime(void); +void TimerTask(void); + +#endif +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ + diff --git a/STM32_4路称重_Git提交精简工程/src/USER/main.c b/STM32_4路称重_Git提交精简工程/src/USER/main.c new file mode 100755 index 0000000..1cc3056 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/main.c @@ -0,0 +1,259 @@ +/*************************** (C) COPYRIGHT 2017 YNHB **************************** + * ļ main.c + * + * V1.0 + * XuZhongPing + * 2017/03/05 +*********************************************************************************/ +#include "stm32f10x.h" +#include "wdg.h" +#include "delay.h" +#include "usart1.h" +#include "usart2.h" +#include "usart3.h" +#include "usart4.h" +#include "usart5.h" +#include "timer.h" + +#include "gsm_gprs.h" +#include "data_typedef.h" +#include "message.h" +#include "device.h" +#include "lcd.h" +#include "display.h" +#include "tcp_protocol.h" +#include "user_app.h" + +#include "bsp_WM8978.h" +#include "sound.h" +#include "spi.h" +#include "flash.h" + +#include "pc_protocol.h" +#include "IR_Distancer.h" +#include "deviceSet.h" + +#include "m_s_comm.h" +#include "netwer_appcall.h" + +void NVIC_Configuration(void); +void RegularUploadTask(void); + +int main(void) +{ + static timer waitingTimer_1s; + timer_set(&waitingTimer_1s, CLOCK_SECOND*120); + + delay_init(); //ʱʼ + NVIC_Configuration(); //NVICжϷ + + USART1_Init(9600); //ڳʼΪ115200RFID_ICάݶȡ + USART2_Init(38400); //MCUͨŽӿ + USART4_Init(9600); //ͨŴ + USART5_Init(115200); //Ϣ + + TIM2_Int_Init(1000, 7200-1); //10KhzļƵʣ1000Ϊ100ms ÿΪ0.1ms + TIM3_Int_Init(100, 7200-1); //10KhzļƵʣÿΪ0.1msʱ10msλغͰťɨ + TIM4_Int_Init(5000, 7200-1); //10KhzļƵʣÿΪ0.1ms5000Ϊ500ms + TIM5_Int_Init(100, 7200-1); //ͨöʱ5ڶάͷݽж + + printf("\r\n***************System Running***************\r\n"); + DeviceInit(); //Ӳ豸ʼ + DeviceTest(); //Ӳ + + printf("\r\nICģ -->\r\n"); + SetRFID_Param(); //ICģ + + Audio_Play(1); + + IWDG_Init(5, 625); //ŹʼƵΪ128,ֵΪ625,ʱΪ2s + PC_ProCommandSend(0x90); //λڿ + + while(1) + { + LED_Task(); //LEDָʾ + BeepTask(); // +// DataUploadPollingTask(); + GSM_GPRS_Task(); //GSM_GPRSͨѶ + DeviceScanning(); //豸ɨ⣨ɨˢICͶά룩 + UserIdentificationTask(); //ûʶ + PutInOpenDoorTask(); //ûͶ + OpenDoorRequestTask(); //񣨼ǷпŰ£ + DeviceControlTask(); //豸ת + OpenDoorControlTask(); //Ͷڿſ + GetTemperatureTask(); //ȡ¶ + DispalyTask(); //ʾ + PC_ProDecodeTask(); //λͨѶ + M_S_DataDecodeTask(); + Audio_PlayTask(); // + BoxOpenTask(); //ſ + CollectorLockCtrlTask(); // + RecycleClearDoorCheckTask(); //ż + +// DistanceDataUpdata(); + if(putInProgress == 0) //ͶŹввͿŰ + { + OverflowDetectionTask(); // + DeviceEnableTask(); //豸/ÿ + KeysSendTask(); //ת + } + + TimerTask(); //ʱ + RegularUploadTask(); //ʱϴ + ParamSetTask(); //豸ز + TimingSprayTask(); //ʱ + TimingUVTask(); //ʱ + FillLightTask(); //ƿ + CoolingFanCtrlTask(); //ɢȷȿ + SprayCtrlTask(); //ܿ +// SprayDisinfectingTask(); // +// DisinfectingTask(); //UV +// SystemExceptionTask(); //ϵͳ쳣 + IWDG_FeedTask(); //Źι + + if(timer_expired(&waitingTimer_1s)) + { + timer_restart(&waitingTimer_1s); + +// gpsStatus = 1; +// gpsLon = 114223476; +// gpsLat = 22687142; + } + + //յ·ʱʾ + if(TCP_recreceiveStatus == 1) + { + TCP_recreceiveStatus = 0; + printf("\r\nTCP <-- %d \r\n", recreceiveOrderCode); + } + + if(getMcu2SensorDataMark == 1) + { + getMcu2SensorDataMark = 0; + +// printf("\r\nSensor:" +// "\r\nW1 = %2.2f Kg, W2 = %2.2f Kg, W3 = %2.2f Kg, W4 = %2.2f Kg"\ +// "\r\nD1 = %3.1f cm, D2 = %3.1f cm, D3 = %3.1f cm, D4 = %3.1f cm"\ +// "\r\nT = %2.1f , SW = %d, T2 = %2.1f , SW1 = %d, SW2 = %d\r\n", +// (float)(weight1)/100, +// (float)(weight2)/100, +// (float)(weight3)/100, +// (float)(weight4)/100, +// (float)getDistance1, +// (float)getDistance2, +// (float)getDistance3, +// (float)getDistance4, +// (float)temperature, +// optoSwitchStatus, +// (float)temperature_A, +// switchKey1Status, +// switchKey2Status +// ); + } + + if(getGpsStatus == 1) + { + getGpsStatus = 0; + +// printf("GPS״̬%d\r\n", gpsConnectSta); +// printf("λ״̬%d\r\n", gpsStatus); +// printf("ȣ%.6f %d\r\n", (double)gpsLon/1000000, gpsEW); +// printf("γȣ%.6f %d\r\n", (double)gpsLat/1000000, gpsNS); + } + } +} + + +/* +*********************************************************************** +* : RegularUploadTask +* ˵: ʱϴ +* Σ +* ֵ: +*********************************************************************** +*/ +void RegularUploadTask(void) +{ + static timer sendDevStaTimer; //ϴ豸״̬Ϣ¶ȡźšࣩ + static timer heartbeatTimer; + static timer gpsSendTimer; + + static uint8_t initDataSendFalg = 0; //ijʼݷͱ־ + static uint8_t gpsInitDataSendFalg = 0; + + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&sendDevStaTimer, CLOCK_SECOND*30); //豸״̬ϴʱ + timer_set(&heartbeatTimer, CLOCK_SECOND*120); //ϴʱ + timer_set(&gpsSendTimer, CLOCK_SECOND*60); + } + + if(gsm_msg.Running == 1) + { + if(initDataSendFalg == 0) //״οͳʼ + { + initDataSendFalg = 1; + + PC_ProCommandSend(0x31); + } + } + + if(gpsInitDataSendFalg == 0) //״ζλϢ + { + if((gpsConnectSta == 1) && (gpsStatus == 1)) + { + gpsInitDataSendFalg = 1; + + printf("\r\n״GPSϢͣ\r\n"); + PC_ProCommandSend(0x67); + } + } + + //ϴ + if(timer_expired(&heartbeatTimer)) + { + timer_restart(&heartbeatTimer); + + if(gsm_msg.Running == 1) + { + PC_ProCommandSend(0x31); + } + } + + //豸״̬Ϣϴ + if(timer_expired(&sendDevStaTimer)) + { + timer_restart(&sendDevStaTimer); + + if(putInProgress == 0) + { + PC_ProCommandSend(0x62); //λ豸״̬Ϣ + } + } + + //豸GPSλϢϴ + if(timer_expired(&gpsSendTimer)) + { + timer_restart(&gpsSendTimer); + + PC_ProCommandSend(0x67); + } +} + +/* +*********************************************************************** +* : RegularUploadTask +* ˵: ʱϴ +* Σ +* ֵ: +*********************************************************************** +*/ +void NVIC_Configuration(void) +{ + NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //NVICжϷ2:2λռȼ2λӦȼ +} + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/message.c b/STM32_4路称重_Git提交精简工程/src/USER/message.c new file mode 100755 index 0000000..592a1ec --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/message.c @@ -0,0 +1,85 @@ +#include "message.h" + +MESSAGE_FIFO MsgFifos[MSG_FIFO_COUNT]; //һϢ +MESSAGE sendMsg; +MESSAGE pcCmdMsg; //λϢ + +/* +*********************************************************************** +* : MessageInit +* ˵: Ϣʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void MessageInit(void) +{ + memset(&MsgFifos, 0, sizeof(MsgFifos)); +} + +/* +*********************************************************************** +* : MessageSend +* ˵: Ϣ +* Σ +* MsgFifoIndexĿ +* eventҪ͵Ϣ +* ֵ: _ErrStatusɹ_OK,ɹ_ERROR +*********************************************************************** +*/ +_ErrStatus MessageSend(uint8_t MsgFifoIndex, MESSAGE msg) +{ + MESSAGE_FIFO *pMsgFifo = &MsgFifos[MsgFifoIndex]; + + if(pMsgFifo->Count >= MAX_FIFO_DEPTH) + { + return _ERROR; + } + pMsgFifo->Buf[(pMsgFifo->IndexHead + (pMsgFifo->Count++)) % MAX_FIFO_DEPTH] = msg; + return OK; +} + + +/* +*********************************************************************** +* : MessageGet +* ˵: ȡϢ +* ΣMsgFifoIndexĿ꣬Ӵģ +* ֵ: fifoΪ򷵻NULL򷵻ضӦϢָ +*********************************************************************** +*/ +MESSAGE *MessageGet(uint8_t MsgFifoIndex) +{ + MESSAGE *pMsg = NULL; + MESSAGE_FIFO* pMsgFifo = &MsgFifos[MsgFifoIndex]; + + if(pMsgFifo->Count) + { + pMsg = &(pMsgFifo->Buf[pMsgFifo->IndexHead]); + pMsgFifo->IndexHead = (pMsgFifo->IndexHead + 1) % MAX_FIFO_DEPTH; + pMsgFifo->Count--; + } + return pMsg; +} + +/* +*********************************************************************** +* : GetMessageStatus +* ˵: ȡϢʣռ +* ΣMsgFifoIndexĿ꣬Ӵģ +* ֵ: صǰлʣռ +*********************************************************************** +*/ +uint8_t GetMessageRemainingSpace(uint8_t MsgFifoIndex) +{ + MESSAGE_FIFO* pMsgFifo = &MsgFifos[MsgFifoIndex]; + + if(pMsgFifo->Count <= MAX_FIFO_DEPTH) + { + return MAX_FIFO_DEPTH - pMsgFifo->Count; + }else{ + return 0; + } +} + +/******************** (C) COPYRIGHT 2017 YNHB *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/message.h b/STM32_4路称重_Git提交精简工程/src/USER/message.h new file mode 100755 index 0000000..4d6fa7d --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/message.h @@ -0,0 +1,60 @@ +#ifndef _MESSAGE_H +#define _MESSAGE_H + +#include "stdio.h" +#include "stdint.h" +#include "string.h" + +#define MAX_FIFO_DEPTH 20 //Ϣ + +typedef enum +{ + FALSE = 0, + TRUE = !FALSE +}_bool; + +typedef enum { + _ERROR = 0, + OK = !_ERROR +}_ErrStatus; + +//Ϣṹ +typedef struct _ControlMessage +{ + uint16_t msgType; //Э + uint8_t msgData; //Ϣ + uint8_t msgQos; //ϢĴȼ + uint16_t msgLen; //Ϣָָݳ + uint8_t* msgDataPrt; //Ϣָ +} MESSAGE; + + +//ϢFIFOṹ +typedef struct _MESSAGE_FIFO +{ + uint8_t IndexHead; + uint8_t Count; + MESSAGE Buf[MAX_FIFO_DEPTH]; //Ϣ + +} MESSAGE_FIFO; + +//ϢͶ +typedef enum _MSG_FIFO_INDEX +{ + MSG_FIFO_PROTOCOL = 0, //̨ͨѶЭϢ + MSG_FIFO_RS485_PROTOCOL, //RS485ͨѶЭϢ + MSG_FIFO_PC_CMD, //λӿͨѶЭϢ + MSG_FIFO_COUNT //Ϣfifo洢 + +} MSG_FIFO_INDEX; + +extern MESSAGE sendMsg; +extern MESSAGE pcCmdMsg; //λӿϢ + +void MessageInit(void); +_ErrStatus MessageSend(uint8_t MsgFifoIndex, MESSAGE event); +MESSAGE *MessageGet(uint8_t MsgFifoIndex); +uint8_t GetMessageRemainingSpace(uint8_t MsgFifoIndex); + +#endif + diff --git a/STM32_4路称重_Git提交精简工程/src/USER/my_math.c b/STM32_4路称重_Git提交精简工程/src/USER/my_math.c new file mode 100755 index 0000000..32332f8 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/my_math.c @@ -0,0 +1,241 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ my_math.c + * 㴦 + * V1.0 + * XuZhongPing + * 2017/04/26 +*********************************************************************************/ +#include "my_math.h" +#include "string.h" + +/* +*********************************************************************** +* : Pow +* ˵: ƽ +* Σm -> +* n -> ָ +* ֵ: Ľ +*********************************************************************** +*/ +uint64_t Pow(uint8_t m, uint8_t n) +{ + uint64_t result = 1; + while(n--)result *= m; + return result; +} + +/* +*********************************************************************** +* : sort_8 +* ˵: +* Σ +* x[]:Ҫ +* n:ij +* ֵ: +*********************************************************************** +*/ +void sort_8(uint8_t x[], uint8_t n) +{ + uint8_t i,j,k,t; + for (i=0; i x[k]) k = j; + } + if(k != i) + { + t = x[i]; + x[i] = x[k]; + x[k] = t; + } + } +} + +/* +*********************************************************************** +* : sort_16 +* ˵: +* Σ +* x[]:Ҫ +* n:ij +* ֵ: +*********************************************************************** +*/ +void sort_16(uint16_t x[], uint8_t n) +{ + uint16_t i,j,k,t; + for (i=0; i x[k]) k = j; + } + if(k != i) + { + t = x[i]; + x[i] = x[k]; + x[k] = t; + } + } +} + +/* +*********************************************************************** +* : sort_16 +* ˵: +* Σ +* x[]:Ҫ +* n:ij +* ֵ: +*********************************************************************** +*/ +void sort_32(uint32_t x[], uint16_t n) +{ + uint16_t i,j,k; + uint32_t t; + for (i=0; i x[k]) k = j; + } + if(k != i) + { + t = x[i]; + x[i] = x[k]; + x[k] = t; + } + } +} + +/* +*********************************************************************** +* : uint average(uint *p,uchar n) +* ˵: ȥСֵƽ +* Σ +* x[]:Ҫ +* n:ij +* discardVal:ֵ +* ֵ: Ľ +*********************************************************************** +*/ +uint8_t average_8(uint8_t x[],uint8_t n, uint8_t discardVal) +{ + uint8_t i; + uint8_t aver = 0; + uint32_t sum = 0; + + for(i = discardVal; i < n-discardVal; i++) + { + sum = sum+x[i]; + } + aver = sum/(n - discardVal*2); + return aver; +} + +/* +*********************************************************************** +* : average_16 +* ˵: ȥСֵƽ +* Σ +* x[]:Ҫ +* n:ij +* discardVal:ֵ +* ֵ: Ľ +*********************************************************************** +*/ +uint16_t average_16(uint16_t x[], uint8_t n, uint8_t discardVal) +{ + uint8_t i; + uint16_t aver = 0; + uint32_t sum = 0; + for(i = discardVal; i < n-discardVal; i++) + { + sum = sum+x[i]; + } + aver = sum/(n - discardVal*2); + return aver; +} + +/* +*********************************************************************** +* : average_16 +* ˵: ȥСֵƽ +* Σ +* x[]:Ҫ +* n:ij +* discardVal:ֵ +* ֵ: Ľ +*********************************************************************** +*/ +uint32_t average_32(uint32_t x[], uint16_t n, uint16_t discardVal) +{ + uint16_t i; + double aver = 0; + float temp0; + uint32_t retData = 0; + uint32_t sum = 0; + uint8_t temp; + + for(i = discardVal; i < n-discardVal; i++) + { + sum = sum+x[i]; + } + aver = (double)sum/(n - discardVal*2); + + temp0 = (float)aver*10; +// printf(" %3.1f, ", aver); + temp = (uint32_t)temp0%10; + if(temp >= 5) + { + aver += 1; + } + +// printf(" %d\r\n", (uint16_t)aver); + retData = aver; + + return aver; +} + +/* +*********************************************************************** +* : DifferenceCompare +* ˵: Ƚϴ뱾ݵIJֵǷ趨ֵ +* ΣnewData:ֵ +* oleData:ֵ +* ֵ: 1趨ֵ0趨ֵ +*********************************************************************** +*/ +uint8_t DifferenceCompare(uint32_t newData, uint32_t oleData, uint16_t LimitValue) +{ + uint16_t difference = 0; + + if(newData > oleData) + { + difference = newData - oleData; + if(difference > LimitValue) //ֵ趨ƫֵʱ1 + { + return 1; + }else + { + return 0; + } + }else if(newData < oleData){ + difference = oleData - newData; + if(difference > LimitValue) //ֵ趨ƫֵʱ1 + { + return 1; + }else + { + return 0; + } + }else{ + return 0; + } +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/my_math.h b/STM32_4路称重_Git提交精简工程/src/USER/my_math.h new file mode 100755 index 0000000..faaba00 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/my_math.h @@ -0,0 +1,26 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ mathematics.h + * ˲ͷļ + * V1.0 + * XuZhongPing + * 2017/04/26 +*********************************************************************************/ +#ifndef __MATHEMATICS_h +#define __MATHEMATICS_h +#include "stdint.h" +#include "string.h" +#include "stdlib.h" +#include "stdio.h" + +uint64_t Pow(uint8_t m, uint8_t n); +void sort_8(uint8_t x[], uint8_t n); +void sort_16(uint16_t x[], uint8_t n); +void sort_32(uint32_t x[], uint16_t n); +uint8_t average_8(uint8_t x[],uint8_t n, uint8_t discardVal); +uint16_t average_16(uint16_t x[], uint8_t n, uint8_t discardVal); +uint32_t average_32(uint32_t x[], uint16_t n, uint16_t discardVal); +uint8_t DifferenceCompare(uint32_t newData, uint32_t oleData, uint16_t LimitValue); + +#endif +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ + diff --git a/STM32_4路称重_Git提交精简工程/src/USER/over_flow.c b/STM32_4路称重_Git提交精简工程/src/USER/over_flow.c new file mode 100755 index 0000000..e5a25c2 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/over_flow.c @@ -0,0 +1,739 @@ +/*************************** (C) COPYRIGHT 2017 Ping **************************** + * ļ user_app.c + * ûӦó + * V1.0 + * XuZhongPing + * 2017/09/04 +*********************************************************************************/ +#include "user_app.h" +#include "usart.h" +#include "delay.h" +#include "timer.h" +#include "display.h" + +#include "sound.h" + + +static uint8_t putInPrompt = 0; //ͶϢ + +/* +*********************************************************************** +* : showHexData +* ˵: ʮʾ +* : +* ֵ: +*********************************************************************** +*/ +void showHexData(uint8_t num[], uint8_t n) +{ + uint8_t i; + printf("\r\n"); + for(i=0; iIC0x02->ά룻0x03->룻0x04-> ť +*********************************************************************** +*/ +uint8_t GetPutInType(void) +{ + uint8_t retData; + if(keyOpenDoorRequest == 1) //Űťж + { + retData = 0x04; + keyOpenDoorRequest = 0; + }else if((RFID_state == 1) || (scanIC_2CodeState == 1)){ //ˢICICάж + retData = 0x01; + RFID_state = 0; + scanIC_2CodeState = 0; + }else if(sweep2CodeState == 1){ //άɨж + retData = 0x02; + sweep2CodeState = 0; + }else if(scanBarCodeState == 1){ //ɨά + retData = 0x03; + scanBarCodeState = 0; + }else if(scanLabelCodeState == 1){ //άֽ2018-04-28 + retData = 0x05; + scanLabelCodeState = 0; + }else{ + retData = 0x00; + } + return retData; +} + +/* +*********************************************************************** +* : GetUserInfo +* ˵: ûĿŷʽȡûϢICά룩 +* ΣinputType->ûŷʽICά룩 +* ֵ: ޣúıȫֱgetDataLengthgetDataBufֵ +*********************************************************************** +*/ +void GetUserInfo(uint8_t inputType) +{ + switch(inputType) //ݿʽضӦϢ + { + case 0x01: //ˢIC + getDataLength = 9; //ICϢΪ9ֽ + memcpy(getDataBuf, RFID_ID, 9); //ICϢ + memcpy(get_IC_ID, RFID_ID, 9); //ICϢ + memcpy(getCardNumberBit, cardNumberBit, 17); //ICϢλʾ +// printf("\r\ngetDataLength = %d\r\n", getDataLength); +// printf("\r\nRFID = %x\r\n", RFID_ID[0]); + break; + + case 0x02: //ɨά뿪 + getDataLength = codeDataLength; //άϢ + memcpy(getDataBuf, codeBuf, codeDataLength); //ά뷢Ϣ + memset(codeBuf, 0x00, 35); // +// printf("\r\ngetDataLength = %d\r\n", getDataLength); + break; + + case 0x03: //ά뿪 + getDataLength = codeDataLength; //άϢ + memcpy(getDataBuf, codeBuf, codeDataLength); //ά뷢Ϣ + memset(codeBuf, 0x00, 35); // + break; + + case 0x04: //ťϢ + getDataLength = 0; + break; + + case 0x05: //άֽ + getDataLength = codeDataLength; //άϢ + memcpy(getDataBuf, codeBuf, codeDataLength); //ά뷢Ϣ + memset(codeBuf, 0x00, 35); // + break; + } +} + +/* +*********************************************************************** +* : ShowPutInMSG +* ˵: ʾͶſͼʶϢ +* ΣͶ0x01->IC0x02->ά룻0x03->룻0x04-> ť +* ֵ: +*********************************************************************** +*/ +void ShowPutInInfo(uint8_t uType) +{ + switch(uType) //ݿʽضӦϢ + { + case 0x01: //ˢIC + printf("\r\nˢICɨICά뿪\r\n"); + break; + + case 0x02: //ɨά뿪 + printf("\r\nɨά뿪\r\n"); + break; + + case 0x03: //뿪 + printf("\r\nɨά뿪\r\n"); + break; + + case 0x04: //ťϢ + printf("\r\nť\r\n"); + break; + + case 0x05: //άֽ + printf("\r\nάֽ\r\n"); + break; + } + + printf("\r\nûʶϢΪ\r\n"); + printf("\r\n <>ͣ%d\r\n", getPutInType); + printf("\r\n <>ݳȣ%d\r\n", getDataLength); +// printf("\r\n <>ݣ%s\r\n", getDataBuf); +// showHexData(getDataBuf, 33); +} + +/* +*********************************************************************** +* : ClearPutInInfo +* ˵: ͶɺͶϢΪһ׼ +* Σ +* ֵ: +*********************************************************************** +*/ +void ClearPutInInfo(void) +{ + keyOpenDoorRequest = 0; //ť±־ + RFID_state = 0; //RFID_ICˢ־ + scanIC_2CodeState = 0; //ɨICά뿨ű־ + sweep2CodeState = 0; //άɨ־ + scanBarCodeState = 0; //ɨά־ + scanLabelCodeState = 0; + + putInPrompt = 0; //ʾͶʶһֻһΣ + + getPutInType = 0x00; //֤ + getDataLength = 0x00; //֤Ϣݳ + memset(getDataBuf, 0x00, 33); //֤Ϣ +} + +/* +*********************************************************************** +* : FaultCodeCheck +* ˵: 豸⣬1:ʾйϴ +* 0:ʾûйϲϴ +* Σ +* ֵ: +*********************************************************************** +*/ +#define codeLen 9 +uint8_t faultCode[codeLen] = {11, 12, 13, 22, 23, 24, 32, 33, 34}; //ϴ + +static void FaultCodeCheck(uint8_t devType) +{ + uint8_t i = 0; + uint8_t faultMark = 0; + + switch(devType) + { + case DOUBLE_BARREL_480L: //˫Ͱ480L + for(i = 0; i < codeLen; i++) + { + if((faultCode_1 == faultCode[i]) || (faultCode_2 == faultCode[i])) + { + faultMark = 1; + break; + } + } + break; + + case DOUBLE_BARREL_BOTTLE_480L: //˫Ͱ480Lƿӣ + for(i = 0; i < codeLen; i++) + { + if(faultCode_1 == faultCode[i]) + { + faultMark = 1; + break; + } + } + break; + + case SINGLE_BARREL_660L: //Ͱ660L + case SINGLE_BARREL_480L: //Ͱ480L + for(i = 0; i < codeLen; i++) + { + if(faultCode_1 == faultCode[i]) + { + faultMark = 1; + break; + } + } + break; + + default: + break; + } + + if(faultMark == 1) //йϴ + { + sendMsg.msgType = 6005; //ϴϴ + MessageSend(MSG_FIFO_PROTOCOL, sendMsg); + } +} + +/* +*********************************************************************** +* : GetLimitKeyStatus +* ˵: ȡλص״̬ +* Σ +* ֵ: λλ״̬1쳣0 +*********************************************************************** +*/ +uint8_t GetLimitKeyStatus(void) +{ + uint8_t retData = 0; + + if(limitKeyExceptionMark > 0) + { + switch(deviceType) + { + case DOUBLE_BARREL_480L: //˫Ͱ480L + if(limitKeyExceptionMark & 0x10) + { + faultCode_1 = 20; + } + if(limitKeyExceptionMark & 0x01) + { + faultCode_2 = 20; + } + break; + + case DOUBLE_BARREL_BOTTLE_480L: + faultCode_1 = 0; //ĿǰƿͰûù + if(limitKeyExceptionMark & 0x10) //ߵλ + { + faultCode_2 = 20; + } + break; + + case SINGLE_BARREL_660L: //Ͱ660L + case SINGLE_BARREL_480L: //Ͱ480L + if(limitKeyExceptionMark & 0x10) + { + faultCode_1 = 20; + } + faultCode_2 = 0; + break; + + default: + break; + } + + displayFaultCode = 20; + retData = 1; + } + return retData; +} + +/* +*********************************************************************** +* : PutInOpenDoorTask +* ˵: Ͷ +* Σ +* ֵ: +*********************************************************************** +*/ +void PutInOpenDoorTask(void) +{ + uint8_t tempData; + static uint8_t putInStatus = 0x00; + static uint8_t infoDisplayStatus = 0; + + static timer waitingPutInTimer; + static timer displayTimer; + static timer waitingUploadTimer; + static timer outTimer; + static timer waitingTimer4S; + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&waitingPutInTimer, CLOCK_SECOND*60); + timer_set(&displayTimer, CLOCK_SECOND*3); + timer_set(&waitingUploadTimer, CLOCK_SECOND*10); + timer_set(&outTimer, CLOCK_SECOND*2); + timer_set(&waitingTimer4S, CLOCK_SECOND*4); + } + + switch(putInStatus) + { + case 0x00: //ʼ״̬ + tempData = GetPutInType(); //ǷпͶ + +//--------------------------------------------------- + //ϻ +// tempData = 0x04; +//--------------------------------------------------- + if(tempData > 0) //п + { + getPutInType = tempData; //濪ͶŵͣťICά롢룩 + tempData = 0; + + swipingCardStatus = 1; //ʾ + isOpenDoor = 1; //־ҪŲ + putInProgress = 1; //־豸ڽв + + GetUserInfo(getPutInType); //ݿŷʽȡûϢ + ShowPutInInfo(getPutInType); //ʾͶϢ + + //ûʶϢ浽ͻ + sendPutInType = getPutInType; //ʶʽ + sendDataLength = getDataLength; //Ϣij + memcpy(sendDataBuf, getDataBuf, 33); //Ϣ + + audioNum = 0; + audioOutputMark = 1; + + putInOKMark = 0; //Ͷɱ־ + disablePutInMark = 0; //װֹű־ + userInfoQueryStatus = 0; //Ӻ̨ȡõûϢ + putInUploadSuccessMark = 0; //Ͷϴɹ־ + + capitalAfter = 0; + accountNum = 0; + capital = 0; + isAuth = 0; + infoDisplayStatus = 0; //ûϢÿһֻʾһ + + //ʾڼû + Screen_Landing(); + + //̨ûϢ + if(sendPutInType != 0x04) //ʱ̨ûϢ + { + sendMsg.msgType = 4001; + MessageSend(MSG_FIFO_PROTOCOL, sendMsg); //̨ȡûϢָ + printf("\r\nȡûϢ\r\n"); + } + + putInStatus = 0x01; + + printf("\r\n---------> ûͶţ\r\n"); + printf("\r\nڽͶŲ......\r\n"); + timer_restart(&waitingPutInTimer); + timer_restart(&waitingTimer4S); + break; + } + + if(GetLimitKeyStatus()) //MCU2豸ָִֹͣʹãֱ޸ + { + sendMsg.msgType = 6005; //ϴϴ + MessageSend(MSG_FIFO_PROTOCOL, sendMsg); + printf("\r\n豸ϣ\r\n"); + putInStatus = 0x10; + break; + } + break; + + case 0x01: //ȴͶ + if(timer_expired(&waitingPutInTimer)) + { + putInStatus = 0x00; + ClearPutInInfo(); + + Screen_Default(); + printf("\r\nȴͶɳʱ\r\n"); + break; + } + + //----------------------------------------------------- + //ʾûͶ + if(putInPrompt == 0) + { + if(timer_expired(&waitingTimer4S)) + { + AudioOutput(1); + putInPrompt = 1; + } + } + + //ǷӳͶ + if(delayCloseDoorStatus == 1) + { + delayCloseDoorStatus = 0; + timer_restart(&waitingPutInTimer); +// printf("\r\nӳͶʱ\r\n"); + } + + //ʾʱ + if(getRemainingTimerStatus == 1) + { + getRemainingTimerStatus = 0; + + if(getUserInfoMark) //ǷѾյ̨صûϢûյʱһֱʾڼ... + { + //ʾûϢ + if(accountNum > 0) //˺Ч + { + if(infoDisplayStatus == 0) //ûϢÿοֻʾһ + { + switch(sendPutInType) + { + case 0x01: //ˢIC + Screen_UserInfo(0x01, 1, getCardNumberBit, accountNum, capital); + break; + + //ɨAPPάά뿪ʾ˺ + case 0x02: //ɨά뿪 + case 0x03: //ά뿪 + case 0x05: + Screen_UserInfo(0x01, 0, NULL, accountNum, capital); + break; + + case 0x04: //ťϢ + break; + } + infoDisplayStatus = 1; //ѾʾûϢ + } + }else{ + Screen_UserInfo(0x05, 0, NULL, 0, 0); + } + }else{ + if(infoDisplayStatus == 0) //ûϢÿοֻʾһ + { + Screen_UserInfo(0x06, 0, NULL, 0, 0); + infoDisplayStatus = 1; //ѾʾûϢ + } + } + + //ʾʱ + Screen_Countdown(remainingTimer); + + //----------------------------------------------------- + //ʾżر + if(remainingTimer == 6) + { + AudioOutput(2); + } + } + + //װֹ +// if(disablePutInMark == 1) +// { +// disablePutInMark = 0; +// Screen_ShowFull(); +// +// timer_restart(&displayTimer); +// printf("\r\nͰװ\r\n"); +// putInStatus = 0x06; +// break; +// } + + + if(userInfoQueryStatus == 1) + { + userInfoQueryStatus = 0; + infoDisplayStatus = 0; //յûϢ¸ʾ + getUserInfoMark = 1; + + printf("\r\nȡûϢOK\r\n"); + printf("\r\naccountNum = %d \r\n", accountNum); + printf("\r\ncapital = %.2f \r\n", (float)capital/100); +// printf("\r\nbarcodeLength = %4x \r\n", barcodeLength); +// printf("\r\nbarcode = %s\r\n", barcode); + + if(accountNum > 0) //˺Ч + { + switch(sendPutInType) + { + case 0x01: //ˢIC + Screen_Query(0x01, 1, getCardNumberBit, accountNum, capital); + break; + + //ɨAPPάά뿪ʾ˺ + case 0x02: //ɨά뿪 + case 0x03: //ά뿪 + case 0x05: + Screen_Query(0x01, 0, NULL, accountNum, capital); + break; + + case 0x04: //ťϢ + + break; + } + + }else{ + Screen_Query(0x05, 0, NULL, 0, 0); + } + + } + + //жǷͶ + if(putInOKMark == 1) + { + putInOKMark = 0; + + getWeight1 = uploadWeight1; + getWeight2 = uploadWeight2; + + getWeightBefore1 = uploadBeforeWeight1; + getWeightAfter1 = uploadAfterWeight1; + getWeightBefore2 = uploadBeforeWeight2; + getWeightAfter2 = uploadAfterWeight2; + + printf("\r\nյͶɣڴ......\r\n"); + + printf("\r\n---> յͶ£\r\n"); + printf("\r\nͣ%d\r\n", sendPutInType); + printf("\r\nݳȣ%d\r\n", sendDataLength); + printf("\r\nݣ%s\r\n", sendDataBuf); +// showHexData(sendDataBuf, 33); + + switch(deviceType) + { + case DOUBLE_BARREL_480L: //˫Ͱ480L + printf("\r\nͰ: %2.2f Kg%2.2f Kg -> %2.2f Kg룺%3.1f cm\r\n",\ + (float)getWeight1/100, (float)getWeightBefore1/100, (float)getWeightAfter1/100, (float)getDistance1); + printf("\r\nͰ: %2.2f Kg%2.2f Kg -> %2.2f Kg룺%3.1f cm\r\n",\ + (float)getWeight2/100, (float)getWeightBefore2/100, (float)getWeightAfter2/100, (float)getDistance2); + + printf("\r\nͰ룺%d\r\n", faultCode_1); + printf("\r\nͰ룺%d\r\n", faultCode_2); + + //ʾûͶϢ + Screen_ShowPutInInfo(deviceType, leftBarrelType, rightBarrelType, getWeight1, getWeight2); + + //ֻҪпžϴ20181101޸ + sendMsg.msgType = 6011; //̨ͶϢ + MessageSend(MSG_FIFO_PROTOCOL, sendMsg); + + break; + + case DOUBLE_BARREL_BOTTLE_480L: //˫Ͱ480Lƿ + smallBottleCount = smallBottleCount + bigBottleCount; //ǰִСƿ + + printf("\r\nƿ: %d = %3.1f cm\r\n", smallBottleCount, (float)getDistance1); + printf("\r\nͰ: %2.2f Kg%2.2f Kg -> %2.2f Kg룺%3.1f cm\r\n",\ + (float)getWeight2/100, (float)getWeightBefore2/100, (float)getWeightAfter2/100, (float)getDistance2); + + printf("\r\nƿӹ룺%d\r\n", faultCode_1); + printf("\r\nͰ룺%d\r\n", faultCode_2); + + + //ʾûͶϢ + Screen_ShowPutInInfo(deviceType, leftBarrelType, rightBarrelType, smallBottleCount, getWeight2); + + //ֻҪпžϴ20181101޸ + sendMsg.msgType = 6011; //̨ͶϢ + MessageSend(MSG_FIFO_PROTOCOL, sendMsg); + + break; + + case SINGLE_BARREL_480L: //Ͱ480L + case SINGLE_BARREL_660L: //Ͱ660L + printf("\r\nͰ: %2.2f Kg%2.2f Kg -> %2.2f Kg룺%3.1f cm\r\n",\ + (float)getWeight1/100, (float)getWeightBefore1/100, (float)getWeightAfter1/100, (float)getDistance1); + + printf("\r\n룺%d\r\n", faultCode_1); + + //ʾûͶϢ + Screen_ShowPutInInfo(deviceType, leftBarrelType, 0, getWeight1, 0); + + sendMsg.msgType = 6011; //̨ͶϢ + MessageSend(MSG_FIFO_PROTOCOL, sendMsg); + break; + + default: + break; + } + +// FaultCodeCheck(deviceType); //ϼϴ + + printf("\r\n---------->Ͷɣллʹã\r\n"); + + putInStatus = 0x02; + timer_restart(&displayTimer); + } + break; + + case 0x02: //ͣʾͶϢ + if(timer_expired(&displayTimer)) + { + //ͶţȴϴظͶź + if((getWeight2 > 0) || (getWeight1 > 0) || (smallBottleCount > 0)) + { + printf("\r\nοͶţȴϴظͶź\r\n"); + + if((deviceType == SINGLE_BARREL_480L) && ((leftBarrelType == KITCHEN) || (leftBarrelType == OTHER))) //Ͱʱʾ + { + AudioOutput(3); + Screen_Exit(); //ʾ˳ʹý桱 + printf("\r\nͶɣ˳\r\n"); + putInStatus = 0x05; + timer_restart(&outTimer); + }else{ + putInStatus = 0x03; + timer_restart(&waitingUploadTimer); + } + }else{ //ûͶתллʹý˳ + AudioOutput(3); + + Screen_Exit(); //ʾ˳ʹý桱 + printf("\r\nʾͶʱ䵽Ͷ˳\r\n"); + putInStatus = 0x05; + timer_restart(&outTimer); + } + + } + break; + + case 0x03: //ȴϴɹʾͶź + if(putInUploadSuccessMark == 1) + { + putInUploadSuccessMark = 0; + printf("\r\n֮ǰ = %.2f \r\n", (float)capital/100); + printf("\r\n֮ = %.2f \r\n", (float)capitalAfter/100); + printf("\r\n = %.2f \r\n", (float)(capitalAfter - capital)/100); + + if(capitalAfter >= capital) + { + Screen_ShowPutInReward(capital, capitalAfter); + +// printf("\r\n = %.2f \r\n", (float)(capitalAfter - capital)/100); +// printf("\r\n = %.2f \r\n", (float)capitalAfter/100); + } + + putInStatus = 0x04; + timer_restart(&displayTimer); + } + + if(timer_expired(&waitingUploadTimer)) + { + audioNum = 3; + audioOutputMark = 1; + + Screen_Exit(); //ʾ˳ʹý桱 + printf("\r\nʾͶʱ䵽\r\n"); + putInStatus = 0x05; + timer_restart(&outTimer); + } + break; + + case 0x04: + if(timer_expired(&displayTimer)) + { + audioNum = 3; + audioOutputMark = 1; + + Screen_Exit(); //ʾ˳ʹý桱 + printf("\r\nʾͶʱ䵽\r\n"); + putInStatus = 0x05; + timer_restart(&outTimer); + } + break; + + case 0x05: //ͣʾ˳ + if(timer_expired(&outTimer)) + { + printf("\r\nʾ\r\n"); + Screen_Default(); + ClearPutInInfo(); + putInProgress = 0; + putInStatus = 0x00; + } + break; + +//----------------------------------------------------------------------------------------- + + case 0x06: //װֹʱʾװʾ + if(timer_expired(&displayTimer)) + { + printf("\r\nʾ\r\n"); + Screen_Default(); + ClearPutInInfo(); + putInStatus = 0x00; + } + break; + + case 0x10: //豸ת˴ȴ + Screen_Error(0, displayFaultCode, 0); + + putInStatus = 0x11; + break; + + case 0x11: + //λسֹ֮еˣֱ޸ + break; + + default: + putInStatus = 0x00; + break; + } +} + +/******************** (C) COPYRIGHT 2017 Ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/over_flow.h b/STM32_4路称重_Git提交精简工程/src/USER/over_flow.h new file mode 100755 index 0000000..37c18aa --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/over_flow.h @@ -0,0 +1,22 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ device.h + * 豸Ƴ + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#ifndef __USER_APP_H +#define __USER_APP_H + +#include "sys.h" +#include "string.h" +#include "stdlib.h" +#include "device.h" +#include "data_typedef.h" + +void showHexData(uint8_t num[], uint8_t n); +void PutInOpenDoorTask(void); + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/pc_protocol.c b/STM32_4路称重_Git提交精简工程/src/USER/pc_protocol.c new file mode 100755 index 0000000..caea29b --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/pc_protocol.c @@ -0,0 +1,909 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ pc_protocol.c + * λЭ鴦 + * V1.0 + * XuZhongPing + * 2017/03/16 +*********************************************************************************/ +#include "pc_protocol.h" +#include "delay.h" +#include "timer.h" +#include "usart1.h" +#include "usart3.h" +#include "string.h" +#include "stdlib.h" +#include "data_typedef.h" +#include "device.h" +#include "gsm_uart_conf.h" +#include "gsm_gprs.h" + +uint8_t PC_PRO_RX_BUF[PC_PRO_RECV_LEN]; //ջ +uint8_t PC_PRO_TX_BUF[PC_PRO_SEND_LEN]; //ͻ + + +static void PC_ProCommandRun(uint8_t *pRxBuf, uint8_t *pTxBuf); + +/* +*********************************************************************** +* : show +* ˵: ʮʾ +* : +* ֵ: +*********************************************************************** +*/ +void showHex(uint8_t num[], uint8_t n) +{ + uint8_t i; + printf("\r\n"); + for(i=0; i ҪݵַdataLen -> ݳ +* ֵ: +*********************************************************************** +*/ +void PC_ProDataPackingAndSend(uint8_t *pdata, uint16_t dataLen) +{ + uint16_t i; + uint8_t CS = 0; + uint16_t TX_Size = 0; + + uint8_t tempSendDataBuf[256]; + uint16_t dataAddrIndex = 0; + + tempSendDataBuf[dataAddrIndex++] = 0xFE; //ǰֽ + tempSendDataBuf[dataAddrIndex++] = 0xFE; + tempSendDataBuf[dataAddrIndex++] = 0xFE; + + tempSendDataBuf[dataAddrIndex++] = 0x68; //֡ͷ + CS += 0x68; + + tempSendDataBuf[dataAddrIndex++] = *(pdata+0); //͵ַ + CS += *pdata; + + tempSendDataBuf[dataAddrIndex++] = 0x68; //֡ͷ + CS += 0x68; + + tempSendDataBuf[dataAddrIndex++] = *(pdata+1); //֡ + CS += *(pdata+1); + + tempSendDataBuf[dataAddrIndex++] = *(pdata+2); //ݳȣ8λ + CS += *(pdata+2); + tempSendDataBuf[dataAddrIndex++] = *(pdata+3); //ݳȣ8λ + CS += *(pdata+3); + + TX_Size = (*(pdata+2) << 8) | (*(pdata+3)); //ȡͨѶݳ + for(i=0; i ջĵַ*pTxBuf -> ݻַ +* ֵ: +*********************************************************************** +*/ +static void PC_ProCommandRun(uint8_t *pRxBuf, uint8_t *pTxBuf) +{ + uint8_t pc_proNum = 0; + uint16_t temp16BitData = 0; + + pc_proNum = *(pRxBuf+1); + + printf("\r\nPC <-- 0x%02X\r\n", pc_proNum); + switch(pc_proNum) //ͨѶ + { + case 0x01: + break; + + case 0x02: //Ͷָ + openDoorNumber = *(pRxBuf+5); + if(openDoorNumber == 0) + { + openDoorNumber = 255; + rspPCDoorNumber = 255; + if((fullMark1 == 0) || (fullMark2 == 0) || + (fullMark3 == 0) || (fullMark4 == 0)) + { + pcRequestOpenDoorMark = 1; + } + }else{ + rspPCDoorNumber = openDoorNumber; + + switch(openDoorNumber) + { + case 1: + if(fullMark1 == 0) //ͨûװſԴ + { + pcRequestOpenDoorMark = 1; + } + break; + + case 2: + if(fullMark2 == 0) //ͨûװſԴ + { + pcRequestOpenDoorMark = 1; + } + break; + + case 3: + if(fullMark3 == 0) + { + pcRequestOpenDoorMark = 1; + } + break; + + case 4: + if(fullMark4 == 0) + { + pcRequestOpenDoorMark = 1; + } + break; + + + default: + break; + } + } + + PC_ProCommandSend(pc_proNum); +// printf("\r\nյλӦָ0x02\r\n"); + break; + + case 0x03: //رͶָ + pcRequestClooseDoorMark = 1; + PC_ProCommandSend(pc_proNum); +// printf("\r\nյλӦָ0x02\r\n"); + break; + + case 0x04: //ָ +// openDoorNumber = *(pRxBuf+5); +// if(openDoorNumber == 0) +// { +// openDoorNumber = 255; +// rspPCDoorNumber = 255; +// }else{ +// rspPCDoorNumber = openDoorNumber; +// } + + boxOpenMark = 1; + PC_ProCommandSend(pc_proNum); + break; + + case 0x20: //ѯָ + rspPCWeightNumber = *(pRxBuf+5); + if(rspPCWeightNumber == 0) + { + rspPCWeightNumber = 255; + } + + PC_ProCommandSend(pc_proNum); + break; + + case 0x21: //״̬ѯ + rspPCDistanceNumber = *(pRxBuf+5); + if(rspPCDistanceNumber == 0) + { + rspPCDistanceNumber = 255; + } + + PC_ProCommandSend(pc_proNum); + break; + + case 0x22: //¶Ȳѯָ + rspPCTemperatureNumber = *(pRxBuf+5); + if(rspPCTemperatureNumber == 0) + { + rspPCTemperatureNumber = 255; + } + + PC_ProCommandSend(pc_proNum); + break; + + case 0x23: //Źر״̬ѯָ + PC_ProCommandSend(pc_proNum); + break; + + case 0x30: //ȡλ汾ָ + PC_ProCommandSend(pc_proNum); + break; + + case 0x31: //ȡIMEIָ + PC_ProCommandSend(pc_proNum); + break; + + case 0x91: //豸ʱͬ + timestamp_s = *(pRxBuf+5) << 24; + timestamp_s |= *(pRxBuf+6) << 16; + timestamp_s |= *(pRxBuf+7) << 8; + timestamp_s |= *(pRxBuf+8); + getDateTimeMark = 1; + break; + + case 0x92: //λ豸״̬ͬ + temp16BitData |= *(pRxBuf+5) << 8; + temp16BitData |= *(pRxBuf+6); + + switch(temp16BitData) + { + case 0x0001: + netStatus = *(pRxBuf+7) << 8; + netStatus |= *(pRxBuf+8); + break; + + case 0x0002: + devRunnigStatus = *(pRxBuf+7) << 8; + devRunnigStatus |= *(pRxBuf+8); + break; + + default: + break; + } + break; + + default: // + break; + } +} + +/* +*********************************************************************** +* : PC_ProDataPacking +* ˵: λλݴ +* : protocolNo -> Э +* ֵ: +*********************************************************************** +*/ +void PC_ProDataPacking(uint8_t protocolNo) +{ + uint16_t dataAddr = 0; //͵ + + uint32_t temp = 0; + uint16_t len = 0; + + uint16_t tmpeData = 0; + uint8_t tempData1 = 0; + uint8_t tempAddr = 0; + uint8_t dataCunt = 0; + + PC_PRO_TX_BUF[dataAddr++] = 0x00; //ôӻͨѶַ + PC_PRO_TX_BUF[dataAddr++] = protocolNo; // + + PC_PRO_TX_BUF[dataAddr++] = 0x00; //͵ݳȣݼɺ룩 + PC_PRO_TX_BUF[dataAddr++] = 0x00; + + printf("\r\nPC --> 0x%02X\r\n", protocolNo); + + switch(protocolNo) + { + case 0x01: //ûʶ + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + + PC_PRO_TX_BUF[dataAddr++] = sendPutInType; //ʶʽ + PC_PRO_TX_BUF[dataAddr++] = sendDataLength; //ݳ + memcpy(&PC_PRO_TX_BUF[dataAddr], sendDataBuf, sendDataLength); // + dataAddr += sendDataLength; + break; + + case 0x02: //λͶڻӦ + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + + if(rspPCDoorNumber == 255) + { + PC_PRO_TX_BUF[dataAddr++] = 4; //Ͷ + + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ1 + PC_PRO_TX_BUF[dataAddr++] = fullMark1; //ǰ״̬ + + PC_PRO_TX_BUF[dataAddr++] = 2; //Ͷ2 + PC_PRO_TX_BUF[dataAddr++] = fullMark2; //ǰ״̬ + + PC_PRO_TX_BUF[dataAddr++] = 3; //Ͷ3 + PC_PRO_TX_BUF[dataAddr++] = fullMark3; //ǰ״̬ + + PC_PRO_TX_BUF[dataAddr++] = 4; //Ͷ4 + PC_PRO_TX_BUF[dataAddr++] = fullMark4; //ǰ״̬ + + }else{ + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ + PC_PRO_TX_BUF[dataAddr++] = rspPCDoorNumber; + switch(rspPCDoorNumber) + { + case 1: + PC_PRO_TX_BUF[dataAddr++] = fullMark1; //ǰ״̬ + break; + + case 2: + PC_PRO_TX_BUF[dataAddr++] = fullMark2; + break; + + case 3: + PC_PRO_TX_BUF[dataAddr++] = fullMark3; + break; + + case 4: + PC_PRO_TX_BUF[dataAddr++] = fullMark4; + break; + + default: + PC_PRO_TX_BUF[dataAddr++] = 0x00; + break; + } + } + break; + + case 0x03: + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + break; + + case 0x04: //λŻӦ + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + + PC_PRO_TX_BUF[dataAddr++] = 1; // + PC_PRO_TX_BUF[dataAddr++] = 1; + PC_PRO_TX_BUF[dataAddr++] = 0x00; //ǰ״̬ + break; + + case 0x08: + break; + + case 0x09: + break; + + case 0x20: //λǰӦ +// ģ +// weight1 = 0x1234; +// weight2 = 0x2345; +// weight3 = 0x3456; +// weight4 = 0x4567; + + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + + switch(rspPCWeightNumber) + { + case 1: + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ + PC_PRO_TX_BUF[dataAddr++] = rspPCWeightNumber; + PC_PRO_TX_BUF[dataAddr++] = weight1 >> 8; //ǰ + PC_PRO_TX_BUF[dataAddr++] = weight1; + break; + + case 2: + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ + PC_PRO_TX_BUF[dataAddr++] = rspPCWeightNumber; + PC_PRO_TX_BUF[dataAddr++] = weight2 >> 8; //ǰ + PC_PRO_TX_BUF[dataAddr++] = weight2; + break; + + case 3: + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ + PC_PRO_TX_BUF[dataAddr++] = rspPCWeightNumber; + PC_PRO_TX_BUF[dataAddr++] = weight3 >> 8; //ǰ + PC_PRO_TX_BUF[dataAddr++] = weight3; + break; + + case 4: + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ + PC_PRO_TX_BUF[dataAddr++] = rspPCWeightNumber; + PC_PRO_TX_BUF[dataAddr++] = weight4 >> 8; //ǰ + PC_PRO_TX_BUF[dataAddr++] = weight4; + break; + + case 255: + PC_PRO_TX_BUF[dataAddr++] = 4; //Ͷ + + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ1 + PC_PRO_TX_BUF[dataAddr++] = weight1 >> 8; //ǰ + PC_PRO_TX_BUF[dataAddr++] = weight1; + + PC_PRO_TX_BUF[dataAddr++] = 2; //Ͷ2 + PC_PRO_TX_BUF[dataAddr++] = weight2 >> 8; //ǰ + PC_PRO_TX_BUF[dataAddr++] = weight2; + + PC_PRO_TX_BUF[dataAddr++] = 3; //Ͷ3 + PC_PRO_TX_BUF[dataAddr++] = weight3 >> 8; //ǰ + PC_PRO_TX_BUF[dataAddr++] = weight3; + + PC_PRO_TX_BUF[dataAddr++] = 4; //Ͷ4 + PC_PRO_TX_BUF[dataAddr++] = weight4 >> 8; //ǰ + PC_PRO_TX_BUF[dataAddr++] = weight4; + break; + + default: + break; + } + break; + + case 0x21: //λǰ״̬Ӧ +// ģ +// getDistance1 = 0x15; +// getDistance2 = 0x25; +// getDistance3 = 0x35; +// getDistance4 = 0x45; + + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + + switch(rspPCDistanceNumber) + { + case 1: + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ + PC_PRO_TX_BUF[dataAddr++] = rspPCDistanceNumber; + PC_PRO_TX_BUF[dataAddr++] = outputDistance1; //ǰֵ + break; + + case 2: + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ + PC_PRO_TX_BUF[dataAddr++] = rspPCDistanceNumber; + PC_PRO_TX_BUF[dataAddr++] = outputDistance2; //ǰֵ + break; + + case 3: + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ + PC_PRO_TX_BUF[dataAddr++] = rspPCDistanceNumber; + PC_PRO_TX_BUF[dataAddr++] = outputDistance3; //ǰֵ + break; + + case 4: + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ + PC_PRO_TX_BUF[dataAddr++] = rspPCDistanceNumber; + PC_PRO_TX_BUF[dataAddr++] = outputDistance4; //ǰֵ + break; + + case 255: + PC_PRO_TX_BUF[dataAddr++] = 4; //Ͷ + + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ1 + PC_PRO_TX_BUF[dataAddr++] = outputDistance1; //ǰֵ + + PC_PRO_TX_BUF[dataAddr++] = 2; //Ͷ2 + PC_PRO_TX_BUF[dataAddr++] = outputDistance2; //ǰֵ + + PC_PRO_TX_BUF[dataAddr++] = 3; //Ͷ3 + PC_PRO_TX_BUF[dataAddr++] = outputDistance3; //ǰֵ + + PC_PRO_TX_BUF[dataAddr++] = 4; //Ͷ4 + PC_PRO_TX_BUF[dataAddr++] = outputDistance4; //ǰֵ + break; + + default: + break; + } + break; + + case 0x22: //λǰ¶ֵӦ + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + switch(rspPCTemperatureNumber) + { + case 1: + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ + PC_PRO_TX_BUF[dataAddr++] = rspPCTemperatureNumber; + PC_PRO_TX_BUF[dataAddr++] = 0x00; //¶ȷ + tmpeData = temperature*10; //ϴݷŴ10 + PC_PRO_TX_BUF[dataAddr++] = tmpeData >> 8; //¶ȸ8λ + PC_PRO_TX_BUF[dataAddr++] = tmpeData; //¶ȵ8λ + break; + + case 2: + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ + PC_PRO_TX_BUF[dataAddr++] = rspPCTemperatureNumber; + PC_PRO_TX_BUF[dataAddr++] = 0x00; //¶ȷ + tmpeData = temperature*10; //ϴݷŴ10 + PC_PRO_TX_BUF[dataAddr++] = tmpeData >> 8; //¶ȸ8λ + PC_PRO_TX_BUF[dataAddr++] = tmpeData; //¶ȵ8λ + break; + + case 3: + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ + PC_PRO_TX_BUF[dataAddr++] = rspPCTemperatureNumber; + PC_PRO_TX_BUF[dataAddr++] = 0x00; //¶ȷ + tmpeData = temperature*10; //ϴݷŴ10 + PC_PRO_TX_BUF[dataAddr++] = tmpeData >> 8; //¶ȸ8λ + PC_PRO_TX_BUF[dataAddr++] = tmpeData; //¶ȵ8λ + break; + + case 4: + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ + PC_PRO_TX_BUF[dataAddr++] = rspPCTemperatureNumber; + PC_PRO_TX_BUF[dataAddr++] = 0x00; //¶ȷ + tmpeData = temperature*10; //ϴݷŴ10 + PC_PRO_TX_BUF[dataAddr++] = tmpeData >> 8; //¶ȸ8λ + PC_PRO_TX_BUF[dataAddr++] = tmpeData; //¶ȵ8λ + break; + + case 255: + PC_PRO_TX_BUF[dataAddr++] = 4; //Ͷ + + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷ1 + PC_PRO_TX_BUF[dataAddr++] = 0x00; //¶ȷ + tmpeData = temperature*10; //ϴݷŴ10 + PC_PRO_TX_BUF[dataAddr++] = tmpeData >> 8; //¶ȸ8λ + PC_PRO_TX_BUF[dataAddr++] = tmpeData; //¶ȵ8λ + + PC_PRO_TX_BUF[dataAddr++] = 2; //Ͷ2 + PC_PRO_TX_BUF[dataAddr++] = 0x00; //¶ȷ + tmpeData = temperature*10; //ϴݷŴ10 + PC_PRO_TX_BUF[dataAddr++] = tmpeData >> 8; //¶ȸ8λ + PC_PRO_TX_BUF[dataAddr++] = tmpeData; //¶ȵ8λ + + PC_PRO_TX_BUF[dataAddr++] = 3; //Ͷ3 + PC_PRO_TX_BUF[dataAddr++] = 0x00; //¶ȷ + tmpeData = temperature*10; //ϴݷŴ10 + PC_PRO_TX_BUF[dataAddr++] = tmpeData >> 8; //¶ȸ8λ + PC_PRO_TX_BUF[dataAddr++] = tmpeData; //¶ȵ8λ + + PC_PRO_TX_BUF[dataAddr++] = 4; //Ͷ4 + PC_PRO_TX_BUF[dataAddr++] = 0x00; //¶ȷ + tmpeData = temperature*10; //ϴݷŴ10 + PC_PRO_TX_BUF[dataAddr++] = tmpeData >> 8; //¶ȸ8λ + PC_PRO_TX_BUF[dataAddr++] = tmpeData; //¶ȵ8λ + break; + + default: + break; + } + break; + + case 0x23: //״̬ + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Ͷ + + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷڱ + PC_PRO_TX_BUF[dataAddr++] = recycleClearDoorMark; //״̬ + break; + + case 0x30: //ȡλ汾 + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + len = strlen(VersionNumber); + PC_PRO_TX_BUF[dataAddr++] = len; //汾ų + memcpy(&PC_PRO_TX_BUF[dataAddr], VersionNumber, len); + dataAddr += len; + break; + + case 0x31: //ȡIMEI + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + PC_PRO_TX_BUF[dataAddr++] = 15; //IMEIų + memcpy(&PC_PRO_TX_BUF[dataAddr], gsm_msg.IMEI, 15); + dataAddr += 15; + break; + + case 0x60: //ŵʱʾ + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + PC_PRO_TX_BUF[dataAddr++] = remainingTimer; + break; + + case 0x61: //Ͷϴ + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + switch(deviceType) + { + case DOUBLE_CLASSIFICATION: // + PC_PRO_TX_BUF[dataAddr++] = 2; // + + //1 + PC_PRO_TX_BUF[dataAddr++] = 1; //ͶƷ + + PC_PRO_TX_BUF[dataAddr++] = getWeight1 >> 8; //Ͷ + PC_PRO_TX_BUF[dataAddr++] = getWeight1; + + PC_PRO_TX_BUF[dataAddr++] = getWeightBefore1 >> 8; //Ͷǰ + PC_PRO_TX_BUF[dataAddr++] = getWeightBefore1; + + PC_PRO_TX_BUF[dataAddr++] = getWeightAfter1 >> 8; //Ͷź + PC_PRO_TX_BUF[dataAddr++] = getWeightAfter1; + + PC_PRO_TX_BUF[dataAddr++] = outputDistance1; //ֵ + + //2 + PC_PRO_TX_BUF[dataAddr++] = 2; //ͶƷ + + PC_PRO_TX_BUF[dataAddr++] = getWeight2 >> 8; //Ͷ + PC_PRO_TX_BUF[dataAddr++] = getWeight2; + + PC_PRO_TX_BUF[dataAddr++] = getWeightBefore2 >> 8; //Ͷǰ + PC_PRO_TX_BUF[dataAddr++] = getWeightBefore2; + + PC_PRO_TX_BUF[dataAddr++] = getWeightAfter2 >> 8; //Ͷź + PC_PRO_TX_BUF[dataAddr++] = getWeightAfter2; + + PC_PRO_TX_BUF[dataAddr++] = outputDistance2; //ֵ + break; + + case FOUR_CLASSIFICATION: + PC_PRO_TX_BUF[dataAddr++] = 4; + + PC_PRO_TX_BUF[dataAddr++] = 1; + PC_PRO_TX_BUF[dataAddr++] = getWeight1 >> 8; + PC_PRO_TX_BUF[dataAddr++] = getWeight1; + PC_PRO_TX_BUF[dataAddr++] = getWeightBefore1 >> 8; + PC_PRO_TX_BUF[dataAddr++] = getWeightBefore1; + PC_PRO_TX_BUF[dataAddr++] = getWeightAfter1 >> 8; + PC_PRO_TX_BUF[dataAddr++] = getWeightAfter1; + PC_PRO_TX_BUF[dataAddr++] = outputDistance1; + + PC_PRO_TX_BUF[dataAddr++] = 2; + PC_PRO_TX_BUF[dataAddr++] = getWeight2 >> 8; + PC_PRO_TX_BUF[dataAddr++] = getWeight2; + PC_PRO_TX_BUF[dataAddr++] = getWeightBefore2 >> 8; + PC_PRO_TX_BUF[dataAddr++] = getWeightBefore2; + PC_PRO_TX_BUF[dataAddr++] = getWeightAfter2 >> 8; + PC_PRO_TX_BUF[dataAddr++] = getWeightAfter2; + PC_PRO_TX_BUF[dataAddr++] = outputDistance2; + + PC_PRO_TX_BUF[dataAddr++] = 3; + PC_PRO_TX_BUF[dataAddr++] = getWeight3 >> 8; + PC_PRO_TX_BUF[dataAddr++] = getWeight3; + PC_PRO_TX_BUF[dataAddr++] = getWeightBefore3 >> 8; + PC_PRO_TX_BUF[dataAddr++] = getWeightBefore3; + PC_PRO_TX_BUF[dataAddr++] = getWeightAfter3 >> 8; + PC_PRO_TX_BUF[dataAddr++] = getWeightAfter3; + PC_PRO_TX_BUF[dataAddr++] = outputDistance3; + + PC_PRO_TX_BUF[dataAddr++] = 4; + PC_PRO_TX_BUF[dataAddr++] = getWeight4 >> 8; + PC_PRO_TX_BUF[dataAddr++] = getWeight4; + PC_PRO_TX_BUF[dataAddr++] = getWeightBefore4 >> 8; + PC_PRO_TX_BUF[dataAddr++] = getWeightBefore4; + PC_PRO_TX_BUF[dataAddr++] = getWeightAfter4 >> 8; + PC_PRO_TX_BUF[dataAddr++] = getWeightAfter4; + PC_PRO_TX_BUF[dataAddr++] = outputDistance4; + break; + + default:break; + } + + printf("\r\n0x61 Update D1=%d, D2=%d, D3=%d, D4=%d\r\n", + outputDistance1, outputDistance2, outputDistance3, outputDistance4); + break; + + case 0x62: + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + switch(deviceType) + { + case DOUBLE_CLASSIFICATION: // + PC_PRO_TX_BUF[dataAddr++] = 2; //Ͷ + + //ͨ1 + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Ͷڱ + + PC_PRO_TX_BUF[dataAddr++] = 0x00; + tmpeData = temperature*10; + PC_PRO_TX_BUF[dataAddr++] = tmpeData >> 8; //¶ȸ8λ + PC_PRO_TX_BUF[dataAddr++] = tmpeData; //¶ȵ8λ + + PC_PRO_TX_BUF[dataAddr++] = outputDistance1; //ֵ + + //ͨ2 + PC_PRO_TX_BUF[dataAddr++] = 0x02; //Ͷڱ + + PC_PRO_TX_BUF[dataAddr++] = 0x00; + tmpeData = temperature*10; + PC_PRO_TX_BUF[dataAddr++] = tmpeData >> 8; //¶ȸ8λ + PC_PRO_TX_BUF[dataAddr++] = tmpeData; //¶ȵ8λ + + PC_PRO_TX_BUF[dataAddr++] = outputDistance2; //ֵ + break; + + case FOUR_CLASSIFICATION: + PC_PRO_TX_BUF[dataAddr++] = 4; + tmpeData = temperature*10; + + PC_PRO_TX_BUF[dataAddr++] = 0x01; + PC_PRO_TX_BUF[dataAddr++] = 0x00; + PC_PRO_TX_BUF[dataAddr++] = tmpeData >> 8; + PC_PRO_TX_BUF[dataAddr++] = tmpeData; + PC_PRO_TX_BUF[dataAddr++] = outputDistance1; + + PC_PRO_TX_BUF[dataAddr++] = 0x02; + PC_PRO_TX_BUF[dataAddr++] = 0x00; + PC_PRO_TX_BUF[dataAddr++] = tmpeData >> 8; + PC_PRO_TX_BUF[dataAddr++] = tmpeData; + PC_PRO_TX_BUF[dataAddr++] = outputDistance2; + + PC_PRO_TX_BUF[dataAddr++] = 0x03; + PC_PRO_TX_BUF[dataAddr++] = 0x00; + PC_PRO_TX_BUF[dataAddr++] = tmpeData >> 8; + PC_PRO_TX_BUF[dataAddr++] = tmpeData; + PC_PRO_TX_BUF[dataAddr++] = outputDistance3; + + PC_PRO_TX_BUF[dataAddr++] = 0x04; + PC_PRO_TX_BUF[dataAddr++] = 0x00; + PC_PRO_TX_BUF[dataAddr++] = tmpeData >> 8; + PC_PRO_TX_BUF[dataAddr++] = tmpeData; + PC_PRO_TX_BUF[dataAddr++] = outputDistance4; + break; + + default: break; + } + printf("\r\n0x62 OF = %d, %d, %d, %d\r\n", + outputDistance1, outputDistance2, outputDistance3, outputDistance4); + break; + + case 0x63: // + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + PC_PRO_TX_BUF[dataAddr++] = keyNum; + PC_PRO_TX_BUF[dataAddr++] = keyStatus; + break; + + case 0x64: //⿪״̬ + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + PC_PRO_TX_BUF[dataAddr++] = 1; //Ӧر + PC_PRO_TX_BUF[dataAddr++] = humanSensingKeyStatus; + break; + + case 0x65: //״̬ + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + PC_PRO_TX_BUF[dataAddr++] = 0x01; // + PC_PRO_TX_BUF[dataAddr++] = 1; // + PC_PRO_TX_BUF[dataAddr++] = smokeAlarmStatus; + break; + + case 0x66: //Ͷſڹر״̬ + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + + //ʱռλݺд + tempAddr = dataAddr; + PC_PRO_TX_BUF[dataAddr++] = 0x00; //Ͷ + + dataCunt = 0; + if(dropOffPortMark1 == 1) + { + dropOffPortMark1 = 0; + PC_PRO_TX_BUF[dataAddr++] = 1; //Ͷڱ + PC_PRO_TX_BUF[dataAddr++] = dropPortClosedStatus1; //Ͷڹر״̬ + + dataCunt++; + } + + if(dropOffPortMark2 == 1) + { + dropOffPortMark2 = 0; + PC_PRO_TX_BUF[dataAddr++] = 2; //Ͷڱ + PC_PRO_TX_BUF[dataAddr++] = dropPortClosedStatus2; //Ͷڹر״̬ + + dataCunt++; + } + PC_PRO_TX_BUF[tempAddr] = dataCunt; // + break; + + case 0x67: //GPSλ + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + PC_PRO_TX_BUF[dataAddr++] = gpsStatus; //λ״̬ + PC_PRO_TX_BUF[dataAddr++] = gpsEW; //ȷ0->E-,W- + PC_PRO_TX_BUF[dataAddr++] = gpsLon >> 24; // + PC_PRO_TX_BUF[dataAddr++] = gpsLon >> 16; + PC_PRO_TX_BUF[dataAddr++] = gpsLon >> 8; + PC_PRO_TX_BUF[dataAddr++] = gpsLon; + + PC_PRO_TX_BUF[dataAddr++] = gpsNS; //γȷ0->N-,1->S-ϣ + PC_PRO_TX_BUF[dataAddr++] = gpsLat >> 24; //γ + PC_PRO_TX_BUF[dataAddr++] = gpsLat >> 16; + PC_PRO_TX_BUF[dataAddr++] = gpsLat >> 8; + PC_PRO_TX_BUF[dataAddr++] = gpsLat; + break; + + case 0x90: //ͬź + PC_PRO_TX_BUF[dataAddr++] = 0x01; //Э汾 + len = strlen("connect"); + memcpy(&PC_PRO_TX_BUF[dataAddr], "connect", len); + dataAddr += len; + break; + + default: + printf("\r\nδָ֪\r\n"); + break; + } + + len = dataAddr - 4; //㵱ǰͨѶݳ + PC_PRO_TX_BUF[2] = (uint8_t)(len >> 8); //ͨѶݳ֣8λ + PC_PRO_TX_BUF[3] = (uint8_t)len; //ͨѶݳ֣8λ + + PC_ProDataPackingAndSend(PC_PRO_TX_BUF, dataAddr); //ָȻ +} + +/* +*********************************************************************** +* : PC_ProCommandSend +* ˵: λλͨѶ +* : protocolNo -> Э +* ֵ: +*********************************************************************** +*/ +void PC_ProCommandSend(uint8_t protocolNo) +{ + pcCmdMsg.msgType = protocolNo; + MessageSend(MSG_FIFO_PC_CMD, pcCmdMsg); +} + +/* +*********************************************************************** +* : PC_ProCommandSendHandler +* ˵: λλͨѶ +* : protocolNo -> Э +* ֵ: +*********************************************************************** +*/ +static void PC_ProCommandSendHandler(void) +{ + static uint8_t currentStatus = 0; + static uint8_t nextStatus = 0; + + static MESSAGE *pMsg; + + static timer waitingTimer; + + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&waitingTimer, 2); + } + + currentStatus = nextStatus; + switch(currentStatus) + { + case 0x00: + pMsg = MessageGet(MSG_FIFO_PC_CMD); + if(pMsg) + { + PC_ProDataPacking((uint8_t)pMsg->msgType); + timer_restart(&waitingTimer); + nextStatus = 0x01; + break; + } + break; + + case 0x01: + if(timer_expired(&waitingTimer)) + { + nextStatus = 0x00; + break; + } + break; + + default: + nextStatus = 0x00; + break; + } +} + +/* +*********************************************************************** +* : PC_ProDecodeTask +* ˵: λͨѶЭ鴦 +* : +* ֵ: +*********************************************************************** +*/ +void PC_ProDecodeTask(void) +{ + if(USART4_RX_STA == 0xfd) //нյ͵ + { + PC_ProCommandRun(USART4_RX_BUF, USART4_TX_BUF); //ͷص + + memset(USART4_RX_BUF, 0x00, USART4_RECV_LEN); // + USART4_RX_STA = 0; + } + + PC_ProCommandSendHandler(); +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/pc_protocol.h b/STM32_4路称重_Git提交精简工程/src/USER/pc_protocol.h new file mode 100755 index 0000000..25b9b13 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/pc_protocol.h @@ -0,0 +1,16 @@ +#ifndef __PC_PROTOCOL_H +#define __PC_PROTOCOL_H +#include "stm32f10x.h" + +#define PC_PRO_RECV_LEN 256 //ջֽ +#define PC_PRO_SEND_LEN 256 //ͻֽ + +extern uint8_t PC_PRO_RX_BUF[PC_PRO_RECV_LEN]; //ջ +extern uint8_t PC_PRO_TX_BUF[PC_PRO_SEND_LEN]; //ͻ + +extern void PC_ProCommandSend(uint8_t protocolNo); +void PC_ProDecodeTask(void); + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/stm32f10x_conf.h b/STM32_4路称重_Git提交精简工程/src/USER/stm32f10x_conf.h new file mode 100755 index 0000000..b17511e --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/stm32f10x_conf.h @@ -0,0 +1,77 @@ +/** + ****************************************************************************** + * @file GPIO/IOToggle/stm32f10x_conf.h + * @author MCD Application Team + * @version V3.5.0 + * @date 08-April-2011 + * @brief Library configuration file. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_CONF_H +#define __STM32F10x_CONF_H + +/* Includes ------------------------------------------------------------------*/ +/* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */ +#include "stm32f10x_adc.h" +//#include "stm32f10x_bkp.h" +//#include "stm32f10x_can.h" +//#include "stm32f10x_cec.h" +//#include "stm32f10x_crc.h" +//#include "stm32f10x_dac.h" +#include "stm32f10x_dbgmcu.h" +#include "stm32f10x_dma.h" +#include "stm32f10x_exti.h" +#include "stm32f10x_flash.h" +#include "stm32f10x_fsmc.h" +#include "stm32f10x_gpio.h" +//#include "stm32f10x_i2c.h" +#include "stm32f10x_iwdg.h" +//#include "stm32f10x_pwr.h" +#include "stm32f10x_rcc.h" +#include "stm32f10x_rtc.h" +//#include "stm32f10x_sdio.h" +#include "stm32f10x_spi.h" +#include "stm32f10x_tim.h" +#include "stm32f10x_usart.h" +//#include "stm32f10x_wwdg.h" +#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Uncomment the line below to expanse the "assert_param" macro in the + Standard Peripheral Library drivers code */ +/* #define USE_FULL_ASSERT 1 */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT + +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function which reports + * the name of the source file and the source line number of the call + * that failed. If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0) +#endif /* USE_FULL_ASSERT */ + +#endif /* __STM32F10x_CONF_H */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/stm32f10x_it.c b/STM32_4路称重_Git提交精简工程/src/USER/stm32f10x_it.c new file mode 100755 index 0000000..9b62a24 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/stm32f10x_it.c @@ -0,0 +1,87 @@ +/** + ****************************************************************************** + * @file GPIO/IOToggle/stm32f10x_it.c + * @author MCD Application Team + * @version V3.5.0 + * @date 08-April-2011 + * @brief Main Interrupt Service Routines. + * This file provides template for all exceptions handler and peripherals + * interrupt service routine. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x_it.h" + + + +void NMI_Handler(void) +{ +} + +void HardFault_Handler(void) +{ + /* Go to infinite loop when Hard Fault exception occurs */ + while (1) + { + } +} + +void MemManage_Handler(void) +{ + /* Go to infinite loop when Memory Manage exception occurs */ + while (1) + { + } +} + + +void BusFault_Handler(void) +{ + /* Go to infinite loop when Bus Fault exception occurs */ + while (1) + { + } +} + +void UsageFault_Handler(void) +{ + /* Go to infinite loop when Usage Fault exception occurs */ + while (1) + { + } +} + +void SVC_Handler(void) +{ +} + +void DebugMon_Handler(void) +{ +} + +void PendSV_Handler(void) +{ +} + +void SysTick_Handler(void) +{ +} + +/******************************************************************************/ +/* STM32F10x Peripherals Interrupt Handlers */ +/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ +/* available peripheral interrupt handler's name please refer to the startup */ +/* file (startup_stm32f10x_xx.s). */ +/******************************************************************************/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/stm32f10x_it.h b/STM32_4路称重_Git提交精简工程/src/USER/stm32f10x_it.h new file mode 100755 index 0000000..696633d --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/stm32f10x_it.h @@ -0,0 +1,46 @@ +/** + ****************************************************************************** + * @file GPIO/IOToggle/stm32f10x_it.h + * @author MCD Application Team + * @version V3.5.0 + * @date 08-April-2011 + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F10x_IT_H +#define __STM32F10x_IT_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f10x.h" + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +void NMI_Handler(void); +void HardFault_Handler(void); +void MemManage_Handler(void); +void BusFault_Handler(void); +void UsageFault_Handler(void); +void SVC_Handler(void); +void DebugMon_Handler(void); +void PendSV_Handler(void); +void SysTick_Handler(void); + +#endif /* __STM32F10x_IT_H */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/tcp_protocol.c b/STM32_4路称重_Git提交精简工程/src/USER/tcp_protocol.c new file mode 100755 index 0000000..262ccb4 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/tcp_protocol.c @@ -0,0 +1,1381 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ protocol.c + * Э鴦 + * V1.0 + * XuZhongPing + * 2017/03/16 +*********************************************************************************/ +#include "tcp_protocol.h" +#include "delay.h" +#include "usart1.h" +#include "usart2.h" +#include "usart3.h" +#include "message.h" +#include "string.h" +#include "stdlib.h" +#include "data_typedef.h" +#include "device.h" + + +protocol_TypeDef userInfoQuery; //ûϢѯָ +protocol_TypeDef tradingDataUpload; //ƷϴѯǷԳ + +uint16_t dataLength = 0; //һ֡ݵij +uint16_t operateType = 0; //ָ̨ +uint16_t sendOrderCode = 0x00; //̨͵Эָ +uint16_t recreceiveOrderCode = 0; //յ̨·Эָ +uint8_t TCP_recreceiveStatus = 0; //TCPݽձ־1ΪյTCPݣ0 + +/* +*********************************************************************** +* : ProtocolInit +* ˵: Эʼ +* Σ +* ֵ: +*********************************************************************** +*/ +void ProtocolInit(void) +{ + memset(GPRS_DATA_BUF, 0x00, GPRS_MAX_SEND_LEN); + + //λ̨ͨѶָ + userInfoQuery.protocolCode = 4002; + userInfoQuery.parseState = 0; + + tradingDataUpload.protocolCode = 4016; + tradingDataUpload.parseState = 0; + + //ŻλλͨѶָ +// VM_ProtocolInit(); +} + +/* +*********************************************************************** +* : CRC_Check +* ˵: λ +* Σ +* ֵ: +*********************************************************************** +*/ +static uint8_t CRC_Check(uint8_t *pData, uint16_t len) +{ + uint8_t crc; + uint16_t i; + //CRCУ + crc = *pData; + for(i = 0; i < len-1; i++) + { + crc ^= *(++pData); + } + return crc; +} + +/* +*********************************************************************** +* : ShowUploadData +* ˵: ʾϴͶ +* Σ +* ֵ: +*********************************************************************** +*/ +static void ShowUploadData(uint8_t type, uint16_t inputVal, uint8_t inputDistance) +{ + switch(type) + { + case PAPER: + printf("\r\nϴֽ = %2.2f Kg = %d cm\r\n", (float)inputVal/100, inputDistance); + break; + + case PLASTIC: + printf("\r\nϴ = %2.2f Kg = %d cm\r\n", (float)inputVal/100, inputDistance); + break; + + case GLASS: + printf("\r\nϴ = %2.2f Kg = %d cm\r\n", (float)inputVal/100, inputDistance); + break; + + case METAL: + printf("\r\nϴ = %2.2f Kg = %d cm\r\n", (float)inputVal/100, inputDistance); + break; + + case RECYCLED: + printf("\r\nϴɻ = %2.2f Kg = %d cm\r\n", (float)inputVal/100, inputDistance); + break; + + case KITCHEN: + printf("\r\nϴ = %2.2f Kg = %d cm\r\n", (float)inputVal/100, inputDistance); + break; + + case SMALL_BOTTLE: + printf("\r\nϴСƿ = %d = %d cm\r\n", inputVal, inputDistance); + break; + + case BIG_BOTTLE: + printf("\r\nϴƿ = %d = %d cm\r\n", inputVal, inputDistance); + break; + + case CANS: + printf("\r\nϴ = %d = %d cm\r\n", inputVal, inputDistance); + break; + + case BATTERY: + printf("\r\nϴ = %d = %d cm\r\n", inputVal, inputDistance); + break; + + case FABRIC: + printf("\r\nϴ֯ = %2.2f Kg = %d cm\r\n", (float)inputVal/100, inputDistance); + break; + + case BOOK: + printf("\r\nϴ鱾 = %2.2f Kg = %d cm\r\n", (float)inputVal/100, inputDistance); + break; + + case NEWSPAPER: + printf("\r\nϴֽ = %2.2f Kg = %d cm\r\n", (float)inputVal/100, inputDistance); + break; + + case KITCHEN_1: + printf("\r\nϴ1 = %2.2f Kg = %d cm\r\n", (float)inputVal/100, inputDistance); + break; + + case KITCHEN_2: + printf("\r\nϴ2 = %2.2f Kg = %d cm\r\n", (float)inputVal/100, inputDistance); + break; + + case PLASTIC_2: + printf("\r\nϴ2 = %2.2f Kg = %d cm\r\n", (float)inputVal/100, inputDistance); + break; + + case OTHER: + printf("\r\nϴ = %2.2f Kg = %d cm\r\n", (float)inputVal/100, inputDistance); + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : ShowDeviceRunningStatus +* ˵: ʾϴ豸״̬Ϣ +* Σ +* ֵ: +*********************************************************************** +*/ +static void ShowDeviceRunningStatus(uint8_t type, uint8_t inputDistance) +{ + switch(type) + { + case PAPER: + printf(" ֽ = %3.1f cm ", (float)inputDistance); + break; + + case PLASTIC: + printf(" = %3.1f cm ", (float)inputDistance); + break; + + case GLASS: + printf(" = %3.1f cm ", (float)inputDistance); + break; + + case METAL: + printf(" = %3.1f cm ", (float)inputDistance); + break; + + case RECYCLED: + printf(" ɻ = %3.1f cm ", (float)inputDistance); + break; + + case KITCHEN: + printf(" = %3.1f cm ", (float)inputDistance); + break; + + case SMALL_BOTTLE: + printf(" Сƿ = %3.1f cm ", (float)inputDistance); + break; + + case BIG_BOTTLE: + printf(" ƿ = %3.1f cm ", (float)inputDistance); + break; + + case CANS: + printf(" = %3.1f cm ", (float)inputDistance); + break; + + case BATTERY: + printf(" = %3.1f cm ", (float)inputDistance); + break; + + case FABRIC: + printf(" ֯ = %3.1f cm ", (float)inputDistance); + break; + + case BOOK: + printf(" 鱾 = %3.1f cm ", (float)inputDistance); + break; + + case NEWSPAPER: + printf(" ֽ = %3.1f cm ", (float)inputDistance); + break; + + case KITCHEN_1: + printf(" 1 = %3.1f cm ", (float)inputDistance); + break; + + case KITCHEN_2: + printf(" 2 = %3.1f cm ", (float)inputDistance); + break; + + case PLASTIC_2: + printf(" 2 = %3.1f cm ", (float)inputDistance); + break; + + case OTHER: + printf(" 2 = %3.1f cm ", (float)inputDistance); + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : ShowUploadAllData +* ˵: ʾϴͶݣǰݣ +* Σ +* ֵ: +*********************************************************************** +*/ +static void ShowUploadAllData(uint8_t type, uint16_t inputVal, uint8_t inputDistance, uint16_t beforeVal, uint16_t afterVal) +{ + switch(type) + { + case PAPER: + printf("\r\nϴֽ"); + break; + + case PLASTIC: + printf("\r\nϴ"); + break; + + case GLASS: + printf("\r\nϴ"); + break; + + case METAL: + printf("\r\nϴ"); + break; + + case RECYCLED: + printf("\r\nϴɻ"); + break; + + case KITCHEN: + printf("\r\nϴ"); + break; + + case SMALL_BOTTLE: + printf("\r\nϴСƿ = %d = %d cm\r\n", inputVal, inputDistance); + break; + + case BIG_BOTTLE: + printf("\r\nϴƿ = %d = %d cm\r\n", inputVal, inputDistance); + break; + + case CANS: + printf("\r\nϴ"); + break; + + case BATTERY: + printf("\r\nϴ"); + break; + + case FABRIC: + printf("\r\nϴ֯"); + break; + + case BOOK: + printf("\r\nϴ鱾"); + break; + + case NEWSPAPER: + printf("\r\nϴֽ"); + break; + + case KITCHEN_1: + printf("\r\nϴ1"); + break; + + case KITCHEN_2: + printf("\r\nϴ2"); + break; + + case PLASTIC_2: + printf("\r\nϴ2"); + + break; + + case OTHER: + printf("\r\nϴ"); + + break; + } + + printf(": %2.2f Kg%2.2f Kg -> %2.2f Kg룺%3.1f cm\r\n",\ + (float)inputVal/100, (float)beforeVal/100, (float)afterVal/100, (float)inputDistance); +} + +/* +*********************************************************************** +* : ProtocolPackaging +* ˵: Э +* Σ +* ֵ: +*********************************************************************** +*/ +uint16_t SendProtocolPackaging(uint16_t proNum) +{ + uint16_t proLen = 0; //Эܳ + uint16_t dataLen = 0; //͵ݳ + uint8_t crc; + uint16_t tmpeData; + uint8_t transformPutInType = 0; + + uint8_t len = 0; + + static uint16_t serial_number = 0; //Эˮ + + //֡ͷ + GPRS_DATA_BUF[0] = 0x48; + GPRS_DATA_BUF[1] = 0x45; + GPRS_DATA_BUF[2] = 0x52; + GPRS_DATA_BUF[3] = 0x4F; + proLen += 4; + + //2ֽݳȣɺ +// GPRS_DATA_BUF[proLen++] = (uint8_t)(dataLen >> 8); +// GPRS_DATA_BUF[proLen++] = (uint8_t)dataLen; + + proLen += 2; //2ֽڱݳ + //豸 + memcpy(&GPRS_DATA_BUF[proLen], gsm_msg.IMEI_HEX, 8); + proLen += 8; + + //ָ + GPRS_DATA_BUF[proLen++] = (uint8_t)(proNum >> 8); + GPRS_DATA_BUF[proLen++] = (uint8_t)proNum; + + //ط͵ݼݳ + switch(proNum) + { + case 1001: //ϴ + GPRS_DATA_BUF[proLen++] = 1; //豸ͣ1䣻2Ż3:POS + break; + + case 1003: //豸ӲϢϴ + GPRS_DATA_BUF[proLen++] = 0; //Э汾 + GPRS_DATA_BUF[proLen++] = 1; + + GPRS_DATA_BUF[proLen++] = 1; //豸ͣ1䣻2Ż3:POS + + len = strlen(VersionNumber); + GPRS_DATA_BUF[proLen++] = len; //Ӳ汾ų + memcpy(&GPRS_DATA_BUF[proLen], VersionNumber, len); //Ӳ汾 + proLen += len; + + len = strlen((const char*)deviceIdBuf); + GPRS_DATA_BUF[proLen++] = len; //豸ų + memcpy(&GPRS_DATA_BUF[proLen], deviceIdBuf, len); //豸 + proLen += len; + + memcpy(&GPRS_DATA_BUF[proLen], gsm_msg.ICCID, 20); //SIMICCID + proLen += 20; + + switch(deviceType) + { + case THREE_CLASSIFICATION: // + GPRS_DATA_BUF[proLen++] = 0; //豸ͺű + GPRS_DATA_BUF[proLen++] = deviceType; + + GPRS_DATA_BUF[proLen++] = 3; //Ͷ + + GPRS_DATA_BUF[proLen++] = devChannel1Type >> 8; //ͶͣǰΪ8λ + GPRS_DATA_BUF[proLen++] = devChannel1Type; + GPRS_DATA_BUF[proLen++] = 1; //Ͷͺ + + GPRS_DATA_BUF[proLen++] = devChannel2Type >> 8; + GPRS_DATA_BUF[proLen++] = devChannel2Type; + GPRS_DATA_BUF[proLen++] = 1; + + GPRS_DATA_BUF[proLen++] = devChannel3Type >> 8; + GPRS_DATA_BUF[proLen++] = devChannel3Type; + GPRS_DATA_BUF[proLen++] = 1; + break; + + case FOUR_CLASSIFICATION: //ķ + GPRS_DATA_BUF[proLen++] = 0; //豸ͺű + GPRS_DATA_BUF[proLen++] = deviceType; + + GPRS_DATA_BUF[proLen++] = 4; //Ͷ + + GPRS_DATA_BUF[proLen++] = devChannel1Type >> 8; //ͶͣǰΪ8λ + GPRS_DATA_BUF[proLen++] = devChannel1Type; + GPRS_DATA_BUF[proLen++] = 1; //Ͷͺ + + GPRS_DATA_BUF[proLen++] = devChannel2Type >> 8; + GPRS_DATA_BUF[proLen++] = devChannel2Type; + GPRS_DATA_BUF[proLen++] = 1; + + GPRS_DATA_BUF[proLen++] = devChannel3Type >> 8; + GPRS_DATA_BUF[proLen++] = devChannel3Type; + GPRS_DATA_BUF[proLen++] = 1; + + GPRS_DATA_BUF[proLen++] = devChannel4Type >> 8; + GPRS_DATA_BUF[proLen++] = devChannel4Type; + GPRS_DATA_BUF[proLen++] = 1; + break; + + } + + GPRS_DATA_BUF[proLen++] = 0; // + GPRS_DATA_BUF[proLen++] = 0; + GPRS_DATA_BUF[proLen++] = 0; + GPRS_DATA_BUF[proLen++] = 0; + GPRS_DATA_BUF[proLen++] = 0; + GPRS_DATA_BUF[proLen++] = 0; + GPRS_DATA_BUF[proLen++] = 0; + GPRS_DATA_BUF[proLen++] = 0; + + printf("\r\n汾: %s, len: %d\r\n", VersionNumber, strlen(VersionNumber)); + printf("\r\n豸: %s, len: %d\r\n", deviceIdBuf, strlen((const char*)deviceIdBuf)); + printf("\r\nICCID: %s\r\n", gsm_msg.ICCID); + + break; + + case 4001: //ȡûϢ + case 4011: //ȡûϢϢά룩ǰڵЭһĿϴظ,4401 + case 4201: //ȡûϢPOSȨƿͶŴϢά룩 + case 4401: //滻4011Ϣά룬ڴӡ + if(sendPutInType == 0x05) //άֽ + { + transformPutInType = 0x04; //ʹάѯûϢΪ0x04 + }else{ + transformPutInType = sendPutInType; + } + GPRS_DATA_BUF[proLen++] = transformPutInType; //ʶʽ + GPRS_DATA_BUF[proLen++] = sendDataLength; //Ϣij + memcpy(&GPRS_DATA_BUF[proLen], sendDataBuf, 33); //Ϣ + proLen += 33; + + printf("\r\nûݲѯ:"); + printf("\r\n--> Type: %d", sendPutInType); + printf("\r\n--> Len: %d", sendDataLength); + if(getPutInType == 1) + { + printf("\r\n--> Data: "); + show(sendDataBuf, sendDataLength); + }else{ + printf("\r\n--> Data: %s\r\n", sendDataBuf); + } + break; + + case 4301: //ڷǷܴͶſ + GPRS_DATA_BUF[proLen++] = 1; //豸ͣ1䣻2Ż3:POS + if(sendPutInType == 0x05) //άֽ + { + transformPutInType = 0x04; //ʹάѯûϢΪ0x04 + }else{ + transformPutInType = sendPutInType; + } + GPRS_DATA_BUF[proLen++] = transformPutInType; //ʶʽ + GPRS_DATA_BUF[proLen++] = sendDataLength; //Ϣij + memcpy(&GPRS_DATA_BUF[proLen], sendDataBuf, 33); //Ϣ + proLen += 33; + + printf("\r\nûݲѯ:"); + printf("\r\n--> Type: %d", sendPutInType); + printf("\r\n--> Len: %d", sendDataLength); + if(getPutInType == 1) + { + printf("\r\n--> Data: "); + show(sendDataBuf, sendDataLength); + }else{ + printf("\r\n--> Data: %s\r\n", sendDataBuf); + } +// show(sendDataBuf, 33); + break; + + case 4701: //ϴ + GPRS_DATA_BUF[proLen++] = collectorSendAuthType; //ʶʽ + GPRS_DATA_BUF[proLen++] = collectorSendDataLength; //Ϣij + memcpy(&GPRS_DATA_BUF[proLen], collectorSendDataBuf, 33); //Ϣ + proLen += 33; +// printf("\r\ntype%d\r\n", sendPutInType); +// printf("\r\nlen%d\r\n", sendDataLength); +// printf("\r\ndata%s\r\n", sendDataBuf); + +// show(GPRS_DATA_BUF, proLen); + +// show(sendDataBuf, 33); + break; + + case 4801: //Ͷϴ + GPRS_DATA_BUF[proLen++] = sendPutInType; //ʶʽ + GPRS_DATA_BUF[proLen++] = sendDataLength; //Ϣij + memcpy(&GPRS_DATA_BUF[proLen], sendDataBuf, 33); //Ϣ + proLen += 33; + + switch(deviceType) + { + case DOUBLE_CLASSIFICATION: //˫Ͱ480L + //ͰͶϴ + GPRS_DATA_BUF[proLen++] = leftBarrelType; //ࣩͣ + + GPRS_DATA_BUF[proLen++] = exceptionWeight1 >> 8; //8λ + GPRS_DATA_BUF[proLen++] = exceptionWeight1; + + GPRS_DATA_BUF[proLen++] = exceptionWeightBefore1 >> 8; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = exceptionWeightBefore1; + GPRS_DATA_BUF[proLen++] = exceptionWeightAfter1 >> 8; //ͶźͰ + GPRS_DATA_BUF[proLen++] = exceptionWeightAfter1; + + ShowUploadAllData(leftBarrelType, exceptionWeight1, getDistance1, exceptionWeightBefore1, exceptionWeightAfter1); + + //ͰͶϴ + GPRS_DATA_BUF[proLen++] = rightBarrelType; //ͣ + + GPRS_DATA_BUF[proLen++] = exceptionWeight2 >> 8; //8λ + GPRS_DATA_BUF[proLen++] = exceptionWeight2; + + GPRS_DATA_BUF[proLen++] = exceptionWeightBefore2 >> 8; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = exceptionWeightBefore2; + GPRS_DATA_BUF[proLen++] = exceptionWeightAfter2 >> 8; //ͶźͰ + GPRS_DATA_BUF[proLen++] = exceptionWeightAfter2; + + ShowUploadAllData(rightBarrelType, exceptionWeight2, getDistance2, exceptionWeightBefore2, exceptionWeightAfter2); + break; + + case DOUBLE_CLASSIFICATION_BOTTLE: //˫Ͱ480Lƿ + //ͰͶϴ + GPRS_DATA_BUF[proLen++] = leftBarrelType; //ɻ + + //ƿʱδ쳣 + smallBottleCount = 0; + + GPRS_DATA_BUF[proLen++] = smallBottleCount >> 8; //Сƿ8λ + GPRS_DATA_BUF[proLen++] = smallBottleCount; //Сƿ8λ + + GPRS_DATA_BUF[proLen++] = 0; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = 0; + GPRS_DATA_BUF[proLen++] = 0; //ͶźͰ + GPRS_DATA_BUF[proLen++] = 0; + + ShowUploadAllData(leftBarrelType, smallBottleCount, getDistance1, 0, 0); + + //ͰͶϴ + GPRS_DATA_BUF[proLen++] = rightBarrelType; // + + GPRS_DATA_BUF[proLen++] = exceptionWeight2 >> 8; //8λ + GPRS_DATA_BUF[proLen++] = exceptionWeight2; + + GPRS_DATA_BUF[proLen++] = exceptionWeightBefore2 >> 8; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = exceptionWeightBefore2; + GPRS_DATA_BUF[proLen++] = exceptionWeightAfter2 >> 8; //ͶźͰ + GPRS_DATA_BUF[proLen++] = exceptionWeightAfter2; + + ShowUploadAllData(rightBarrelType, exceptionWeight2, getDistance2, exceptionWeightBefore2, exceptionWeightAfter2); + break; + + case SINGLE_CLASSIFICATION: //Ͱ660L + //ͰͶϴ + GPRS_DATA_BUF[proLen++] = leftBarrelType; // + + GPRS_DATA_BUF[proLen++] = exceptionWeight1 >> 8; //8λ + GPRS_DATA_BUF[proLen++] = exceptionWeight1; + + GPRS_DATA_BUF[proLen++] = exceptionWeightBefore1 >> 8; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = exceptionWeightBefore1; + GPRS_DATA_BUF[proLen++] = exceptionWeightAfter1 >> 8; //ͶźͰ + GPRS_DATA_BUF[proLen++] = exceptionWeightAfter1; + + ShowUploadAllData(leftBarrelType, exceptionWeight1, getDistance1, exceptionWeightBefore1, exceptionWeightAfter1); + break; + + default: + break; + } + break; + + case 6001: //ϴͶ + GPRS_DATA_BUF[proLen++] = sendPutInType; //ʶʽ + GPRS_DATA_BUF[proLen++] = sendDataLength; //Ϣij + memcpy(&GPRS_DATA_BUF[proLen], sendDataBuf, 33); //Ϣ + proLen += 33; + + printf("\r\nsendUserData:"); + show(sendDataBuf, 33); + + switch(deviceType) + { + case DOUBLE_CLASSIFICATION: //˫Ͱ480L + //ͰϴͶ + GPRS_DATA_BUF[proLen++] = leftBarrelType; // + + GPRS_DATA_BUF[proLen++] = getWeight1 >> 8; //8λ + GPRS_DATA_BUF[proLen++] = getWeight1; + + GPRS_DATA_BUF[proLen++] = getDistance1; //ֵ + + ShowUploadData(leftBarrelType, getWeight1, getDistance1); //ʾϴϢ + + //ͰϴͶ + GPRS_DATA_BUF[proLen++] = rightBarrelType; // + + GPRS_DATA_BUF[proLen++] = getWeight2 >> 8; //8λ + GPRS_DATA_BUF[proLen++] = getWeight2; + + GPRS_DATA_BUF[proLen++] = getDistance2; //ֵ + + ShowUploadData(rightBarrelType, getWeight2, getDistance2); //ʾϴϢ + break; + + case DOUBLE_CLASSIFICATION_BOTTLE: //˫Ͱ480Lƿ + //ͰϴͶ + GPRS_DATA_BUF[proLen++] = leftBarrelType; //ɻ + + GPRS_DATA_BUF[proLen++] = smallBottleCount >> 8; //Сƿ8λ + GPRS_DATA_BUF[proLen++] = smallBottleCount; //Сƿ8λ + + GPRS_DATA_BUF[proLen++] = getDistance1; //ֵ + + ShowUploadData(leftBarrelType, smallBottleCount, getDistance1); //ʾϴϢ + + //ͰϴͶ + GPRS_DATA_BUF[proLen++] = rightBarrelType; // + + GPRS_DATA_BUF[proLen++] = getWeight2 >> 8; //8λ + GPRS_DATA_BUF[proLen++] = getWeight2; + + GPRS_DATA_BUF[proLen++] = getDistance2; //ֵ + + ShowUploadData(rightBarrelType, getWeight2, getDistance2); //ʾϴϢ + break; + + case SINGLE_CLASSIFICATION: //Ͱ660L + //ͰϴͶ + GPRS_DATA_BUF[proLen++] = leftBarrelType; //ֽࣩͣ + + GPRS_DATA_BUF[proLen++] = getWeight1 >> 8; //8λ + GPRS_DATA_BUF[proLen++] = getWeight1; + + GPRS_DATA_BUF[proLen++] = getDistance1; //ֵ + + ShowUploadData(leftBarrelType, getWeight1, getDistance1); //ʾϴϢ + break; + + default: + break; + } + + //Ԥֶ + GPRS_DATA_BUF[proLen++] = 0x00; + GPRS_DATA_BUF[proLen++] = 0x00; + GPRS_DATA_BUF[proLen++] = 0x00; + GPRS_DATA_BUF[proLen++] = 0x00; + + break; + +//-----------------------------ϴ豸״̬Ϣ¶ȡźšࣩ--------------------------------- + case 6004: //ϴ豸״̬Ϣ¶ȡźšࣩ + GPRS_DATA_BUF[proLen++] = 0x00; //¶ȱʾλ + tmpeData = temperature*10; + GPRS_DATA_BUF[proLen++] = tmpeData >> 8; //¶ȸ8λ + GPRS_DATA_BUF[proLen++] = tmpeData; //¶ȵ8λ + + GPRS_DATA_BUF[proLen++] = signal; //GSMź + + switch(deviceType) + { + case DOUBLE_CLASSIFICATION: //˫Ͱ480L + //Ͱϴ豸״̬Ϣ + GPRS_DATA_BUF[proLen++] = leftBarrelType; // + GPRS_DATA_BUF[proLen++] = getDistance1; //ֵ + + //Ͱϴ豸״̬Ϣ + GPRS_DATA_BUF[proLen++] = rightBarrelType; // + GPRS_DATA_BUF[proLen++] = getDistance2; //ֵ + + printf("\r\n-----> ϴ豸״̬Ϊ\r\n"); + printf("\r\n¶ = %2.1f , ", (float)temperature); + printf("ź = %d \r\n", signal); + printf("\r\nࣨ"); + ShowDeviceRunningStatus(leftBarrelType, getDistance1); + ShowDeviceRunningStatus(rightBarrelType, getDistance2); + printf("\r\n"); + break; + + case DOUBLE_CLASSIFICATION_BOTTLE: //˫Ͱ480Lƿ + //Ͱϴ豸״̬Ϣ + GPRS_DATA_BUF[proLen++] = leftBarrelType; // + GPRS_DATA_BUF[proLen++] = getDistance1; //ֵ + + //Ͱϴ豸״̬Ϣ + GPRS_DATA_BUF[proLen++] = rightBarrelType; // + GPRS_DATA_BUF[proLen++] = getDistance2; //ֵ + + printf("\r\n-----> ϴ豸״̬Ϊ\r\n"); + printf("\r\n¶ = %2.1f , ", (float)temperature); + printf("ź = %d \r\n", signal); + printf("\r\nࣨ"); + ShowDeviceRunningStatus(leftBarrelType, getDistance1); + ShowDeviceRunningStatus(rightBarrelType, getDistance2); + printf("\r\n"); + break; + + case SINGLE_CLASSIFICATION: //Ͱ660L + //Ͱϴ豸״̬Ϣ + GPRS_DATA_BUF[proLen++] = leftBarrelType; // + GPRS_DATA_BUF[proLen++] = getDistance1; //ֵ + + printf("\r\n-----> ϴ豸״̬Ϊ\r\n"); + printf("\r\n¶ = %2.1f , ", (float)temperature); + printf("ź = %d \r\n", signal); + printf("\r\nࣨ"); + ShowDeviceRunningStatus(leftBarrelType, getDistance1); + printf("\r\n"); + break; + + case THREE_CLASSIFICATION: // + //ص1ͨͶ + GPRS_DATA_BUF[proLen++] = devChannel1Type; // + GPRS_DATA_BUF[proLen++] = getDistance1; //ֵ + + //ص2ͨͶ + GPRS_DATA_BUF[proLen++] = devChannel2Type; // + GPRS_DATA_BUF[proLen++] = getDistance2; //ֵ + + //ص3ͨͶ + GPRS_DATA_BUF[proLen++] = devChannel3Type; // + GPRS_DATA_BUF[proLen++] = getDistance3; //ֵ + break; + + case FOUR_CLASSIFICATION: //ķ + //ص1ͨͶ + GPRS_DATA_BUF[proLen++] = devChannel1Type; // + GPRS_DATA_BUF[proLen++] = getDistance1; //ֵ + + //ص2ͨͶ + GPRS_DATA_BUF[proLen++] = devChannel2Type; // + GPRS_DATA_BUF[proLen++] = getDistance2; //ֵ + + //ص3ͨͶ + GPRS_DATA_BUF[proLen++] = devChannel3Type; // + GPRS_DATA_BUF[proLen++] = getDistance3; //ֵ + + //ص4ͨͶ + GPRS_DATA_BUF[proLen++] = devChannel4Type; // + GPRS_DATA_BUF[proLen++] = getDistance4; //ֵ + break; + + default: + break; + + } + break; + + case 6005: //ϴ豸 + switch(deviceType) + { + case DOUBLE_CLASSIFICATION: //˫Ͱ480L + GPRS_DATA_BUF[proLen++] = leftBarrelType; // + GPRS_DATA_BUF[proLen++] = 0x00; // + GPRS_DATA_BUF[proLen++] = faultCode_1; // + + GPRS_DATA_BUF[proLen++] = rightBarrelType; // + GPRS_DATA_BUF[proLen++] = 0x00; // + GPRS_DATA_BUF[proLen++] = faultCode_2; // + + printf("\r\n-----> ϴ\r\n"); + printf("\r\nͰ = %d, ", faultCode_1); + printf("Ͱ = %d\r\n", faultCode_2); + break; + + case DOUBLE_CLASSIFICATION_BOTTLE: //˫Ͱ480Lƿ + faultCode_1 = 0; //ĿǰƿͰûù + GPRS_DATA_BUF[proLen++] = leftBarrelType; // + GPRS_DATA_BUF[proLen++] = 0x00; // + GPRS_DATA_BUF[proLen++] = faultCode_1; // + + GPRS_DATA_BUF[proLen++] = rightBarrelType; // + GPRS_DATA_BUF[proLen++] = 0x00; // + GPRS_DATA_BUF[proLen++] = faultCode_2; // + + printf("\r\n-----> ϴ\r\n"); + printf("\r\nͰ = %d, ", faultCode_1); + printf("Ͱ = %d\r\n", faultCode_2); + break; + + case SINGLE_CLASSIFICATION: //Ͱ660L + GPRS_DATA_BUF[proLen++] = leftBarrelType; // + GPRS_DATA_BUF[proLen++] = 0x00; // + GPRS_DATA_BUF[proLen++] = faultCode_1; // + + printf("\r\n-----> ϴ\r\n"); + printf("\r\n = %d\r\n", faultCode_1); + break; + } + break; + +//-------------------------------------ɶ̨------------------------------------- + case 6008: //ɶ̨Э + + break; + +//-------------------------------------ϴûͶϢŵͰ------------------------------------- + case 6011: //ϴͶ + GPRS_DATA_BUF[proLen++] = sendPutInType; //ʶʽ + GPRS_DATA_BUF[proLen++] = sendDataLength; //Ϣij + memcpy(&GPRS_DATA_BUF[proLen], sendDataBuf, 33); //Ϣ + proLen += 33; + +// printf("\r\nsendUserData:"); +// show(sendDataBuf, 33); + + switch(deviceType) + { + case DOUBLE_CLASSIFICATION: //˫Ͱ480L + //ͰͶϴ + GPRS_DATA_BUF[proLen++] = leftBarrelType; //ࣩͣ + + GPRS_DATA_BUF[proLen++] = getWeight1 >> 8; //8λ + GPRS_DATA_BUF[proLen++] = getWeight1; + + GPRS_DATA_BUF[proLen++] = getDistance1; //ֵ + + GPRS_DATA_BUF[proLen++] = getWeightBefore1 >> 8; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = getWeightBefore1; + GPRS_DATA_BUF[proLen++] = getWeightAfter1 >> 8; //ͶźͰ + GPRS_DATA_BUF[proLen++] = getWeightAfter1; + + ShowUploadAllData(leftBarrelType, getWeight1, getDistance1, getWeightBefore1, getWeightAfter1); + + //ͰͶϴ + GPRS_DATA_BUF[proLen++] = rightBarrelType; //ͣ + + GPRS_DATA_BUF[proLen++] = getWeight2 >> 8; //8λ + GPRS_DATA_BUF[proLen++] = getWeight2; + + GPRS_DATA_BUF[proLen++] = getDistance2; //ֵ + + GPRS_DATA_BUF[proLen++] = getWeightBefore2 >> 8; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = getWeightBefore2; + GPRS_DATA_BUF[proLen++] = getWeightAfter2 >> 8; //ͶźͰ + GPRS_DATA_BUF[proLen++] = getWeightAfter2; + + ShowUploadAllData(rightBarrelType, getWeight2, getDistance2, getWeightBefore2, getWeightAfter2); + break; + + case DOUBLE_CLASSIFICATION_BOTTLE: //˫Ͱ480Lƿ + //ͰͶϴ + GPRS_DATA_BUF[proLen++] = leftBarrelType; //ɻ + + GPRS_DATA_BUF[proLen++] = smallBottleCount >> 8; //Сƿ8λ + GPRS_DATA_BUF[proLen++] = smallBottleCount; //Сƿ8λ + + GPRS_DATA_BUF[proLen++] = getDistance1; //ֵ + + GPRS_DATA_BUF[proLen++] = 0; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = 0; + GPRS_DATA_BUF[proLen++] = 0; //ͶźͰ + GPRS_DATA_BUF[proLen++] = 0; + + ShowUploadAllData(leftBarrelType, smallBottleCount, getDistance1, 0, 0); + + //ͰͶϴ + GPRS_DATA_BUF[proLen++] = rightBarrelType; // + + GPRS_DATA_BUF[proLen++] = getWeight2 >> 8; //8λ + GPRS_DATA_BUF[proLen++] = getWeight2; + + GPRS_DATA_BUF[proLen++] = getDistance2; //ֵ + + GPRS_DATA_BUF[proLen++] = getWeightBefore2 >> 8; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = getWeightBefore2; + GPRS_DATA_BUF[proLen++] = getWeightAfter2 >> 8; //ͶźͰ + GPRS_DATA_BUF[proLen++] = getWeightAfter2; + + ShowUploadAllData(rightBarrelType, getWeight2, getDistance2, getWeightBefore2, getWeightAfter2); + break; + + case SINGLE_CLASSIFICATION: //Ͱ660L + //ͰͶϴ + GPRS_DATA_BUF[proLen++] = leftBarrelType; // + + GPRS_DATA_BUF[proLen++] = getWeight1 >> 8; //8λ + GPRS_DATA_BUF[proLen++] = getWeight1; + + GPRS_DATA_BUF[proLen++] = getDistance1; //ֵ + + GPRS_DATA_BUF[proLen++] = getWeightBefore1 >> 8; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = getWeightBefore1; + GPRS_DATA_BUF[proLen++] = getWeightAfter1 >> 8; //ͶźͰ + GPRS_DATA_BUF[proLen++] = getWeightAfter1; + + ShowUploadAllData(leftBarrelType, getWeight1, getDistance1, getWeightBefore1, getWeightAfter1); + break; + + case THREE_CLASSIFICATION: // + //ص1ͨͶ + GPRS_DATA_BUF[proLen++] = devChannel1Type; // + + GPRS_DATA_BUF[proLen++] = getWeight1 >> 8; // + GPRS_DATA_BUF[proLen++] = getWeight1; + + GPRS_DATA_BUF[proLen++] = getDistance1; //ֵ + + GPRS_DATA_BUF[proLen++] = getWeightBefore1 >> 8; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = getWeightBefore1; + GPRS_DATA_BUF[proLen++] = getWeightAfter1 >> 8; //ͶźͰ + GPRS_DATA_BUF[proLen++] = getWeightAfter1; + + ShowUploadAllData(devChannel1Type, getWeight1, getDistance1, getWeightBefore1, getWeightAfter1); + + //ص2ͨͶ + GPRS_DATA_BUF[proLen++] = devChannel2Type; // + + GPRS_DATA_BUF[proLen++] = getWeight2 >> 8; // + GPRS_DATA_BUF[proLen++] = getWeight2; + + GPRS_DATA_BUF[proLen++] = getDistance2; //ֵ + + GPRS_DATA_BUF[proLen++] = getWeightBefore2 >> 8; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = getWeightBefore2; + GPRS_DATA_BUF[proLen++] = getWeightAfter2 >> 8; //ͶźͰ + GPRS_DATA_BUF[proLen++] = getWeightAfter2; + + ShowUploadAllData(devChannel2Type, getWeight2, getDistance2, getWeightBefore2, getWeightAfter2); + + //ص3ͨͶ + GPRS_DATA_BUF[proLen++] = devChannel3Type; // + + GPRS_DATA_BUF[proLen++] = getWeight3 >> 8; // + GPRS_DATA_BUF[proLen++] = getWeight3; + + GPRS_DATA_BUF[proLen++] = getDistance3; //ֵ + + GPRS_DATA_BUF[proLen++] = getWeightBefore3 >> 8; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = getWeightBefore3; + GPRS_DATA_BUF[proLen++] = getWeightAfter3 >> 8; //ͶźͰ + GPRS_DATA_BUF[proLen++] = getWeightAfter3; + + ShowUploadAllData(devChannel3Type, getWeight3, getDistance3, getWeightBefore3, getWeightAfter3); + break; + + case FOUR_CLASSIFICATION: //ķ + //ص1ͨͶ + GPRS_DATA_BUF[proLen++] = devChannel1Type; // + + GPRS_DATA_BUF[proLen++] = getWeight1 >> 8; // + GPRS_DATA_BUF[proLen++] = getWeight1; + + GPRS_DATA_BUF[proLen++] = getDistance1; //ֵ + + GPRS_DATA_BUF[proLen++] = getWeightBefore1 >> 8; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = getWeightBefore1; + GPRS_DATA_BUF[proLen++] = getWeightAfter1 >> 8; //ͶźͰ + GPRS_DATA_BUF[proLen++] = getWeightAfter1; + + ShowUploadAllData(devChannel1Type, getWeight1, getDistance1, getWeightBefore1, getWeightAfter1); + + //ص2ͨͶ + GPRS_DATA_BUF[proLen++] = devChannel2Type; // + + GPRS_DATA_BUF[proLen++] = getWeight2 >> 8; // + GPRS_DATA_BUF[proLen++] = getWeight2; + + GPRS_DATA_BUF[proLen++] = getDistance2; //ֵ + + GPRS_DATA_BUF[proLen++] = getWeightBefore2 >> 8; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = getWeightBefore2; + GPRS_DATA_BUF[proLen++] = getWeightAfter2 >> 8; //ͶźͰ + GPRS_DATA_BUF[proLen++] = getWeightAfter2; + + ShowUploadAllData(devChannel2Type, getWeight2, getDistance2, getWeightBefore2, getWeightAfter2); + + //ص3ͨͶ + GPRS_DATA_BUF[proLen++] = devChannel3Type; // + + GPRS_DATA_BUF[proLen++] = getWeight3 >> 8; // + GPRS_DATA_BUF[proLen++] = getWeight3; + + GPRS_DATA_BUF[proLen++] = getDistance3; //ֵ + + GPRS_DATA_BUF[proLen++] = getWeightBefore3 >> 8; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = getWeightBefore3; + GPRS_DATA_BUF[proLen++] = getWeightAfter3 >> 8; //ͶźͰ + GPRS_DATA_BUF[proLen++] = getWeightAfter3; + + ShowUploadAllData(devChannel3Type, getWeight3, getDistance3, getWeightBefore3, getWeightAfter3); + + //ص4ͨͶ + GPRS_DATA_BUF[proLen++] = devChannel4Type; // + + GPRS_DATA_BUF[proLen++] = getWeight4 >> 8; // + GPRS_DATA_BUF[proLen++] = getWeight4; + + GPRS_DATA_BUF[proLen++] = getDistance4; //ֵ + + GPRS_DATA_BUF[proLen++] = getWeightBefore4 >> 8; //ͶǰͰ + GPRS_DATA_BUF[proLen++] = getWeightBefore4; + GPRS_DATA_BUF[proLen++] = getWeightAfter4 >> 8; //ͶźͰ + GPRS_DATA_BUF[proLen++] = getWeightAfter4; + + ShowUploadAllData(devChannel4Type, getWeight4, getDistance4, getWeightBefore4, getWeightAfter4); + break; + + default: + break; + } + break; + + } + //ˮ + GPRS_DATA_BUF[proLen++] = (uint8_t)serial_number >> 8; + GPRS_DATA_BUF[proLen++] = (uint8_t)serial_number; + + crc = CRC_Check(&GPRS_DATA_BUF[6], proLen - 6); //ȥ֡ͷͳ6ֽ + + //CRCУ + GPRS_DATA_BUF[proLen++] = crc; + + //͵ݳ + dataLen = proLen - 6; //Эܳ - 4ֽ֡ͷ + 2ֽڳȣ + + GPRS_DATA_BUF[4] = (uint8_t)(dataLen >> 8); + GPRS_DATA_BUF[5] = (uint8_t)dataLen; + + printf("\r\nTCP --> No = %4d; Len = %d\r\n", proNum, proLen); +// show(GPRS_DATA_BUF, proLen); + + serial_number++; + return proLen; //رЭܳ +} + +/* +*********************************************************************** +* : GetOrderCode +* ˵: ȡָ +* Σ +* ֵ: յݵָ +*********************************************************************** +*/ +uint16_t GetOrderCode(uint8_t *pInputData) +{ + uint16_t returnData; + returnData = pInputData[14] << 8; + returnData |= pInputData[15]; + return returnData; +} + +/* +*********************************************************************** +* : CheckOrderCodeUploadAck +* ˵: ָϴǷɹӦ +* Σ +* ֵ: յݵָ +*********************************************************************** +*/ +uint8_t CheckOrderCodeUploadAck(uint16_t upCmd, uint16_t ackCmd) +{ + uint8_t returnSta = 0; + + switch(upCmd) + { + case 1001: if(ackCmd == 10011) returnSta = 1; break; + case 1003: if(ackCmd == 1003) returnSta = 1; break; + case 2001: if(ackCmd == 2001) returnSta = 1; break; + case 2003: if(ackCmd == 2003) returnSta = 1; break; + case 4001: if(ackCmd == 4002) returnSta = 1; break; + case 4011: if(ackCmd == 4022) returnSta = 1; break; + case 4201: if(ackCmd == 4202) returnSta = 1; break; + case 4301: if(ackCmd == 4302) returnSta = 1; break; + case 4401: if(ackCmd == 4402) returnSta = 1; break; + case 4111: if(ackCmd == 4222) returnSta = 1; break; + case 6011: if(ackCmd == 60011) returnSta = 1; break; + case 6021: if(ackCmd == 6021) returnSta = 1; break; + case 4701: if(ackCmd == 4702) returnSta = 1; break; + case 4801: if(ackCmd == 4802) returnSta = 1; break; + case 4901: if(ackCmd == 4901) returnSta = 1; break; + case 5001: if(ackCmd == 5001) returnSta = 1; break; + case 5002: if(ackCmd == 5002) returnSta = 1; break; + case 6004: if(ackCmd == 60041) returnSta = 1; break; + + + default: + break; + } + return returnSta; +} + +/* +*********************************************************************** +* : ProtocolParsing +* ˵: ԽյݽЭ +* Σ +* ֵ: +*********************************************************************** +*/ +void TCP_Protocol(uint8_t* pCdmStr, uint8_t length) +{ + char *p; + uint8_t *pdata; //صָ + uint32_t dataTemp; + uint8_t tempData[32]; + +// p = (char*)strstr((const char*)pCdmStr, ":"); +// pdata = (uint8_t*)(p + 1); + + pdata = pCdmStr; + + if((*(pdata) == 'H') && (*(pdata+1) == 'E') && (*(pdata+2) == 'R') && (*(pdata+3) == 'O')) //ǺϷЭ + { + TCP_recreceiveStatus = 1; //־յTCP + recreceiveOrderCode = GetOrderCode(pdata); //Ӧָ + + //ӡյĺ̨ +// printf("\r\nS -> %d \r\n", recreceiveOrderCode); +// show(pCdmStr, length); + + if(CheckOrderCodeUploadAck(sendOrderCode, recreceiveOrderCode)) + { + receiveDataMark = 1; + } + + switch(recreceiveOrderCode) //ָݵĽ + { + case 10011: + pdata += 16; + getDeviceWorkStatusVal = *(pdata++); + getDeviceWorkStatusMark = 1; + break; + + case 4002: //ûѯϢ + //ȡǷ֤ͨ + pdata += 16; + isAuth = *(pdata++); + + //ûID + dataTemp = *(pdata++) << 24; + dataTemp |= *(pdata++) << 16; + dataTemp |= *(pdata++) << 8; + dataTemp |= *(pdata++); + userID = dataTemp; + + //û˺ + dataTemp = *(pdata++) << 24; + dataTemp |= *(pdata++) << 16; + dataTemp |= *(pdata++) << 8; + dataTemp |= *(pdata++); + accountNum = dataTemp; + + //ȡdzƵij + nickNameLength = *(pdata++); + if(nickNameLength > 64) + { + printf("\r\nData overflow\r\n"); + memcpy(nickName, pdata, 64); + + }else{ + //ȡdz + memcpy(nickName, pdata, nickNameLength); + } + pdata += nickNameLength; + + //ȡʽ + dataTemp = *(pdata++) << 24; + dataTemp |= *(pdata++) << 16; + dataTemp |= *(pdata++) << 8; + dataTemp |= *(pdata++); + capital = dataTemp; + + //ȡ + residue = *(pdata++); + + userInfoQueryStatus = 1; //ûϢѯɹⲿ + +// printf("\r\nisAuth = %x \r\n", isAuth); +// printf("\r\nuserID = %4x \r\n", userID); +// printf("\r\naccountNum = %4x \r\n", accountNum); +// printf("\r\nnickNameLength = %x \r\n", nickNameLength); +// show(nickName, 20); +// printf("\r\ncapital = %4x \r\n", capital); +// printf("\r\nresidue = %x \r\n", residue); + break; + + //ûѯϢûĹ̶ݶάϢ + case 4022: //ǰڵЭһĿϴظ,4402 + case 4202: //ȡûϢPOSȨƿͶŴϢά룩 + case 4302: //ڷǷܴͶſ + case 4402: //滻4011Ϣά룬ڴӡ + //ȡǷ֤ͨ + pdata += 16; + isAuth = *(pdata++); + + //ûID + dataTemp = *(pdata++) << 24; + dataTemp |= *(pdata++) << 16; + dataTemp |= *(pdata++) << 8; + dataTemp |= *(pdata++); + userID = dataTemp; + + //û˺ + dataTemp = *(pdata++) << 24; + dataTemp |= *(pdata++) << 16; + dataTemp |= *(pdata++) << 8; + dataTemp |= *(pdata++); + accountNum = dataTemp; + + //ȡdzƵij + nickNameLength = *(pdata++); + if(nickNameLength > 64) + { + printf("\r\nData overflow\r\n"); + memcpy(nickName, pdata, 64); + + }else{ + //ȡdz + memcpy(nickName, pdata, nickNameLength); + } + pdata += nickNameLength; + + //ȡʽ + dataTemp = *(pdata++) << 24; + dataTemp |= *(pdata++) << 16; + dataTemp |= *(pdata++) << 8; + dataTemp |= *(pdata++); + capital = dataTemp; + + //ȡ + residue = *(pdata++); + + //ȡûIDάϢûӡά룩 + barcodeLength = *(pdata++); + memset(tempData, 0, 32); + + if(barcodeLength > 32) + { + printf("\r\nData overflow\r\n"); + memcpy(tempData, pdata, 32); + }else{ + memcpy(tempData, pdata, barcodeLength); + } + + sprintf((char*)barcode, "yueng=%s", (char*)tempData); //̨صûIDάûаͷϢ"yueng=" + barcodeLength += 6; + + userInfoQueryStatus = 1; //ûϢѯɹⲿ +// +// printf("\r\nisAuth = %x \r\n", isAuth); +// printf("\r\nuserID = %4x \r\n", userID); +// printf("\r\naccountNum = %4x \r\n", accountNum); +// printf("\r\nnickNameLength = %x \r\n", nickNameLength); +// show(nickName, 20); +// printf("\r\ncapital = %4x \r\n", capital); +// printf("\r\nresidue = %x \r\n", residue); +// printf("\r\nbarcode = %s \r\n", barcode); + break; + + case 4702: //˺֤Ӧ + pdata += 16; + + boxOpenAckStatus = *(pdata++); + getBoxOpenAckMark = 1; + break; + + case 60011: + pdata += 16; + //ȡʽ + dataTemp = *(pdata++) << 24; + dataTemp |= *(pdata++) << 16; + dataTemp |= *(pdata++) << 8; + dataTemp |= *(pdata++); + capitalAfter = dataTemp; + + putInUploadSuccessMark = 1; + + break; + + case 60041: //̨Ӧ豸״̬ϴ + pdata += 16; + + getDevChannelNumbers = *(pdata++); + + if((getDevChannelNumbers >= 1) && (getDevChannelNumbers <= 4)) + { + getDevChannel1Type = *(pdata++); + getDevChannel1DisDepthVal = *(pdata++); + getDevChannel1DisMaxVal = *(pdata++); + getDevChannel1DisAlarmPercent = *(pdata++); + + if(getDevChannelNumbers >= 2) + { + getDevChannel2Type = *(pdata++); + getDevChannel2DisDepthVal = *(pdata++); + getDevChannel2DisMaxVal = *(pdata++); + getDevChannel2DisAlarmPercent = *(pdata++); + } + + if(getDevChannelNumbers >= 3) + { + getDevChannel3Type = *(pdata++); + getDevChannel3DisDepthVal = *(pdata++); + getDevChannel3DisMaxVal = *(pdata++); + getDevChannel3DisAlarmPercent = *(pdata++); + } + + if(getDevChannelNumbers >= 4) + { + getDevChannel4Type = *(pdata++); + getDevChannel4DisDepthVal = *(pdata++); + getDevChannel4DisMaxVal = *(pdata++); + getDevChannel4DisAlarmPercent = *(pdata++); + } + + getSetDistanceParamMark = 1; + }else{} + + break; + + default: + break; + } + } + memset(GPRS_RX_BUF, 0, GPRS_MAX_RECV_LEN); +} + +/* +*********************************************************************** +* : SetSendProcotolSuccess +* ˵: ñη͵Эѳɹ +* Σ +* ֵ: +*********************************************************************** +*/ +void SetSendProcotolSuccess(void) +{ + switch(sendOrderCode) + { + case 6008: +// printf("\r\nϴɹ\r\n"); +// uploadWightMark = 1; +// SendScaleUploadOkMark(); + break; + + default: + break; + } +} + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/tcp_protocol.h b/STM32_4路称重_Git提交精简工程/src/USER/tcp_protocol.h new file mode 100755 index 0000000..006f5b5 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/tcp_protocol.h @@ -0,0 +1,26 @@ +#ifndef __PROTOCOL_H +#define __PROTOCOL_H +#include "stm32f10x.h" + +//ͨѶЭṹ +typedef struct _protocol +{ + uint16_t protocolCode; //ָ + uint8_t parseState; //Ϣ +} protocol_TypeDef; + +extern uint16_t dataLength; //һ֡ݵij +extern uint16_t operateType; //ָ̨ +extern uint16_t sendOrderCode; //̨͵Эָ +extern uint16_t recreceiveOrderCode; //յ̨·Эָ +extern uint8_t TCP_recreceiveStatus; //TCPݽձ־1ΪյTCPݣ0 + +void ProtocolInit(void); +uint16_t SendProtocolPackaging(uint16_t proNum); +void TCP_Protocol(uint8_t* pCdmStr, uint8_t length); + +void SetSendProcotolSuccess(void); + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/user_app.c b/STM32_4路称重_Git提交精简工程/src/USER/user_app.c new file mode 100755 index 0000000..2cd9120 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/user_app.c @@ -0,0 +1,1661 @@ +/*************************** (C) COPYRIGHT 2017 Ping **************************** + * ļ user_app.c + * ûӦó + * V1.0 + * XuZhongPing + * 2017/09/04 +*********************************************************************************/ +#include "user_app.h" +#include "usart1.h" +#include "delay.h" +#include "timer.h" +#include "display.h" + +#include "sound.h" +#include "pc_protocol.h" +#include "stmflash.h" +#include "user_manag.h" +#include "deviceSet.h" + +/* +*********************************************************************** +* : showHexData +* ˵: ʮʾ +* : +* ֵ: +*********************************************************************** +*/ +void showHexData(uint8_t num[], uint8_t n) +{ + uint8_t i; + printf("\r\n"); + for(i=0; i 0)) + { + beep_shortBeepMark = 1; + + sendPutInType = 0; + sendDataLength = 0; + memset(sendDataBuf, 0, 256); + + sendPutInType = getPutInType; + sendDataLength = getDataLength; + memcpy(sendDataBuf, getDataBuf, getDataLength); + + printf("\r\nûʶ\r\n"); + printf("Type: %d\r\n", sendPutInType); + printf("Len: %d\r\n", sendDataLength); + printf("DataBuf: %s\r\n", sendDataBuf); + + PC_ProCommandSend(0x01); + } +} + +/* +*********************************************************************** +* : GetPutInType +* ˵: ȡͶſŷʽ +* Σ +* ֵ: 0x01->IC0x02->ά룻0x03->룻0x04-> ť +*********************************************************************** +*/ +uint8_t GetPutInType(void) +{ + uint8_t retData; + if(keyOpenDoorRequest == 1) //Űťж + { + retData = 0x04; + keyOpenDoorRequest = 0; + }else if((RFID_state == 1) || (scanIC_2CodeState == 1)){ //ˢICICάж + retData = 0x01; + RFID_state = 0; + scanIC_2CodeState = 0; + }else if(sweep2CodeState == 1){ //άɨж + retData = 0x02; + sweep2CodeState = 0; + }else if(scanBarCodeState == 1){ //ɨά + retData = 0x03; + scanBarCodeState = 0; + }else if(scanLabelCodeState == 1){ //άֽ2018-04-28 + retData = 0x05; + scanLabelCodeState = 0; + }else if(RFID_state == 3){ //п + if(cardNumberLen == 10) //ųΪ10λԶ忨ţ + { + retData = 0x0A; + }else{ //пΪɫ + retData = 0x07; + } + RFID_state = 0; + }else if(RFID_state == 4){ //֤ + retData = 0x08; + RFID_state = 0; + }else if(RFID_state == 5){ //IC + retData = 0x09; + RFID_state = 0; + }else{ + retData = 0x00; + } + return retData; +} + +/* +*********************************************************************** +* : GetUserInfo +* ˵: ûĿŷʽȡûϢICά룩 +* ΣinputType->ûŷʽICά룩 +* ֵ: ޣúıȫֱgetDataLengthgetDataBufֵ +*********************************************************************** +*/ +void GetUserInfo(uint8_t inputType) +{ + uint8_t dataBuf[17] = {0}; + + switch(inputType) //ݿʽضӦϢ + { + case 0x01: //ˢIC + getDataLength = 9; //ICϢΪ9ֽ + memcpy(getDataBuf, RFID_ID, 9); //ICϢ + memcpy(get_IC_ID, RFID_ID, 9); //ICϢ + memcpy(getCardNumberBit, cardNumberBit, 17); //ICϢλʾ +// printf("\r\ngetDataLength = %d\r\n", getDataLength); +// printf("\r\nRFID = %x\r\n", RFID_ID[0]); + break; + + case 0x02: //ɨά뿪 + getDataLength = codeDataLength; //άϢ + memcpy(getDataBuf, codeBuf, codeDataLength); //ά뷢Ϣ + memset(codeBuf, 0x00, 35); // +// printf("\r\ngetDataLength = %d\r\n", getDataLength); + break; + + case 0x03: //ά뿪 + getDataLength = codeDataLength; //άϢ + memcpy(getDataBuf, codeBuf, codeDataLength); //ά뷢Ϣ + memset(codeBuf, 0x00, 35); // + break; + + case 0x04: //ťϢ + getDataLength = 0; + break; + + case 0x05: //άֽ + getDataLength = codeDataLength; //άϢ + memcpy(getDataBuf, codeBuf, codeDataLength); //ά뷢Ϣ + memset(codeBuf, 0x00, 35); // + break; + + case 0x07: //п + case 0x0A: //п(Զ忨) + getDataLength = cardNumberLen; + memcpy(getDataBuf, cardNumberStr, getDataLength); + + memcpy(&dataBuf[11], &cardNumberBit[getDataLength-6], 6); //ȡŵĺ6λʾ + memcpy(getCardNumberBit, dataBuf, 17); + memset(cardNumberStr, 0x00, 33); + break; + + case 0x09: //IC + getDataLength = 24; //άϢ + memcpy(getDataBuf, cardNumberStr, getDataLength); //ά뷢Ϣ + memset(cardNumberStr, 0x00, 33); // + break; + } +} + +/* +*********************************************************************** +* : ShowPutInMSG +* ˵: ʾͶſͼʶϢ +* ΣͶ0x01->IC0x02->ά룻0x03->룻0x04-> ť +* ֵ: +*********************************************************************** +*/ +void ShowPutInInfo(uint8_t uType) +{ + switch(uType) //ݿʽضӦϢ + { + case 0x01: //ˢIC + printf("\r\nˢICɨICά뿪\r\n"); + break; + + case 0x02: //ɨά뿪 + printf("\r\nɨά뿪\r\n"); + break; + + case 0x03: //뿪 + printf("\r\nɨά뿪\r\n"); + break; + + case 0x04: //ťϢ + printf("\r\nť\r\n"); + break; + + case 0x05: //άֽ + printf("\r\nάֽ\r\n"); + break; + } + + printf("\r\nûʶϢΪ\r\n"); + printf("\r\n <>ͣ%d\r\n", getPutInType); + printf("\r\n <>ݳȣ%d\r\n", getDataLength); +// printf("\r\n <>ݣ%s\r\n", getDataBuf); +// showHexData(getDataBuf, 33); +} + +/* +*********************************************************************** +* : ClearPutInInfo +* ˵: ͶɺͶϢΪһ׼ +* Σ +* ֵ: +*********************************************************************** +*/ +void ClearPutInInfo(void) +{ + keyOpenDoorRequest = 0; //ť±־ + RFID_state = 0; //RFID_ICˢ־ + scanIC_2CodeState = 0; //ɨICά뿨ű־ + sweep2CodeState = 0; //άɨ־ + scanBarCodeState = 0; //ɨά־ + scanLabelCodeState = 0; + + optoKeyStatus = 0; + putInProgress = 0; + + getPutInType = 0x00; //֤ + getDataLength = 0x00; //֤Ϣݳ + memset(getDataBuf, 0x00, 33); //֤Ϣ + memset(get_IC_ID, 0x00, 9); //ȡõIC + memset(getCardNumberBit, 0x00, 17); //ȡõIC +} + +/* +*********************************************************************** +* : FaultCodeCheck +* ˵: 豸⣬1:ʾйϴ +* 0:ʾûйϲϴ +* Σ +* ֵ: +*********************************************************************** +*/ +#define codeLen 9 +uint8_t faultCode[codeLen] = {11, 12, 13, 22, 23, 24, 32, 33, 34}; //ϴ + +static void FaultCodeCheck(uint8_t devType) +{ + uint8_t i = 0; + uint8_t faultMark = 0; + + switch(devType) + { + case DOUBLE_CLASSIFICATION: //˫Ͱ480L + for(i = 0; i < codeLen; i++) + { + if((faultCode_1 == faultCode[i]) || (faultCode_2 == faultCode[i])) + { + faultMark = 1; + break; + } + } + break; + + case DOUBLE_CLASSIFICATION_BOTTLE: //˫Ͱ480Lƿӣ + for(i = 0; i < codeLen; i++) + { + if(faultCode_1 == faultCode[i]) + { + faultMark = 1; + break; + } + } + break; + + case SINGLE_CLASSIFICATION: //Ͱ660L + for(i = 0; i < codeLen; i++) + { + if(faultCode_1 == faultCode[i]) + { + faultMark = 1; + break; + } + } + break; + + default: + break; + } + + if(faultMark == 1) //йϴ + { + sendMsg.msgType = 6005; //ϴϴ + MessageSend(MSG_FIFO_PROTOCOL, sendMsg); + } +} + +/* +*********************************************************************** +* : GetLimitKeyStatus +* ˵: ȡλص״̬ +* Σ +* ֵ: λλ״̬1쳣0 +*********************************************************************** +*/ +uint8_t GetLimitKeyStatus(void) +{ + uint8_t retData = 0; + + if(limitKeyExceptionMark > 0) + { + switch(deviceType) + { + case DOUBLE_CLASSIFICATION: //˫Ͱ480L + if(limitKeyExceptionMark & 0x10) + { + faultCode_1 = 20; + } + if(limitKeyExceptionMark & 0x01) + { + faultCode_2 = 20; + } + break; + + case DOUBLE_CLASSIFICATION_BOTTLE: + faultCode_1 = 0; //ĿǰƿͰûù + if(limitKeyExceptionMark & 0x10) //ߵλ + { + faultCode_2 = 20; + } + break; + + case SINGLE_CLASSIFICATION: //Ͱ660L + if(limitKeyExceptionMark & 0x10) + { + faultCode_1 = 20; + } + faultCode_2 = 0; + break; + + default: + break; + } + + displayFaultCode = 20; + retData = 1; + } + return retData; +} + +/* +*********************************************************************** +* : PutInOpenDoorTask +* ˵: Ͷ +* Σ +* ֵ: +*********************************************************************** +*/ +void PutInOpenDoorTask(void) +{ + uint8_t tempData = 0; + uint8_t temp = 0; + static uint8_t putInStatus = 0x00; + static uint8_t infoDisplayStatus = 0; + + static uint8_t putInPrompt = 0; //ͶʾţÿһβһΣ + + static timer waitingTimer; + static timer playWaitingTimer; + static timer waitingPutInTimer; + static timer displayTimer; + static timer waitingUploadTimer; + static timer outTimer; + static timer waitingTimer4S; + static timer faceEntryTimer; + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&waitingTimer, 10); + timer_set(&playWaitingTimer, 15); + timer_set(&waitingPutInTimer, CLOCK_SECOND*200); + timer_set(&displayTimer, CLOCK_SECOND*3); + timer_set(&waitingUploadTimer, CLOCK_SECOND*10); + timer_set(&outTimer, CLOCK_SECOND*2); + timer_set(&waitingTimer4S, CLOCK_SECOND*3); + timer_set(&faceEntryTimer, CLOCK_SECOND*60*5); + } + + switch(putInStatus) + { + case 0x00: //ʼ״̬ + if(pcRequestOpenDoorMark == 1) //п + { + pcRequestOpenDoorMark = 0; + + beep_shortBeepMark = 1; //ʾ + + //ǰ״̬־ + putInOKMark = 0; //Ͷɱ־ + disablePutInMark = 0; //װֹű־ + userInfoQueryStatus = 0; //Ӻ̨ȡõûϢ + putInUploadSuccessMark = 0; //Ͷϴɹ־ + + infoDisplayStatus = 0; //ûϢÿһֻʾһ + getUserInfoMark = 0; + putInPrompt = 0; //ʾͶʶһͶֻһΣ + + Audio_Play(1); + + Screen_Landing(); + + printf("\r\n---------> ûͶţ\r\n"); + isOpenDoor = 1; //־ҪŲ + putInProgress = 1; //־豸ڽв + printf("\r\nڽͶŲ......\r\n"); + timer_restart(&playWaitingTimer); + timer_restart(&waitingPutInTimer); + timer_restart(&waitingTimer4S); + + putInStatus = 0x01; + break; + } + break; + + case 0x01: //ȴͶ + if(timer_expired(&waitingPutInTimer)) + { + putInStatus = 0x00; + ClearPutInInfo(); + + Screen_Default(); + printf("\r\nȴͶɳʱ\r\n"); + break; + } + + //----------------------------------------------------- + //ʾûͶ + if(putInPrompt == 0) + { + if(timer_expired(&waitingTimer4S)) + { + if(synchronousOpenDoorMark == 1) + { + Audio_Play(2); + }else{ + Audio_Play(6); + } + putInPrompt = 1; + } + } + + //ǷӳͶ + if(delayCloseDoorStatus == 1) + { + delayCloseDoorStatus = 0; + timer_restart(&waitingPutInTimer); +// printf("\r\nӳͶʱ\r\n"); + } + + //ʾʱ + if(getRemainingTimerStatus == 1) + { + getRemainingTimerStatus = 0; + + //ʾʱ + Screen_Countdown(remainingTimer); + PC_ProCommandSend(0x60); //λʾĹŵʱ + + //----------------------------------------------------- + //ʾżر + if(remainingTimer == 6) + { + Audio_Play(3); + } + } + + //յ˳ָ˳ + if(exitMark == 1) + { + exitMark = 0; + putInStatus = 0x05; + timer_restart(&outTimer); + break; + } + + //жǷͶ + if(putInOKMark == 1) + { + putInOKMark = 0; + + printf("\r\nյͶɣڴ......\r\n"); + + //Ͷ״̬ + DropOffPortCheckTask(); + + PC_ProCommandSend(0x61); //λûͶʾ + + printf("\r\n--> յͶ£"); + printf("\r\n--> Type: %d", sendPutInType); + printf("\r\n--> Len: %d", sendDataLength); + if(getPutInType == 1) + { + printf("\r\n--> Data: "); + showHexData(sendDataBuf, sendDataLength); + }else{ + printf("\r\n--> Data: %s\r\n", sendDataBuf); + } + + switch(deviceType) + { + case THREE_CLASSIFICATION: // + printf("\r\nͰ1: %2.2f Kg%2.2f Kg -> %2.2f Kg룺%3.1f cm\r\n",\ + (float)getWeight1/100, (float)getWeightBefore1/100, (float)getWeightAfter1/100, (float)getDistance1); + + printf("\r\nͰ2: %2.2f Kg%2.2f Kg -> %2.2f Kg룺%3.1f cm\r\n",\ + (float)getWeight2/100, (float)getWeightBefore2/100, (float)getWeightAfter2/100, (float)getDistance2); + + printf("\r\nͰ3: %2.2f Kg%2.2f Kg -> %2.2f Kg룺%3.1f cm\r\n",\ + (float)getWeight3/100, (float)getWeightBefore3/100, (float)getWeightAfter3/100, (float)getDistance3); + +// printf("\r\n = %d\r\n", faultCode_L); + + //ʾûͶϢ + Screen_ShowPutInInfo2(getWeight1, getWeight2, getWeight3, getWeight4); + break; + + case FOUR_CLASSIFICATION: //ķ + printf("\r\nͰ1: %2.2f Kg%2.2f Kg -> %2.2f Kg룺%3.1f cm\r\n",\ + (float)getWeight1/100, (float)getWeightBefore1/100, (float)getWeightAfter1/100, (float)getDistance1); + + printf("\r\nͰ2: %2.2f Kg%2.2f Kg -> %2.2f Kg룺%3.1f cm\r\n",\ + (float)getWeight2/100, (float)getWeightBefore2/100, (float)getWeightAfter2/100, (float)getDistance2); + + printf("\r\nͰ3: %2.2f Kg%2.2f Kg -> %2.2f Kg룺%3.1f cm\r\n",\ + (float)getWeight3/100, (float)getWeightBefore3/100, (float)getWeightAfter3/100, (float)getDistance3); + + printf("\r\nͰ4: %2.2f Kg%2.2f Kg -> %2.2f Kg룺%3.1f cm\r\n",\ + (float)getWeight4/100, (float)getWeightBefore4/100, (float)getWeightAfter4/100, (float)getDistance4); + +// printf("\r\n = %d\r\n", faultCode_L); + + //ʾûͶϢ + Screen_ShowPutInInfo2(getWeight1, getWeight2, getWeight3, getWeight4); + break; + + default: + break; + } + +// FaultCodeCheck(deviceType); //ϼϴ + + printf("\r\n---------->Ͷɣ\r\n"); + + fillLightMask = 1; + +// putInStatus = 0x02; +// timer_restart(&displayTimer); + + timer_restart(&outTimer); + putInStatus = 0x05; + break; + } + break; + + case 0x02: //ͣʾͶϢ + if(timer_expired(&displayTimer)) + { + //ͶţȴϴظͶź + if((getWeight1 > 0) || (getWeight2 > 0) || (getWeight3 > 0) || (getWeight4 > 0) || (smallBottleCount > 0)) + { + printf("\r\nͶţȴ̨Ӧ\r\n"); + + timer_restart(&waitingUploadTimer); + putInStatus = 0x03; + break; + }else{ //ûͶתллʹý˳ + Audio_Play(4); + Screen_Exit(); //ʾ˳ʹý桱 + printf("\r\nʾͶʱ䵽Ͷ˳\r\n"); + timer_restart(&outTimer); + putInStatus = 0x05; + break; + } + + } + break; + + case 0x03: //ȴϴɹʾͶź + if(putInUploadSuccessMark == 1) + { + putInUploadSuccessMark = 0; + printf("\r\n֮ǰ = %.2f \r\n", (float)capital/100); + printf("\r\n֮ = %.2f \r\n", (float)capitalAfter/100); + + if(capitalAfter >= capital) + { + Screen_ShowPutInReward(capital, capitalAfter); + PC_ProCommandSend(0x05); //λûͶʾ + printf("\r\n = %.2f \r\n", (float)(capitalAfter - capital)/100); + +// printf("\r\n = %.2f \r\n", (float)(capitalAfter - capital)/100); +// printf("\r\n = %.2f \r\n", (float)capitalAfter/100); + } + + putInStatus = 0x04; + timer_restart(&displayTimer); + } + + if(timer_expired(&waitingUploadTimer)) + { + Audio_Play(4); + + Screen_Exit(); //ʾ˳ʹý桱 + printf("\r\nʾͶʱ䵽\r\n"); + putInStatus = 0x05; + timer_restart(&outTimer); + } + break; + + case 0x04: + if(timer_expired(&displayTimer)) + { + Audio_Play(4); + + Screen_Exit(); //ʾ˳ʹý桱 + printf("\r\nʾͶʱ䵽\r\n"); + putInStatus = 0x05; + timer_restart(&outTimer); + } + break; + + case 0x05: //ͣʾ˳ + if(timer_expired(&outTimer)) + { + printf("\r\nʾ\r\n"); + Screen_Default(); + + PC_ProCommandSend(0x09); //λͶŽ + ClearPutInInfo(); + putInProgress = 0; + pcRequestOpenDoorMark = 0; + putInStatus = 0x00; + } + break; + + case 0x06: + if(timer_expired(&outTimer)) + { + putInStatus = 0x00; + } + break; + +//----------------------------------------------------------------------------------------- + + case 0x66: //װֹʱʾװʾ + if(timer_expired(&displayTimer)) + { + printf("\r\nʾ\r\n"); + Screen_Default(); + ClearPutInInfo(); + putInStatus = 0x00; + } + break; + + case 0x10: //豸ת˴ȴ + Screen_Error(0, displayFaultCode, 0); + PC_ProCommandSend(0x30); //λ豸ʾ + putInStatus = 0x11; + break; + + case 0x11: + //λسֹ֮еˣֱ޸ + break; + +//---------------------------------------------------------------------------------- +//ûô + case 0x20: //õûʾ + Screen_Query(0x03, 0, NULL, 0, 0); + + sendMsg.msgType = 4301; + MessageSend(MSG_FIFO_PROTOCOL, sendMsg); //̨ȡûϢָ + printf("\r\nGet user Info\r\n"); + + putInStatus = 0x21; + timer_restart(&waitingUploadTimer); + timer_restart(&outTimer); + break; + + case 0x21: //ȴ̨ûϢ + if(timer_expired(&waitingUploadTimer)) + { + putInStatus = 0x05; + break; + } + + //յ̨ӦûϢ + if(userInfoQueryStatus == 1) + { + userInfoQueryStatus = 0; + + if(isAuth == 1) //˺Ч + { + printf("\r\n˺Żָ\r\n"); + DelDisableUser(curIcCard); + ShowDisableUserList(); + }else{ + printf("\r\n˺Ŵڽ״̬\r\n"); + } + putInStatus = 0x05; + break; + } + break; + +//------------------------------------------------------------------------------------ +//¼봦 + case 0x30: //¼ + sendMsg.msgType = 4401; + MessageSend(MSG_FIFO_PROTOCOL, sendMsg); //̨ȡûϢָ + putInStatus = 0x31; + timer_restart(&faceEntryTimer); + break; + + case 0x31: //¼ + if(userInfoQueryStatus == 1) + { + userInfoQueryStatus = 0; + + PC_ProCommandSend(0x02); //λûϢʾ + } + + //¼ʧܿԼϢ + tempData = GetPutInType(); //ǷпͶ + if(tempData > 0) //п + { + getPutInType = tempData; //濪ͶŵͣťICά롢룩 + tempData = 0; + + //20190627޸ǰһεûϢ + accountNum = 0; + isAuth = 0; + userInfoQueryStatus = 0; + memset(get_IC_ID, 0x00, 9); //ȡõIC + + GetUserInfo(getPutInType); //ݿŷʽȡûϢ +// ShowPutInInfo(getPutInType); //ʾͶϢ + + //ûʶϢ浽ͻ + sendPutInType = getPutInType; //ʶʽ + sendDataLength = getDataLength; //Ϣij + memcpy(sendDataBuf, getDataBuf, 33); //Ϣ + + putInStatus = 0x30; + printf("\r\n¼²\r\n"); + break; + } + + if(faceEntryFlag == 0) + { + printf("\r\n¼˳\r\n"); + ClearPutInInfo(); + putInStatus = 0x00; + break; + } + + if(timer_expired(&faceEntryTimer)) + { + printf("\r\n¼볬ʱ˳\r\n"); + ClearPutInInfo(); + faceEntryFlag = 0; + putInStatus = 0x00; + break; + } + break; + + default: + putInStatus = 0x00; + break; + } +} + +/* +*********************************************************************** +* : BoxOpenTask +* ˵: ţţſ +* Σ +* ֵ: +*********************************************************************** +*/ +void BoxOpenTask(void) +{ + uint8_t temp = 0; + static uint8_t boxOpenSteps = 0; + static uint8_t boxOpenType = 0; //ŵķʽ + + static timer waitingTimer; + static timer waitingAckTimer; //ȴ̨Ӧʱ + static timer waitingUnlockingTimer; //ȴʱ + + static uint8_t timer_ok = 0; + + if(timer_ok == 0) + { + timer_ok = 1; + timer_set(&waitingTimer, CLOCK_SECOND*1); + timer_set(&waitingAckTimer, CLOCK_SECOND*10); + timer_set(&waitingUnlockingTimer, CLOCK_SECOND*2); + } + + switch(boxOpenSteps) + { + case 0x00: //ʼ״̬ + //ˢ˿ + if(RFID_state == 2) + { + RFID_state = 0; + + boxOpenType = 1; //־ǰΪIC + beep_shortBeepMark = 1; //ʾ + + //ȡǰͻ + getCustomerID = 0; + getCustomerID = RFID_ID[0] << 16; + getCustomerID |= RFID_ID[1] << 8; + getCustomerID |= RFID_ID[2]; + + if(getCustomerID == customerID) //ǷΪ˿ + { + printf("\r\nſƥ䣡\r\n"); + + memcpy(curIcCard, RFID_ID, 9); //ȡǰICϢ + printf("\r\nʼ\r\n"); + temp = FindUserStatus(curIcCard); + if(temp > 0) + { + beep_warningBeepMark = 1; + printf("\r\nǰûѾã %d λ\r\n", temp); + boxOpenSteps =0x20; + break; + }else{ + printf("\r\nǰû\r\n"); + boxOpenSteps = 0x01; + break; + } + }else{ + beep_warningBeepMark = 1; + printf("\r\nſƥ䣡\r\n"); + timer_restart(&waitingTimer); + boxOpenSteps = 0x04; //˳ + break; + } + } + + //ʱά뿪 + if(boxOpenQRMark == 1) + { + boxOpenQRMark = 0; //־Ҫţɿ + beep_shortBeepMark = 1; //ʾ + + if(enableCleanQRCodeStatus == 1) //˶ά뿪 + { + printf("\r\nʱŶά뿪ţ\r\n"); + boxOpenType = 2; + boxOpenSteps = 0x01; + break; + }else{ + printf("\r\n˶ά뿪šͣã\r\n"); + boxOpenSteps = 0x04; + break; + } + } + break; + + case 0x01: //ϴԱϢ + if(boxOpenType == 1) + { + boxOpenMark = 1; //־Ҫţɿ + + //ϴԱϢ + getDataLength = 9; //ICϢΪ9ֽ + memcpy(getDataBuf, RFID_ID, 9); //ICϢ + }else if(boxOpenType == 2){ + //ʱûжά뿪Ϣ + }else{ + boxOpenSteps = 0x04; + } + + //ûʶϢ浽ͻ + collectorSendAuthType = boxOpenType; //ʶʽ + collectorSendDataLength = getDataLength; //Ϣij + memcpy(collectorSendDataBuf, getDataBuf, 33); //Ϣ + + + if(ConnectionStatus == OFFLINE) + { + boxOpenSteps = 0x04; + break; + } + + //ֱ˳ + timer_restart(&waitingUnlockingTimer); + boxOpenSteps = 0x03; + break; + +// sendMsg.msgType = 4701; +// MessageSend(MSG_FIFO_PROTOCOL, sendMsg); //̨ȡûϢָ +// +// timer_restart(&waitingAckTimer); +// boxOpenSteps = 0x02; +// break; + + case 0x02: //ȴ̨û֤ + if(timer_expired(&waitingAckTimer)) + { + printf("\r\n֤ʱ˳\r\n"); + boxOpenSteps = 0x04; + break; + } + + if(getBoxOpenAckMark == 1) //յ̨ϴӦ + { + getBoxOpenAckMark = 0; + + //ݺ̨Ӧ״̬ӦĴ + switch(boxOpenAckStatus) + { + case 0: //ЧδǼ + //ʱICǰһ״̬ѾԿţά޷ + printf("\r\n˺ЧδǼǣ\r\n"); + break; + + case 1: //˺ + printf("\r\n˺\r\n"); + if(boxOpenType == 1) //IC + { +// boxOpenMark = 1; //־Ҫţɿ +// unlockMark = 1; //ɿɣƱ־ + break; + }else if(boxOpenType == 2) //˶ά뿪 + { + boxOpenMark = 1; //־Ҫţɿ + break; + } + break; + + case 2: //õ˺ + if(boxOpenType == 1) //IC + { + AddDisableUser(curIcCard); // ӵб + ShowDisableUserList(); + }else if(boxOpenType == 2) //˶ά뿪 + { + //õ˺޷ + printf("\r\n˺űã\r\n"); + } + break; + + default: + break; + } + + timer_restart(&waitingUnlockingTimer); + boxOpenSteps = 0x03; + break; + } + break; + + case 0x03: //ȴ + if(timer_expired(&waitingUnlockingTimer)) + { + boxOpenSteps = 0x04; + } + break; + + case 0x04: //˳ + //صı + RFID_state = 0; + boxOpenMark = 0; + boxOpenSteps = 0x00; + break; + +//---------------------------------------------------------------------------- +//õ˺Ŵ + case 0x20: //õ˺ŴٴжǷָ +// Screen_Query(0x03, 0, NULL, 0, 0); + //ϴԱϢ + getDataLength = 9; //ICϢΪ9ֽ + memcpy(getDataBuf, RFID_ID, 9); //ICϢ + + //ûʶϢ浽ͻ + collectorSendAuthType = boxOpenType; //ʶʽ + collectorSendDataLength = getDataLength; //Ϣij + memcpy(collectorSendDataBuf, getDataBuf, 33); //Ϣ + + sendMsg.msgType = 4701; + MessageSend(MSG_FIFO_PROTOCOL, sendMsg); //̨ȡûϢָ + printf("\r\nGet user Info\r\n"); + + boxOpenSteps = 0x21; + timer_restart(&waitingAckTimer); + break; + + case 0x21: //ȴ̨ûϢ + if(timer_expired(&waitingAckTimer)) + { + boxOpenSteps = 0x04; + break; + } + + //յ̨ӦûϢ + if(getBoxOpenAckMark == 1) + { + getBoxOpenAckMark = 0; + + //ݺ̨Ӧ״̬ӦĴ + switch(boxOpenAckStatus) + { + case 0: //ЧδǼ + //ʱ + printf("\r\n˺ЧδǼǣ\r\n"); + break; + + case 1: //˺ + printf("\r\n˺\r\n"); + if(boxOpenType == 1) //IC + { + printf("\r\n˺Żָ\r\n"); + DelDisableUser(curIcCard); + ShowDisableUserList(); + break; + }else if(boxOpenType == 2) //˶ά뿪 + { + boxOpenMark = 1; //־Ҫţɿ + break; + } + break; + + case 2: //õ˺ + if(boxOpenType == 1) //IC + { + printf("\r\n˺Ŵڽ״̬\r\n"); + }else if(boxOpenType == 2) //˶ά뿪 + { + //õ˺޷ + printf("\r\n˺űã\r\n"); + } + break; + + default: + break; + } + + boxOpenSteps = 0x04; + break; + } + break; + + default: + boxOpenSteps = 0x00; + break; + } +} + +/* +*********************************************************************** +* : ServerSetupParam +* ˵: ̨ò +* Σ +* ֵ: +*********************************************************************** +*/ +void ServerSetupParamTask(void) +{ + uint8_t passMark = 0; + + if(getSetDistanceParamMark == 1) + { + getSetDistanceParamMark = 0; + + printf("\r\nGetDis: N=%d, T1=%d, h1=%d, H1=%d, A1=%d; T2=%d, h2=%d, H2=%d, A2=%d\r\n", getDevChannelNumbers, + getDevChannel1Type, getDevChannel1DisDepthVal, getDevChannel1DisMaxVal, getDevChannel1DisAlarmPercent, + getDevChannel2Type, getDevChannel2DisDepthVal, getDevChannel2DisMaxVal, getDevChannel2DisAlarmPercent); + + //ݼ + if((getDevChannelNumbers == devChannelNumbers) && + (getDevChannel1Type == devChannel1Type) && + (getDevChannel2Type == devChannel2Type) && + (getDevChannel3Type == devChannel3Type) && + (getDevChannel4Type == devChannel4Type) && + (getDevChannel1DisDepthVal > 0) && (getDevChannel1DisMaxVal >= getDevChannel1DisDepthVal) && + (getDevChannel2DisDepthVal > 0) && (getDevChannel2DisMaxVal >= getDevChannel2DisDepthVal) && + (getDevChannel3DisDepthVal > 0) && (getDevChannel3DisMaxVal >= getDevChannel3DisDepthVal) && + (getDevChannel4DisDepthVal > 0) && (getDevChannel4DisMaxVal >= getDevChannel4DisDepthVal) && + (getDevChannel1DisAlarmPercent <= 140) && (getDevChannel2DisAlarmPercent <= 140) && + (getDevChannel3DisAlarmPercent <= 140) && (getDevChannel4DisAlarmPercent <= 140)) + { + passMark = 1; + }else{ + passMark = 0; + printf("\r\nݼ\r\n"); + } + + if(passMark == 1) + { + setDevChannel1DisMaxVal = getDevChannel1DisMaxVal; + setDevChannel1DisDepthVal = getDevChannel1DisDepthVal; + setDevChannel1DisAlarmPercent = getDevChannel1DisAlarmPercent; + + setDevChannel2DisMaxVal = getDevChannel2DisMaxVal; + setDevChannel2DisDepthVal = getDevChannel2DisDepthVal; + setDevChannel2DisAlarmPercent = getDevChannel2DisAlarmPercent; + + setDevChannel3DisMaxVal = getDevChannel3DisMaxVal; + setDevChannel3DisDepthVal = getDevChannel3DisDepthVal; + setDevChannel3DisAlarmPercent = getDevChannel3DisAlarmPercent; + + setDevChannel4DisMaxVal = getDevChannel4DisMaxVal; + setDevChannel4DisDepthVal = getDevChannel4DisDepthVal; + setDevChannel4DisAlarmPercent = getDevChannel4DisAlarmPercent; + + SaveDeviceConfig(); + DeviceParamInit(); //б䶯³ʼ豸 + CalcOverflowStartPointParam(); + } + } +} + +/* +*********************************************************************** +* : DeviceEnableTask +* ˵: 豸/ÿ +* Σ +* ֵ: +*********************************************************************** +*/ +void DeviceEnableTask(void) +{ + uint8_t dataTemp = 0; + + if(getDeviceWorkStatusMark == 1) + { + getDeviceWorkStatusMark = 0; + + printf("\r\nWorkSta = %d\r\n", getDeviceWorkStatusVal); + + if(getDeviceWorkStatusVal >= 1) + { + deviceWorkStatus = 1; + }else{ + deviceWorkStatus = 0; + } + + //豸ǰ״̬ʾ + if(deviceWorkStatus == 0) + { + Screen_DeviceDisable(); + }else{ + Screen_Default(); + } + + if(deviceWorkStatus != deviceWorkStatusPre) + { + printf("\r\n豸״̬б仯\r\n"); + deviceWorkStatusPre = deviceWorkStatus; + } + } +} + +/* +*********************************************************************** +* : KeysSendTask +* ˵: תλ +* : +* ֵ: +*********************************************************************** +*/ +void KeysSendTask(void) +{ + if(keyType == 1) //ʹô + { + if(keyValue > 0) + { + // printf("\r\nkey = %x\r\n", keyValue); + if((keyValue & 0xF0) == 0) //̰ + { + keyNum = keyValue; + keyStatus = 1; + // printf("\r\n̰key = %x\r\n", keyNum); + }else{ // + keyNum = keyValue & 0x0F; + keyStatus = 2; + // printf("\r\nkey = %x\r\n", keyNum); + } + + PC_ProCommandSend(0x11); //λûϢʾ + printf("\r\n: Num = %x, Sta = %x\r\n", keyNum, keyStatus); + keyValue = 0; + } + + if(keyReleaseMark == 1) //ɿʱ + { + keyStatus = 3; + PC_ProCommandSend(0x11); //λûϢʾ + printf("\r\n: Num = %x, Sta = %x\r\n", keyNum, keyStatus); + + keyReleaseMark = 0; + } + } + + + //ͬʱʹûеʹл͵ļֵMCU2Ĺ翪ؽӿ룩 +// if(optoKeyStatus > 0) +// { +// if(optoKeyStatus == 1) +// { +// keyNum = 3; +// keyStatus = 1; +// }else if(optoKeyStatus == 3){ +// keyNum = 3; +// keyStatus = 3; +// }else{} +// +// PC_ProCommandSend(0x11); //λûϢʾ +// printf("\r\n: Num = %x, Sta = %x\r\n", keyNum, keyStatus); +// +// optoKeyStatus = 0; +// } +} + +/* +*********************************************************************** +* : HumanSensingTask +* ˵: Ӧ +* : +* ֵ: +*********************************************************************** +*/ +void HumanSensingTask(void) +{ + if(optoKeyStatus > 0) + { + if(optoKeyStatus == 1) + { + humanSensingKeyStatus = 1; + }else if(optoKeyStatus == 3){ + humanSensingKeyStatus = 3; + }else{} + + PC_ProCommandSend(0x64); //λûϢʾ + printf("\r\nӦ״̬: Num = %x, Sta = %x\r\n", 1, humanSensingKeyStatus); + + optoKeyStatus = 0; + } +} + +/* +*********************************************************************** +* : DropOffPortCheck +* ˵: Ͷſ״̬ +* Σ +* ֵ: +*********************************************************************** +*/ +void DropOffPortCheckTask(void) +{ + static uint8_t preDropOffPortSta1 = 0; + static uint8_t preDropOffPortSta2 = 0; + + if(preDropOffPortSta1 != switchKey1Status) + { + dropOffPortMark1 = 1; //־ǰͶſ״̬仯 + dropPortClosedStatus1 = switchKey1Status; + preDropOffPortSta1 = dropPortClosedStatus1; + printf("\r\nͶſ1״̬仯%d\r\n", dropPortClosedStatus1); + } + + if(preDropOffPortSta2 != switchKey2Status) + { + dropOffPortMark2 = 1; //־ǰͶſ״̬仯 + dropPortClosedStatus2 = switchKey2Status; + preDropOffPortSta2 = dropPortClosedStatus2; + printf("\r\nͶſ2״̬仯%d\r\n", dropPortClosedStatus2); + } + + if((dropOffPortMark1 == 1) || (dropOffPortMark2 == 1)) + { + PC_ProCommandSend(0x66); //λͶڹر״̬ + } +} + +/* +*********************************************************************** +* : RecycleClearDoorCheckTask +* ˵: ״̬ +* : +* ֵ: +*********************************************************************** +*/ +void RecycleClearDoorCheckTask(void) +{ + static uint8_t currentStatus = 0x00; + static uint8_t nextStatus = 0x00; + + static uint8_t preStatus = 0; + uint8_t curStatus = 0; + + static uint8_t preRecycleClearDoorMark = 0; + + static uint8_t initOk = 0; + + static timer waitingInitTimer; + static timer waitingTimer; + + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&waitingInitTimer, CLOCK_SECOND*30); + timer_set(&waitingTimer, CLOCK_SECOND*2); + } + + curStatus = getRecycleClearDoorMark; + + currentStatus = nextStatus; + switch(currentStatus) + { + case 0x00: + if(curStatus != preStatus) + { + timer_restart(&waitingTimer); + nextStatus = 0x01; + break; + } + break; + + case 0x01: + if(timer_expired(&waitingTimer)) + { + if(curStatus != preStatus) + { + printf("\r\n״̬仯\r\n"); + recycleClearDoorMark = curStatus; + preStatus = curStatus; + } + nextStatus = 0x00; + } + break; + + default: + nextStatus = 0x00; + break; + } + + + if(recycleClearDoorMark != preRecycleClearDoorMark) + { + if(recycleClearDoorMark == 0) + { + printf("\r\nŹرգ\r\n"); + }else{ + printf("\r\nŴ򿪣\r\n"); + } + + preRecycleClearDoorMark = recycleClearDoorMark; + + PC_ProCommandSend(0x23); + } + + + if(initOk == 0) + { + if(timer_expired(&waitingInitTimer)) + { + initOk = 1; + + printf("\r\nολ״̬\r\n"); + if(recycleClearDoorMark == 0) + { + printf("\r\nŹرգ\r\n"); + }else{ + printf("\r\nŴ򿪣\r\n"); + } + PC_ProCommandSend(0x23); + } + } +} + +/* +*********************************************************************** +* : NowTimeIsOnTheHour +* ˵: ǰʱǷΪ +* Σ +* ֵ: 㷵1,򷵻0 +*********************************************************************** +*/ +uint8_t NowTimeIsOnTheHour(void) +{ + if((nowTime->tm_min == 0) && (nowTime->tm_sec == 0)) + { + return 1; + }else{ + return 0; + } +} + +/* +*********************************************************************** +* : TimingSprayTask +* ˵: ʱ +* Σ +* ֵ: +*********************************************************************** +*/ +void TimingSprayTask(void) +{ + static uint8_t currentStatus = 0x00; + static uint8_t nextStatus = 0x00; + uint8_t onTheHourStatus = 0; + + static timer waitingTimer; + static timer turnOnTimer; + + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&waitingTimer, CLOCK_SECOND*1); + timer_set(&turnOnTimer, CLOCK_SECOND*2); + } + + onTheHourStatus = NowTimeIsOnTheHour(); + + currentStatus = nextStatus; + switch(currentStatus) + { + case 0x00: + if((getDateTimeMark == 1) && (onTheHourStatus == 1)) + { +// //ݲͬʱܴ00:00 - 08:59 3СʱһΣ09:00 - 23:59M 1СʱһΣ +// if((nowTime->tm_hour == 0) || (nowTime->tm_hour == 3) || (nowTime->tm_hour == 6) || (nowTime->tm_hour >= 9)) + + if((nowTime->tm_hour)%3 == 0) //ÿ3Сʱһ 20230727޸ + { + printf("\r\nʱ(%s)\r\n", systemTime); + + if((sprayDisinfectingMark != 2) && (putInProgress != 1)) //ǰûд״̬ûͶŲִ + { + StartUpSprayDisinfection(); + } + timer_restart(&turnOnTimer); + nextStatus = 0x01; + break; + } + } + break; + + case 0x01: //״̬ + if(timer_expired(&turnOnTimer)) + { + printf("\r\nʱ䵽ر\r\n"); + + StopSprayDisinfection(); + nextStatus = 0x00; + break; + } + + //Ͷʱͣ + if(putInProgress == 1) + { + printf("\r\nǰͶţͣ\r\n"); + + StopSprayDisinfection(); + nextStatus = 0x02; + break; + } + + //Ž + if(sprayDisinfectingMark == 2) + { + printf("\r\nŽ\r\n"); + + StopSprayDisinfection(); + sprayDisinfectingMark = 0; + + timer_restart(&waitingTimer); + nextStatus = 0x10; + break; + } + break; + + case 0x02: //ͣ״̬ + if(putInProgress == 0) + { + printf("\r\nͶŽָ\r\n"); + + StartUpSprayDisinfection(); + timer_restart(&turnOnTimer); + nextStatus = 0x01; + break; + } + break; + + case 0x10: + if(timer_expired(&waitingTimer)) + { + sprayDisinfectingMark = 0; + nextStatus = 0x00; + break; + } + break; + + default: + break; + } +} + +/* +*********************************************************************** +* : TimingUVTask +* ˵: ʱ +* Σ +* ֵ: +*********************************************************************** +*/ +void TimingUVTask(void) +{ + static uint8_t currentStatus = 0x00; + static uint8_t nextStatus = 0x00; + uint8_t onTheHourStatus = 0; + + static timer waitingTimer; + static timer turnOnTimer; + + static uint8_t timer_ok = 0; + if(timer_ok == 0) + { + timer_ok = 1; + + timer_set(&waitingTimer, CLOCK_SECOND*1); + timer_set(&turnOnTimer, CLOCK_SECOND*60*10); + } + + onTheHourStatus = NowTimeIsOnTheHour(); + + currentStatus = nextStatus; + switch(currentStatus) + { + case 0x00: + if((getDateTimeMark == 1) && (onTheHourStatus == 1)) + { + printf("\r\nʱUV(%s)\r\n", systemTime); + + if((disinfectingMark != 2) && (putInProgress != 1)) //ǰûд״̬ûͶŲִUV + { + StartUpDisinfection(); + } + timer_restart(&turnOnTimer); + nextStatus = 0x01; + break; + } + break; + + case 0x01: //״̬ + if(timer_expired(&turnOnTimer)) + { + printf("\r\nʱ䵽رUV\r\n"); + + StopDisinfection(); + nextStatus = 0x00; + } + + //Ͷʱͣ + if(putInProgress == 1) + { + printf("\r\nǰͶţͣUV\r\n"); + + StopDisinfection(); + nextStatus = 0x02; + break; + } + + //ŽUV + if(disinfectingMark == 2) + { + printf("\r\nŽUV\r\n"); + + StopDisinfection(); + disinfectingMark = 0; + + timer_restart(&waitingTimer); + nextStatus = 0x10; + break; + } + break; + + case 0x02: //ͣ״̬ + if(putInProgress == 0) + { + printf("\r\nͶŽָUV\r\n"); + + StartUpDisinfection(); +// timer_restart(&turnOnTimer); + nextStatus = 0x01; + break; + } + break; + + case 0x10: + if(timer_expired(&waitingTimer)) + { + disinfectingMark = 0; + nextStatus = 0x00; + break; + } + break; + + default: + break; + } +} + +/******************** (C) COPYRIGHT 2017 Ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/user_app.h b/STM32_4路称重_Git提交精简工程/src/USER/user_app.h new file mode 100755 index 0000000..f98b42e --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/user_app.h @@ -0,0 +1,31 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ device.h + * 豸Ƴ + * V1.0 + * XuZhongPing + * 2017/03/06 +*********************************************************************************/ +#ifndef __USER_APP_H +#define __USER_APP_H +#include "stm32f10x.h" +#include "string.h" +#include "stdlib.h" +#include "device.h" +#include "data_typedef.h" + +void showHexData(uint8_t num[], uint8_t n); +void PutInOpenDoorTask(void); +void BoxOpenTask(void); +void ServerSetupParamTask(void); +void DeviceEnableTask(void); + +void KeysSendTask(void); +void HumanSensingTask(void); +void DropOffPortCheckTask(void); +void RecycleClearDoorCheckTask(void); +void TimingSprayTask(void); +void TimingUVTask(void); + +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/user_manag.c b/STM32_4路称重_Git提交精简工程/src/USER/user_manag.c new file mode 100755 index 0000000..6091141 --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/user_manag.c @@ -0,0 +1,207 @@ +/*************************** (C) COPYRIGHT 2017 Ping **************************** + * ļ : user_manag.c + * û + * V1.0 + * XuZhongPing + * 2019/07/20 +*********************************************************************************/ +#include "user_manag.h" +#include "usart1.h" +#include "delay.h" +#include "timer.h" +#include "display.h" + +#include "stmflash.h" + +IC_CARD DisableUserList[USER_LEN]; //һ黺ڱõICûϢ +IC_CARD curIcCard; //ǰICûϢ +uint8_t nextSaveIndex = 0; //һҪICַ +uint8_t DisUserCount = 0; //ǰѾĽû + + +/* +*********************************************************************** +* : showHexData +* ˵: ʮʾ +* : +* ֵ: +*********************************************************************** +*/ +void showHex1(uint8_t num[], uint8_t n) +{ + uint8_t i; + + printf("\r\n"); + for(i=0; iͬ0x01->ͬ +*********************************************************************** +*/ +void DisableUserListInit(void) +{ + uint8_t i; + IC_CARD userTemp = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + if(DisUserCount == 0) + { + nextSaveIndex = 0; + } + + for(i = 0; i < 15; i++) + { + userTemp[8] += 1; + AddDisableUser(userTemp); + + ShowDisableUserList(); + } +} + +/* +*********************************************************************** +* : CheckArrayEquality +* ˵: жǷͬûϢǷȣ +* Σ +* ֵ: 0x00->ͬ0x01->ͬ +*********************************************************************** +*/ +static uint8_t CheckArrayEquality(IC_CARD arr1, IC_CARD arr2) +{ + uint8_t i; + + for(i = 0; i < 16; i++) + { + if(arr1[i] != arr2[i]) + { + return 0; + } + } + + return 1; +} + +/* +*********************************************************************** +* : FindUserStatus +* ˵: ѯǰICû״̬ѯǷ񱻽ã +* Σ +* ֵ: 0x00->н򷵻ضӦıַ1ʼ㣩 +*********************************************************************** +*/ +uint8_t FindUserStatus(IC_CARD inPutInfo) +{ + uint8_t i; + + if(DisUserCount > 0) + { + for(i = 0; i < DisUserCount; i++) + { + if(CheckArrayEquality(DisableUserList[i], inPutInfo)) + { + return i+1; //беǰûϢ򷵻صǰλ + } + } + return 0; //бûз֣򷵻0 + + }else{ + return 0; + } +} + +/* +*********************************************************************** +* : ArrCpy +* ˵: 鿽 +* ΣdesArr -> Ŀ飻SouArr -> Դ +* ֵ: +*********************************************************************** +*/ +static void ArrCpy(IC_CARD desArr, IC_CARD SouArr) +{ + memcpy(desArr, SouArr, 16); +} + +/* +*********************************************************************** +* : AddDisableUser +* ˵: ӽõûб +* Σ +* ֵ: +*********************************************************************** +*/ +void AddDisableUser(IC_CARD inPutInfo) +{ + ArrCpy(DisableUserList[nextSaveIndex], inPutInfo); + + nextSaveIndex++; + DisUserCount++; + + if(nextSaveIndex >= USER_LEN) //λѾһλµλ + { + nextSaveIndex = 0; + } + + if(DisUserCount >= USER_LEN) //û󣬸ǰģֵ + { + DisUserCount = USER_LEN; + } +} + +/* +*********************************************************************** +* : DelDisableUser +* ˵: ǰûӽбƳ +* ΣҪɾûϢ +* ֵ: +*********************************************************************** +*/ +void DelDisableUser(IC_CARD delUserInfo) +{ + uint8_t i; + uint8_t curIndex = 0; + uint8_t tempBuf[16]; + + memset(tempBuf, 0xff, 16); + + curIndex = FindUserStatus(delUserInfo); + if(curIndex > 0) //ǰûڽб + { + for(i = curIndex - 1; i < (DisUserCount - 1); i++) + { + ArrCpy(DisableUserList[i], DisableUserList[i+1]); + } + ArrCpy(DisableUserList[DisUserCount - 1], tempBuf); + DisUserCount--; + nextSaveIndex = DisUserCount; //һҪдλ + } +} + +/******************** (C) COPYRIGHT 2017 Ping *****END OF FILE*******************/ diff --git a/STM32_4路称重_Git提交精简工程/src/USER/user_manag.h b/STM32_4路称重_Git提交精简工程/src/USER/user_manag.h new file mode 100755 index 0000000..136ec5a --- /dev/null +++ b/STM32_4路称重_Git提交精简工程/src/USER/user_manag.h @@ -0,0 +1,31 @@ +/*************************** (C) COPYRIGHT 2017 CXHY **************************** + * ļ user_manag.h + * û + * V1.0 + * XuZhongPing + * 2019/07/20 +*********************************************************************************/ +#ifndef __USER_MANAG_H +#define __USER_MANAG_H + +#include "stm32f10x.h" +#include "string.h" +#include "stdlib.h" +#include "device.h" +#include "data_typedef.h" + +#define USER_LEN 100 //ܱĽû +typedef uint8_t IC_CARD[16]; //һICϢ +extern IC_CARD DisableUserList[USER_LEN]; //һ黺ڱõICûϢ +extern IC_CARD curIcCard; //ǰICûϢ +extern uint8_t nextSaveIndex; //һҪICַ +extern uint8_t DisUserCount; //ǰѾĽû + +void ShowDisableUserList(void); +void DisableUserListInit(void); +uint8_t FindUserStatus(IC_CARD inPutInfo); +void AddDisableUser(IC_CARD inPutInfo); +void DelDisableUser(IC_CARD inPutInfo); +#endif + +/******************** (C) COPYRIGHT 2017 CXHY *****END OF FILE*******************/