芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

飞芯科技-芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

单片机解密STM32F4+W5500以太网通讯

  1. 单片机解密/******************** (C) COPYRIGHT 2014 91mcu **************************
  2. 单片机解密* 文件名  :main.c
  3. 单片机解密* 描述    :W5500 以太网模块测试程序:Modbus-TCP 功能实现。      
  4. 单片机解密* 实验平台:STM32F103VCT6+W5500
  5. 单片机解密* 库版本  :ST3.5.0
  6. *
  7. * 作者    :zhangsz
  8. **********************************************************************************/       
  9. #include <string.h>
  10. #include <stdio.h>
  11. #include "stm32f10x.h"

  12. #include "W5500.h"
  13. #include "device.h"
  14. #include "systick.h"
  15. #include "led.h"
  16. #include "mb.h"


  17. /* ----------------------- Holding register Defines ------------------------------------------*/

  18. #define REG_HOLDING_START 1000
  19. #define REG_HOLDING_NREGS 4

  20. /* ----------------------- Static variables ---------------------------------*/
  21. static unsigned short usRegHoldingStart = REG_HOLDING_START;
  22. static unsigned short usRegHoldingBuf[REG_HOLDING_NREGS]={0xaa,0x55,0x5599,0x5588};

  23. /* ----------------------- input register Defines ------------------------------------------*/
  24. #define REG_INPUT_START 1000
  25. #define REG_INPUT_NREGS 4

  26. /* ----------------------- Static variables ---------------------------------*/
  27. static unsigned short usRegInputStart = REG_INPUT_START;
  28. static unsigned short usRegInputBuf[REG_INPUT_NREGS]={0,0,0x5599,0x5588};

  29. /* ----------------------- coils register Defines ------------------------------------------*/
  30. #define REG_COILS_START     1000
  31. #define REG_COILS_SIZE      16

  32. /* ----------------------- Static variables ---------------------------------*/
  33. static unsigned char ucRegCoilsBuf[REG_COILS_SIZE / 8]={0xaa,0xfe};          //数量低于8个还需要验证一下,是否需要加1呢。

  34. /* ----------------------- discrete register Defines ------------------------------------------*/
  35. #define REG_DISC_START     1000
  36. #define REG_DISC_SIZE      16

  37. /* ----------------------- Static variables ---------------------------------*/
  38. static unsigned char ucRegDiscBuf[REG_DISC_SIZE / 8] = { 0x98, 0x6e };           //数量8的整数倍。


  39. void BSP_LED(void);          //LED指示线圈操作

  40. /* W5500 configuration */
  41. void W5500_Configuration()
  42. {
  43.         unsigned char array[6];

  44.         GPIO_SetBits(GPIO_W5500_RST_PORT, GPIO_W5500_RST_Pin);
  45.         Delay_ms(100);    /*delay 100ms 使用systick 1ms时基的延时*/
  46.         while((Read_1_Byte(PHYCFGR)&LINK)==0);                 /* Waiting for Ethernet Link */

  47.         Write_1_Byte(MR, RST);
  48.         Delay_ms(20);                /*delay 20ms */

  49.         /* Set Gateway IP as: 192.168.1.1 */
  50.         array[0]=192;
  51.         array[1]=168;
  52.         array[2]=1;
  53.         array[3]=1;
  54.         Write_Bytes(GAR, array, 4);

  55.         /* Set Subnet Mask as: 255.255.255.0 */
  56.         array[0]=255;
  57.         array[1]=255;
  58.         array[2]=255;
  59.         array[3]=0;
  60.         Write_Bytes(SUBR, array, 4);

  61.         /* Set MAC Address as: 0x48,0x53,0x00,0x57,0x55,0x00 */
  62.         array[0]=0x48;
  63.         array[1]=0x53;
  64.         array[2]=0x00;
  65.         array[3]=0x57;
  66.         array[4]=0x55;
  67.         array[5]=0x00;
  68.         Write_Bytes(SHAR, array, 6);

  69.         /* Set W5500 IP as: 192.168.1.128 */
  70.         array[0]=192;
  71.         array[1]=168;
  72.         array[2]=1;
  73.         array[3]=128;
  74.         Write_Bytes(SIPR, array, 4);
  75. }



联系方式

地址:石家庄市新华区民族路77号华强广场D座2009
电话:0311-88816616/87087811
手机:13315190088
传真:0311-67901001
联系人:张工
网址:www.feixindz.com
邮箱:feixindz@163.com
微信:xinpianjiemi
QQ:527263666/568069805

在线客服
热线电话

企业微信