├── .gitignore ├── ProfiBUS-DP数据实例.txt ├── Soft_MCU ├── Abstract.txt ├── App │ ├── ProfiBUS_DP.bak.c │ ├── ProfiBUS_DP.bak1.c │ ├── ProfiBUS_DP.bak2.c │ ├── ProfiBUS_DP.bak3.c │ ├── ProfiBUS_DP.bak4.c │ ├── ProfiBUS_DP.c │ ├── ProfiBUS_DP.h │ ├── cfg.c │ ├── cfg.h │ ├── crc.c │ ├── crc.h │ ├── main.c │ ├── net_http_cgi.c │ ├── net_user.c │ ├── net_user.h │ ├── netiod.c │ └── netiod.h ├── Auto_FcArm_Cmd.inp ├── BSP │ ├── STM32F40xxx_41xxx_OPT.s │ ├── STM32F4xx_OTP.s │ ├── SVC_Table.s │ ├── board.c │ ├── board.h │ ├── stm32f4_iap_flash.c │ └── stm32f4_iap_flash.h ├── Debug.ini ├── HTTP_Server.c ├── HTTP_Server.uvguix ├── HTTP_Server.uvoptx ├── HTTP_Server.uvprojx ├── HTTP_Server_CGI.c ├── HTTP_Server_Error.c ├── IniParser │ └── src │ │ ├── dictionary.c │ │ ├── dictionary.h │ │ ├── iniparser.c │ │ └── iniparser.h ├── JLinkSettings.ini ├── RTE │ ├── CMSIS │ │ └── RTX_Conf_CM.c │ ├── Compiler │ │ ├── retarget_io.c │ │ └── stdio_usart.c │ ├── Device │ │ └── STM32F407IGHx │ │ │ ├── RTE_Device.h │ │ │ ├── STM32F401xx_OPT.s │ │ │ ├── STM32F40xxx_41xxx_OPT.s │ │ │ ├── STM32F42xxx_43xxx_OPT.s │ │ │ ├── STM32F4xx_OTP.s │ │ │ ├── startup_stm32f407xx.s │ │ │ ├── stm32f4xx_hal_conf.h │ │ │ └── system_stm32f4xx.c │ ├── File_System │ │ ├── FS_Config.c │ │ └── FS_Config_NOR_0.h │ ├── Network │ │ ├── Net_Config.c │ │ ├── Net_Config_BSD.h │ │ ├── Net_Config_ETH_0.h │ │ ├── Net_Config_FTP_Server.h │ │ ├── Net_Config_HTTP_Server.h │ │ ├── Net_Config_TCP.h │ │ ├── Net_Config_UDP.h │ │ └── Net_Debug.c │ └── RTE_Components.h ├── Web │ ├── ad.cgi │ ├── ad.cgx │ ├── buttons.cgi │ ├── buttons.cgx │ ├── home.png │ ├── index.htm │ ├── keil.gif │ ├── language.cgi │ ├── lcd.cgi │ ├── leds.cgi │ ├── llblue.jpg │ ├── logo.gif │ ├── network.cgi │ ├── pabb.gif │ ├── pg_footer.inc │ ├── pg_header.inc │ ├── setting.cgi │ ├── system.cgi │ ├── tcp.cgi │ ├── top_bg.jpg │ └── xml_http.js └── config.sys ├── _PCB ├── 3.3v通信板.SchDoc ├── BOM SL-DPT100.xlsx ├── Ethernet.SchDoc ├── IPC-7352 Chip_Capacitor_N.PcbLib ├── IPC-7352 Chip_Resistor_N.PcbLib ├── MCU.SchDoc ├── MCU_1.SchDoc ├── Phoenix ME MAX 22.5 2-2 KMGY.PcbDoc ├── Phoenix ME MAX 22.5 SF G 2-2 KMGY.PcbDoc ├── Power.SchDoc ├── SL-DPT100 (2016-3-25 15-01-02).zip ├── SL-DPT100 v1.0.0.rar ├── SL-DPT100 v1.1.0.rar ├── SL-DPT100.PcbDoc ├── SL-DPT100.PcbLib ├── SL-DPT100.PrjPcb ├── SL-DPT100.PrjPcbStructure ├── SL-DPT100.SchLib ├── STM32F407封装库.IntLib ├── _PCB_v1.1.0.rar └── 制板说明.txt └── 测试1.bmp /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM/ 33 | *.su 34 | 35 | 36 | /__资料 37 | /__Back 38 | 39 | /_PCB/Project Outputs for SL-DPT100 40 | /_PCB/Project Logs for SL-DPT100 41 | 42 | /Soft_MCU/Output 43 | /Soft_MCU/RTE/Network/Net_Config_HTTP_Server.h.0000 44 | /Soft_MCU/RTE/Network/Net_Debug.c.0000 45 | /Soft_MCU/RTE/Device/STM32F407IGHx/RTE_Device.h~RF34c9ea92.TMP 46 | /Soft_MCU/Auto_FcArm_Cmd_inp.Bak 47 | /Soft_MCU/JLinkLog.txt 48 | /_PCB/*.SchDocPreview 49 | /_PCB/*.PcbDocPreview 50 | *.uvguix.User 51 | *.SchDocPreview 52 | *.PcbDocPreview 53 | *.SchDocPreview 54 | -------------------------------------------------------------------------------- /ProfiBUS-DP数据实例.txt: -------------------------------------------------------------------------------- 1 | Receiving idle characters in a row counter A2 77 02 49 01 02 03 04 05 06 07 08 C2 16 2 | 3 | 68 05 05 68 04 02 7D 00 00 83 16 4 | 5 | DC 02 02 6 | 68 05 05 68 04 02 7D 00 00 83 16 7 | 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 8 | 10 77 02 49 C2 16 9 | DC 02 02 10 | 68 05 05 68 04 02 5D 00 00 63 16 11 | 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 12 | 10 78 02 49 C3 16 13 | DC 02 02 14 | 68 05 05 68 04 02 7D 00 00 83 16 15 | 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 16 | 10 79 02 49 C4 16 17 | DC 02 02 18 | 68 05 05 68 04 02 5D 00 00 63 16 19 | 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 20 | 10 7A 02 49 C5 16 21 | DC 02 02 22 | 68 05 05 68 04 02 7D 00 00 83 16 23 | 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 24 | 10 7B 02 49 C6 16 25 | DC 02 02 26 | 68 05 05 68 04 02 5D 00 00 63 16 27 | 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 28 | 10 7C 02 49 C7 16 29 | DC 02 02 30 | 68 05 05 68 04 02 7D 00 00 83 16 31 | 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 32 | 10 7D 02 49 C8 16 33 | DC 02 02 34 | 68 05 05 68 04 02 5D 00 00 63 16 35 | 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 7E 02 49 C9 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 00 02 49 4B 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 01 02 49 4C 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 03 02 49 4E 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 04 02 49 4F 16 10 02 04 00 06 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 05 02 49 50 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 06 02 49 51 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 07 02 49 52 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 08 02 49 53 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 09 02 49 54 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 0A 02 49 55 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 0B 02 49 56 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 0C 02 49 57 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 0D 02 49 58 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 0E 02 49 59 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 0F 02 49 5A 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 10 02 49 5B 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 11 02 49 5C 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 12 02 49 5D 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 13 02 49 5E 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 14 02 49 5F 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 15 02 49 60 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 16 02 49 61 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 17 02 49 62 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 18 02 49 63 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 19 02 49 64 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 1A 02 49 65 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 1B 02 49 66 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 1C 02 49 67 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 1D 02 49 68 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 68 43 43 68 FF 82 44 3F 3E 01 02 00 01 1E 01 00 01 00 FF 02 00 00 64 00 0B 00 3C 00 01 00 55 00 00 0A 7E 01 02 02 A2 77 4C 02 A2 1C 02 00 01 00 00 02 00 00 00 00 01 D8 00 00 02 00 FF 01 00 00 00 00 00 00 00 00 00 FA 16 10 1E 02 49 69 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 1F 02 49 6A 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 20 02 49 6B 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 21 02 49 6C 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 22 02 49 6D 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 23 02 49 6E 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 24 02 49 6F 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 25 02 49 70 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 26 02 49 71 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 27 02 49 72 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 28 02 49 73 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 29 02 49 74 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 2A 02 49 75 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 2B 02 49 76 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 2C 02 49 77 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 2D 02 49 78 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 2E 02 49 79 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 2F 02 49 7A 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 30 02 49 7B 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 31 02 49 7C 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 32 02 49 7D 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 33 02 49 7E 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 34 02 49 7F 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 35 02 49 80 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 36 02 49 81 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 37 02 49 82 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 38 02 49 83 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 39 02 49 84 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 3A 02 49 85 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 3B 02 49 86 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 3C 02 49 87 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 3D 02 49 88 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 3E 02 49 89 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 3F 02 49 8A 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 40 02 49 8B 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 41 02 49 8C 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 42 02 49 8D 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 43 02 49 8E 16 DC 02 02 68 05 05 68 04 02 7D 00 00 83 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 44 02 49 8F 16 DC 02 02 68 05 05 68 04 02 5D 00 00 63 16 68 09 09 68 02 04 08 00 00 00 00 00 00 0E 16 10 45 02 49 90 16 DC 02 02 -------------------------------------------------------------------------------- /Soft_MCU/Abstract.txt: -------------------------------------------------------------------------------- 1 | This is a HTTP_Server example. It shows you how to use the 2 | Web Server CGI interface as well. 3 | 4 | Detailed description is available on: 5 | www.keil.com/pack/doc/MW/Network/html/_compact__web__server__example.html 6 | 7 | Use this example to connect an evaluation board to a LAN with DHCP 8 | server (most LANs have this). The example will configure the network 9 | parameters automatically using a DHCP protocol. 10 | 11 | If a DHCP server is not available, you may connect an evaluation 12 | board to PC directly over a crosslink network cable. In this case 13 | configure a PC to use a static IP address 192.168.0.1 and disable 14 | a 'Dynamic Host Configuration' in Net_Config.c configuration file. 15 | The default static IP address of this example is then 192.168.0.100 16 | 17 | To test this example, open your web browser and enter the 18 | address http://mcbstm32f400/ or http:// 19 | 20 | Default user : admin 21 | Default password: 22 | 23 | The HTTP_Server example is available for multiple targets: 24 | 25 | MCBSTM32F400 V1.1: 26 | Standalone application for MCBSTM32F400 V1.1 board using 27 | ST802RT1 Ethernet PHY. 28 | Program code is loaded into on-chip flash. 29 | 30 | MCBSTM32F400 V1.2: 31 | Standalone application for MCBSTM32F400 V1.2 board using 32 | KSZ8081RNA Ethernet PHY. 33 | Program code is loaded into on-chip flash. 34 | -------------------------------------------------------------------------------- /Soft_MCU/App/ProfiBUS_DP.bak.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/Soft_MCU/App/ProfiBUS_DP.bak.c -------------------------------------------------------------------------------- /Soft_MCU/App/ProfiBUS_DP.bak1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/Soft_MCU/App/ProfiBUS_DP.bak1.c -------------------------------------------------------------------------------- /Soft_MCU/App/ProfiBUS_DP.bak2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/Soft_MCU/App/ProfiBUS_DP.bak2.c -------------------------------------------------------------------------------- /Soft_MCU/App/ProfiBUS_DP.bak3.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/Soft_MCU/App/ProfiBUS_DP.bak3.c -------------------------------------------------------------------------------- /Soft_MCU/App/ProfiBUS_DP.bak4.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/Soft_MCU/App/ProfiBUS_DP.bak4.c -------------------------------------------------------------------------------- /Soft_MCU/App/ProfiBUS_DP.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/Soft_MCU/App/ProfiBUS_DP.c -------------------------------------------------------------------------------- /Soft_MCU/App/ProfiBUS_DP.h: -------------------------------------------------------------------------------- 1 | /**********************************************************************************************************/ 2 | /** @file ProfiBUS_DP.h 3 | *** @author Linghu 4 | *** @version V1.0.0 5 | *** @date 2015/7/30 6 | *** @brief ProfiBUS DP 7 | *********************************************************************************************************** 8 | *** @par Last Commit: 9 | *** \$Author$ \n 10 | *** \$Date$ \n 11 | *** \$Rev$ \n 12 | *** \$URL$ \n 13 | *** 14 | *** @par Change Logs: 15 | *** 2015/7/30 -- Linghu -- the first version 16 | ***********************************************************************************************************/ 17 | #ifndef __PROFIBUS_DP_H___20150730_112501 18 | #define __PROFIBUS_DP_H___20150730_112501 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | /**********************************************************************************************************/ 24 | /** @addtogroup PROFIBUS_DP 25 | *** @{ 26 | *** @addtogroup PROFIBUS_DP_Exported_Constants 27 | *** @{ 28 | ***********************************************************************************************************/ 29 | 30 | #define PBDP_EVENT_ERR (0x1u << 0) /* PBDP Event error */ 31 | #define PBDP_EVENT_IDLE (0x1u << 1) /* PBDP Event Recv Idle char */ 32 | #define PBDP_EVENT_TRCP (0x1u << 2) /* PBDP Event Transmission complete */ 33 | 34 | 35 | /**********************************************************************************************************/ 36 | /** @} 37 | *** @addtogroup PROFIBUS_DP_Exported_Functions 38 | *** @{ 39 | ***********************************************************************************************************/ 40 | 41 | /* ProfiBUS DP User function */ 42 | extern int PBDP_Statc(char* buff, int size); 43 | extern void PBDP_Init(uint32_t baud); 44 | extern int PBDP_Recv(uint8_t buff[260]); 45 | extern int PBDP_Send(const uint8_t *buff, int len); 46 | 47 | /* ProfiBUS DP Uart callback function */ 48 | extern void PBDP_UART_RecvCB(int ch); 49 | extern int PBDP_UART_SendCB(void); 50 | extern void PBDP_UART_EventCB(int event); 51 | 52 | /* ProfiBUS DP Uart driver function */ 53 | extern void PBDP_UART_Init(uint32_t BaudRate); 54 | extern void PBDP_UART_EnDEN(void); 55 | extern void PBDP_UART_DsDEN(void); 56 | extern void PBDP_UART_EnTXE(void); 57 | extern void PBDP_UART_DsTXE(void); 58 | extern void PBDP_UART_EnIRQ(void); 59 | extern void PBDP_UART_DsIRQ(void); 60 | 61 | /***************************** END OF FILE **************************************************************/ 62 | /** @} 63 | *** @} 64 | *****/ 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | #endif 69 | /**********************************************************************************************************/ 70 | 71 | -------------------------------------------------------------------------------- /Soft_MCU/App/cfg.c: -------------------------------------------------------------------------------- 1 | /**********************************************************************************************************/ 2 | /** @file cfg.c 3 | *** @author Linghu 4 | *** @version V1.0.0 5 | *** @date 2016-10-18 6 | *** @brief Read and Write Config to ".ini" file 7 | *********************************************************************************************************** 8 | *** @par Last Commit: 9 | *** \$Author$ \n 10 | *** \$Date$ \n 11 | *** \$Rev$ \n 12 | *** \$URL$ \n 13 | *** 14 | *** @par Change Logs: 15 | *** 2016-10-18 -- Linghu -- the first version 16 | ***********************************************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "iniparser.h" 23 | #include "cfg.h" 24 | 25 | 26 | /**********************************************************************************************************/ 27 | /** @addtogroup CFG 28 | *** @{ 29 | *** @addtogroup CFG_Pravate 30 | *** @{ 31 | *** @addtogroup CFG_Private_Variables 32 | *** @{ 33 | ***********************************************************************************************************/ 34 | 35 | dictionary* g_CfgDic; /* Pointer to allocated dictionary */ 36 | char g_CfgFileName[64]; /* Pointer to config file name */ 37 | 38 | 39 | /**********************************************************************************************************/ 40 | /** @} 41 | *** @addtogroup CFG_Private_Functions 42 | *** @{ 43 | ***********************************************************************************************************/ 44 | /** @brief Config module Initialize 45 | *** 46 | *** @param[in] cfg_file_name Config file name. 47 | ***********************************************************************************************************/ 48 | 49 | void cfg_init(const char* cfg_file_name) 50 | { 51 | strncpy(g_CfgFileName, cfg_file_name, sizeof(g_CfgFileName) - 1); 52 | g_CfgFileName[sizeof(g_CfgFileName) - 1] = '\0'; 53 | 54 | iniparser_set_error_callback(NULL); 55 | 56 | g_CfgDic = iniparser_load(g_CfgFileName); 57 | if( g_CfgDic == NULL ) cfg_reset(); 58 | } 59 | 60 | 61 | /**********************************************************************************************************/ 62 | /** @brief Reset all Config to default value 63 | ***********************************************************************************************************/ 64 | 65 | void cfg_reset(void) 66 | { 67 | FILE* fini; 68 | 69 | if( g_CfgDic != NULL ) { 70 | iniparser_freedict(g_CfgDic); 71 | g_CfgDic = NULL; 72 | } 73 | 74 | fini = fopen(g_CfgFileName, "w"); assert(fini); 75 | fprintf(fini, 76 | "[System]\n" 77 | "Password = sanlian ;\n" 78 | "\n" 79 | "[Ethernet]\n" 80 | "DHCP = Y ;\n" 81 | "IPADDR = 192.168.0.99 ;\n" 82 | "DefGW = 192.168.0.1 ;\n" 83 | "MASK = 255.255.255.0 ;\n" 84 | "MACADDR = UNDEF ;\"1E-30-AA-BB-CC-DD\" or \"UNDEF\"\n" 85 | "\n" 86 | "[ProfiBUS]\n" 87 | "BAUD = 187500 ;\n" 88 | "\n" 89 | ); 90 | fclose(fini); 91 | 92 | g_CfgDic = iniparser_load(g_CfgFileName); assert(g_CfgDic); 93 | } 94 | 95 | 96 | /**********************************************************************************************************/ 97 | /** @brief Save config to config file. 98 | ***********************************************************************************************************/ 99 | 100 | static void cfg_save(const char* entry, const char* val) 101 | { 102 | FILE* fini; 103 | 104 | iniparser_set(g_CfgDic, entry, val); 105 | 106 | fini = fopen(g_CfgFileName, "w"); assert(fini); 107 | iniparser_dump_ini(g_CfgDic, fini); 108 | fclose(fini); 109 | } 110 | 111 | /**********************************************************************************************************/ 112 | /** @brief Read system password from config file 113 | ***********************************************************************************************************/ 114 | 115 | const char* cfg_get_password(void) 116 | { 117 | return( iniparser_getstring(g_CfgDic, "System:Password", "sanlian") ); 118 | } 119 | 120 | 121 | /**********************************************************************************************************/ 122 | /** @brief Write system password to config file 123 | ***********************************************************************************************************/ 124 | 125 | void cfg_set_password(const char* psw) 126 | { 127 | if( psw == NULL ) psw = "sanlian"; 128 | cfg_save("System:Password", psw); 129 | } 130 | 131 | 132 | /**********************************************************************************************************/ 133 | /** @brief Read DHCP enable or disable form config file. 134 | ***********************************************************************************************************/ 135 | 136 | int cfg_get_dhcp(void) 137 | { 138 | return( iniparser_getboolean(g_CfgDic, "Ethernet:DHCP", 1) ); 139 | } 140 | 141 | 142 | /**********************************************************************************************************/ 143 | /** @brief Write DHCP enable or disable to config file. 144 | ***********************************************************************************************************/ 145 | 146 | void cfg_set_dhcp(int dhcp) 147 | { 148 | cfg_save("Ethernet:DHCP", dhcp ? "Y" : "N"); 149 | } 150 | 151 | 152 | /**********************************************************************************************************/ 153 | /** @brief Read IP address from config file. 154 | ***********************************************************************************************************/ 155 | 156 | const char* cfg_get_ipaddr(void) 157 | { 158 | return( iniparser_getstring(g_CfgDic, "Ethernet:IPADDR", "192.168.0.99") ); 159 | } 160 | 161 | 162 | /**********************************************************************************************************/ 163 | /** @brief Write IP address to config file. 164 | ***********************************************************************************************************/ 165 | 166 | void cfg_set_ipaddr(const char* ipaddr) 167 | { 168 | if( ipaddr == NULL ) ipaddr = "192.168.0.99"; 169 | cfg_save("Ethernet:IPADDR", ipaddr); 170 | } 171 | 172 | 173 | /**********************************************************************************************************/ 174 | /** @brief Read Default Gateway Address from config file. 175 | ***********************************************************************************************************/ 176 | 177 | const char* cfg_get_defgw(void) 178 | { 179 | return( iniparser_getstring(g_CfgDic, "Ethernet:DefGW", "192.168.0.1") ); 180 | } 181 | 182 | 183 | /**********************************************************************************************************/ 184 | /** @brief Write Default Gateway Address to config file. 185 | ***********************************************************************************************************/ 186 | 187 | void cfg_set_defgw(const char* defgw) 188 | { 189 | if( defgw == NULL ) defgw = "192.168.0.1"; 190 | cfg_save("Ethernet:DefGW", defgw); 191 | } 192 | 193 | 194 | /**********************************************************************************************************/ 195 | /** @brief Read Local Subnet mask from config file. 196 | ***********************************************************************************************************/ 197 | 198 | const char* cfg_get_mask(void) 199 | { 200 | return( iniparser_getstring(g_CfgDic, "Ethernet:MASK", "255.255.255.0") ); 201 | } 202 | 203 | 204 | /**********************************************************************************************************/ 205 | /** @brief Write Local Subnet mask to config file. 206 | ***********************************************************************************************************/ 207 | 208 | void cfg_set_mask(const char* mask) 209 | { 210 | if( mask == NULL ) mask = "255.255.255.0"; 211 | cfg_save("Ethernet:MASK", mask); 212 | } 213 | 214 | 215 | /**********************************************************************************************************/ 216 | /** @brief Read Local Ethernet MAC Address from config file. 217 | ***********************************************************************************************************/ 218 | 219 | const char* cfg_get_macaddr(void) 220 | { 221 | return( iniparser_getstring(g_CfgDic, "Ethernet:MACADDR", "UNDEF") ); 222 | } 223 | 224 | 225 | /**********************************************************************************************************/ 226 | /** @brief Write Local Ethernet MAC Address to config file. 227 | ***********************************************************************************************************/ 228 | 229 | void cfg_set_macaddr(const char* macaddr) 230 | { 231 | if( macaddr == NULL ) macaddr = "UNDEF"; 232 | cfg_save("Ethernet:MACADDR", macaddr); 233 | } 234 | 235 | 236 | /**********************************************************************************************************/ 237 | /** @brief Read ProfiBUS-DP baudrate from config file. 238 | ***********************************************************************************************************/ 239 | 240 | uint32_t cfg_get_baudrate(void) 241 | { 242 | return( iniparser_getlongint(g_CfgDic, "ProfiBUS:BAUD", 187500) ); 243 | } 244 | 245 | 246 | /**********************************************************************************************************/ 247 | /** @brief Write ProfiBUS-DP baudrate to config file. 248 | ***********************************************************************************************************/ 249 | 250 | void cfg_set_baudrate(uint32_t baud) 251 | { 252 | const char* pb; 253 | 254 | switch( baud ) { 255 | case 9600: pb = "9600"; break; 256 | case 19200: pb = "19200"; break; 257 | case 45450: pb = "45450"; break; 258 | case 93750: pb = "93750"; break; 259 | case 187500: pb = "187500"; break; 260 | case 500000: pb = "500000"; break; 261 | case 1500000: pb = "1500000"; break; 262 | default: pb = "187500"; break; 263 | } 264 | cfg_save("ProfiBUS:BAUD", pb); 265 | } 266 | 267 | 268 | /***************************** END OF FILE **************************************************************/ 269 | /** @} 270 | *** @} 271 | *** @} 272 | ***********************************************************************************************************/ 273 | 274 | -------------------------------------------------------------------------------- /Soft_MCU/App/cfg.h: -------------------------------------------------------------------------------- 1 | /**********************************************************************************************************/ 2 | /** @file cfg.h 3 | *** @author Linghu 4 | *** @version V1.0.0 5 | *** @date 2016-10-18 6 | *** @brief Read and Write Config to ".ini" file 7 | *********************************************************************************************************** 8 | *** @par Last Commit: 9 | *** \$Author$ \n 10 | *** \$Date$ \n 11 | *** \$Rev$ \n 12 | *** \$URL$ \n 13 | *** 14 | *** @par Change Logs: 15 | *** 2016-10-18 -- Linghu -- the first version 16 | ***********************************************************************************************************/ 17 | #ifndef __CFG_H___20161018_155239 18 | #define __CFG_H___20161018_155239 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | /**********************************************************************************************************/ 24 | /** @addtogroup CFG 25 | *** @{ 26 | *** @addtogr 27 | *** @addtogroup CFG_Exported_Functions 28 | *** @{ 29 | ***********************************************************************************************************/ 30 | 31 | void cfg_init(const char* cfg_file_name); 32 | void cfg_reset(void); 33 | 34 | const char* cfg_get_password(void); 35 | void cfg_set_password(const char* psw); 36 | 37 | int cfg_get_dhcp(void); 38 | void cfg_set_dhcp(int dhcp); 39 | 40 | const char* cfg_get_ipaddr(void); 41 | void cfg_set_ipaddr(const char* ipaddr); 42 | 43 | const char* cfg_get_defgw(void); 44 | void cfg_set_defgw(const char* defgw); 45 | 46 | const char* cfg_get_mask(void); 47 | void cfg_set_mask(const char* mask); 48 | 49 | const char* cfg_get_macaddr(void); 50 | void cfg_set_macaddr(const char* macaddr); 51 | 52 | uint32_t cfg_get_baudrate(void); 53 | void cfg_set_baudrate(uint32_t baud); 54 | 55 | 56 | /***************************** END OF FILE **************************************************************/ 57 | /** @} 58 | *** @} 59 | *****/ 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | #endif 64 | /**********************************************************************************************************/ 65 | 66 | -------------------------------------------------------------------------------- /Soft_MCU/App/crc.c: -------------------------------------------------------------------------------- 1 | /**********************************************************************************************************/ 2 | /** @file crc.c 3 | *** @brief CRC(Cyclic Redundancy Check) calculation. 4 | *** 5 | *********************************************************************************************************** 6 | *** @copy 7 | *** 8 | *** The software is owned by Linghu, and is protected under applicable 9 | *** copyright laws. All rights are reserved. Any use in violation of 10 | *** the foregoing restrictions may subject the user to criminal sanctions 11 | *** under applicable laws, as well as to civil liability for the breach of the 12 | *** terms and conditions of this license. 13 | *** 14 | ***

© COPYRIGHT 2010 Linghu

15 | *********************************************************************************************************** 16 | *** @author Linghu 17 | *** @version V1.0.0 18 | *** @date 2013.04.07 19 | *** @history Prelimnary version, first Release 20 | *** 21 | ***********************************************************************************************************/ 22 | 23 | #include "crc.h" 24 | 25 | 26 | /**********************************************************************************************************/ 27 | /** @addtogroup CRC 28 | *** @{ 29 | *** @addtogroup CRC_Pravate 30 | *** @{ 31 | *** @addtogroup CRC_Private_Constants 32 | *** @{ 33 | ***********************************************************************************************************/ 34 | 35 | #define CCITT_CRC_TABLE_DATA \ 36 | 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, \ 37 | 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, \ 38 | 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, \ 39 | 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, \ 40 | 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, \ 41 | 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, \ 42 | 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, \ 43 | 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, \ 44 | 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, \ 45 | 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, \ 46 | 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, \ 47 | 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, \ 48 | 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, \ 49 | 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, \ 50 | 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, \ 51 | 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, \ 52 | 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, \ 53 | 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, \ 54 | 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, \ 55 | 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, \ 56 | 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, \ 57 | 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, \ 58 | 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, \ 59 | 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, \ 60 | 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, \ 61 | 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, \ 62 | 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, \ 63 | 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, \ 64 | 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, \ 65 | 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, \ 66 | 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, \ 67 | 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 68 | 69 | #define CRC32_TABLE_DATA \ 70 | 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, \ 71 | 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, \ 72 | 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, \ 73 | 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, \ 74 | 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, \ 75 | 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, \ 76 | 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, \ 77 | 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, \ 78 | 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, \ 79 | 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, \ 80 | 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, \ 81 | 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, \ 82 | 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, \ 83 | 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, \ 84 | 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, \ 85 | 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, \ 86 | 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, \ 87 | 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, \ 88 | 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, \ 89 | 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, \ 90 | 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, \ 91 | 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, \ 92 | 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, \ 93 | 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, \ 94 | 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, \ 95 | 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, \ 96 | 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, \ 97 | 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, \ 98 | 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, \ 99 | 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, \ 100 | 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, \ 101 | 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D 102 | 103 | 104 | /**********************************************************************************************************/ 105 | /** @} 106 | *** @addtogroup CRC_Private_Functions 107 | *** @{ 108 | ***********************************************************************************************************/ 109 | /** @brief Calculation CRC16 Value. 110 | *** 111 | *** @param[in] seed Seed of CRC Value. 112 | *** @param[in] message Message data. 113 | *** @param[in] size Message length of Byte. 114 | *** 115 | *** @return CRC16 Value without XOROUT 116 | *** 117 | *** @note width: 16 poly: 0x1021 init: 0x1d0f refin: false refout: false 118 | *** xorout: 0x0000 check: 0xe5cc name: "CRC-16/AUG-CCITT" 119 | ***********************************************************************************************************/ 120 | 121 | uint16 crc16_ccitt(uint16 seed, const void* message, uint size) 122 | { 123 | static const uint16 table[256] = { CCITT_CRC_TABLE_DATA }; 124 | uint16 crc_result = seed; 125 | const uint8* msg = (const uint8*)message; 126 | 127 | while( size-- ) 128 | { 129 | crc_result = ( (uint16)( crc_result << 8 ) ) 130 | ^ ( table[ ( (crc_result >> 8) ^ *msg++ ) & 0xff ] ); 131 | } 132 | 133 | return crc_result; 134 | } 135 | 136 | /**********************************************************************************************************/ 137 | /** @brief Calculation CRC32 value of 0x04C11DB7 Poly 138 | *** 139 | *** @param[in] seed Seed of CRC Value. 140 | *** @param[in] message Message data. 141 | *** @param[in] size Message length of Byte. 142 | *** 143 | *** @return CRC32 Value. 144 | *** 145 | *** @note width: 32 poly: 0x04c11db7 init: 0xffffffff refin: true refout: true 146 | *** xorout: 0xffffffff check: 0xcbf43926 name: "CRC-32" 147 | ***********************************************************************************************************/ 148 | 149 | uint32 crc32_pkzip(uint32 seed, const void *message, uint size) 150 | { 151 | static const uint32 table[256] = { CRC32_TABLE_DATA }; 152 | uint32 crc_result = seed; 153 | const uint8 *msg = (const uint8*)message; 154 | 155 | while( size-- ) { 156 | crc_result = table[(crc_result ^ *msg++) & 0xFF] ^ (crc_result >> 8); 157 | } 158 | 159 | return crc_result; 160 | } 161 | 162 | 163 | /***************************** END OF FILE **************************************************************/ 164 | /** @} 165 | *** @} 166 | *** @} 167 | ****************************** END OF FILE **************************************************************/ 168 | -------------------------------------------------------------------------------- /Soft_MCU/App/crc.h: -------------------------------------------------------------------------------- 1 | /**********************************************************************************************************/ 2 | /** @file crc.h 3 | *** @brief CRC(Cyclic Redundancy Check) calculation. 4 | *** 5 | *********************************************************************************************************** 6 | *** @copy 7 | *** 8 | *** The software is owned by Linghu, and is protected under applicable 9 | *** copyright laws. All rights are reserved. Any use in violation of 10 | *** the foregoing restrictions may subject the user to criminal sanctions 11 | *** under applicable laws, as well as to civil liability for the breach of the 12 | *** terms and conditions of this license. 13 | *** 14 | ***

© COPYRIGHT 2010 Linghu

15 | ***********************************************************************************************************/ 16 | #ifndef __CRC_H 17 | #define __CRC_H 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | /**********************************************************************************************************/ 22 | /** @addtogroup CRC 23 | *** @{ 24 | *** @addtogroup CRC_Exported_Types 25 | *** @{ 26 | ***********************************************************************************************************/ 27 | 28 | #ifndef uint8 29 | #define uint8 unsigned char 30 | #endif 31 | 32 | #ifndef uint16 33 | #define uint16 unsigned short 34 | #endif 35 | 36 | #ifndef uint 37 | #define uint unsigned int 38 | #endif 39 | 40 | #ifndef uint32 41 | #define uint32 unsigned long 42 | #endif 43 | 44 | 45 | /**********************************************************************************************************/ 46 | /** @} 47 | *** @addtogroup CRC_Exported_Functions 48 | *** @{ 49 | ***********************************************************************************************************/ 50 | 51 | #define CRC16_CCITT_INIT 0x1D0F 52 | #define CRC16_CCITT_XOROUT 0x0000 53 | uint16 crc16_ccitt(uint16 seed, const void* message, uint size); 54 | 55 | #define CRC32_PKZIP_INIT 0xFFFFFFFF 56 | #define CRC32_PKZIP_XOROUT 0xFFFFFFFF 57 | uint32 crc32_pkzip(uint32 seed, const void *message, uint size); 58 | 59 | 60 | /***************************** END OF FILE **************************************************************/ 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | #endif 65 | /***************************** END OF FILE **************************************************************/ 66 | /** @} 67 | *** @} 68 | ****************************** END OF FILE **************************************************************/ 69 | -------------------------------------------------------------------------------- /Soft_MCU/App/main.c: -------------------------------------------------------------------------------- 1 | /**********************************************************************************************************/ 2 | /** @file main.c 3 | *** @author Linghu 4 | *** @version V1.0.0 5 | *** @date 2015/7/24 6 | *** @brief C Run Library main() function. 7 | *********************************************************************************************************** 8 | *** @par Last Commit: 9 | *** \$Author$ \n 10 | *** \$Date$ \n 11 | *** \$Rev$ \n 12 | *** \$URL$ \n 13 | *** 14 | *** @par Change Logs: 15 | *** 2015/7/24 -- Linghu -- the first version 16 | ***********************************************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "cmsis_os.h" /* CMSIS RTOS definitions */ 25 | #include "rl_net.h" /* Network definitions */ 26 | #include "rl_fs.h" /* FileSystem definitions */ 27 | 28 | #include "cfg.h" 29 | #include "board.h" 30 | #include "net_user.h" 31 | #include "netiod.h" 32 | #include "ProfiBUS_DP.h" 33 | 34 | 35 | /**********************************************************************************************************/ 36 | /** @addtogroup MAIN 37 | *** @{ 38 | *** @addtogroup MAIN_Pravate 39 | *** @{ 40 | *** @addtogroup MAIN_Private_Constants 41 | *** @{ 42 | ***********************************************************************************************************/ 43 | 44 | #define PORT_DP2NET 18354 45 | #define PORT_NET2DP 18355 46 | 47 | 48 | /**********************************************************************************************************/ 49 | /** @} 50 | *** @addtogroup MAIN_Private_Macros 51 | *** @{ 52 | ***********************************************************************************************************/ 53 | 54 | 55 | 56 | /**********************************************************************************************************/ 57 | /** @} 58 | *** @addtogroup MAIN_Private_Types 59 | *** @{ 60 | ***********************************************************************************************************/ 61 | 62 | 63 | /**********************************************************************************************************/ 64 | /** @} 65 | *** @addtogroup MAIN_Private_Prototypes 66 | *** @{ 67 | ***********************************************************************************************************/ 68 | 69 | static void fs_init(const char *drive); 70 | static void thread_dp2net(void const *arg); 71 | static void thread_net2dp(void const *arg); 72 | 73 | 74 | /**********************************************************************************************************/ 75 | /** @} 76 | *** @addtogroup MAIN_Private_Variables 77 | *** @{ 78 | ***********************************************************************************************************/ 79 | 80 | osThreadDef(thread_dp2net, osPriorityNormal, 1, 0); 81 | osThreadDef(thread_net2dp, osPriorityNormal, 1, 0); 82 | 83 | static uint32_t g_statistic[8] = {0, 0, 0, 0, 0, 0, 0, 0}; 84 | 85 | 86 | /**********************************************************************************************************/ 87 | /** @} 88 | *** @addtogroup MAIN_Private_Functions 89 | *** @{ 90 | ***********************************************************************************************************/ 91 | /** @brief Standard entry point for C code. 92 | ***********************************************************************************************************/ 93 | 94 | int main(void) 95 | { 96 | osThreadSetPriority(osThreadGetId(), osPriorityBelowNormal); 97 | board_init(); osDelay(10); /* Board Initialize */ 98 | fs_init("F0:"); osDelay(10); /* File System Initialize: NOR or SPI Flash drive 0 */ 99 | fs_init("M0:"); osDelay(10); /* File System Initialize: Memory Card drive 0 */ 100 | fs_init("N0:"); osDelay(10); /* File System Initialize: NAND Flash drive 0 */ 101 | if( bsp_clear_key() ) { 102 | fdelete("config.sys", NULL); 103 | printf("[Main] System setting reset to default!\r\n"); 104 | } 105 | cfg_init("config.sys"); osDelay(10); 106 | PBDP_Init(cfg_get_baudrate()); osDelay(10); /* PorfiBUS_DP Initialize */ 107 | net_init(); osDelay(10); /* Net Initialize */ 108 | netiod_init(); osDelay(10); /* NetIO Server Initialize */ 109 | 110 | if( osThreadCreate(osThread(thread_net2dp), NULL) == NULL ) { 111 | printf("[Main] Initialize Failed!\r\n"); /* Create thread of Net to ProfiBUS_DP */ 112 | } 113 | osDelay(10); 114 | if( osThreadCreate(osThread(thread_dp2net), NULL) == NULL ) { 115 | printf("[Main] Initialize Failed!\r\n"); /* Create thread of ProfiBUS_DP to Net */ 116 | } 117 | osDelay(10); 118 | osThreadSetPriority(osThreadGetId(), osPriorityNormal); 119 | 120 | while(1) { 121 | net_main(); 122 | osThreadYield(); 123 | } 124 | } 125 | 126 | 127 | /**********************************************************************************************************/ 128 | /** @brief Thread of ProfiBUS_DP to Net 129 | ***********************************************************************************************************/ 130 | 131 | static void thread_dp2net(void const *arg) 132 | { 133 | struct sockaddr_in addr; 134 | int sock; 135 | static uint8_t buff[256 + 16]; 136 | int recv; 137 | 138 | (void)arg; 139 | osDelay(5000); 140 | 141 | printf("[DP2NET] Server start, "); 142 | if( (sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) { 143 | printf("malloc socket failed!\r\n"); 144 | return; 145 | } 146 | addr.sin_family = PF_INET; 147 | addr.sin_port = htons(PORT_DP2NET); 148 | addr.sin_addr.s_addr = INADDR_ANY; 149 | if( bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0 ) { 150 | printf("bind socket failed!\r\n"); 151 | closesocket(sock); 152 | return; 153 | } else { 154 | printf("UDP Port: %d\r\n", PORT_DP2NET); 155 | } 156 | addr.sin_family = PF_INET; 157 | addr.sin_port = htons(PORT_NET2DP); 158 | addr.sin_addr.s_addr = INADDR_NONE; 159 | 160 | for(; ;) 161 | { 162 | if( (recv = PBDP_Recv(buff)) <= 0 ) { 163 | continue; // ProfiBUS_DP Recv Failed 164 | } 165 | g_statistic[0] += 1; g_statistic[1] += recv; // ProfiBUS_DP Recv Statistic information 166 | 167 | if( !eth_linkstatus_get() ) { 168 | continue; // Network_IP ETH LinkDown 169 | } 170 | addr.sin_addr.s_addr = ~net_mask_local() | net_ipaddr_local(); 171 | if( recv != sendto(sock, (char*)buff, recv, 0, (struct sockaddr*)&addr, sizeof(addr)) ) { 172 | continue; // Network_IP Send Failed 173 | } 174 | g_statistic[2] += 1; g_statistic[3] += recv; // Network_IP Send Statistic information 175 | } 176 | } 177 | 178 | 179 | /**********************************************************************************************************/ 180 | /** @brief Thread of Net to ProfiBUS_DP 181 | ***********************************************************************************************************/ 182 | 183 | static void thread_net2dp(void const *arg) 184 | { 185 | struct sockaddr_in addr; 186 | int alen; 187 | int sock; 188 | static uint8_t buff[256 + 16]; 189 | int recv; 190 | 191 | (void)arg; 192 | osDelay(5000); 193 | 194 | printf("[NET2DP] Server start, "); 195 | if( (sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) { 196 | printf("malloc socket failed!\r\n"); 197 | return; 198 | } 199 | addr.sin_family = PF_INET; 200 | addr.sin_port = htons(PORT_NET2DP); 201 | addr.sin_addr.s_addr = INADDR_ANY; 202 | if( bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0 ) { 203 | printf("bind socket failed!\r\n"); 204 | closesocket(sock); 205 | return; 206 | } else { 207 | printf("UDP Port: %d\r\n", PORT_NET2DP); 208 | } 209 | 210 | for(; ;) 211 | { 212 | alen = sizeof(addr); 213 | if( (recv = recvfrom(sock, (char*)buff, sizeof(buff), 0, (struct sockaddr*)&addr, &alen)) <= 0) { 214 | continue; // Network_IP Recv Failed 215 | } 216 | if( (addr.sin_addr.s_addr == net_ipaddr_local()) || (addr.sin_port != htons(PORT_DP2NET)) ) { 217 | continue; // Network_IP Recv Invalid 218 | } 219 | if( !eth_linkstatus_get() ) { 220 | continue; // Network_IP ETH LinkDown 221 | } 222 | g_statistic[4] += 1; g_statistic[5] += recv; // Network_IP Recv Statistic information 223 | 224 | if( recv != PBDP_Send(buff, recv) ) { 225 | continue; // ProfiBUS_DP Send Failed 226 | } 227 | g_statistic[6] += 1; g_statistic[7] += recv; // ProfiBUS_DP Send Statistic information 228 | } 229 | } 230 | 231 | 232 | /**********************************************************************************************************/ 233 | /** @brief File System Initialize 234 | *** 235 | *** @param[in] drive a string specifying the memory or storage device. Ref: finit(). 236 | ***********************************************************************************************************/ 237 | 238 | static void fs_init(const char *drive) 239 | { 240 | printf("[FileSystem] Initialize and Mount drive: %.2s ", drive); 241 | 242 | if( fsOK == finit(drive) ) { 243 | switch( fmount(drive) ) 244 | { 245 | case fsOK: 246 | printf ("Succeed! Free space: %lld\r\n", ffree(drive)); 247 | break; 248 | 249 | case fsNoFileSystem: 250 | printf("not formatted!\r\n"); 251 | break; 252 | 253 | default: 254 | printf("Mount failed!\r\n"); 255 | break; 256 | } 257 | } 258 | else { printf("Failed!\r\n"); } 259 | } 260 | 261 | 262 | 263 | 264 | 265 | 266 | uint16_t AD_in (uint32_t ch) { 267 | return (0); 268 | } 269 | uint8_t get_button (void) { 270 | return (0); 271 | } 272 | 273 | bool LEDrun; 274 | bool LCDupdate; 275 | char lcd_text[2][20+1]; 276 | 277 | /***************************** END OF FILE **************************************************************/ 278 | /** @} 279 | *** @} 280 | *** @} 281 | ***********************************************************************************************************/ 282 | 283 | -------------------------------------------------------------------------------- /Soft_MCU/App/net_http_cgi.c: -------------------------------------------------------------------------------- 1 | /**********************************************************************************************************/ 2 | /** @file net_http_cgi.c 3 | *** @author Linghu 4 | *** @version V1.0.0 5 | *** @date 2017-01-09 6 | *** @brief HTTP Server CGI Module 7 | *********************************************************************************************************** 8 | *** @par Last Commit: 9 | *** \$Author$ \n 10 | *** \$Date$ \n 11 | *** \$Rev$ \n 12 | *** \$URL$ \n 13 | *** 14 | *** @par Change Logs: 15 | *** 2017-01-09 -- Linghu -- the first version 16 | ***********************************************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "rl_net.h" 22 | #include "net_user.h" 23 | #include "cfg.h" 24 | 25 | 26 | /**********************************************************************************************************/ 27 | /** @addtogroup net_http_cgi 28 | *** @{ 29 | *** @addtogroup net_http_cgi_Pravate 30 | *** @{ 31 | *** @addtogroup net_http_cgi_Private_Functions 32 | *** @{ 33 | ***********************************************************************************************************/ 34 | /** @brief Generate dynamic web data from a script line. 35 | ***********************************************************************************************************/ 36 | 37 | uint32_t cgi_script (const char *env, char *buf, uint32_t buflen, uint32_t *pcgi) 38 | { 39 | uint32_t len = 0; 40 | 41 | // Analyze a 'c' script line starting position 2 42 | switch( env[0] ) { 43 | case 'a' : // Network parameters from 'setting.cgi' 44 | switch( env[2] ) { 45 | case 'i': // --- Write local IP address 46 | len = sprintf(buf, &env[4], net_ipaddr_get()); 47 | break; 48 | case 'm': // --- Write local network mask 49 | len = sprintf(buf, &env[4], net_mask_get()); 50 | break; 51 | case 'g': // --- Write default gateway IP address 52 | len = sprintf(buf, &env[4], net_defgw_get()); 53 | break; 54 | case 'p': // --- Write primary DNS server IP address 55 | len = sprintf(buf, &env[4], net_pridns_get()); 56 | break; 57 | case 's': // --- Write secondary DNS server IP address 58 | len = sprintf(buf, &env[4], net_secdns_get()); 59 | break; 60 | case 'a': // --- Write MAC Address 61 | len = sprintf(buf, &env[4], eth_macaddr_get()); 62 | break; 63 | case 'b': // --- Write ProfiBUS-DP Baud rate 64 | len = sprintf(buf, &env[4], cfg_get_baudrate()); 65 | break; 66 | case 'd': // --- Write DHCP status 67 | len = sprintf(buf, &env[4], cfg_get_dhcp() ? "" : "checked"); 68 | break; 69 | case 'w': // --- Write Password 70 | len = sprintf(buf, &env[4], net_psw_get()); 71 | break; 72 | } 73 | break; 74 | } 75 | 76 | return( len ); 77 | } 78 | 79 | 80 | /**********************************************************************************************************/ 81 | /** @brief Process query string received by GET request. 82 | ***********************************************************************************************************/ 83 | 84 | void cgi_process_query(const char *qstr) 85 | { 86 | char *var = malloc(40 * sizeof(char)); 87 | 88 | do{ 89 | qstr = http_get_env_var(qstr, var, 40 * sizeof(char)); // Loop through all the parameters 90 | if( var[0] != 0 ) { 91 | if( strncmp(var, "dhcp=", 5) == 0 ) { // DHCP 92 | cfg_set_dhcp(var[5] == 'Y'); 93 | } 94 | else if( strncmp(var, "ip=", 3) == 0 ) { // Local IP address 95 | net_ipaddr_set(&var[3]); 96 | cfg_set_ipaddr(&var[3]); 97 | } 98 | else if( strncmp (var, "msk=", 4) == 0 ) { // Local network mask 99 | net_mask_set(&var[4]); 100 | cfg_set_mask(&var[4]); 101 | } 102 | else if( strncmp (var, "gw=", 3) == 0 ) { // Default gateway IP address 103 | net_defgw_set(&var[3]); 104 | cfg_set_defgw(&var[3]); 105 | } 106 | else if( strncmp (var, "pdns=", 5) == 0 ) { // Primary DNS server IP address 107 | net_pridns_set(&var[5]); 108 | } 109 | else if( strncmp (var, "sdns=", 5) == 0 ) { // Secondary DNS server IP address 110 | net_secdns_set(&var[5]); 111 | } 112 | else if( strncmp (var, "mac=", 4) == 0 ) { // MAC Address 113 | eth_macaddr_set(&var[4]); 114 | cfg_set_macaddr(&var[4]); 115 | } 116 | else if( strncmp (var, "bdr=", 4) == 0 ) { // ProfiBUS-DP Baud rate 117 | cfg_set_baudrate(atol(&var[4])); 118 | } 119 | else if( strncmp (var, "psw=", 4) == 0 ) { // Password 120 | net_psw_set(&var[4]); 121 | cfg_set_password(&var[4]); 122 | } 123 | } 124 | } while(qstr); 125 | 126 | free(var); 127 | } 128 | 129 | 130 | /***************************** END OF FILE **************************************************************/ 131 | /** @} 132 | *** @} 133 | *** @} 134 | ***********************************************************************************************************/ 135 | 136 | 137 | -------------------------------------------------------------------------------- /Soft_MCU/App/net_user.h: -------------------------------------------------------------------------------- 1 | /**********************************************************************************************************/ 2 | /** @file net_user.h 3 | *** @author Linghu 4 | *** @version V1.0.0 5 | *** @date 2015/7/27 6 | *** @brief TCP/IP stack user. 7 | *********************************************************************************************************** 8 | *** @par Last Commit: 9 | *** \$Author$ \n 10 | *** \$Date$ \n 11 | *** \$Rev$ \n 12 | *** \$URL$ \n 13 | *** 14 | *** @par Change Logs: 15 | *** 2015/7/27 -- Linghu -- the first version 16 | ***********************************************************************************************************/ 17 | #ifndef __NET_USER_H___20150727_110308 18 | #define __NET_USER_H___20150727_110308 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | /**********************************************************************************************************/ 24 | /** @addtogroup NET_USER 25 | *** @{ 26 | *** @addtogroup NET_USER_Exported_Functions 27 | *** @{ 28 | ***********************************************************************************************************/ 29 | 30 | void net_init(void); 31 | 32 | int eth_dhcp_status(void); 33 | void eth_dhcp_disable(void); 34 | 35 | const char* eth_macaddr_get(void); 36 | int eth_macaddr_set(const char* mac_in); 37 | 38 | int eth_linkstatus_get(void); 39 | void eth_linkstatus_set(uint8_t status); 40 | 41 | uint32_t net_ipaddr_local(void); 42 | const char* net_ipaddr_get(void); 43 | int net_ipaddr_set(const char* ip_in); 44 | 45 | uint32_t net_defgw_local(void); 46 | const char* net_defgw_get(void); 47 | int net_defgw_set(const char* ip_in); 48 | 49 | uint32_t net_mask_local(void); 50 | const char* net_mask_get(void); 51 | int net_mask_set(const char* ip_in); 52 | 53 | const char* net_pridns_get(void); 54 | int net_pridns_set(const char* ip_in); 55 | 56 | const char* net_secdns_get(void); 57 | int net_secdns_set(const char* ip_in); 58 | 59 | const char* net_psw_get(void); 60 | int net_psw_set(const char* psw_in); 61 | 62 | 63 | /***************************** END OF FILE **************************************************************/ 64 | /** @} 65 | *** @} 66 | *****/ 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | #endif 71 | /**********************************************************************************************************/ 72 | 73 | -------------------------------------------------------------------------------- /Soft_MCU/App/netiod.c: -------------------------------------------------------------------------------- 1 | /**********************************************************************************************************/ 2 | /** @file netio.c 3 | *** @author Linghu 4 | *** @version V1.0.0 5 | *** @date 2015/7/24 6 | *** @brief NetIO Server for CMSIS_OS and MDK TCP/IP stack. 7 | *********************************************************************************************************** 8 | *** @par Last Commit: 9 | *** \$Author$ \n 10 | *** \$Date$ \n 11 | *** \$Rev$ \n 12 | *** \$URL$ \n 13 | *** 14 | *** @par Change Logs: 15 | *** 2015/7/24 -- Linghu -- the first version 16 | ***********************************************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "cmsis_os.h" /* CMSIS RTOS definitions */ 22 | #include "rl_net.h" /* Network definitions */ 23 | #include "netiod.h" 24 | 25 | 26 | /**********************************************************************************************************/ 27 | /** @addtogroup NETIO 28 | *** @{ 29 | *** @addtogroup NETIO_Pravate 30 | *** @{ 31 | *** @addtogroup NETIO_Private_Constants 32 | *** @{ 33 | ***********************************************************************************************************/ 34 | 35 | #define DEFAULTPORT 0x494F /* "IO" */ 36 | #define TMAXSIZE (1 * 1024) /* buff size */ 37 | #define INTERVAL 6 /* timeout of seconds */ 38 | 39 | #define CMD_QUIT 0 40 | #define CMD_C2S 1 41 | #define CMD_S2C 2 42 | #define CMD_RES 3 43 | #define CTLSIZE sizeof(CONTROL) 44 | 45 | 46 | /**********************************************************************************************************/ 47 | /** @} 48 | *** @addtogroup NETIO_Private_Macros 49 | *** @{ 50 | ***********************************************************************************************************/ 51 | 52 | #ifndef max 53 | #define max(x, y) ((x) > (y) ? (x) : (y)) 54 | #endif 55 | 56 | #ifndef min 57 | #define min(x, y) ((x) < (y) ? (x) : (y)) 58 | #endif 59 | 60 | 61 | /**********************************************************************************************************/ 62 | /** @} 63 | *** @addtogroup NETIO_Private_Types 64 | *** @{ 65 | ***********************************************************************************************************/ 66 | 67 | typedef struct { 68 | uint32_t cmd; 69 | uint32_t data; 70 | } CONTROL; 71 | 72 | 73 | /**********************************************************************************************************/ 74 | /** @} 75 | *** @addtogroup NETIO_Private_Variables 76 | *** @{ 77 | ***********************************************************************************************************/ 78 | 79 | static char cBuffer[TMAXSIZE] __attribute__((aligned(256))); /* Send & Recv buffer */ 80 | 81 | /**********************************************************************************************************/ 82 | /** @} 83 | *** @addtogroup NETIO_Private_Prototypes 84 | *** @{ 85 | ***********************************************************************************************************/ 86 | 87 | static void NetioD_TCP(void const *arg); 88 | 89 | /**********************************************************************************************************/ 90 | /** @} 91 | *** @addtogroup NETIO_Private_Functions 92 | *** @{ 93 | ***********************************************************************************************************/ 94 | /** @brief Initialize NetIO Server. 95 | ***********************************************************************************************************/ 96 | 97 | void netiod_init( void ) 98 | { 99 | static osThreadDef(NetioD_TCP, osPriorityAboveNormal, 1, 0); 100 | osThreadId threadID; 101 | 102 | threadID = osThreadCreate(osThread(NetioD_TCP), NULL); 103 | assert(threadID != NULL); (void)threadID; 104 | } 105 | 106 | 107 | /**********************************************************************************************************/ 108 | /** @brief NetIO Server function 109 | ***********************************************************************************************************/ 110 | 111 | static void NetioD_TCP(void const *arg) 112 | { 113 | CONTROL ctl; 114 | struct sockaddr_in addr; 115 | int server, client; 116 | uint32_t nByte; 117 | uint32_t nData; 118 | int rc; 119 | uint32_t ed; 120 | 121 | osDelay(5000); 122 | printf("[NetIO] Server start, "); 123 | if( (server = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) { 124 | printf("malloc socket failed!\r\n"); 125 | return; 126 | } 127 | addr.sin_family = PF_INET; 128 | addr.sin_port = htons(DEFAULTPORT); 129 | addr.sin_addr.s_addr = INADDR_ANY; 130 | if( bind(server, (struct sockaddr *)&addr, sizeof(addr)) < 0 ) { 131 | printf("bind socket failed!\r\n"); 132 | closesocket(server); 133 | return; 134 | } 135 | if( listen(server, 2) != 0 ) { 136 | printf("listen failed!\r\n"); 137 | closesocket(server); 138 | return; 139 | } else { 140 | printf("TCP Port: %d\r\n", DEFAULTPORT); 141 | } 142 | 143 | for(;;) 144 | { 145 | if( (client = accept(server, NULL, NULL)) < 0 ) continue; 146 | //printf("[NetIO] client accepted \r\n"); 147 | 148 | for(rc = 1; ; ) 149 | { 150 | if( recv(client, (void*)&ctl, CTLSIZE, 0) != CTLSIZE ) break; 151 | ctl.cmd = ntohl(ctl.cmd); 152 | ctl.data = ntohl(ctl.data); 153 | 154 | if( ctl.cmd == CMD_C2S ) 155 | { 156 | //printf("[NetIO] CMD_C2S start: %lu \r\n", ctl.data); 157 | for(nData = 0, rc = ed = 1; (rc > 0) && (ed); nData += ctl.data) 158 | { 159 | for(nByte = 0; nByte < ctl.data; nByte += rc) 160 | { 161 | rc = recv(client, cBuffer, min(TMAXSIZE, ctl.data - nByte), 0); 162 | if( rc <= 0 ) break; 163 | if( (nByte == 0) && (cBuffer[0] != 0) ) ed = 0; 164 | } 165 | if( rc <= 0 ) break; 166 | } 167 | //printf("[NetIO] CMD_C2S end: %lu \r\n", nData); 168 | } 169 | else if( ctl.cmd == CMD_S2C ) 170 | { 171 | extern volatile uint32_t os_time; // only for Keil RTX 172 | extern const uint32_t os_clockrate; // only for Keil RTX 173 | //printf("[NetIO] CMD_S2C start: %lu \r\n", ctl.data); 174 | for(nData = 0, ed = os_time; (os_time - ed) < (INTERVAL * os_clockrate); nData += ctl.data) 175 | { 176 | for(cBuffer[0] = 0, nByte = 0; nByte < ctl.data; nByte += rc) 177 | { 178 | rc = send(client, cBuffer, min(TMAXSIZE, ctl.data - nByte), 0); 179 | if( rc <= 0 ) break; 180 | } 181 | if( rc <= 0 ) break; 182 | } 183 | { 184 | for(cBuffer[0] = 1, nByte = 0; nByte < ctl.data; nByte += rc) 185 | { 186 | rc = send(client, cBuffer, min(TMAXSIZE, ctl.data - nByte), 0); 187 | if( rc <= 0 ) break; 188 | } 189 | } 190 | //printf("[NetIO] CMD_S2C end: %lu \r\n", nData + ctl.data); 191 | } 192 | else break; /* quit */ 193 | } 194 | 195 | closesocket(client); 196 | //printf("[NetIO] client close \r\n"); 197 | if( rc <= 0 ) break; 198 | } 199 | 200 | return; 201 | } 202 | 203 | 204 | /***************************** END OF FILE **************************************************************/ 205 | /** @} 206 | *** @} 207 | *** @} 208 | ***********************************************************************************************************/ 209 | 210 | -------------------------------------------------------------------------------- /Soft_MCU/App/netiod.h: -------------------------------------------------------------------------------- 1 | /**********************************************************************************************************/ 2 | /** @file netio.h 3 | *** @author Linghu 4 | *** @version V1.0.0 5 | *** @date 2015/7/24 6 | *** @brief NetIO Server for CMSIS_OS and MDK TCP/IP stack. 7 | *********************************************************************************************************** 8 | *** @par Last Commit: 9 | *** \$Author$ \n 10 | *** \$Date$ \n 11 | *** \$Rev$ \n 12 | *** \$URL$ \n 13 | *** 14 | *** @par Change Logs: 15 | *** 2015/7/24 -- Linghu -- the first version 16 | ***********************************************************************************************************/ 17 | #ifndef __NETIO_H___20150724_100956 18 | #define __NETIO_H___20150724_100956 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | /**********************************************************************************************************/ 24 | /** @addtogroup NETIO 25 | *** @{ 26 | *** @addtogroup NETIO_Exported_Functions 27 | *** @{ 28 | ***********************************************************************************************************/ 29 | 30 | extern void netiod_init(void); 31 | 32 | /***************************** END OF FILE **************************************************************/ 33 | /** @} 34 | *** @} 35 | *****/ 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | #endif 40 | /**********************************************************************************************************/ 41 | 42 | -------------------------------------------------------------------------------- /Soft_MCU/Auto_FcArm_Cmd.inp: -------------------------------------------------------------------------------- 1 | index.htm, 2 | pg_header.inc, 3 | pg_footer.inc, 4 | ad.cgi, 5 | ad.cgx, 6 | buttons.cgi, 7 | buttons.cgx, 8 | language.cgi, 9 | lcd.cgi, 10 | leds.cgi, 11 | network.cgi, 12 | system.cgi, 13 | tcp.cgi, 14 | xml_http.js, 15 | home.png, 16 | keil.gif, 17 | logo.gif, 18 | llblue.jpg, 19 | pabb.gif 20 | TO Web.c RTE NOPRINT ROOT(Web) 21 | -------------------------------------------------------------------------------- /Soft_MCU/BSP/STM32F40xxx_41xxx_OPT.s: -------------------------------------------------------------------------------- 1 | ;/*****************************************************************************/ 2 | ;/* STM32F40xxx_41xxx_OPT.s: STM32F405xx/07xx and */ 3 | ;/* STM32F415xx/17xx Flash Option Bytes */ 4 | ;/*****************************************************************************/ 5 | ;/* <<< Use Configuration Wizard in Context Menu >>> */ 6 | ;/*****************************************************************************/ 7 | ;/* This file is part of the uVision/ARM development tools */ 8 | ;/* Copyright (c) 2014 Keil - An ARM Company. */ 9 | ;/* All rights reserved. */ 10 | ;/*****************************************************************************/ 11 | 12 | ;// Flash Option Bytes 13 | FLASH_OPT EQU 0 14 | 15 | ;// Flash Read Protection 16 | ;// Read protection is used to protect the software code stored in Flash memory 17 | ;// Read Protection Level 18 | ;// Level 0: No Protection 19 | ;// Level 1: Read Protection of Memories (debug features limited) 20 | ;// Level 2: Chip Protection (debug and boot in RAM features disabled) 21 | ;// <0xAA=> Level 0 (No Protection) 22 | ;// <0x00=> Level 1 (Read Protection of Memories) 23 | ;// <0xCC=> Level 2 (Chip Protection) 24 | ;// 25 | 26 | ;// Flash Write Protection 27 | ;// nWRP Sectors 0 to 11 28 | ;// Not write protect Sectors 0 to 11 29 | ;// Sector 0 30 | ;// Sector 1 31 | ;// Sector 2 32 | ;// Sector 3 33 | ;// Sector 4 34 | ;// Sector 5 35 | ;// Sector 6 36 | ;// Sector 7 37 | ;// Sector 8 38 | ;// Sector 9 39 | ;// Sector 10 40 | ;// Sector 11 41 | ;// 42 | ;// 43 | 44 | ;// User Configuration 45 | ;// BOR_LEV 46 | ;// <0=> BOR Level 3 (VBOR3). Reset threshold level from 2.70 to 3.60 V 47 | ;// <1=> BOR Level 2 (VBOR2). Reset threshold level from 2.40 to 2.70 V 48 | ;// <2=> BOR Level 1 (VBOR1). Reset threshold level from 2.10 to 2.40 V 49 | ;// <3=> BOR off (VBOR0). Reset threshold level from 1.80 to 2.10 V 50 | ;// WDG_SW 51 | ;// <0=> HW Watchdog 52 | ;// <1=> SW Watchdog 53 | ;// nRST_STOP 54 | ;// Generate Reset when entering STOP Mode 55 | ;// <0=> Enabled 56 | ;// <1=> Disabled 57 | ;// nRST_STDBY 58 | ;// Generate Reset when entering Standby Mode 59 | ;// <0=> Enabled 60 | ;// <1=> Disabled 61 | ;// 62 | 63 | FLASH_OPTCR EQU 0x0FFFAAEC 64 | ;// 65 | 66 | 67 | IF FLASH_OPT <> 0 68 | AREA |.ARM.__AT_0x1FFFC000|, CODE, READONLY 69 | DCD FLASH_OPTCR 70 | ENDIF 71 | 72 | END 73 | -------------------------------------------------------------------------------- /Soft_MCU/BSP/SVC_Table.s: -------------------------------------------------------------------------------- 1 | ;/*---------------------------------------------------------------------------- 2 | ; * CMSIS-RTOS - RTX 3 | ; *---------------------------------------------------------------------------- 4 | ; * Name: SVC_TABLE.S 5 | ; * Purpose: Pre-defined SVC Table for Cortex-M 6 | ; * Rev.: V4.70 7 | ; *---------------------------------------------------------------------------- 8 | ; * 9 | ; * Copyright (c) 1999-2009 KEIL, 2009-2013 ARM Germany GmbH 10 | ; * All rights reserved. 11 | ; * Redistribution and use in source and binary forms, with or without 12 | ; * modification, are permitted provided that the following conditions are met: 13 | ; * - Redistributions of source code must retain the above copyright 14 | ; * notice, this list of conditions and the following disclaimer. 15 | ; * - Redistributions in binary form must reproduce the above copyright 16 | ; * notice, this list of conditions and the following disclaimer in the 17 | ; * documentation and/or other materials provided with the distribution. 18 | ; * - Neither the name of ARM nor the names of its contributors may be used 19 | ; * to endorse or promote products derived from this software without 20 | ; * specific prior written permission. 21 | ; * 22 | ; * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | ; * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | ; * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | ; * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 26 | ; * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | ; * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | ; * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | ; * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | ; * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | ; * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | ; * POSSIBILITY OF SUCH DAMAGE. 33 | ; *---------------------------------------------------------------------------*/ 34 | 35 | 36 | AREA SVC_TABLE, CODE, READONLY 37 | 38 | EXPORT SVC_Count 39 | 40 | SVC_Cnt EQU (SVC_End-SVC_Table)/4 41 | SVC_Count DCD SVC_Cnt 42 | 43 | ; Import user SVC functions here. 44 | ; IMPORT __SVC_1 45 | 46 | EXPORT SVC_Table 47 | SVC_Table 48 | ; Insert user SVC functions here. SVC 0 used by RTL Kernel. 49 | ; DCD __SVC_1 ; user SVC function 50 | 51 | SVC_End 52 | 53 | END 54 | 55 | /*---------------------------------------------------------------------------- 56 | * end of file 57 | *---------------------------------------------------------------------------*/ 58 | -------------------------------------------------------------------------------- /Soft_MCU/BSP/board.c: -------------------------------------------------------------------------------- 1 | /**********************************************************************************************************/ 2 | /** @file board.c 3 | *** @author Linghu 4 | *** @version V1.0.0 5 | *** @date 2015/7/23 6 | *** @brief Board Support Package. 7 | *********************************************************************************************************** 8 | *** @par Last Commit: 9 | *** \$Author$ \n 10 | *** \$Date$ \n 11 | *** \$Rev$ \n 12 | *** \$URL$ \n 13 | *** 14 | *** @par Change Logs: 15 | *** 2015/7/23 -- Linghu -- the first version 16 | ***********************************************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include "cmsis_os.h" /* CMSIS RTOS definitions */ 21 | #include "stm32f4xx.h" 22 | #include "board.h" 23 | 24 | 25 | /**********************************************************************************************************/ 26 | /** @addtogroup BOARD 27 | *** @{ 28 | *** @addtogroup BOARD_Pravate 29 | *** @{ 30 | *** @addtogroup BOARD_Private_Functions 31 | *** @{ 32 | ***********************************************************************************************************/ 33 | /** @brief Board Initialize 34 | ***********************************************************************************************************/ 35 | 36 | void board_init(void) 37 | { 38 | extern int stdio_init(void); 39 | 40 | 41 | MODIFY_REG(RCC->CFGR, (0x3u << 21) | (0x7u << 24) /* MCO1 selected HSE oscillator clock */ 42 | , (0x2u << 21) | (0x0u << 24)); 43 | MODIFY_REG(RCC->AHB1ENR, 0 /* Enable GPIOA clock */ 44 | , RCC_AHB1ENR_GPIOAEN); 45 | MODIFY_REG(GPIOA->MODER, (0x3u << 2*(8)) /* PA8 to MCO1 */ 46 | , (0x2u << 2*(8))); 47 | MODIFY_REG(GPIOA->AFR[1], (0xFu << 4*(8-8)) 48 | , (0x0u << 4*(8-8))); 49 | MODIFY_REG(GPIOA->OTYPER, (0x1u << 1*(8)) /* PA8 Output push-pull */ 50 | , (0x0u << 1*(8))); 51 | MODIFY_REG(GPIOA->OSPEEDR, (0x3u << 2*(8)) /* PA8 Output High speed */ 52 | , (0x3u << 2*(8))); 53 | MODIFY_REG(GPIOA->PUPDR, (0x3u << 2*(8)) /* PA8 No pull-up, pull-down */ 54 | , (0x0u << 2*(8))); 55 | 56 | MODIFY_REG(RCC->AHB1ENR, 0 /* Enable GPIOD clock */ 57 | , RCC_AHB1ENR_GPIODEN); 58 | MODIFY_REG(GPIOD->MODER, (0x3u << 2*(8)) /* PD8 Input mode */ 59 | , (0x0u << 2*(8))); 60 | MODIFY_REG(GPIOD->PUPDR, (0x3u << 2*(8)) /* PD8 pull-up */ 61 | , (0x1u << 2*(8))); 62 | 63 | //stdio_init(); // Init StdIO of Compiler retarget_io 64 | HAL_Init(); // Init STM32 HAL drivers 65 | stdio_init(); // Init StdIO of Compiler retarget_io 66 | 67 | printf("\r\n[Board] Syetme start...\r\n"); 68 | printf("[Board] System Clock Configed. System Core Clock: %luHz\r\n", (unsigned long)HAL_RCC_GetHCLKFreq()); 69 | } 70 | 71 | 72 | /**********************************************************************************************************/ 73 | /** @brief Reset default setting key status 74 | ***********************************************************************************************************/ 75 | 76 | int bsp_clear_key(void) 77 | { 78 | int i; 79 | 80 | if( !READ_BIT(GPIOD->IDR, (0x1u << 8)) ) 81 | { 82 | for(i = 0; !READ_BIT(GPIOD->IDR, (0x1u << 8)); i++) 83 | { 84 | osDelay(10); 85 | if( ++i > 300 ) { 86 | return( 1 ); 87 | } 88 | } 89 | } 90 | return( 0 ); 91 | } 92 | 93 | 94 | /**********************************************************************************************************/ 95 | /** @brief System Clock Configuration. 96 | ***********************************************************************************************************/ 97 | 98 | static void SystemClock_Config(void) 99 | { 100 | RCC_OscInitTypeDef RCC_OscInitStruct; 101 | RCC_ClkInitTypeDef RCC_ClkInitStruct; 102 | 103 | /* Enable Power Control clock */ 104 | // __PWR_CLK_ENABLE(); 105 | 106 | /* The voltage scaling allows optimizing the power consumption when the 107 | device is clocked below the maximum system frequency (see datasheet). */ 108 | // __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); 109 | 110 | /* Enable HSE Oscillator and activate PLL with HSE as source */ 111 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; 112 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; 113 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 114 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; 115 | RCC_OscInitStruct.PLL.PLLM = 25; 116 | RCC_OscInitStruct.PLL.PLLN = 336; 117 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; 118 | RCC_OscInitStruct.PLL.PLLQ = 7; 119 | HAL_RCC_OscConfig(&RCC_OscInitStruct); 120 | 121 | /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ 122 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; 123 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 124 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 125 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; 126 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; 127 | HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5); 128 | 129 | /* Update SystemCoreClock variable */ 130 | SystemCoreClockUpdate(); 131 | } 132 | 133 | 134 | /**********************************************************************************************************/ 135 | /** brief Redefine HAL function. 136 | ***********************************************************************************************************/ 137 | 138 | void HAL_MspInit(void) 139 | { 140 | SystemClock_Config(); 141 | } 142 | 143 | void HAL_MspDeInit(void) 144 | { 145 | } 146 | 147 | #ifdef __RTX 148 | HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) 149 | { 150 | (void)TickPriority; 151 | return HAL_OK; 152 | } 153 | 154 | void HAL_IncTick(void) 155 | { 156 | } 157 | 158 | uint32_t HAL_GetTick(void) 159 | { 160 | extern uint32_t os_time; 161 | return os_time; 162 | } 163 | 164 | void HAL_Delay(__IO uint32_t Delay) 165 | { 166 | osStatus HAL_Delay_Status = osDelay(Delay); 167 | assert(HAL_Delay_Status == osEventTimeout); (void)HAL_Delay_Status; 168 | } 169 | 170 | void HAL_SuspendTick(void) 171 | { 172 | assert(0); 173 | } 174 | 175 | void HAL_ResumeTick(void) 176 | { 177 | assert(0); 178 | } 179 | #endif 180 | 181 | #ifdef USE_FULL_ASSERT 182 | void assert_failed(uint8_t *file, uint32_t line) 183 | { 184 | void _ttywrs(const char *s); 185 | void _ttywrd(int32_t n); 186 | 187 | _ttywrs("\r\n*** assertion failed at file: "); 188 | _ttywrs((const char*)file); 189 | _ttywrs(", line: "); 190 | _ttywrd((int32_t)line); 191 | _ttywrs("\r\n"); 192 | 193 | abort(); 194 | } 195 | 196 | __inline void _ttywrs(const char *s) 197 | { 198 | extern void _ttywrch(int ch); 199 | 200 | for(; s[0] != '\0'; s++) { 201 | _ttywrch(s[0]); 202 | } 203 | } 204 | 205 | __inline void _ttywrd(int32_t n) 206 | { 207 | extern void _ttywrch(int ch); 208 | int32_t x, y; 209 | int b; 210 | 211 | for(b = 0, y = 1000000000; y != 0; y /= 10) 212 | { 213 | x = n / y; n %= y; 214 | if( x != 0 ) b = 1; 215 | if( b != 0 ) _ttywrch(x + '0'); 216 | } 217 | } 218 | #endif 219 | 220 | 221 | /***************************** END OF FILE **************************************************************/ 222 | /** @} 223 | *** @} 224 | *** @} 225 | ***********************************************************************************************************/ 226 | 227 | -------------------------------------------------------------------------------- /Soft_MCU/BSP/board.h: -------------------------------------------------------------------------------- 1 | /**********************************************************************************************************/ 2 | /** @file board.h 3 | *** @author Linghu 4 | *** @version V1.0.0 5 | *** @date 2015/7/23 6 | *** @brief Board Support Package. 7 | *********************************************************************************************************** 8 | *** @par Last Commit: 9 | *** \$Author$ \n 10 | *** \$Date$ \n 11 | *** \$Rev$ \n 12 | *** \$URL$ \n 13 | *** 14 | *** @par Change Logs: 15 | *** 2015/7/23 -- Linghu -- the first version 16 | ***********************************************************************************************************/ 17 | #ifndef __BOARD_H___20150723_160326 18 | #define __BOARD_H___20150723_160326 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | /**********************************************************************************************************/ 24 | /** @addtogroup BOARD 25 | *** @{ 26 | *** @addtogroup BOARD_Exported_Functions 27 | *** @{ 28 | ***********************************************************************************************************/ 29 | 30 | extern void board_init(void); 31 | extern int bsp_clear_key(void); 32 | 33 | 34 | /***************************** END OF FILE **************************************************************/ 35 | /** @} 36 | *** @} 37 | *****/ 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | #endif 42 | /**********************************************************************************************************/ 43 | 44 | -------------------------------------------------------------------------------- /Soft_MCU/BSP/stm32f4_iap_flash.h: -------------------------------------------------------------------------------- 1 | /**********************************************************************************************************/ 2 | /** @file stm32f4_iap_flash.h 3 | *** @author Linghu 4 | *** @version V1.0.0 5 | *** @date 2015/7/20 6 | *** @brief File System Flash Device Driver for STM32F4XX IAP. 7 | *********************************************************************************************************** 8 | *** @par Last Commit: 9 | *** \$Author$ \n 10 | *** \$Date$ \n 11 | *** \$Rev$ \n 12 | *** \$URL$ \n 13 | *** 14 | *** @par Change Logs: 15 | *** 2015/7/20 -- Linghu -- the first version 16 | ***********************************************************************************************************/ 17 | #ifndef __IAP_FLASH_H___20150720_151446 18 | #define __IAP_FLASH_H___20150720_151446 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | /**********************************************************************************************************/ 24 | /** @addtogroup IAP_FLASH 25 | *** @{ 26 | *** @addtogroup IAP_FLASH_Exported_Constants 27 | *** @{ 28 | ***********************************************************************************************************/ 29 | 30 | #define DRIVER_FLASH_NUM 0 /* Driver number */ 31 | 32 | #define FLASH_EFS_ADDR 0x08040000 /* Flash base address */ 33 | #define FLASH_EFS_SIZE (6 * 128 * 1024) /* Flash size in bytes */ 34 | 35 | #define FLASH_SECTOR_COUNT 6 /* Number of Sectors */ 36 | #define FLASH_SECTOR_SIZE 0 /* FLASH_SECTORS information used */ 37 | #define FLASH_PAGE_SIZE 4 /* Programming page size in bytes */ 38 | #define FLASH_PROGRAM_UNIT 4 /* Smallest programmable unit in bytes */ 39 | #define FLASH_ERASED_VALUE 0xFF /* Contents of erased memory */ 40 | 41 | 42 | #define FLASH_SECTORS \ 43 | ARM_FLASH_SECTOR_INFO(0x000000*2, 0x20000), /* Sector size 128kB */ \ 44 | ARM_FLASH_SECTOR_INFO(0x010000*2, 0x20000), /* Sector size 128kB */ \ 45 | ARM_FLASH_SECTOR_INFO(0x020000*2, 0x20000), /* Sector size 128kB */ \ 46 | ARM_FLASH_SECTOR_INFO(0x030000*2, 0x20000), /* Sector size 128kB */ \ 47 | ARM_FLASH_SECTOR_INFO(0x040000*2, 0x20000), /* Sector size 128kB */ \ 48 | ARM_FLASH_SECTOR_INFO(0x050000*2, 0x20000) /* Sector size 128kB */ 49 | 50 | 51 | /***************************** END OF FILE **************************************************************/ 52 | /** @} 53 | *** @} 54 | *****/ 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | #endif 59 | /**********************************************************************************************************/ 60 | 61 | -------------------------------------------------------------------------------- /Soft_MCU/Debug.ini: -------------------------------------------------------------------------------- 1 | WS 2, `PBDP_Info.idl_cnt,0x0A 2 | WS 2, `PBDP_Info.rx_que.head % 4096,0x0A 3 | WS 2, `PBDP_Info.rx_que.tail % 4096,0x0A 4 | WS 2, `PBDP_Info.rx_que.elem 5 | WS 2, `PBDP_Info 6 | WS 2, `PBDP_Info.err_ovr,0x0A 7 | WS 2, `PBDP_Info.err_chk,0x0A 8 | WS 2, `s_ErrPE,0x0A 9 | WS 2, `s_ErrFE,0x0A 10 | WS 2, `s_ErrNE,0x0A 11 | WS 2, `s_ErrORE,0x0A 12 | WS 2, `PBDP_Info.dbg_evt.head % 1024,0x0A 13 | WS 2, `PBDP_Info.dbg_evt.tail % 1024,0x0A 14 | WS 2, `PBDP_Info.dbg_evt.elem 15 | -------------------------------------------------------------------------------- /Soft_MCU/HTTP_Server.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * MDK Middleware - Component ::Network 3 | * Copyright (c) 2004-2014 ARM Germany GmbH. All rights reserved. 4 | *------------------------------------------------------------------------------ 5 | * Name: HTTP_Server.c 6 | * Purpose: HTTP Server example 7 | *----------------------------------------------------------------------------*/ 8 | 9 | #include 10 | #include 11 | #include "cmsis_os.h" /* CMSIS RTOS definitions */ 12 | #include "rl_net.h" /* Network definitions */ 13 | #include "rl_fs.h" /* FileSystem definitions */ 14 | 15 | #include "stm32f4xx_hal.h" 16 | #ifndef MINI_STM32F429 17 | #include "Board_GLCD.h" 18 | #include "GLCD_Config.h" 19 | #endif 20 | #include "Board_LED.h" 21 | #include "Board_Buttons.h" 22 | #include "Board_ADC.h" 23 | 24 | #ifndef MINI_STM32F429 25 | extern GLCD_FONT GLCD_Font_6x8; 26 | extern GLCD_FONT GLCD_Font_16x24; 27 | #endif 28 | 29 | bool LEDrun; 30 | bool LCDupdate; 31 | char lcd_text[2][20+1]; 32 | 33 | static void BlinkLed (void const *arg); 34 | static void Display (void const *arg); 35 | 36 | osThreadDef(BlinkLed, osPriorityNormal, 1, 0); 37 | osThreadDef(Display, osPriorityNormal, 1, 0); 38 | 39 | /// Read analog inputs 40 | uint16_t AD_in (uint32_t ch) { 41 | int32_t val = 0; 42 | 43 | if (ch == 0) { 44 | ADC_StartConversion(); 45 | while (ADC_ConversionDone () < 0); 46 | val = ADC_GetValue(); 47 | } 48 | return (val); 49 | } 50 | 51 | /// Read digital inputs 52 | uint8_t get_button (void) { 53 | return (Buttons_GetState ()); 54 | } 55 | 56 | /// IP address change notification 57 | void dhcp_client_notify (uint32_t if_num, 58 | dhcpClientOption opt, const uint8_t *val, uint32_t len) { 59 | if (opt == dhcpClientIPaddress) { 60 | // IP address has changed 61 | sprintf (lcd_text[0],"IP address:"); 62 | sprintf (lcd_text[1],"%s", ip4_ntoa (val)); 63 | LCDupdate = true; 64 | } 65 | } 66 | 67 | /*---------------------------------------------------------------------------- 68 | Thread 'Display': LCD display handler 69 | *---------------------------------------------------------------------------*/ 70 | static void Display (void const *arg) { 71 | #ifndef MINI_STM32F429 72 | char lcd_buf[20+1]; 73 | 74 | GLCD_Initialize (); 75 | GLCD_SetBackgroundColor (GLCD_COLOR_BLUE); 76 | GLCD_SetForegroundColor (GLCD_COLOR_WHITE); 77 | GLCD_ClearScreen (); 78 | GLCD_SetFont (&GLCD_Font_16x24); 79 | GLCD_DrawString (0, 1*24, " MDK-MW "); 80 | GLCD_DrawString (0, 2*24, "HTTP Server example "); 81 | 82 | sprintf (lcd_text[0], ""); 83 | sprintf (lcd_text[1], "Waiting for DHCP"); 84 | LCDupdate = true; 85 | 86 | while(1) { 87 | if (LCDupdate == true) { 88 | sprintf (lcd_buf, "%-20s", lcd_text[0]); 89 | GLCD_DrawString (0, 5*24, lcd_buf); 90 | sprintf (lcd_buf, "%-20s", lcd_text[1]); 91 | GLCD_DrawString (0, 6*24, lcd_buf); 92 | LCDupdate = false; 93 | } 94 | osDelay (250); 95 | } 96 | #else 97 | while(1) { 98 | osDelay(250); 99 | } 100 | #endif 101 | } 102 | 103 | /*---------------------------------------------------------------------------- 104 | Thread 'BlinkLed': Blink the LEDs on an eval board 105 | *---------------------------------------------------------------------------*/ 106 | static void BlinkLed (void const *arg) { 107 | const uint8_t led_val[16] = { 0x48,0x88,0x84,0x44,0x42,0x22,0x21,0x11, 108 | 0x12,0x0A,0x0C,0x14,0x18,0x28,0x30,0x50 }; 109 | int cnt = 0; 110 | 111 | LEDrun = true; 112 | while(1) { 113 | // Every 100 ms 114 | if (LEDrun == true) { 115 | LED_SetOut (led_val[cnt]); 116 | if (++cnt >= sizeof(led_val)) { 117 | cnt = 0; 118 | } 119 | } 120 | osDelay (100); 121 | } 122 | } 123 | 124 | 125 | 126 | static void init_filesystem (void) { 127 | fsStatus stat; 128 | 129 | printf ("Initializing and mounting enabled drives...\n\n"); 130 | 131 | /* Initialize and mount drive "F0" */ 132 | stat = finit ("F0:"); 133 | if (stat == fsOK) { 134 | stat = fmount ("F0:"); 135 | if (stat == fsOK) { 136 | int64_t sp = ffree("F0:"); 137 | if( sp < 0 ) { 138 | sp = 0 -sp; 139 | } 140 | printf ("Drive F0 ready! free space: %lld\n", sp); 141 | } 142 | else if (stat == fsNoFileSystem) { 143 | /* Format the drive */ 144 | printf ("Drive F0 not formatted!\n"); 145 | fformat ("F0:", ""); 146 | } 147 | else { 148 | printf ("Drive F0 mount failed with error code %d\n", stat); 149 | } 150 | } 151 | else { 152 | printf ("Drive F0 initialization failed!\n"); 153 | } 154 | 155 | /* Initialize and mount drive "M0" */ 156 | stat = finit ("M0:"); 157 | if (stat == fsOK) { 158 | stat = fmount ("M0:"); 159 | if (stat == fsOK) { 160 | printf ("Drive M0 ready!\n"); 161 | } 162 | else if (stat == fsNoFileSystem) { 163 | /* Format the drive */ 164 | printf ("Drive M0 not formatted!\n"); 165 | fformat ("M0:", ""); 166 | } 167 | else { 168 | printf ("Drive M0 mount failed with error code %d\n", stat); 169 | } 170 | } 171 | else { 172 | printf ("Drive M0 initialization failed!\n"); 173 | } 174 | 175 | /* Initialize and mount drive "N0" */ 176 | stat = finit ("N0:"); 177 | if (stat == fsOK) { 178 | stat = fmount ("N0:"); 179 | if (stat == fsOK) { 180 | printf ("Drive N0 ready!\n"); 181 | } 182 | else if (stat == fsNoFileSystem) { 183 | /* Format the drive */ 184 | printf ("Drive N0 not formatted!\n"); 185 | fformat ("N0:", ""); 186 | } 187 | else { 188 | printf ("Drive N0 mount failed with error code %d\n", stat); 189 | } 190 | } 191 | else { 192 | printf ("Drive N0 initialization failed!\n"); 193 | } 194 | 195 | printf ("\nDone!\n"); 196 | } 197 | 198 | 199 | /*---------------------------------------------------------------------------- 200 | Main Thread 'main': Run Network 201 | *---------------------------------------------------------------------------*/ 202 | 203 | extern void netiod_init( void ); 204 | int main (void) { 205 | HAL_Init(); 206 | LED_Initialize (); 207 | LED_Uninitialize (); 208 | Buttons_Initialize (); 209 | ADC_Initialize (); 210 | init_filesystem (); 211 | net_initialize (); 212 | 213 | // osThreadCreate (osThread(BlinkLed), NULL); 214 | // osThreadCreate (osThread(Display), NULL); 215 | netiod_init(); 216 | 217 | // osThreadSetPriority(osThreadGetId(), osPriorityIdle); 218 | 219 | while(1) { 220 | net_main (); 221 | osThreadYield (); 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /Soft_MCU/HTTP_Server_CGI.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * MDK Middleware - Component ::Network:Service 3 | * Copyright (c) 2004-2014 ARM Germany GmbH. All rights reserved. 4 | *------------------------------------------------------------------------------ 5 | * Name: HTTP_Server_CGI.c 6 | * Purpose: HTTP Server CGI Module 7 | * Rev.: V6.00 8 | *----------------------------------------------------------------------------*/ 9 | 10 | #include 11 | #include 12 | #include "rl_net.h" 13 | #include "rl_net_lib.h" 14 | #include "Board_LED.h" 15 | 16 | // http_server.c 17 | extern uint16_t AD_in (uint32_t ch); 18 | extern uint8_t get_button (void); 19 | 20 | // net_sys.c 21 | extern LOCALM localm[]; 22 | #define LocM localm[NETIF_ETH] 23 | 24 | // Net_Config.c 25 | extern struct tcp_cfg tcp_config; 26 | extern struct http_cfg http_config; 27 | #define tcp_NumSocks tcp_config.NumSocks 28 | #define tcp_socket tcp_config.Scb 29 | #define http_EnAuth http_config.EnAuth 30 | #define http_auth_passw http_config.Passw 31 | 32 | extern bool LEDrun; 33 | extern bool LCDupdate; 34 | extern char lcd_text[2][20+1]; 35 | 36 | // Local variables. 37 | static uint8_t P2; 38 | 39 | // My structure of CGI status variable. 40 | typedef struct { 41 | uint16_t xcnt; 42 | uint16_t unused; 43 | } MY_BUF; 44 | #define MYBUF(p) ((MY_BUF *)p) 45 | 46 | 47 | // Process query string received by GET request. 48 | __weak void cgi_process_query (const char *qstr) { 49 | char var[40]; 50 | 51 | do { 52 | // Loop through all the parameters 53 | qstr = http_get_env_var (qstr, var, sizeof (var)); 54 | // Check return string, 'qstr' now points to the next parameter 55 | if (var[0] != 0) { 56 | // First character is non-null, string exists 57 | if (strncmp (var, "ip=", 3) == 0) { 58 | // Local IP address 59 | ip4_aton (&var[3], LocM.IpAddr); 60 | } 61 | else if (strncmp (var, "msk=", 4) == 0) { 62 | // Local network mask 63 | ip4_aton (&var[4], LocM.NetMask); 64 | } 65 | else if (strncmp (var, "gw=", 3) == 0) { 66 | // Default gateway IP address 67 | ip4_aton (&var[3], LocM.DefGW); 68 | } 69 | else if (strncmp (var, "pdns=", 5) == 0) { 70 | // Primary DNS server IP address 71 | ip4_aton (&var[5], LocM.PriDNS); 72 | } 73 | else if (strncmp (var, "sdns=", 5) == 0) { 74 | // Secondary DNS server IP address 75 | ip4_aton (&var[5], LocM.SecDNS); 76 | } 77 | } 78 | } while (qstr); 79 | } 80 | 81 | 82 | 83 | // Process data received by POST request. 84 | // Type code: - 0 = www-url-encoded form data. 85 | // - 1 = filename for file upload (null-terminated string). 86 | // - 2 = file upload raw data. 87 | // - 3 = end of file upload (file close requested). 88 | // - 4 = any XML encoded POST data (single or last stream). 89 | // - 5 = the same as 4, but with more XML data to follow. 90 | void cgi_process_data (uint8_t code, const char *data, uint32_t len) { 91 | char var[40],passw[12]; 92 | 93 | if (code != 0) { 94 | // Ignore all other codes 95 | return; 96 | } 97 | 98 | P2 = 0; 99 | LEDrun = true; 100 | if (len == 0) { 101 | // No data or all items (radio, checkbox) are off 102 | LED_SetOut (P2); 103 | return; 104 | } 105 | passw[0] = 1; 106 | do { 107 | // Parse all parameters 108 | data = http_get_env_var (data, var, sizeof (var)); 109 | if (var[0] != 0) { 110 | // First character is non-null, string exists 111 | if (strcmp (var, "led0=on") == 0) { 112 | P2 |= 0x01; 113 | } 114 | else if (strcmp (var, "led1=on") == 0) { 115 | P2 |= 0x02; 116 | } 117 | else if (strcmp (var, "led2=on") == 0) { 118 | P2 |= 0x04; 119 | } 120 | else if (strcmp (var, "led3=on") == 0) { 121 | P2 |= 0x08; 122 | } 123 | else if (strcmp (var, "led4=on") == 0) { 124 | P2 |= 0x10; 125 | } 126 | else if (strcmp (var, "led5=on") == 0) { 127 | P2 |= 0x20; 128 | } 129 | else if (strcmp (var, "led6=on") == 0) { 130 | P2 |= 0x40; 131 | } 132 | else if (strcmp (var, "led7=on") == 0) { 133 | P2 |= 0x80; 134 | } 135 | else if (strcmp (var, "ctrl=Browser") == 0) { 136 | LEDrun = false; 137 | } 138 | else if ((strncmp (var, "pw0=", 4) == 0) || 139 | (strncmp (var, "pw2=", 4) == 0)) { 140 | // Change password, retyped password 141 | if (http_EnAuth) { 142 | if (passw[0] == 1) { 143 | strcpy (passw, var+4); 144 | } 145 | else if (strcmp (passw, var+4) == 0) { 146 | // Both strings are equal, change the password 147 | strcpy (http_auth_passw, passw); 148 | } 149 | } 150 | } 151 | else if (strncmp (var, "lcd1=", 5) == 0) { 152 | // LCD Module line 1 text 153 | strcpy (lcd_text[0], var+5); 154 | LCDupdate = true; 155 | } 156 | else if (strncmp (var, "lcd2=", 5) == 0) { 157 | // LCD Module line 2 text 158 | strcpy (lcd_text[1], var+5); 159 | LCDupdate = true; 160 | } 161 | } 162 | } while (data); 163 | LED_SetOut (P2); 164 | } 165 | 166 | /* 167 | // Generate dynamic web data from a script line. 168 | __weak uint32_t cgi_script (const char *env, char *buf, uint32_t buflen, uint32_t *pcgi) { 169 | TCP_INFO *tsoc; 170 | const char *lang; 171 | uint32_t len = 0; 172 | uint8_t id; 173 | static uint32_t adv; 174 | 175 | switch (env[0]) { 176 | // Analyze a 'c' script line starting position 2 177 | case 'a' : 178 | // Network parameters from 'network.cgi' 179 | switch (env[2]) { 180 | case 'i': 181 | // Write local IP address 182 | len = sprintf (buf, &env[4], ip4_ntoa (LocM.IpAddr)); 183 | break; 184 | case 'm': 185 | // Write local network mask 186 | len = sprintf (buf, &env[4], ip4_ntoa (LocM.NetMask)); 187 | break; 188 | case 'g': 189 | // Write default gateway IP address 190 | len = sprintf (buf, &env[4], ip4_ntoa (LocM.DefGW)); 191 | break; 192 | case 'p': 193 | // Write primary DNS server IP address 194 | len = sprintf (buf, &env[4], ip4_ntoa (LocM.PriDNS)); 195 | break; 196 | case 's': 197 | // Write secondary DNS server IP address 198 | len = sprintf (buf, &env[4], ip4_ntoa (LocM.SecDNS)); 199 | break; 200 | } 201 | break; 202 | 203 | case 'b': 204 | // LED control from 'led.cgi' 205 | if (env[2] == 'c') { 206 | // Select Control 207 | len = sprintf (buf, &env[4], LEDrun ? "" : "selected", 208 | LEDrun ? "selected" : "" ); 209 | break; 210 | } 211 | // LED CheckBoxes 212 | id = env[2] - '0'; 213 | if (id > 7) { 214 | id = 0; 215 | } 216 | id = 1 << id; 217 | len = sprintf (buf, &env[4], (P2 & id) ? "checked" : ""); 218 | break; 219 | 220 | case 'c': 221 | // TCP status from 'tcp.cgi' 222 | while ((len + 150) < buflen) { 223 | tsoc = &tcp_socket[MYBUF(pcgi)->xcnt]; 224 | MYBUF(pcgi)->xcnt++; 225 | // 'sprintf' format string is defined here 226 | len += sprintf (buf+len, ""); 227 | if (tsoc->State <= tcpStateCLOSED) { 228 | len += sprintf (buf+len, "%d%s--" 229 | "--\r\n", 230 | MYBUF(pcgi)->xcnt,tcp_ntoa(tsoc->State)); 231 | } 232 | else if (tsoc->State == tcpStateLISTEN) { 233 | len += sprintf (buf+len, "%d%s%d-" 234 | "--\r\n", 235 | MYBUF(pcgi)->xcnt, tcp_ntoa(tsoc->State), tsoc->LocPort); 236 | } 237 | else { 238 | len += sprintf (buf+len, "%d%s%d" 239 | "%d%s%d\r\n", 240 | MYBUF(pcgi)->xcnt, tcp_ntoa(tsoc->State), tsoc->LocPort, 241 | tsoc->AliveTimer, ip4_ntoa (tsoc->RemAddr), tsoc->RemPort); 242 | } 243 | // Repeat for all TCP Sockets 244 | if (MYBUF(pcgi)->xcnt == tcp_NumSocks) { 245 | break; 246 | } 247 | } 248 | if (MYBUF(pcgi)->xcnt < tcp_NumSocks) { 249 | // Hi bit is a repeat flag 250 | len |= (1u << 31); 251 | } 252 | break; 253 | 254 | case 'd': 255 | // System password from 'system.cgi' 256 | switch (env[2]) { 257 | case '1': 258 | len = sprintf (buf, &env[4], http_EnAuth ? "Enabled" : "Disabled"); 259 | break; 260 | case '2': 261 | len = sprintf (buf, &env[4], http_auth_passw); 262 | break; 263 | } 264 | break; 265 | 266 | case 'e': 267 | // Browser Language from 'language.cgi' 268 | lang = http_server_get_lang (); 269 | if (strncmp (lang, "en", 2) == 0) { 270 | lang = "English"; 271 | } 272 | else if (strncmp (lang, "de", 2) == 0) { 273 | lang = "German"; 274 | } 275 | else if (strncmp (lang, "fr", 2) == 0) { 276 | lang = "French"; 277 | } 278 | else if (strncmp (lang, "sl", 2) == 0) { 279 | lang = "Slovene"; 280 | } 281 | else { 282 | lang = "Unknown"; 283 | } 284 | len = sprintf (buf, &env[2], lang, http_server_get_lang()); 285 | break; 286 | 287 | case 'f': 288 | // LCD Module control from 'lcd.cgi' 289 | switch (env[2]) { 290 | case '1': 291 | len = sprintf (buf, &env[4], lcd_text[0]); 292 | break; 293 | case '2': 294 | len = sprintf (buf, &env[4], lcd_text[1]); 295 | break; 296 | } 297 | break; 298 | 299 | case 'g': 300 | // AD Input from 'ad.cgi' 301 | switch (env[2]) { 302 | case '1': 303 | adv = AD_in (0); 304 | len = sprintf (buf, &env[4], adv); 305 | break; 306 | case '2': 307 | len = sprintf (buf, &env[4], (float)adv*3.3f/4096); 308 | break; 309 | case '3': 310 | adv = (adv * 100) / 4096; 311 | len = sprintf (buf, &env[4], adv); 312 | break; 313 | } 314 | break; 315 | 316 | case 'x': 317 | // AD Input from 'ad.cgx' 318 | adv = AD_in (0); 319 | len = sprintf (buf, &env[1], adv); 320 | break; 321 | 322 | case 'y': 323 | // Button state from 'button.cgx' 324 | len = sprintf (buf, "button%c%s", 325 | env[1], (get_button () & (1 << (env[1]-'0'))) ? "true" : "false"); 326 | break; 327 | } 328 | return (len); 329 | } 330 | */ 331 | -------------------------------------------------------------------------------- /Soft_MCU/HTTP_Server_Error.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * MDK Middleware - Component ::Network:Service 3 | * Copyright (c) 2004-2014 ARM Germany GmbH. All rights reserved. 4 | *------------------------------------------------------------------------------ 5 | * Name: HTTP_Server_Error.c 6 | * Purpose: HTTP Server Friendly Error Message Definitions 7 | * Rev.: V6.00 8 | *----------------------------------------------------------------------------*/ 9 | //! [code_HTTP_Server_Error] 10 | #include "rl_net_lib.h" 11 | 12 | // Keep HTTP Error page size small 13 | HTTP_ERROR http_error = { 14 | // HTTP Error page header 15 | "Server Error" 16 | "", 17 | 18 | // HTTP Error page footer 19 | "

" 20 | "Embedded WEB Server, 2015
" 21 | "www.github.com" 22 | " - Embedded Development Tools
" 23 | "", 24 | 25 | // HTTP Error 401 - Unauthorized access 26 | "

Error 401 - Unauthorized Access

" 27 | "You are not authorized to access this server.", 28 | 29 | // HTTP Error 403 - Forbidden 30 | "

Error 403 - Forbidden

" 31 | "You don't have permission to access this resource.", 32 | 33 | // HTTP Error 404 - Not Found 34 | "

Error 404 - Not Found

" 35 | "The requested URL was not found on this server.", 36 | 37 | // HTTP Error 501 - Not Implemented 38 | "

Error 501 - Not Implemented

" 39 | "The requested Method is not supported." 40 | }; 41 | //! [code_HTTP_Server_Error] 42 | -------------------------------------------------------------------------------- /Soft_MCU/IniParser/src/dictionary.c: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------*/ 2 | /** 3 | @file dictionary.c 4 | @author N. Devillard 5 | @brief Implements a dictionary for string variables. 6 | 7 | This module implements a simple dictionary object, i.e. a list 8 | of string/string associations. This object is useful to store e.g. 9 | informations retrieved from a configuration file (ini files). 10 | */ 11 | /*--------------------------------------------------------------------------*/ 12 | 13 | /*--------------------------------------------------------------------------- 14 | Includes 15 | ---------------------------------------------------------------------------*/ 16 | #include "dictionary.h" 17 | 18 | #include 19 | #include 20 | #include 21 | #ifdef __GNUC__ 22 | #include 23 | #endif 24 | 25 | /** Maximum value size for integers and doubles. */ 26 | #define MAXVALSZ 1024 27 | 28 | /** Minimal allocated number of entries in a dictionary */ 29 | #ifndef INI_DICTMINSZ 30 | #define INI_DICTMINSZ 128 31 | #endif 32 | 33 | /** Invalid key token */ 34 | #define DICT_INVALID_KEY ((char*)-1) 35 | 36 | /*--------------------------------------------------------------------------- 37 | Private functions 38 | ---------------------------------------------------------------------------*/ 39 | 40 | /*-------------------------------------------------------------------------*/ 41 | /** 42 | @brief Duplicate a string 43 | @param s String to duplicate 44 | @return Pointer to a newly allocated string, to be freed with free() 45 | 46 | This is a replacement for strdup(). This implementation is provided 47 | for systems that do not have it. 48 | */ 49 | /*--------------------------------------------------------------------------*/ 50 | static char * xstrdup(const char * s) 51 | { 52 | char * t ; 53 | size_t len ; 54 | if (!s) 55 | return NULL ; 56 | 57 | len = strlen(s) + 1 ; 58 | t = (char*) malloc(len) ; 59 | if (t) { 60 | memcpy(t, s, len) ; 61 | } 62 | return t ; 63 | } 64 | 65 | /*-------------------------------------------------------------------------*/ 66 | /** 67 | @brief Double the size of the dictionary 68 | @param d Dictionary to grow 69 | @return This function returns non-zero in case of failure 70 | */ 71 | /*--------------------------------------------------------------------------*/ 72 | static int dictionary_grow(dictionary * d) 73 | { 74 | char ** new_val ; 75 | char ** new_key ; 76 | unsigned * new_hash ; 77 | 78 | new_val = (char**) calloc(d->size * 2, sizeof *d->val); 79 | new_key = (char**) calloc(d->size * 2, sizeof *d->key); 80 | new_hash = (unsigned*) calloc(d->size * 2, sizeof *d->hash); 81 | if (!new_val || !new_key || !new_hash) { 82 | /* An allocation failed, leave the dictionary unchanged */ 83 | if (new_val) 84 | free(new_val); 85 | if (new_key) 86 | free(new_key); 87 | if (new_hash) 88 | free(new_hash); 89 | return -1 ; 90 | } 91 | /* Initialize the newly allocated space */ 92 | memcpy(new_val, d->val, d->size * sizeof(char *)); 93 | memcpy(new_key, d->key, d->size * sizeof(char *)); 94 | memcpy(new_hash, d->hash, d->size * sizeof(unsigned)); 95 | /* Delete previous data */ 96 | free(d->val); 97 | free(d->key); 98 | free(d->hash); 99 | /* Actually update the dictionary */ 100 | d->size *= 2 ; 101 | d->val = new_val; 102 | d->key = new_key; 103 | d->hash = new_hash; 104 | return 0 ; 105 | } 106 | 107 | /*--------------------------------------------------------------------------- 108 | Function codes 109 | ---------------------------------------------------------------------------*/ 110 | /*-------------------------------------------------------------------------*/ 111 | /** 112 | @brief Compute the hash key for a string. 113 | @param key Character string to use for key. 114 | @return 1 unsigned int on at least 32 bits. 115 | 116 | This hash function has been taken from an Article in Dr Dobbs Journal. 117 | This is normally a collision-free function, distributing keys evenly. 118 | The key is stored anyway in the struct so that collision can be avoided 119 | by comparing the key itself in last resort. 120 | */ 121 | /*--------------------------------------------------------------------------*/ 122 | unsigned dictionary_hash(const char * key) 123 | { 124 | size_t len ; 125 | unsigned hash ; 126 | size_t i ; 127 | 128 | if (!key) 129 | return 0 ; 130 | 131 | len = strlen(key); 132 | for (hash=0, i=0 ; i>6) ; 136 | } 137 | hash += (hash <<3); 138 | hash ^= (hash >>11); 139 | hash += (hash <<15); 140 | return hash ; 141 | } 142 | 143 | /*-------------------------------------------------------------------------*/ 144 | /** 145 | @brief Create a new dictionary object. 146 | @param size Optional initial size of the dictionary. 147 | @return 1 newly allocated dictionary objet. 148 | 149 | This function allocates a new dictionary object of given size and returns 150 | it. If you do not know in advance (roughly) the number of entries in the 151 | dictionary, give size=0. 152 | */ 153 | /*-------------------------------------------------------------------------*/ 154 | dictionary * dictionary_new(size_t size) 155 | { 156 | dictionary * d ; 157 | 158 | /* If no size was specified, allocate space for INI_DICTMINSZ */ 159 | if (size < INI_DICTMINSZ) size = INI_DICTMINSZ ; 160 | 161 | d = (dictionary*) calloc(1, sizeof *d) ; 162 | 163 | if (d) { 164 | d->size = size ; 165 | d->val = (char**) calloc(size, sizeof *d->val); 166 | d->key = (char**) calloc(size, sizeof *d->key); 167 | d->hash = (unsigned*) calloc(size, sizeof *d->hash); 168 | } 169 | return d ; 170 | } 171 | 172 | /*-------------------------------------------------------------------------*/ 173 | /** 174 | @brief Delete a dictionary object 175 | @param d dictionary object to deallocate. 176 | @return void 177 | 178 | Deallocate a dictionary object and all memory associated to it. 179 | */ 180 | /*--------------------------------------------------------------------------*/ 181 | void dictionary_del(dictionary * d) 182 | { 183 | ssize_t i ; 184 | 185 | if (d==NULL) return ; 186 | for (i=0 ; isize ; i++) { 187 | if (d->key[i]!=NULL) 188 | free(d->key[i]); 189 | if (d->val[i]!=NULL) 190 | free(d->val[i]); 191 | } 192 | free(d->val); 193 | free(d->key); 194 | free(d->hash); 195 | free(d); 196 | return ; 197 | } 198 | 199 | /*-------------------------------------------------------------------------*/ 200 | /** 201 | @brief Get a value from a dictionary. 202 | @param d dictionary object to search. 203 | @param key Key to look for in the dictionary. 204 | @param def Default value to return if key not found. 205 | @return 1 pointer to internally allocated character string. 206 | 207 | This function locates a key in a dictionary and returns a pointer to its 208 | value, or the passed 'def' pointer if no such key can be found in 209 | dictionary. The returned character pointer points to data internal to the 210 | dictionary object, you should not try to free it or modify it. 211 | */ 212 | /*--------------------------------------------------------------------------*/ 213 | const char * dictionary_get(const dictionary * d, const char * key, const char * def) 214 | { 215 | unsigned hash ; 216 | ssize_t i ; 217 | 218 | hash = dictionary_hash(key); 219 | for (i=0 ; isize ; i++) { 220 | if (d->key[i]==NULL) 221 | continue ; 222 | /* Compare hash */ 223 | if (hash==d->hash[i]) { 224 | /* Compare string, to avoid hash collisions */ 225 | if (!strcmp(key, d->key[i])) { 226 | return d->val[i] ; 227 | } 228 | } 229 | } 230 | return def ; 231 | } 232 | 233 | /*-------------------------------------------------------------------------*/ 234 | /** 235 | @brief Set a value in a dictionary. 236 | @param d dictionary object to modify. 237 | @param key Key to modify or add. 238 | @param val Value to add. 239 | @return int 0 if Ok, anything else otherwise 240 | 241 | If the given key is found in the dictionary, the associated value is 242 | replaced by the provided one. If the key cannot be found in the 243 | dictionary, it is added to it. 244 | 245 | It is Ok to provide a NULL value for val, but NULL values for the dictionary 246 | or the key are considered as errors: the function will return immediately 247 | in such a case. 248 | 249 | Notice that if you dictionary_set a variable to NULL, a call to 250 | dictionary_get will return a NULL value: the variable will be found, and 251 | its value (NULL) is returned. In other words, setting the variable 252 | content to NULL is equivalent to deleting the variable from the 253 | dictionary. It is not possible (in this implementation) to have a key in 254 | the dictionary without value. 255 | 256 | This function returns non-zero in case of failure. 257 | */ 258 | /*--------------------------------------------------------------------------*/ 259 | int dictionary_set(dictionary * d, const char * key, const char * val) 260 | { 261 | ssize_t i ; 262 | unsigned hash ; 263 | 264 | if (d==NULL || key==NULL) return -1 ; 265 | 266 | /* Compute hash for this key */ 267 | hash = dictionary_hash(key) ; 268 | /* Find if value is already in dictionary */ 269 | if (d->n>0) { 270 | for (i=0 ; isize ; i++) { 271 | if (d->key[i]==NULL) 272 | continue ; 273 | if (hash==d->hash[i]) { /* Same hash value */ 274 | if (!strcmp(key, d->key[i])) { /* Same key */ 275 | /* Found a value: modify and return */ 276 | if (d->val[i]!=NULL) 277 | free(d->val[i]); 278 | d->val[i] = (val ? xstrdup(val) : NULL); 279 | /* Value has been modified: return */ 280 | return 0 ; 281 | } 282 | } 283 | } 284 | } 285 | /* Add a new value */ 286 | /* See if dictionary needs to grow */ 287 | if (d->n==d->size) { 288 | /* Reached maximum size: reallocate dictionary */ 289 | if (dictionary_grow(d) != 0) 290 | return -1; 291 | } 292 | 293 | /* Insert key in the first empty slot. Start at d->n and wrap at 294 | d->size. Because d->n < d->size this will necessarily 295 | terminate. */ 296 | for (i=d->n ; d->key[i] ; ) { 297 | if(++i == d->size) i = 0; 298 | } 299 | /* Copy key */ 300 | d->key[i] = xstrdup(key); 301 | d->val[i] = (val ? xstrdup(val) : NULL) ; 302 | d->hash[i] = hash; 303 | d->n ++ ; 304 | return 0 ; 305 | } 306 | 307 | /*-------------------------------------------------------------------------*/ 308 | /** 309 | @brief Delete a key in a dictionary 310 | @param d dictionary object to modify. 311 | @param key Key to remove. 312 | @return void 313 | 314 | This function deletes a key in a dictionary. Nothing is done if the 315 | key cannot be found. 316 | */ 317 | /*--------------------------------------------------------------------------*/ 318 | void dictionary_unset(dictionary * d, const char * key) 319 | { 320 | unsigned hash ; 321 | ssize_t i ; 322 | 323 | if (key == NULL || d == NULL) { 324 | return; 325 | } 326 | 327 | hash = dictionary_hash(key); 328 | for (i=0 ; isize ; i++) { 329 | if (d->key[i]==NULL) 330 | continue ; 331 | /* Compare hash */ 332 | if (hash==d->hash[i]) { 333 | /* Compare string, to avoid hash collisions */ 334 | if (!strcmp(key, d->key[i])) { 335 | /* Found key */ 336 | break ; 337 | } 338 | } 339 | } 340 | if (i>=d->size) 341 | /* Key not found */ 342 | return ; 343 | 344 | free(d->key[i]); 345 | d->key[i] = NULL ; 346 | if (d->val[i]!=NULL) { 347 | free(d->val[i]); 348 | d->val[i] = NULL ; 349 | } 350 | d->hash[i] = 0 ; 351 | d->n -- ; 352 | return ; 353 | } 354 | 355 | /*-------------------------------------------------------------------------*/ 356 | /** 357 | @brief Dump a dictionary to an opened file pointer. 358 | @param d Dictionary to dump 359 | @param f Opened file pointer. 360 | @return void 361 | 362 | Dumps a dictionary onto an opened file pointer. Key pairs are printed out 363 | as @c [Key]=[Value], one per line. It is Ok to provide stdout or stderr as 364 | output file pointers. 365 | */ 366 | /*--------------------------------------------------------------------------*/ 367 | void dictionary_dump(const dictionary * d, FILE * out) 368 | { 369 | ssize_t i ; 370 | 371 | if (d==NULL || out==NULL) return ; 372 | if (d->n<1) { 373 | fprintf(out, "empty dictionary\n"); 374 | return ; 375 | } 376 | for (i=0 ; isize ; i++) { 377 | if (d->key[i]) { 378 | fprintf(out, "%20s\t[%s]\n", 379 | d->key[i], 380 | d->val[i] ? d->val[i] : "UNDEF"); 381 | } 382 | } 383 | return ; 384 | } 385 | -------------------------------------------------------------------------------- /Soft_MCU/IniParser/src/dictionary.h: -------------------------------------------------------------------------------- 1 | 2 | /*-------------------------------------------------------------------------*/ 3 | /** 4 | @file dictionary.h 5 | @author N. Devillard 6 | @brief Implements a dictionary for string variables. 7 | 8 | This module implements a simple dictionary object, i.e. a list 9 | of string/string associations. This object is useful to store e.g. 10 | informations retrieved from a configuration file (ini files). 11 | */ 12 | /*--------------------------------------------------------------------------*/ 13 | 14 | #ifndef _DICTIONARY_H_ 15 | #define _DICTIONARY_H_ 16 | 17 | /*--------------------------------------------------------------------------- 18 | Includes 19 | ---------------------------------------------------------------------------*/ 20 | 21 | #include 22 | #include 23 | #include 24 | #ifdef __GNUC__ 25 | #include 26 | #endif 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | #if (defined _MSC_VER) | (defined __CC_ARM) 33 | typedef long ssize_t; 34 | #endif 35 | 36 | /*--------------------------------------------------------------------------- 37 | New types 38 | ---------------------------------------------------------------------------*/ 39 | 40 | 41 | /*-------------------------------------------------------------------------*/ 42 | /** 43 | @brief Dictionary object 44 | 45 | This object contains a list of string/string associations. Each 46 | association is identified by a unique string key. Looking up values 47 | in the dictionary is speeded up by the use of a (hopefully collision-free) 48 | hash function. 49 | */ 50 | /*-------------------------------------------------------------------------*/ 51 | typedef struct _dictionary_ { 52 | int n ; /** Number of entries in dictionary */ 53 | ssize_t size ; /** Storage size */ 54 | char ** val ; /** List of string values */ 55 | char ** key ; /** List of string keys */ 56 | unsigned * hash ; /** List of hash values for keys */ 57 | } dictionary ; 58 | 59 | 60 | /*--------------------------------------------------------------------------- 61 | Function prototypes 62 | ---------------------------------------------------------------------------*/ 63 | 64 | /*-------------------------------------------------------------------------*/ 65 | /** 66 | @brief Compute the hash key for a string. 67 | @param key Character string to use for key. 68 | @return 1 unsigned int on at least 32 bits. 69 | 70 | This hash function has been taken from an Article in Dr Dobbs Journal. 71 | This is normally a collision-free function, distributing keys evenly. 72 | The key is stored anyway in the struct so that collision can be avoided 73 | by comparing the key itself in last resort. 74 | */ 75 | /*--------------------------------------------------------------------------*/ 76 | unsigned dictionary_hash(const char * key); 77 | 78 | /*-------------------------------------------------------------------------*/ 79 | /** 80 | @brief Create a new dictionary object. 81 | @param size Optional initial size of the dictionary. 82 | @return 1 newly allocated dictionary objet. 83 | 84 | This function allocates a new dictionary object of given size and returns 85 | it. If you do not know in advance (roughly) the number of entries in the 86 | dictionary, give size=0. 87 | */ 88 | /*--------------------------------------------------------------------------*/ 89 | dictionary * dictionary_new(size_t size); 90 | 91 | /*-------------------------------------------------------------------------*/ 92 | /** 93 | @brief Delete a dictionary object 94 | @param d dictionary object to deallocate. 95 | @return void 96 | 97 | Deallocate a dictionary object and all memory associated to it. 98 | */ 99 | /*--------------------------------------------------------------------------*/ 100 | void dictionary_del(dictionary * vd); 101 | 102 | /*-------------------------------------------------------------------------*/ 103 | /** 104 | @brief Get a value from a dictionary. 105 | @param d dictionary object to search. 106 | @param key Key to look for in the dictionary. 107 | @param def Default value to return if key not found. 108 | @return 1 pointer to internally allocated character string. 109 | 110 | This function locates a key in a dictionary and returns a pointer to its 111 | value, or the passed 'def' pointer if no such key can be found in 112 | dictionary. The returned character pointer points to data internal to the 113 | dictionary object, you should not try to free it or modify it. 114 | */ 115 | /*--------------------------------------------------------------------------*/ 116 | const char * dictionary_get(const dictionary * d, const char * key, const char * def); 117 | 118 | 119 | /*-------------------------------------------------------------------------*/ 120 | /** 121 | @brief Set a value in a dictionary. 122 | @param d dictionary object to modify. 123 | @param key Key to modify or add. 124 | @param val Value to add. 125 | @return int 0 if Ok, anything else otherwise 126 | 127 | If the given key is found in the dictionary, the associated value is 128 | replaced by the provided one. If the key cannot be found in the 129 | dictionary, it is added to it. 130 | 131 | It is Ok to provide a NULL value for val, but NULL values for the dictionary 132 | or the key are considered as errors: the function will return immediately 133 | in such a case. 134 | 135 | Notice that if you dictionary_set a variable to NULL, a call to 136 | dictionary_get will return a NULL value: the variable will be found, and 137 | its value (NULL) is returned. In other words, setting the variable 138 | content to NULL is equivalent to deleting the variable from the 139 | dictionary. It is not possible (in this implementation) to have a key in 140 | the dictionary without value. 141 | 142 | This function returns non-zero in case of failure. 143 | */ 144 | /*--------------------------------------------------------------------------*/ 145 | int dictionary_set(dictionary * vd, const char * key, const char * val); 146 | 147 | /*-------------------------------------------------------------------------*/ 148 | /** 149 | @brief Delete a key in a dictionary 150 | @param d dictionary object to modify. 151 | @param key Key to remove. 152 | @return void 153 | 154 | This function deletes a key in a dictionary. Nothing is done if the 155 | key cannot be found. 156 | */ 157 | /*--------------------------------------------------------------------------*/ 158 | void dictionary_unset(dictionary * d, const char * key); 159 | 160 | 161 | /*-------------------------------------------------------------------------*/ 162 | /** 163 | @brief Dump a dictionary to an opened file pointer. 164 | @param d Dictionary to dump 165 | @param f Opened file pointer. 166 | @return void 167 | 168 | Dumps a dictionary onto an opened file pointer. Key pairs are printed out 169 | as @c [Key]=[Value], one per line. It is Ok to provide stdout or stderr as 170 | output file pointers. 171 | */ 172 | /*--------------------------------------------------------------------------*/ 173 | void dictionary_dump(const dictionary * d, FILE * out); 174 | 175 | #ifdef __cplusplus 176 | } 177 | #endif 178 | 179 | #endif 180 | -------------------------------------------------------------------------------- /Soft_MCU/JLinkSettings.ini: -------------------------------------------------------------------------------- 1 | [BREAKPOINTS] 2 | ForceImpTypeAny = 0 3 | ShowInfoWin = 1 4 | EnableFlashBP = 2 5 | BPDuringExecution = 0 6 | [CFI] 7 | CFISize = 0x00 8 | CFIAddr = 0x00 9 | [CPU] 10 | OverrideMemMap = 0 11 | AllowSimulation = 1 12 | ScriptFile="" 13 | [FLASH] 14 | CacheExcludeSize = 0x00 15 | CacheExcludeAddr = 0x00 16 | MinNumBytesFlashDL = 0 17 | SkipProgOnCRCMatch = 1 18 | VerifyDownload = 1 19 | AllowCaching = 1 20 | EnableFlashDL = 2 21 | Override = 1 22 | Device="STM32F429IG" 23 | [GENERAL] 24 | WorkRAMSize = 0x00 25 | WorkRAMAddr = 0x00 26 | RAMUsageLimit = 0x00 27 | [SWO] 28 | SWOLogFile="" 29 | [MEM] 30 | RdOverrideOrMask = 0x00 31 | RdOverrideAndMask = 0xFFFFFFFF 32 | RdOverrideAddr = 0xFFFFFFFF 33 | WrOverrideOrMask = 0x00 34 | WrOverrideAndMask = 0xFFFFFFFF 35 | WrOverrideAddr = 0xFFFFFFFF 36 | -------------------------------------------------------------------------------- /Soft_MCU/RTE/CMSIS/RTX_Conf_CM.c: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------- 2 | * RL-ARM - RTX 3 | *---------------------------------------------------------------------------- 4 | * Name: RTX_Conf_CM.C 5 | * Purpose: Configuration of CMSIS RTX Kernel for Cortex-M 6 | * Rev.: V4.73 7 | *---------------------------------------------------------------------------- 8 | * 9 | * Copyright (c) 1999-2009 KEIL, 2009-2013 ARM Germany GmbH 10 | * All rights reserved. 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * - Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * - Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * - Neither the name of ARM nor the names of its contributors may be used 19 | * to endorse or promote products derived from this software without 20 | * specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | *---------------------------------------------------------------------------*/ 34 | 35 | #include "cmsis_os.h" 36 | 37 | 38 | /*---------------------------------------------------------------------------- 39 | * RTX User configuration part BEGIN 40 | *---------------------------------------------------------------------------*/ 41 | 42 | //-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- 43 | // 44 | // Thread Configuration 45 | // ======================= 46 | // 47 | // Number of concurrent running threads <0-250> 48 | // Defines max. number of threads that will run at the same time. 49 | // Default: 6 50 | #ifndef OS_TASKCNT 51 | #define OS_TASKCNT 8 52 | #endif 53 | 54 | // Default Thread stack size [bytes] <64-4096:8><#/4> 55 | // Defines default stack size for threads with osThreadDef stacksz = 0 56 | // Default: 200 57 | #ifndef OS_STKSIZE 58 | #define OS_STKSIZE 256 59 | #endif 60 | 61 | // Main Thread stack size [bytes] <64-32768:8><#/4> 62 | // Defines stack size for main thread. 63 | // Default: 200 64 | #ifndef OS_MAINSTKSIZE 65 | #define OS_MAINSTKSIZE 256 66 | #endif 67 | 68 | // Number of threads with user-provided stack size <0-250> 69 | // Defines the number of threads with user-provided stack size. 70 | // Default: 0 71 | #ifndef OS_PRIVCNT 72 | #define OS_PRIVCNT 0 73 | #endif 74 | 75 | // Total stack size [bytes] for threads with user-provided stack size <0-1048576:8><#/4> 76 | // Defines the combined stack size for threads with user-provided stack size. 77 | // Default: 0 78 | #ifndef OS_PRIVSTKSIZE 79 | #define OS_PRIVSTKSIZE 0 80 | #endif 81 | 82 | // Check for stack overflow 83 | // Includes the stack checking code for stack overflow. 84 | // Note that additional code reduces the Kernel performance. 85 | #ifndef OS_STKCHECK 86 | #define OS_STKCHECK 1 87 | #endif 88 | 89 | // Processor mode for thread execution 90 | // <0=> Unprivileged mode 91 | // <1=> Privileged mode 92 | // Default: Privileged mode 93 | #ifndef OS_RUNPRIV 94 | #define OS_RUNPRIV 1 95 | #endif 96 | 97 | // 98 | 99 | // RTX Kernel Timer Tick Configuration 100 | // ====================================== 101 | // Use Cortex-M SysTick timer as RTX Kernel Timer 102 | // Use the Cortex-M SysTick timer as a time-base for RTX. 103 | #ifndef OS_SYSTICK 104 | #define OS_SYSTICK 1 105 | #endif 106 | // 107 | // Timer clock value [Hz] <1-1000000000> 108 | // Defines the timer clock value. 109 | // Default: 12000000 (12MHz) 110 | #ifndef OS_CLOCK 111 | #define OS_CLOCK 168000000 112 | #endif 113 | 114 | // Timer tick value [us] <1-1000000> 115 | // Defines the timer tick value. 116 | // Default: 1000 (1ms) 117 | #ifndef OS_TICK 118 | #define OS_TICK 1000 119 | #endif 120 | 121 | // 122 | 123 | // System Configuration 124 | // ======================= 125 | // 126 | // Round-Robin Thread switching 127 | // =============================== 128 | // 129 | // Enables Round-Robin Thread switching. 130 | #ifndef OS_ROBIN 131 | #define OS_ROBIN 1 132 | #endif 133 | 134 | // Round-Robin Timeout [ticks] <1-1000> 135 | // Defines how long a thread will execute before a thread switch. 136 | // Default: 5 137 | #ifndef OS_ROBINTOUT 138 | #define OS_ROBINTOUT 1 139 | #endif 140 | 141 | // 142 | 143 | // User Timers 144 | // ============== 145 | // Enables user Timers 146 | #ifndef OS_TIMERS 147 | #define OS_TIMERS 1 148 | #endif 149 | 150 | // Timer Thread Priority 151 | // <1=> Low 152 | // <2=> Below Normal <3=> Normal <4=> Above Normal 153 | // <5=> High 154 | // <6=> Realtime (highest) 155 | // Defines priority for Timer Thread 156 | // Default: High 157 | #ifndef OS_TIMERPRIO 158 | #define OS_TIMERPRIO 5 159 | #endif 160 | 161 | // Timer Thread stack size [bytes] <64-4096:8><#/4> 162 | // Defines stack size for Timer thread. 163 | // Default: 200 164 | #ifndef OS_TIMERSTKSZ 165 | #define OS_TIMERSTKSZ 256 166 | #endif 167 | 168 | // Timer Callback Queue size <1-32> 169 | // Number of concurrent active timer callback functions. 170 | // Default: 4 171 | #ifndef OS_TIMERCBQS 172 | #define OS_TIMERCBQS 4 173 | #endif 174 | 175 | // 176 | 177 | // ISR FIFO Queue size<4=> 4 entries <8=> 8 entries 178 | // <12=> 12 entries <16=> 16 entries 179 | // <24=> 24 entries <32=> 32 entries 180 | // <48=> 48 entries <64=> 64 entries 181 | // <96=> 96 entries 182 | // ISR functions store requests to this buffer, 183 | // when they are called from the interrupt handler. 184 | // Default: 16 entries 185 | #ifndef OS_FIFOSZ 186 | #define OS_FIFOSZ 96 187 | #endif 188 | 189 | // 190 | 191 | //------------- <<< end of configuration section >>> ----------------------- 192 | 193 | // Standard library system mutexes 194 | // =============================== 195 | // Define max. number system mutexes that are used to protect 196 | // the arm standard runtime library. For microlib they are not used. 197 | #ifndef OS_MUTEXCNT 198 | #define OS_MUTEXCNT 8 199 | #endif 200 | 201 | /*---------------------------------------------------------------------------- 202 | * RTX User configuration part END 203 | *---------------------------------------------------------------------------*/ 204 | 205 | #define OS_TRV ((uint32_t)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1) 206 | 207 | 208 | /*---------------------------------------------------------------------------- 209 | * Global Functions 210 | *---------------------------------------------------------------------------*/ 211 | 212 | /*--------------------------- os_idle_demon ---------------------------------*/ 213 | 214 | void os_idle_demon (void) { 215 | /* The idle demon is a system thread, running when no other thread is */ 216 | /* ready to run. */ 217 | 218 | for (;;) { 219 | /* HERE: include optional user code to be executed when no thread runs.*/ 220 | } 221 | } 222 | 223 | #if (OS_SYSTICK == 0) // Functions for alternative timer as RTX kernel timer 224 | 225 | /*--------------------------- os_tick_init ----------------------------------*/ 226 | 227 | // Initialize alternative hardware timer as RTX kernel timer 228 | // Return: IRQ number of the alternative hardware timer 229 | int os_tick_init (void) { 230 | return (-1); /* Return IRQ number of timer (0..239) */ 231 | } 232 | 233 | /*--------------------------- os_tick_val -----------------------------------*/ 234 | 235 | // Get alternative hardware timer current value (0 .. OS_TRV) 236 | uint32_t os_tick_val (void) { 237 | return (0); 238 | } 239 | 240 | /*--------------------------- os_tick_ovf -----------------------------------*/ 241 | 242 | // Get alternative hardware timer overflow flag 243 | // Return: 1 - overflow, 0 - no overflow 244 | uint32_t os_tick_ovf (void) { 245 | return (0); 246 | } 247 | 248 | /*--------------------------- os_tick_irqack --------------------------------*/ 249 | 250 | // Acknowledge alternative hardware timer interrupt 251 | void os_tick_irqack (void) { 252 | /* ... */ 253 | } 254 | 255 | #endif // (OS_SYSTICK == 0) 256 | 257 | /*--------------------------- os_error --------------------------------------*/ 258 | 259 | /* OS Error Codes */ 260 | #define OS_ERROR_STACK_OVF 1 261 | #define OS_ERROR_FIFO_OVF 2 262 | #define OS_ERROR_MBX_OVF 3 263 | 264 | extern osThreadId svcThreadGetId (void); 265 | 266 | void os_error (uint32_t error_code) { 267 | /* This function is called when a runtime error is detected. */ 268 | /* Parameter 'error_code' holds the runtime error code. */ 269 | 270 | /* HERE: include optional code to be executed on runtime error. */ 271 | switch (error_code) { 272 | case OS_ERROR_STACK_OVF: 273 | /* Stack overflow detected for the currently running task. */ 274 | /* Thread can be identified by calling svcThreadGetId(). */ 275 | break; 276 | case OS_ERROR_FIFO_OVF: 277 | /* ISR FIFO Queue buffer overflow detected. */ 278 | break; 279 | case OS_ERROR_MBX_OVF: 280 | /* Mailbox overflow detected. */ 281 | break; 282 | } 283 | for (;;); 284 | } 285 | 286 | 287 | /*---------------------------------------------------------------------------- 288 | * RTX Configuration Functions 289 | *---------------------------------------------------------------------------*/ 290 | 291 | #include "RTX_CM_lib.h" 292 | 293 | /*---------------------------------------------------------------------------- 294 | * end of file 295 | *---------------------------------------------------------------------------*/ 296 | -------------------------------------------------------------------------------- /Soft_MCU/RTE/Compiler/retarget_io.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/Soft_MCU/RTE/Compiler/retarget_io.c -------------------------------------------------------------------------------- /Soft_MCU/RTE/Compiler/stdio_usart.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/Soft_MCU/RTE/Compiler/stdio_usart.c -------------------------------------------------------------------------------- /Soft_MCU/RTE/Device/STM32F407IGHx/STM32F401xx_OPT.s: -------------------------------------------------------------------------------- 1 | ;/*****************************************************************************/ 2 | ;/* STM32F401xx_OPT.s: STM32F401xB/C Flash Option Bytes */ 3 | ;/*****************************************************************************/ 4 | ;/* <<< Use Configuration Wizard in Context Menu >>> */ 5 | ;/*****************************************************************************/ 6 | ;/* This file is part of the uVision/ARM development tools */ 7 | ;/* Copyright (c) 2014 Keil - An ARM Company. */ 8 | ;/* All rights reserved. */ 9 | ;/*****************************************************************************/ 10 | 11 | ;// Flash Option Bytes 12 | FLASH_OPT EQU 1 13 | 14 | ;// Flash Read Protection 15 | ;// Read protection is used to protect the software code stored in Flash memory 16 | ;// Read Protection Level 17 | ;// Level 0: No Protection 18 | ;// Level 1: Read Protection of Memories (debug features limited) 19 | ;// Level 2: Chip Protection (debug and boot in RAM features disabled) 20 | ;// <0xAA=> Level 0 (No Protection) 21 | ;// <0x00=> Level 1 (Read Protection of Memories) 22 | ;// <0xCC=> Level 2 (Chip Protection) 23 | ;// 24 | 25 | ;// Flash Write Protection 26 | ;// SPRMOD 27 | ;// Selection of protection mode for nWPRi bits 28 | ;// <0=> PCROP disabled 29 | ;// <1=> PCROP enabled 30 | ;// nWRP Sectors 0 to 11 31 | ;// Not write protect Sectors 0 to 11 32 | ;// Sector 0 33 | ;// Sector 1 34 | ;// Sector 2 35 | ;// Sector 3 36 | ;// Sector 4 37 | ;// Sector 5 38 | ;// 39 | ;// 40 | 41 | ;// User Configuration 42 | ;// BOR_LEV 43 | ;// <0=> BOR Level 3 (VBOR3). Reset threshold level from 2.70 to 3.60 V 44 | ;// <1=> BOR Level 2 (VBOR2). Reset threshold level from 2.40 to 2.70 V 45 | ;// <2=> BOR Level 1 (VBOR1). Reset threshold level from 2.10 to 2.40 V 46 | ;// <3=> BOR off (VBOR0). Reset threshold level from 1.80 to 2.10 V 47 | ;// WDG_SW 48 | ;// <0=> HW Watchdog 49 | ;// <1=> SW Watchdog 50 | ;// nRST_STOP 51 | ;// Generate Reset when entering STOP Mode 52 | ;// <0=> Enabled 53 | ;// <1=> Disabled 54 | ;// nRST_STDBY 55 | ;// Generate Reset when entering Standby Mode 56 | ;// <0=> Enabled 57 | ;// <1=> Disabled 58 | ;// 59 | 60 | FLASH_OPTCR EQU 0x0FFFAAEC 61 | ;// 62 | 63 | 64 | IF FLASH_OPT <> 0 65 | AREA |.ARM.__AT_0x1FFFC000|, CODE, READONLY 66 | DCD FLASH_OPTCR 67 | ENDIF 68 | 69 | END 70 | -------------------------------------------------------------------------------- /Soft_MCU/RTE/Device/STM32F407IGHx/STM32F40xxx_41xxx_OPT.s: -------------------------------------------------------------------------------- 1 | ;/*****************************************************************************/ 2 | ;/* STM32F40xxx_41xxx_OPT.s: STM32F405xx/07xx and */ 3 | ;/* STM32F415xx/17xx Flash Option Bytes */ 4 | ;/*****************************************************************************/ 5 | ;/* <<< Use Configuration Wizard in Context Menu >>> */ 6 | ;/*****************************************************************************/ 7 | ;/* This file is part of the uVision/ARM development tools */ 8 | ;/* Copyright (c) 2014 Keil - An ARM Company. */ 9 | ;/* All rights reserved. */ 10 | ;/*****************************************************************************/ 11 | 12 | ;// Flash Option Bytes 13 | FLASH_OPT EQU 1 14 | 15 | ;// Flash Read Protection 16 | ;// Read protection is used to protect the software code stored in Flash memory 17 | ;// Read Protection Level 18 | ;// Level 0: No Protection 19 | ;// Level 1: Read Protection of Memories (debug features limited) 20 | ;// Level 2: Chip Protection (debug and boot in RAM features disabled) 21 | ;// <0xAA=> Level 0 (No Protection) 22 | ;// <0x00=> Level 1 (Read Protection of Memories) 23 | ;// <0xCC=> Level 2 (Chip Protection) 24 | ;// 25 | 26 | ;// Flash Write Protection 27 | ;// nWRP Sectors 0 to 11 28 | ;// Not write protect Sectors 0 to 11 29 | ;// Sector 0 30 | ;// Sector 1 31 | ;// Sector 2 32 | ;// Sector 3 33 | ;// Sector 4 34 | ;// Sector 5 35 | ;// Sector 6 36 | ;// Sector 7 37 | ;// Sector 8 38 | ;// Sector 9 39 | ;// Sector 10 40 | ;// Sector 11 41 | ;// 42 | ;// 43 | 44 | ;// User Configuration 45 | ;// BOR_LEV 46 | ;// <0=> BOR Level 3 (VBOR3). Reset threshold level from 2.70 to 3.60 V 47 | ;// <1=> BOR Level 2 (VBOR2). Reset threshold level from 2.40 to 2.70 V 48 | ;// <2=> BOR Level 1 (VBOR1). Reset threshold level from 2.10 to 2.40 V 49 | ;// <3=> BOR off (VBOR0). Reset threshold level from 1.80 to 2.10 V 50 | ;// WDG_SW 51 | ;// <0=> HW Watchdog 52 | ;// <1=> SW Watchdog 53 | ;// nRST_STOP 54 | ;// Generate Reset when entering STOP Mode 55 | ;// <0=> Enabled 56 | ;// <1=> Disabled 57 | ;// nRST_STDBY 58 | ;// Generate Reset when entering Standby Mode 59 | ;// <0=> Enabled 60 | ;// <1=> Disabled 61 | ;// 62 | 63 | FLASH_OPTCR EQU 0x0FFFAAEC 64 | ;// 65 | 66 | 67 | IF FLASH_OPT <> 0 68 | AREA |.ARM.__AT_0x1FFFC000|, CODE, READONLY 69 | DCD FLASH_OPTCR 70 | ENDIF 71 | 72 | END 73 | -------------------------------------------------------------------------------- /Soft_MCU/RTE/Device/STM32F407IGHx/STM32F42xxx_43xxx_OPT.s: -------------------------------------------------------------------------------- 1 | ;/*****************************************************************************/ 2 | ;/* STM32F42xxx_43xxx_OPT.s: STM32F42xxx and STM32F43xxx Flash Option Bytes */ 3 | ;/*****************************************************************************/ 4 | ;/* <<< Use Configuration Wizard in Context Menu >>> */ 5 | ;/*****************************************************************************/ 6 | ;/* This file is part of the uVision/ARM development tools */ 7 | ;/* Copyright (c) 2014 Keil - An ARM Company. */ 8 | ;/* All rights reserved. */ 9 | ;/*****************************************************************************/ 10 | 11 | ;// Flash Option Bytes 12 | FLASH_OPT EQU 1 13 | 14 | ;// Flash Read Protection 15 | ;// Read protection is used to protect the software code stored in Flash memory 16 | ;// Read Protection Level 17 | ;// Level 0: No Protection 18 | ;// Level 1: Read Protection of Memories (debug features limited) 19 | ;// Level 2: Chip Protection (debug and boot in RAM features disabled) 20 | ;// <0xAA=> Level 0 (No Protection) 21 | ;// <0x00=> Level 1 (Read Protection of Memories) 22 | ;// <0xCC=> Level 2 (Chip Protection) 23 | ;// 24 | 25 | ;// Flash Write Protection 26 | ;// SPRMOD 27 | ;// Selection of protection mode for nWPRi bits 28 | ;// <0=> PCROP disabled 29 | ;// <1=> PCROP enabled 30 | ;// DB1M 31 | ;// Dual-bank on 1 Mbyte Flash memory devices 32 | ;// <0=> 1 Mbyte single bank Flash memory 33 | ;// <1=> 1 Mbyte dual bank Flash memory 34 | ;// nWRP Sectors 0 to 11 35 | ;// Not write protect Sectors 0 to 11 36 | ;// Sector 0 37 | ;// Sector 1 38 | ;// Sector 2 39 | ;// Sector 3 40 | ;// Sector 4 41 | ;// Sector 5 42 | ;// Sector 6 43 | ;// Sector 7 44 | ;// Sector 8 45 | ;// Sector 9 46 | ;// Sector 10 47 | ;// Sector 11 48 | ;// 49 | ;// nWRP Sectors 12 to 23 50 | ;// Not write protect Sectors 12 to 23 51 | ;// Sector 12 52 | ;// Sector 13 53 | ;// Sector 14 54 | ;// Sector 15 55 | ;// Sector 16 56 | ;// Sector 17 57 | ;// Sector 18 58 | ;// Sector 19 59 | ;// Sector 20 60 | ;// Sector 21 61 | ;// Sector 22 62 | ;// Sector 23 63 | ;// 64 | ;// 65 | 66 | ;// User Configuration 67 | ;// BOR_LEV 68 | ;// <0=> BOR Level 3 (VBOR3). Reset threshold level from 2.70 to 3.60 V 69 | ;// <1=> BOR Level 2 (VBOR2). Reset threshold level from 2.40 to 2.70 V 70 | ;// <2=> BOR Level 1 (VBOR1). Reset threshold level from 2.10 to 2.40 V 71 | ;// <3=> BOR off (VBOR0). Reset threshold level from 1.80 to 2.10 V 72 | ;// Dual-bank Boot Option 73 | ;// <0=> Dual-bank Boot Disabled 74 | ;// <1=> Dual-bank Boot Enabled 75 | ;// WDG_SW 76 | ;// <0=> HW Watchdog 77 | ;// <1=> SW Watchdog 78 | ;// nRST_STOP 79 | ;// Generate Reset when entering STOP Mode 80 | ;// <0=> Enabled 81 | ;// <1=> Disabled 82 | ;// nRST_STDBY 83 | ;// Generate Reset when entering Standby Mode 84 | ;// <0=> Enabled 85 | ;// <1=> Disabled 86 | ;// 87 | 88 | FLASH_OPTCR EQU 0x0FFFAAEC 89 | FLASH_OPTCR1 EQU 0x0FFF0000 90 | ;// 91 | 92 | 93 | IF FLASH_OPT <> 0 94 | AREA |.ARM.__AT_0x1FFFC000|, CODE, READONLY 95 | DCD FLASH_OPTCR 96 | DCD FLASH_OPTCR1 97 | ENDIF 98 | 99 | END 100 | -------------------------------------------------------------------------------- /Soft_MCU/RTE/File_System/FS_Config.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * MDK Middleware - Component ::File System 3 | * Copyright (c) 2004-2014 ARM Germany GmbH. All rights reserved. 4 | *------------------------------------------------------------------------------ 5 | * Name: FS_Config.c 6 | * Purpose: File System Configuration 7 | * Rev.: V6.2 8 | *----------------------------------------------------------------------------*/ 9 | 10 | //-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- 11 | 12 | // FAT File System 13 | // Define FAT File System parameters 14 | 15 | // Number of open files <1-16> 16 | // Define number of files that can be opened at the same time. 17 | // Default: 4 18 | #define FAT_MAX_OPEN_FILES 8 19 | 20 | // 21 | 22 | // Embedded File System 23 | // Define Embedded File System parameters 24 | 25 | // Number of open files <1-16> 26 | // Define number of files that can be opened at the same time. 27 | // Default: 4 28 | #define EFS_MAX_OPEN_FILES 8 29 | 30 | // 31 | 32 | // Initial Current Drive <0=>F0: <1=>F1: 33 | // <2=>M0: <3=>M1: 34 | // <4=>N0: <5=>N1: 35 | // <6=>R0: 36 | // <7=>U0: <8=>U1: 37 | // Set initial setting for current drive. Current drive is used for File System functions 38 | // that are invoked with the "" string and can be altered anytime during run-time. 39 | #define FS_INITIAL_CDRIVE 0 40 | 41 | #include "..\RTE_Components.h" 42 | 43 | #ifdef RTE_FileSystem_Drive_RAM 44 | #include "FS_Config_RAM.h" 45 | #endif 46 | 47 | #ifdef RTE_FileSystem_Drive_NOR_0 48 | #include "FS_Config_NOR_0.h" 49 | #endif 50 | #ifdef RTE_FileSystem_Drive_NOR_1 51 | #include "FS_Config_NOR_1.h" 52 | #endif 53 | 54 | #ifdef RTE_FileSystem_Drive_NAND_0 55 | #include "FS_Config_NAND_0.h" 56 | #endif 57 | #ifdef RTE_FileSystem_Drive_NAND_1 58 | #include "FS_Config_NAND_1.h" 59 | #endif 60 | 61 | #ifdef RTE_FileSystem_Drive_MC_0 62 | #include "FS_Config_MC_0.h" 63 | #endif 64 | #ifdef RTE_FileSystem_Drive_MC_1 65 | #include "FS_Config_MC_1.h" 66 | #endif 67 | 68 | #ifdef RTE_FileSystem_Drive_USB_0 69 | #include "FS_Config_USB_0.h" 70 | #endif 71 | #ifdef RTE_FileSystem_Drive_USB_1 72 | #include "FS_Config_USB_1.h" 73 | #endif 74 | 75 | #include "fs_config.h" 76 | -------------------------------------------------------------------------------- /Soft_MCU/RTE/File_System/FS_Config_NOR_0.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * MDK Middleware - Component ::File System:Drive 3 | * Copyright (c) 2004-2014 ARM Germany GmbH. All rights reserved. 4 | *------------------------------------------------------------------------------ 5 | * Name: FS_Config_NOR_0.h 6 | * Purpose: File System Configuration for NOR Flash Drive 7 | * Rev.: V6.2 8 | *----------------------------------------------------------------------------*/ 9 | 10 | //-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- 11 | 12 | // NOR Flash Drive 0 13 | // Configuration for NOR Flash device assigned to drive letter "F0:" 14 | #define NOR0_ENABLE 1 15 | 16 | // Connect to hardware via Driver_Flash# <0-255> 17 | // Select driver control block for hardware interface 18 | #define NOR0_DRIVER 0 19 | 20 | // 21 | -------------------------------------------------------------------------------- /Soft_MCU/RTE/Network/Net_Config.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * MDK Middleware - Component ::Network 3 | * Copyright (c) 2004-2014 ARM Germany GmbH. All rights reserved. 4 | *------------------------------------------------------------------------------ 5 | * Name: Net_Config.c 6 | * Purpose: Network Configuration 7 | * Rev.: V5.00 8 | *----------------------------------------------------------------------------*/ 9 | 10 | //-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- 11 | 12 | // System Definitions 13 | // Global Network System definitions 14 | // Local Host Name 15 | // This is the name under which embedded host can be 16 | // accessed on a local area network. 17 | // Default: "my_host" 18 | #define NET_HOST_NAME "SL-DPT100" 19 | 20 | // Memory Pool size <1536-262144:4><#/4> 21 | // This is the size of a memory pool in bytes. Buffers for 22 | // Network packets are allocated from this memory pool. 23 | // Default: 12000 bytes 24 | #define NET_MEM_SIZE 4096 25 | 26 | // 27 | 28 | #include "..\RTE_Components.h" 29 | 30 | #ifdef RTE_Network_Interface_ETH_0 31 | #include "Net_Config_ETH_0.h" 32 | #endif 33 | #ifdef RTE_Network_Interface_ETH_1 34 | #include "Net_Config_ETH_1.h" 35 | #endif 36 | 37 | #ifdef RTE_Network_Interface_PPP 38 | #include "Net_Config_PPP.h" 39 | #endif 40 | 41 | #ifdef RTE_Network_Interface_SLIP 42 | #include "Net_Config_SLIP.h" 43 | #endif 44 | 45 | #ifdef RTE_Network_Socket_UDP 46 | #include "Net_Config_UDP.h" 47 | #endif 48 | #ifdef RTE_Network_Socket_TCP 49 | #include "Net_Config_TCP.h" 50 | #endif 51 | #ifdef RTE_Network_Socket_BSD 52 | #include "Net_Config_BSD.h" 53 | #endif 54 | 55 | #ifdef RTE_Network_Web_Server_RO 56 | #include "Net_Config_HTTP_Server.h" 57 | #endif 58 | #ifdef RTE_Network_Web_Server_FS 59 | #include "Net_Config_HTTP_Server.h" 60 | #endif 61 | 62 | #ifdef RTE_Network_Telnet_Server 63 | #include "Net_Config_Telnet_Server.h" 64 | #endif 65 | 66 | #ifdef RTE_Network_TFTP_Server 67 | #include "Net_Config_TFTP_Server.h" 68 | #endif 69 | #ifdef RTE_Network_TFTP_Client 70 | #include "Net_Config_TFTP_Client.h" 71 | #endif 72 | 73 | #ifdef RTE_Network_FTP_Server 74 | #include "Net_Config_FTP_Server.h" 75 | #endif 76 | #ifdef RTE_Network_FTP_Client 77 | #include "Net_Config_FTP_Client.h" 78 | #endif 79 | 80 | #ifdef RTE_Network_DNS_Client 81 | #include "Net_Config_DNS_Client.h" 82 | #endif 83 | 84 | #ifdef RTE_Network_SMTP_Client 85 | #include "Net_Config_SMTP_Client.h" 86 | #endif 87 | 88 | #ifdef RTE_Network_SNMP_Agent 89 | #include "Net_Config_SNMP_Agent.h" 90 | #endif 91 | 92 | #ifdef RTE_Network_SNTP_Client 93 | #include "Net_Config_SNTP_Client.h" 94 | #endif 95 | 96 | #include "net_config.h" 97 | 98 | /** 99 | \fn void net_sys_error (ERROR_CODE error) 100 | \brief Network system error handler. 101 | */ 102 | void net_sys_error (ERROR_CODE error) { 103 | /* This function is called when a fatal error is encountered. */ 104 | /* The normal program execution is not possible anymore. */ 105 | 106 | switch (error) { 107 | case ERR_MEM_ALLOC: 108 | /* Out of memory */ 109 | break; 110 | 111 | case ERR_MEM_FREE: 112 | /* Trying to release non existing memory block */ 113 | break; 114 | 115 | case ERR_MEM_CORRUPT: 116 | /* Memory Link pointer Corrupted */ 117 | /* More data written than the size of allocated mem block */ 118 | break; 119 | 120 | case ERR_MEM_LOCK: 121 | /* Locked Memory management function (alloc/free) re-entered */ 122 | break; 123 | 124 | case ERR_UDP_ALLOC: 125 | /* Out of UDP Sockets */ 126 | break; 127 | 128 | case ERR_TCP_ALLOC: 129 | /* Out of TCP Sockets */ 130 | break; 131 | 132 | case ERR_TCP_STATE: 133 | /* TCP State machine in undefined state */ 134 | break; 135 | } 136 | 137 | /* End-less loop */ 138 | while (1); 139 | } 140 | -------------------------------------------------------------------------------- /Soft_MCU/RTE/Network/Net_Config_BSD.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * MDK Middleware - Component ::Network:Socket 3 | * Copyright (c) 2004-2014 ARM Germany GmbH. All rights reserved. 4 | *------------------------------------------------------------------------------ 5 | * Name: Net_Config_BSD.h 6 | * Purpose: Network Configuration for BSD Sockets 7 | * Rev.: V5.00 8 | *----------------------------------------------------------------------------*/ 9 | 10 | //-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- 11 | 12 | // Berkley (BSD) Sockets 13 | #define BSD_ENABLE 1 14 | 15 | // Number of BSD Sockets <1-20> 16 | // Number of available Berkeley Sockets 17 | // Default: 2 18 | #define BSD_NUM_SOCKS 4 19 | 20 | // Number of Streaming Server Sockets <0-20> 21 | // Defines a number of Streaming (TCP) Server sockets, 22 | // that listen for an incoming connection from the client. 23 | // Default: 1 24 | #define BSD_SERVER_SOCKS 2 25 | 26 | // Receive Timeout in seconds <0-600> 27 | // A timeout for socket receive in blocking mode. 28 | // Timeout value of 0 means indefinite timeout. 29 | // Default: 20 30 | #define BSD_RECEIVE_TOUT 20 31 | 32 | // Hostname Resolver 33 | // Enable or disable Berkeley style hostname resolver. 34 | #define BSD_HOSTNAME_ENABLE 0 35 | 36 | // 37 | -------------------------------------------------------------------------------- /Soft_MCU/RTE/Network/Net_Config_ETH_0.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * MDK Middleware - Component ::Network:Interface 3 | * Copyright (c) 2004-2014 ARM Germany GmbH. All rights reserved. 4 | *------------------------------------------------------------------------------ 5 | * Name: Net_Config_ETH_0.h 6 | * Purpose: Network Configuration for ETH Interface 7 | * Rev.: V5.01 8 | *----------------------------------------------------------------------------*/ 9 | 10 | //-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- 11 | 12 | // Ethernet Network Interface 0 13 | #define ETH0_ENABLE 1 14 | 15 | // Connect to hardware via Driver_ETH# <0-255> 16 | // Select driver control block for MAC and PHY interface 17 | #define ETH0_DRIVER 0 18 | 19 | // MAC Address 20 | // Local Ethernet MAC Address 21 | // Value FF:FF:FF:FF:FF:FF is not allowed. 22 | // It is an ethernet Broadcast MAC address. 23 | // Address byte 1 <0x00-0xff:2> 24 | // LSB is an ethernet Multicast bit. 25 | // Must be 0 for local MAC address. 26 | // Default: 0x1E 27 | #define ETH0_MAC1 0x1E 28 | 29 | // Address byte 2 <0x00-0xff> 30 | // Default: 0x30 31 | #define ETH0_MAC2 0x30 32 | 33 | // Address byte 3 <0x00-0xff> 34 | // Default: 0x6C 35 | #define ETH0_MAC3 0x6C 36 | 37 | // Address byte 4 <0x00-0xff> 38 | // Default: 0xA2 39 | #define ETH0_MAC4 0xA2 40 | 41 | // Address byte 5 <0x00-0xff> 42 | // Default: 0x45 43 | #define ETH0_MAC5 0x45 44 | 45 | // Address byte 6 <0x00-0xff> 46 | // Default: 0x5E 47 | #define ETH0_MAC6 0x5E 48 | // 49 | 50 | // IP Address 51 | // Local Static IP Address 52 | // Value 255.255.255.255 is not allowed. 53 | // It is a Broadcast IP address. 54 | // Address byte 1 <0-255> 55 | // Default: 192 56 | #define ETH0_IP1 192 57 | 58 | // Address byte 2 <0-255> 59 | // Default: 168 60 | #define ETH0_IP2 168 61 | 62 | // Address byte 3 <0-255> 63 | // Default: 0 64 | #define ETH0_IP3 0 65 | 66 | // Address byte 4 <0-255> 67 | // Default: 100 68 | #define ETH0_IP4 32 69 | // 70 | 71 | // Subnet mask 72 | // Local Subnet mask 73 | // Mask byte 1 <0-255> 74 | // Default: 255 75 | #define ETH0_MASK1 255 76 | 77 | // Mask byte 2 <0-255> 78 | // Default: 255 79 | #define ETH0_MASK2 255 80 | 81 | // Mask byte 3 <0-255> 82 | // Default: 255 83 | #define ETH0_MASK3 255 84 | 85 | // Mask byte 4 <0-255> 86 | // Default: 0 87 | #define ETH0_MASK4 0 88 | // 89 | 90 | // Default Gateway 91 | // Default Gateway IP Address 92 | // Address byte 1 <0-255> 93 | // Default: 192 94 | #define ETH0_GW1 192 95 | 96 | // Address byte 2 <0-255> 97 | // Default: 168 98 | #define ETH0_GW2 168 99 | 100 | // Address byte 3 <0-255> 101 | // Default: 0 102 | #define ETH0_GW3 0 103 | 104 | // Address byte 4 <0-255> 105 | // Default: 254 106 | #define ETH0_GW4 1 107 | // 108 | 109 | // Primary DNS Server 110 | // Primary DNS Server IP Address 111 | // Address byte 1 <0-255> 112 | // Default: 194 113 | #define ETH0_PRI_DNS1 202 114 | 115 | // Address byte 2 <0-255> 116 | // Default: 25 117 | #define ETH0_PRI_DNS2 103 118 | 119 | // Address byte 3 <0-255> 120 | // Default: 2 121 | #define ETH0_PRI_DNS3 24 122 | 123 | // Address byte 4 <0-255> 124 | // Default: 129 125 | #define ETH0_PRI_DNS4 68 126 | // 127 | 128 | // Secondary DNS Server 129 | // Secondary DNS Server IP Address 130 | // Address byte 1 <0-255> 131 | // Default: 194 132 | #define ETH0_SEC_DNS1 202 133 | 134 | // Address byte 2 <0-255> 135 | // Default: 25 136 | #define ETH0_SEC_DNS2 103 137 | 138 | // Address byte 3 <0-255> 139 | // Default: 2 140 | #define ETH0_SEC_DNS3 44 141 | 142 | // Address byte 4 <0-255> 143 | // Default: 130 144 | #define ETH0_SEC_DNS4 150 145 | // 146 | 147 | // ARP Definitions 148 | // Address Resolution Protocol Definitions 149 | // Cache Table size <5-100> 150 | // Number of cached hardware/IP addresses 151 | // Default: 10 152 | #define ETH0_ARP_TAB_SIZE 10 153 | 154 | // Cache Timeout in seconds <5-255> 155 | // A timeout for a cached hardware/IP addresses 156 | // Default: 150 157 | #define ETH0_ARP_CACHE_TOUT 150 158 | 159 | // Number of Retries <0-20> 160 | // Number of Retries to resolve an IP address 161 | // before ARP module gives up 162 | // Default: 4 163 | #define ETH0_ARP_MAX_RETRY 4 164 | 165 | // Resend Timeout in seconds <1-10> 166 | // A timeout to resend the ARP Request 167 | // Default: 2 168 | #define ETH0_ARP_RESEND_TOUT 2 169 | 170 | // Send Notification on Address changes 171 | // When this option is enabled, the embedded host 172 | // will send a Gratuitous ARP notification at startup, 173 | // or when the device IP address has changed. 174 | // Default: Disabled 175 | #define ETH0_ARP_NOTIFY 0 176 | // 177 | 178 | // IGMP Group Management 179 | // Enable or disable Internet Group Management Protocol 180 | #define ETH0_IGMP_ENABLE 0 181 | 182 | // Membership Table size <2-50> 183 | // Number of Groups this host can join 184 | // Default: 5 185 | #define ETH0_IGMP_TAB_SIZE 5 186 | // 187 | 188 | // NetBIOS Name Service 189 | // When this option is enabled, the embedded host can be 190 | // accessed by his name on the local LAN using NBNS protocol. 191 | // You need to modify also the number of UDP Sockets, 192 | // because NBNS protocol uses one UDP socket to run. 193 | #define ETH0_NBNS_ENABLE 1 194 | 195 | // Dynamic Host Configuration 196 | // When this option is enabled, local IP address, Net Mask 197 | // and Default Gateway are obtained automatically from 198 | // the DHCP Server on local LAN. 199 | // You need to modify also the number of UDP Sockets, 200 | // because DHCP protocol uses one UDP socket to run. 201 | #define ETH0_DHCP_ENABLE 1 202 | 203 | // Vendor Class Identifier 204 | // This value is optional. If specified, it is added 205 | // to DHCP request message, identifying vendor type. 206 | // Default: "" 207 | #define ETH0_DHCP_VCID "" 208 | 209 | // Bootfile Name 210 | // This value is optional. If enabled, the Bootfile Name 211 | // (option 67) is also requested from DHCP server. 212 | // Default: disabled 213 | #define ETH0_DHCP_BOOTFILE 0 214 | 215 | // NTP Servers 216 | // This value is optional. If enabled, a list of NTP Servers 217 | // (option 42) is also requested from DHCP server. 218 | // Default: disabled 219 | #define ETH0_DHCP_NTP_SERVERS 0 220 | // 221 | 222 | // 223 | -------------------------------------------------------------------------------- /Soft_MCU/RTE/Network/Net_Config_FTP_Server.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * MDK Middleware - Component ::Network:Service 3 | * Copyright (c) 2004-2014 ARM Germany GmbH. All rights reserved. 4 | *------------------------------------------------------------------------------ 5 | * Name: Net_Config_FTP_Server.h 6 | * Purpose: Network Configuration for FTP Server 7 | * Rev.: V5.00 8 | *----------------------------------------------------------------------------*/ 9 | 10 | //-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- 11 | 12 | // FTP Server 13 | #define FTP_SERVER_ENABLE 1 14 | 15 | // Number of FTP Sessions <1-10> 16 | // Number of simultaneously active FTP Sessions 17 | // Default: 1 18 | #define FTP_SERVER_NUM_SESSIONS 2 19 | 20 | // Port Number <1-65535> 21 | // Listening port number. 22 | // Default: 21 23 | #define FTP_SERVER_PORT_NUM 21 24 | 25 | // Welcome Message 26 | // This value is optional. If specified, 27 | // it overrides the default welcome message. 28 | // Default: "" 29 | #define FTP_SERVER_MESSAGE "SL-DPT100" 30 | 31 | // Idle Session Timeout in seconds <0-3600> 32 | // When timeout expires, the connection is closed. 33 | // A value of 0 disables disconnection on timeout. 34 | // Default: 120 35 | #define FTP_SERVER_TOUT 120 36 | 37 | // Enable User Authentication 38 | // When enabled, the user will have to authenticate 39 | // himself by username and password before access 40 | // to the system is allowed. 41 | #define FTP_SERVER_AUTH_ENABLE 1 42 | 43 | // Authentication Username 44 | // Default: "admin" 45 | #define FTP_SERVER_AUTH_USER "admin" 46 | 47 | // Authentication Password 48 | // Default: "" 49 | #define FTP_SERVER_AUTH_PASS "sanlian" 50 | // 51 | 52 | // 53 | -------------------------------------------------------------------------------- /Soft_MCU/RTE/Network/Net_Config_HTTP_Server.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * MDK Middleware - Component ::Network:Service 3 | * Copyright (c) 2004-2015 ARM Germany GmbH. All rights reserved. 4 | *------------------------------------------------------------------------------ 5 | * Name: Net_Config_HTTP_Server.h 6 | * Purpose: Network Configuration for HTTP Server 7 | * Rev.: V5.0.1 8 | *----------------------------------------------------------------------------*/ 9 | 10 | //-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- 11 | 12 | // HTTP Server 13 | #define HTTP_SERVER_ENABLE 1 14 | 15 | // Number of HTTP Sessions <1-10> 16 | // Number of simultaneously active HTTP Sessions. 17 | // Default: 6 18 | #define HTTP_SERVER_NUM_SESSIONS 2 19 | 20 | // Port Number <1-65535> 21 | // Listening port number. 22 | // Default: 80 23 | #define HTTP_SERVER_PORT_NUM 80 24 | 25 | // Server-Id header 26 | // This value is optional. If specified, it overrides 27 | // the default HTTP Server header from the library. 28 | // Default: "" 29 | #define HTTP_SERVER_ID "SL-DPT100" 30 | 31 | // Enable User Authentication 32 | // When enabled, the user will have to authenticate 33 | // himself by username and password before accessing 34 | // any page on this Embedded WEB server. 35 | #define HTTP_SERVER_AUTH_ENABLE 1 36 | 37 | // Authentication Realm 38 | // Default: "Embedded WEB Server" 39 | #define HTTP_SERVER_AUTH_REALM "SL-DPT100" 40 | 41 | // Authentication Username 42 | // Default: "admin" 43 | #define HTTP_SERVER_AUTH_USER "admin" 44 | 45 | // Authentication Password 46 | // Default: "" 47 | #define HTTP_SERVER_AUTH_PASS "sanlian" 48 | // 49 | 50 | // 51 | -------------------------------------------------------------------------------- /Soft_MCU/RTE/Network/Net_Config_TCP.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * MDK Middleware - Component ::Network:Socket 3 | * Copyright (c) 2004-2014 ARM Germany GmbH. All rights reserved. 4 | *------------------------------------------------------------------------------ 5 | * Name: Net_Config_TCP.h 6 | * Purpose: Network Configuration for TCP Sockets 7 | * Rev.: V5.00 8 | *----------------------------------------------------------------------------*/ 9 | 10 | //-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- 11 | 12 | // TCP Sockets 13 | #define TCP_ENABLE 1 14 | 15 | // Number of TCP Sockets <1-20> 16 | // Number of available TCP sockets 17 | // Default: 5 18 | #define TCP_NUM_SOCKS 10 19 | 20 | // Number of Retries <0-20> 21 | // How many times TCP module will try to retransmit data 22 | // before giving up. Increase this value for high-latency 23 | // and low_throughput networks. 24 | // Default: 5 25 | #define TCP_MAX_RETRY 5 26 | 27 | // Retry Timeout in seconds <1-10> 28 | // If data frame not acknowledged within this time frame, 29 | // TCP module will try to resend the data again. 30 | // Default: 4 31 | #define TCP_RETRY_TOUT 4 32 | 33 | // Default Connect Timeout in seconds <1-600> 34 | // Default TCP Socket Keep Alive timeout. When it expires 35 | // with no TCP data frame send, TCP Connection is closed. 36 | // Default: 120 37 | #define TCP_DEFAULT_TOUT 120 38 | 39 | // Maximum Segment Size <536-1460> 40 | // The Maximum Segment Size specifies the maximum 41 | // number of bytes in the TCP segment's Data field. 42 | // Default: 1460 43 | #define TCP_MAX_SEG_SIZE 1460 44 | 45 | // Receive Window Size <536-65535> 46 | // Receive Window Size specifies the size of data, 47 | // that the socket is able to buffer in flow-control mode. 48 | // Default: 4380 49 | #define TCP_RECEIVE_WIN_SIZE 4380 50 | 51 | // 52 | 53 | // TCP Initial Retransmit period in seconds 54 | #define TCP_INITIAL_RETRY_TOUT 1 55 | 56 | // TCP SYN frame retransmit period in seconds 57 | #define TCP_SYN_RETRY_TOUT 2 58 | 59 | // Number of retries to establish a connection 60 | #define TCP_CONNECT_RETRY 7 61 | 62 | -------------------------------------------------------------------------------- /Soft_MCU/RTE/Network/Net_Config_UDP.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * MDK Middleware - Component ::Network:Socket 3 | * Copyright (c) 2004-2014 ARM Germany GmbH. All rights reserved. 4 | *------------------------------------------------------------------------------ 5 | * Name: Net_Config_UDP.h 6 | * Purpose: Network Configuration for UDP Sockets 7 | * Rev.: V5.00 8 | *----------------------------------------------------------------------------*/ 9 | 10 | //-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- 11 | 12 | // UDP Sockets 13 | #define UDP_ENABLE 1 14 | 15 | // Number of UDP Sockets <1-20> 16 | // Number of available UDP sockets 17 | // Default: 5 18 | #define UDP_NUM_SOCKS 8 19 | 20 | // 21 | -------------------------------------------------------------------------------- /Soft_MCU/RTE/Network/Net_Debug.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * MDK Middleware - Component ::Network 3 | * Copyright (c) 2004-2014 ARM Germany GmbH. All rights reserved. 4 | *------------------------------------------------------------------------------ 5 | * Name: Net_Debug.c 6 | * Purpose: Network Debug Configuration 7 | * Rev.: V5.00 8 | *----------------------------------------------------------------------------*/ 9 | 10 | //-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- 11 | 12 | // Print Time Stamp 13 | // Enable printing the time-info in debug messages 14 | #define DBG_TIME 0 15 | 16 | // Network Debug Definitions 17 | // Memory Management Debug <0=> Off <1=> Errors only <2=> Full debug 18 | // Turn On/Off Dynamic Memory debug messages 19 | #define DBG_MEM 0 20 | 21 | // Ethernet Debug <0=> Off <1=> Errors only <2=> Full debug 22 | // Turn On/Off Ethernet debug messages 23 | #define DBG_ETH 0 24 | 25 | // PPP Debug <0=> Off <1=> Errors only <2=> Full debug 26 | // Turn On/Off PPP debug messages 27 | #define DBG_PPP 0 28 | 29 | // SLIP Debug <0=> Off <1=> Errors only <2=> Full debug 30 | // Turn On/Off SLIP debug messages 31 | #define DBG_SLIP 0 32 | 33 | // ARP Debug <0=> Off <1=> Errors only <2=> Full debug 34 | // Turn On/Off ARP debug messages 35 | #define DBG_ARP 0 36 | 37 | // IP Debug <0=> Off <1=> Errors only <2=> Full debug 38 | // Turn On/Off IP debug messages 39 | #define DBG_IP 0 40 | 41 | // ICMP Debug <0=> Off <1=> Errors only <2=> Full debug 42 | // Turn On/Off ICMP debug messages 43 | #define DBG_ICMP 0 44 | 45 | // IGMP Debug <0=> Off <1=> Errors only <2=> Full debug 46 | // Turn On/Off IGMP debug messages 47 | #define DBG_IGMP 0 48 | 49 | // UDP Debug <0=> Off <1=> Errors only <2=> Full debug 50 | // Turn On/Off UDP debug messages 51 | #define DBG_UDP 0 52 | 53 | // TCP Debug <0=> Off <1=> Errors only <2=> Full debug 54 | // Turn On/Off TCP debug messages 55 | #define DBG_TCP 0 56 | 57 | // NBNS Debug <0=> Off <1=> Errors only <2=> Full debug 58 | // Turn On/Off NetBIOS Name Service debug messages 59 | #define DBG_NBNS 0 60 | 61 | // DHCP Debug <0=> Off <1=> Errors only <2=> Full debug 62 | // Turn On/Off Dynamic Host Configuration debug messages 63 | #define DBG_DHCP 0 64 | 65 | // DNS Debug <0=> Off <1=> Errors only <2=> Full debug 66 | // Turn On/Off Domain Name Service debug messages 67 | #define DBG_DNS 0 68 | 69 | // SNMP Debug <0=> Off <1=> Errors only <2=> Full debug 70 | // Turn On/Off Simple Network Management debug messages 71 | #define DBG_SNMP 0 72 | 73 | // SNTP Debug <0=> Off <1=> Errors only <2=> Full debug 74 | // Turn On/Off Simple Network Time debug messages 75 | #define DBG_SNTP 0 76 | 77 | // BSD Debug <0=> Off <1=> Errors only <2=> Full debug 78 | // Turn On/Off BSD Interface debug messages 79 | #define DBG_BSD 0 80 | // 81 | 82 | // Application Debug Definitions 83 | // HTTP Server Debug <0=> Off <1=> Errors only <2=> Full debug 84 | // Turn On/Off Web Server debug messages 85 | #define DBG_HTTP_SERVER 0 86 | 87 | // FTP Server Debug <0=> Off <1=> Errors only <2=> Full debug 88 | // Turn On/Off FTP Server debug messages 89 | #define DBG_FTP_SERVER 0 90 | 91 | // FTP Client Debug <0=> Off <1=> Errors only <2=> Full debug 92 | // Turn On/Off FTP Client debug messages 93 | #define DBG_FTP_CLIENT 0 94 | 95 | // Telnet Server Debug <0=> Off <1=> Errors only <2=> Full debug 96 | // Turn On/Off Telnet Server debug messages 97 | #define DBG_TELNET_SERVER 0 98 | 99 | // TFTP Server Debug <0=> Off <1=> Errors only <2=> Full debug 100 | // Turn On/Off TFTP Server debug messages 101 | #define DBG_TFTP_SERVER 0 102 | 103 | // TFTP Client Debug <0=> Off <1=> Errors only <2=> Full debug 104 | // Turn On/Off TFTP Client debug messages 105 | #define DBG_TFTP_CLIENT 0 106 | 107 | // SMTP Client Debug <0=> Off <1=> Errors only <2=> Full debug 108 | // Turn On/Off SMTP Client debug messages 109 | #define DBG_SMTP_CLIENT 0 110 | // 111 | 112 | 113 | #include "net_debug.h" 114 | 115 | 116 | /** 117 | \fn void net_debug_init (void) 118 | \brief Initialize Network Debug Interface. 119 | */ 120 | void net_debug_init (void) { 121 | /* Add your code to initialize the Debug output. This is usually the */ 122 | /* serial interface. The function is called at Network system startup.*/ 123 | /* You may need to customize also the 'putchar()' function. */ 124 | 125 | } 126 | -------------------------------------------------------------------------------- /Soft_MCU/RTE/RTE_Components.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Auto generated Run-Time-Environment Component Configuration File 4 | * *** Do not modify ! *** 5 | * 6 | * Project: 'HTTP_Server' 7 | * Target: 'MCBSTM32F400 V1.1' 8 | */ 9 | 10 | #ifndef RTE_COMPONENTS_H 11 | #define RTE_COMPONENTS_H 12 | 13 | #define RTE_CMSIS_RTOS /* CMSIS-RTOS */ 14 | #define RTE_CMSIS_RTOS_RTX /* CMSIS-RTOS Keil RTX */ 15 | #define RTE_Compiler_IO_File /* Compiler I/O: File */ 16 | #define RTE_Compiler_IO_File_FS /* Compiler I/O: File (File System) */ 17 | #define RTE_Compiler_IO_STDERR /* Compiler I/O: STDERR */ 18 | #define RTE_Compiler_IO_STDERR_User /* Compiler I/O: STDERR User */ 19 | #define RTE_Compiler_IO_STDIN /* Compiler I/O: STDIN */ 20 | #define RTE_Compiler_IO_STDIN_User /* Compiler I/O: STDIN User */ 21 | #define RTE_Compiler_IO_STDOUT /* Compiler I/O: STDOUT */ 22 | #define RTE_Compiler_IO_STDOUT_User /* Compiler I/O: STDOUT User */ 23 | #define RTE_Compiler_IO_TTY /* Compiler I/O: TTY */ 24 | #define RTE_Compiler_IO_TTY_ITM /* Compiler I/O: TTY ITM */ 25 | #define RTE_DEVICE_FRAMEWORK_CLASSIC 26 | #define RTE_DEVICE_HAL_ADC 27 | #define RTE_DEVICE_HAL_CAN 28 | #define RTE_DEVICE_HAL_COMMON 29 | #define RTE_DEVICE_HAL_CORTEX 30 | #define RTE_DEVICE_HAL_CRC 31 | #define RTE_DEVICE_HAL_DAC 32 | #define RTE_DEVICE_HAL_DCMI 33 | #define RTE_DEVICE_HAL_DMA 34 | #define RTE_DEVICE_HAL_ETH 35 | #define RTE_DEVICE_HAL_FLASH 36 | #define RTE_DEVICE_HAL_GPIO 37 | #define RTE_DEVICE_HAL_HCD 38 | #define RTE_DEVICE_HAL_I2C 39 | #define RTE_DEVICE_HAL_I2S 40 | #define RTE_DEVICE_HAL_IRDA 41 | #define RTE_DEVICE_HAL_IWDG 42 | #define RTE_DEVICE_HAL_NAND 43 | #define RTE_DEVICE_HAL_NOR 44 | #define RTE_DEVICE_HAL_PCCARD 45 | #define RTE_DEVICE_HAL_PCD 46 | #define RTE_DEVICE_HAL_PWR 47 | #define RTE_DEVICE_HAL_RCC 48 | #define RTE_DEVICE_HAL_RNG 49 | #define RTE_DEVICE_HAL_RTC 50 | #define RTE_DEVICE_HAL_SD 51 | #define RTE_DEVICE_HAL_SMARTCARD 52 | #define RTE_DEVICE_HAL_SPI 53 | #define RTE_DEVICE_HAL_SRAM 54 | #define RTE_DEVICE_HAL_TIM 55 | #define RTE_DEVICE_HAL_UART 56 | #define RTE_DEVICE_HAL_USART 57 | #define RTE_DEVICE_HAL_WWDG 58 | #define RTE_DEVICE_STARTUP_STM32F4XX /* Device Startup for STM32F4 */ 59 | #define RTE_Drivers_ETH_MAC0 /* Driver ETH_MAC0 */ 60 | #define RTE_Drivers_PHY_DP83848C /* Driver PHY DP83848C */ 61 | #define RTE_Drivers_USART1 /* Driver USART1 */ 62 | #define RTE_Drivers_USART2 /* Driver USART2 */ 63 | #define RTE_Drivers_USART3 /* Driver USART3 */ 64 | #define RTE_Drivers_USART4 /* Driver USART4 */ 65 | #define RTE_Drivers_USART5 /* Driver USART5 */ 66 | #define RTE_Drivers_USART6 /* Driver USART6 */ 67 | #define RTE_Drivers_USART7 /* Driver USART7 */ 68 | #define RTE_Drivers_USART8 /* Driver USART8 */ 69 | #define RTE_FileSystem_Core /* File System Core */ 70 | #define RTE_FileSystem_LFN /* File System with Long Filename support */ 71 | #define RTE_FileSystem_Drive_NOR_0 /* File System NOR Flash Drive 0 */ 72 | #define RTE_Network_Core /* Network Core */ 73 | #define RTE_Network_Debug /* Network Debug Version */ 74 | #define RTE_Network_FTP_Server /* Network FTP Server */ 75 | #define RTE_Network_Interface_ETH_0 /* Network Interface ETH 0 */ 76 | #define RTE_Network_Socket_BSD /* Network Socket BSD */ 77 | #define RTE_Network_Socket_TCP /* Network Socket TCP */ 78 | #define RTE_Network_Socket_UDP /* Network Socket UDP */ 79 | #define RTE_Network_Web_Server_FS /* Network Web Server with Web Resources on File System */ 80 | 81 | #endif /* RTE_COMPONENTS_H */ 82 | -------------------------------------------------------------------------------- /Soft_MCU/Web/ad.cgi: -------------------------------------------------------------------------------- 1 | t AD Input 2 | t 3 | t 23 | i pg_header.inc 24 | t


AD Converter Input

25 | t

This page allows you to monitor AD input value in numeric 26 | t and graphics form. Periodic screen update is based on xml technology. 27 | t This results in smooth flicker-free screen update.

28 | t Turn potentiometer on an evaluation board clockwise or counterclockwise 29 | t and observe the change of AD value on the screen.

30 | t
31 | t 32 | t 33 | t 34 | t 35 | t 36 | t 37 | t 38 | t 39 | t 42 | t 44 | t 47 | t
ItemValueVoltsBargraph
POT1: 40 | t 45 | c g 3
46 | t
 
48 | t

49 | t 50 | t Periodic: 51 | t

52 | i pg_footer.inc 53 | . End of script must be closed with period 54 | -------------------------------------------------------------------------------- /Soft_MCU/Web/ad.cgx: -------------------------------------------------------------------------------- 1 | t
2 | t 3 | t ad_value 4 | c x0x%03X 5 | t 6 | t
7 | . 8 | -------------------------------------------------------------------------------- /Soft_MCU/Web/buttons.cgi: -------------------------------------------------------------------------------- 1 | t Button inputs 2 | t 3 | t 15 | i pg_header.inc 16 | t


Buttons on the board

17 | t

This page allows you to monitor on board buttons state. 18 | t Periodic screen update is based on xml technology. This results in smooth 19 | t flicker-free screen update.

20 | t Press a button on an evaluation board and observe the change on the screen.

21 | t
22 | t 23 | t 24 | t 25 | t 26 | t 27 | t 28 | t 29 | t 39 | t 40 | t
ItemStatus
Buttons [7..0]: 30 | t 7 31 | t 6 32 | t 5 33 | t 4 34 | t 3 35 | t 2 36 | t 1 37 | t 0 38 | t
41 | t

42 | t 43 | t Periodic: 44 | t

45 | i pg_footer.inc 46 | . End of script must be closed with period. 47 | -------------------------------------------------------------------------------- /Soft_MCU/Web/buttons.cgx: -------------------------------------------------------------------------------- 1 | t
2 | c y0 3 | c y1 4 | c y2 5 | c y3 6 | c y4 7 | c y5 8 | c y6 9 | c y7 10 | t
11 | . 12 | -------------------------------------------------------------------------------- /Soft_MCU/Web/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/Soft_MCU/Web/home.png -------------------------------------------------------------------------------- /Soft_MCU/Web/index.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | SL-DPT100 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Soft_MCU/Web/keil.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/Soft_MCU/Web/keil.gif -------------------------------------------------------------------------------- /Soft_MCU/Web/language.cgi: -------------------------------------------------------------------------------- 1 | t Browser Language Preference 2 | i pg_header.inc 3 | t


Browser Language Preference

4 | t

You may use this information to create Multi Language 5 | t web pages.

6 | t The language preferences can be set in Internet Explorer via 7 | t Tools / Internet Options... / Languages and in Mozilla Firefox via Tools / 8 | t Options... / Content / Languages. You may change the setting in your browser 9 | t and reload this page again to check.

10 | t Your browser is currently sending the following language preference:

11 | t
12 | t 13 | t 14 | t 15 | t 16 | t 17 | # Here begin data setting which is formatted in HTTP_CGI.C module 18 | c e 19 | t
ItemSetting
Browser Language%s [%s]
20 | i pg_footer.inc 21 | . End of script must be closed with period. 22 | -------------------------------------------------------------------------------- /Soft_MCU/Web/lcd.cgi: -------------------------------------------------------------------------------- 1 | t LCD Control 2 | i pg_header.inc 3 | t


LCD Module Control

4 | t

This page allows you to change a message displayed on LCD Module. 5 | t Simply enter the text which you want to display and click Send.

6 | t This Form uses a POST method to send data to a Web server.

7 | t 8 | t 9 | t 10 | t 11 | t 12 | t 13 | # Here begin data setting which is formatted in HTTP_CGI.C module 14 | t 15 | c f 1 16 | t 17 | c f 2 18 | t
ItemSetting
Line 1 Text
Line 2 Text
19 | # Here begin button definitions 20 | t

21 | t 22 | t 23 | t

24 | i pg_footer.inc 25 | . End of script must be closed with period. 26 | -------------------------------------------------------------------------------- /Soft_MCU/Web/leds.cgi: -------------------------------------------------------------------------------- 1 | t LED Control 2 | t 12 | i pg_header.inc 13 | t


Control LEDs on the board

14 | t

This page shows you how to use the following http form input objects: 15 | t checkbox, select and button. It uses also a simple Java Script 16 | t function to check/uncheck all checkboxes and submit the data.

17 | t This Form uses a POST method to send data to a Web server.

18 | t
19 | t 20 | t 21 | t 22 | t 23 | t 24 | t 25 | t 27 | t 28 | t 40 | t 41 | t 43 | t
ItemSetting
LED control:
LED diode ports [7..0]: 29 | # Here begin the 'checkbox' definitions 30 | c b 7 31 | c b 6 32 | c b 5 33 | c b 4 34 | t 35 | c b 3 36 | c b 2 37 | c b 1 38 | c b 0 39 | t
76543210
All LED diodes On or OFF 42 | t
44 | i pg_footer.inc 45 | . End of script must be closed with period. 46 | 47 | 48 | -------------------------------------------------------------------------------- /Soft_MCU/Web/llblue.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/Soft_MCU/Web/llblue.jpg -------------------------------------------------------------------------------- /Soft_MCU/Web/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/Soft_MCU/Web/logo.gif -------------------------------------------------------------------------------- /Soft_MCU/Web/network.cgi: -------------------------------------------------------------------------------- 1 | t Network Settings 2 | t 8 | i pg_header.inc 9 | t


Network Settings

10 | t

Here you can change the system Network Settings. 11 | t After you have changed the IP address, you need to change also the host IP address in 12 | t you Internet browser to re-connect to target.

13 | t This Form uses a GET method to send data to a Web server.

14 | t
15 | t 16 | t 17 | t 18 | t 19 | t 20 | # Here begin data setting which is formatted in HTTP_CGI.C module 21 | t 22 | c a i 23 | t 24 | c a m 25 | t 26 | c a g 27 | t 28 | c a p 29 | t 30 | c a s 31 | t
ItemSetting
IP Address
Network Mask
Default Gateway
Primary DNS Server
Secondary DNS Server
32 | # Here begin button definitions 33 | t

34 | t 35 | t 36 | t

37 | i pg_footer.inc 38 | . End of script must be closed with period. 39 | 40 | -------------------------------------------------------------------------------- /Soft_MCU/Web/pabb.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/Soft_MCU/Web/pabb.gif -------------------------------------------------------------------------------- /Soft_MCU/Web/pg_footer.inc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/Soft_MCU/Web/pg_footer.inc -------------------------------------------------------------------------------- /Soft_MCU/Web/pg_header.inc: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 20 | 23 | 24 |
18 |

Profibus-DP to Ethernet

19 |
21 | 22 |
25 |
26 |
27 | 28 |
-------------------------------------------------------------------------------- /Soft_MCU/Web/setting.cgi: -------------------------------------------------------------------------------- 1 | t 2 | t 3 | t SL-DPT100 4 | t 5 | t 24 | t 25 | # 26 | i pg_header.inc 27 | t 28 | t
29 | t 30 | # 31 | t
32 | t 33 | t 34 | t 35 | c a b 46 | t 47 | t 48 | # 49 | t 50 | t 51 | t 54 | t 55 | t 56 | c a i 57 | t 58 | t 59 | c a m 60 | t 61 | t 62 | c a g 63 | t 64 | t 65 | c a a 66 | t 67 | t 68 | # 69 | t 70 | t 71 | c a w 72 | t 73 | t
ProfiBUS-DP Config
Baud rate:   36 | t 37 | t 45 | t
Ethernet Network Config
DHCP:   Enable   52 | c a d Disable 53 | t
IP Address:  
Network Mask:  
Default Gateway:  
MAC Address:  
System Config
Password:  
74 | t
75 | # 76 | t

77 | t 78 | t 79 | t

80 | t
81 | t 82 | i pg_footer.inc 83 | # 84 | t 85 | . End of script must be closed with period. --> 86 | 87 | -------------------------------------------------------------------------------- /Soft_MCU/Web/system.cgi: -------------------------------------------------------------------------------- 1 | t System Settings 2 | t 8 | i pg_header.inc 9 | t


System Settings

10 | t

This page allows you to change the system 11 | t Password, for the username admin. Default realm, 12 | t user and password can be set in configuraton file.

13 | t This Form uses a POST method to send data to a Web server.

14 | t
15 | t 16 | t 17 | t 18 | t 19 | t 20 | # Here begin data setting which is formatted in HTTP_CGI.C module 21 | c d 1 22 | t 23 | c d 2 24 | t 25 | c d 2 26 | t
ItemSetting
Authentication%s
Password for user 'admin'
Retype your password
27 | # Here begin button definitions 28 | t

29 | t 30 | t 31 | t

32 | i pg_footer.inc 33 | . End of script must be closed with period. 34 | -------------------------------------------------------------------------------- /Soft_MCU/Web/tcp.cgi: -------------------------------------------------------------------------------- 1 | t TCP Socket Status 2 | t 3 | i pg_header.inc 4 | t


Tcp Socket online Status

5 | t
6 | t 7 | t 8 | t 9 | t 10 | t 11 | t 12 | t 13 | t 14 | t 15 | c c 16 | t
SocketStatePortTimerRemote AddressPort
17 | t
18 | t 19 | t
20 | t 21 | t
22 | t
23 | t 24 | i pg_footer.inc 25 | . End of script must be closed with period. 26 | 27 | -------------------------------------------------------------------------------- /Soft_MCU/Web/top_bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/Soft_MCU/Web/top_bg.jpg -------------------------------------------------------------------------------- /Soft_MCU/Web/xml_http.js: -------------------------------------------------------------------------------- 1 | /* Main function, that handles request and responses in background. 2 | * Response functions are handled if response code equals to OK 200. */ 3 | function updateMultiple(formUpd, callBack, userName, userPassword) { 4 | xmlHttp = GetXmlHttpObject(); 5 | if(xmlHttp == null) { 6 | alert("XmlHttp not initialized!"); 7 | return 0; 8 | } 9 | xmlHttp.onreadystatechange = responseHandler; 10 | xmlHttp.open("GET", formUpd.url, true, userName, userPassword); 11 | xmlHttp.send(null); 12 | 13 | function responseHandler(){ 14 | if(xmlHttp.readyState == 4) { //response ready 15 | if(xmlHttp.status == 200) { //handle received data 16 | var xmlDoc = xmlHttp.responseXML; 17 | if(xmlDoc == null) 18 | return 0; 19 | try { //catching IE bug 20 | processResponse(xmlDoc); 21 | } 22 | catch(e) { 23 | return 0; 24 | } 25 | /* Callback function for custom update. */ 26 | if (callBack != undefined) 27 | callBack(); 28 | } 29 | else if(xmlHttp.status == 401) 30 | alert("Error code 401: Unauthorized"); 31 | else if(xmlHttp.status == 403) 32 | alert("Error code 403: Forbidden"); 33 | else if(xmlHttp.status == 404) 34 | alert("Error code 404: URL not found!"); 35 | } 36 | } 37 | } 38 | 39 | function processResponse(xmlDoc) { 40 | textElementArr = xmlDoc.getElementsByTagName("text"); 41 | for(var i = 0; i < textElementArr.length; i++) { 42 | try { 43 | elId = textElementArr[i].childNodes[0].childNodes[0].nodeValue; 44 | elValue = textElementArr[i].childNodes[1].childNodes[0].nodeValue; 45 | document.getElementById(elId).value = elValue; 46 | } 47 | catch(error) { 48 | if(elId == undefined){ 49 | continue; 50 | } 51 | else if(elValue == undefined) { 52 | elValue = ""; 53 | document.getElementById(elId).value = elValue; 54 | } 55 | } 56 | } 57 | checkboxElementArr = xmlDoc.getElementsByTagName("checkbox"); 58 | for(var i = 0; i < checkboxElementArr.length; i++) { 59 | try { 60 | elId = checkboxElementArr[i].childNodes[0].childNodes[0].nodeValue; 61 | elValue = checkboxElementArr[i].childNodes[1].childNodes[0].nodeValue; 62 | if(elValue.match("true")) 63 | document.getElementById(elId).checked = true; 64 | else 65 | document.getElementById(elId).checked = false; 66 | } 67 | catch(error) { 68 | if(elId == undefined) { 69 | continue; 70 | } 71 | else if(elValue == undefined) //we leave current state 72 | continue; 73 | } 74 | } 75 | selectElementArr = xmlDoc.getElementsByTagName("select"); 76 | for(var i = 0; i < selectElementArr.length; i++) { 77 | try { 78 | elId = selectElementArr[i].childNodes[0].childNodes[0].nodeValue; 79 | elValue = selectElementArr[i].childNodes[1].childNodes[0].nodeValue; 80 | document.getElementById(elId).value = elValue; 81 | if(elValue.match("true")) 82 | document.getElementById(elId).selected = true; 83 | else 84 | document.getElementById(elId).selected = false; 85 | } 86 | catch(error) { 87 | if(elId == undefined) { 88 | continue; 89 | } 90 | else if(elValue == undefined) { 91 | elValue = ""; 92 | document.getElementById(elId).value = elValue; 93 | } 94 | } 95 | } 96 | radioElementArr = xmlDoc.getElementsByTagName("radio"); 97 | for(var i = 0; i < radioElementArr.length; i++) { 98 | try { 99 | elId = radioElementArr[i].childNodes[0].childNodes[0].nodeValue; 100 | elValue = radioElementArr[i].childNodes[1].childNodes[0].nodeValue; 101 | if(elValue.match("true")) 102 | document.getElementById(elId).checked = true; 103 | else 104 | document.getElementById(elId).checked = false; 105 | } 106 | catch(error) { 107 | if(elId == undefined) { 108 | continue; 109 | } 110 | else if(elValue == undefined) //we leave current state 111 | continue; 112 | } 113 | } 114 | } 115 | 116 | /* XMLHttpRequest object specific functions */ 117 | function GetXmlHttpObject() { //init XMLHttp object 118 | var xmlHttp=null; 119 | try { 120 | xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari 121 | } 122 | catch (e) { 123 | try { // Internet Explorer 124 | xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 125 | } 126 | catch (e) { 127 | xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 128 | } 129 | } 130 | return xmlHttp; 131 | } 132 | 133 | /* Objects templates */ 134 | function periodicObj(url, period) { 135 | this.url = url; 136 | this.period = (typeof period == "undefined") ? 0 : period; 137 | } 138 | -------------------------------------------------------------------------------- /Soft_MCU/config.sys: -------------------------------------------------------------------------------- 1 | [System] 2 | Password = sanlian ; 3 | 4 | [Ethernet] 5 | DHCP = Y ; 6 | IPADDR = 192.168.0.99 ; 7 | DefGW = 192.168.0.1 ; 8 | MASK = 255.255.255.0 ; 9 | MACADDR = UNDEF ;"1E-30-AA-BB-CC-DD" or "UNDEF" 10 | 11 | [ProfiBUS] 12 | BAUD = 187500 ; 13 | 14 | -------------------------------------------------------------------------------- /_PCB/3.3v通信板.SchDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/3.3v通信板.SchDoc -------------------------------------------------------------------------------- /_PCB/BOM SL-DPT100.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/BOM SL-DPT100.xlsx -------------------------------------------------------------------------------- /_PCB/Ethernet.SchDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/Ethernet.SchDoc -------------------------------------------------------------------------------- /_PCB/IPC-7352 Chip_Capacitor_N.PcbLib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/IPC-7352 Chip_Capacitor_N.PcbLib -------------------------------------------------------------------------------- /_PCB/IPC-7352 Chip_Resistor_N.PcbLib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/IPC-7352 Chip_Resistor_N.PcbLib -------------------------------------------------------------------------------- /_PCB/MCU.SchDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/MCU.SchDoc -------------------------------------------------------------------------------- /_PCB/MCU_1.SchDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/MCU_1.SchDoc -------------------------------------------------------------------------------- /_PCB/Phoenix ME MAX 22.5 2-2 KMGY.PcbDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/Phoenix ME MAX 22.5 2-2 KMGY.PcbDoc -------------------------------------------------------------------------------- /_PCB/Phoenix ME MAX 22.5 SF G 2-2 KMGY.PcbDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/Phoenix ME MAX 22.5 SF G 2-2 KMGY.PcbDoc -------------------------------------------------------------------------------- /_PCB/Power.SchDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/Power.SchDoc -------------------------------------------------------------------------------- /_PCB/SL-DPT100 (2016-3-25 15-01-02).zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/SL-DPT100 (2016-3-25 15-01-02).zip -------------------------------------------------------------------------------- /_PCB/SL-DPT100 v1.0.0.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/SL-DPT100 v1.0.0.rar -------------------------------------------------------------------------------- /_PCB/SL-DPT100 v1.1.0.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/SL-DPT100 v1.1.0.rar -------------------------------------------------------------------------------- /_PCB/SL-DPT100.PcbDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/SL-DPT100.PcbDoc -------------------------------------------------------------------------------- /_PCB/SL-DPT100.PcbLib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/SL-DPT100.PcbLib -------------------------------------------------------------------------------- /_PCB/SL-DPT100.PrjPcb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/SL-DPT100.PrjPcb -------------------------------------------------------------------------------- /_PCB/SL-DPT100.PrjPcbStructure: -------------------------------------------------------------------------------- 1 | Record=TopLevelDocument|FileName=Ethernet.SchDoc 2 | -------------------------------------------------------------------------------- /_PCB/SL-DPT100.SchLib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/SL-DPT100.SchLib -------------------------------------------------------------------------------- /_PCB/STM32F407封装库.IntLib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/STM32F407封装库.IntLib -------------------------------------------------------------------------------- /_PCB/_PCB_v1.1.0.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/_PCB_v1.1.0.rar -------------------------------------------------------------------------------- /_PCB/制板说明.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/_PCB/制板说明.txt -------------------------------------------------------------------------------- /测试1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linghu0060/SL-DPT100/8c2f5e46534cc5840027bee75acf5037fd70e0f4/测试1.bmp --------------------------------------------------------------------------------