轉發一個例程,希望對用到的人有幫助,實測沒有問題。
單片機源程序如下:
- #include "sys.h"
- #include "usart.h"
- #include "delay.h"
- #include "stdio.h"
- #include "mcu_int.h"
- #include "config.h"
- #include "ult.h"
- #include "w5500.h"
- #include "socket.h"
- #include "spi.h"
- #include "snmpLib.h"
- #include "snmpDemo.h"
- #include "device.h"
- #include "24c16.h"
- #include <stdio.h>
- #include <string.h>
- CONFIG_MSG Config_Msg;
- CHCONFIG_TYPE_DEF Chconfig_Type_Def;
- uint8 ch_status[MAX_SOCK_NUM] = { 0, }; /** 0:close, 1:ready, 2:connected */
- uint8 TX_BUF[TX_RX_MAX_BUF_SIZE]; // TX Buffer for applications
- uint8 RX_BUF[TX_RX_MAX_BUF_SIZE]; // RX Buffer for applications
-
- int main(void)
- {
- uint8 m=0;
- delay_init(); //延時函數初始化
- NVIC_Configuration(); //設置NVIC中斷分組2:2位搶占優先級,2位響應優先級
- GPIO_Configuration();/* 配置GPIO*/
- uart_init(115200); //串口初始化為9600
- at24c16_init();/*初始化eeprom*/
- printf("W5500 EVB initialization over.\r\n");
-
- Reset_W5500();/*硬重啟W5500*/
- SPI2_Init();
- printf("W5500 initialized!\r\n");
- set_default();
- set_network();
- printf("Network is ready.\r\n");
- //GPIO_ResetBits(GPIOA, LED0);
- GPIO_ResetBits(GPIOA, LED3);
- // GPIO_SetBits(GPIOA, LED2); // led
- while(1)
- {
- for ( m=0; m<10; m++)
- {
- GPIO_SetBits(GPIOA, LED2);
- delay_ms(100);
- GPIO_ResetBits(GPIOA, LED2);
- delay_ms(100);
- }
- UserSnmpDemo();
- }
- }
復制代碼
所有資料51hei提供下載:
SNMP.rar
(334.13 KB, 下載次數: 115)
2018-11-30 15:45 上傳
點擊文件名下載附件
|