已经完成了网络,DI口,RS485的数据透传,可通过RS485接收数据
This commit is contained in:
46
User/user_main/user_main.c
Normal file
46
User/user_main/user_main.c
Normal file
@ -0,0 +1,46 @@
|
||||
#include "user_main.h"
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include "wizchip_conf.h"
|
||||
#include "wiz_interface.h"
|
||||
#include "loopback.h"
|
||||
|
||||
/*wizchip->STM32 Hardware Pin define*/
|
||||
// wizchip_SCS ---> STM32_GPIOD7
|
||||
// wizchip_SCLK ---> STM32_GPIOB13
|
||||
// wizchip_MISO ---> STM32_GPIOB14
|
||||
// wizchip_MOSI ---> STM32_GPIOB15
|
||||
// wizchip_RESET ---> STM32_GPIOD8
|
||||
// wizchip_INT ---> STM32_GPIOD9
|
||||
|
||||
/* Define network information */
|
||||
wiz_NetInfo default_net_info = {
|
||||
.mac = {0x00, 0x08, 0xdc, 0x12, 0x22, 0x12},
|
||||
.ip = {192, 168, 6, 212},
|
||||
.gw = {192, 168, 6, 1},
|
||||
.sn = {255, 255, 255, 0},
|
||||
.dns = {8, 8, 8, 8},
|
||||
.dhcp = NETINFO_STATIC
|
||||
//.dhcp = NETINFO_STATIC //static ip
|
||||
};
|
||||
uint16_t local_port = 8000;
|
||||
static uint8_t ethernet_buf[ETHERNET_BUF_MAX_SIZE] = {0};
|
||||
/**
|
||||
* @brief User Run Program
|
||||
* @param none
|
||||
* @return none
|
||||
*/
|
||||
void user_run(void)
|
||||
{
|
||||
printf("wizchip UDP example\r\n");
|
||||
|
||||
/* wizchip init */
|
||||
wizchip_initialize();
|
||||
|
||||
/* set network information */
|
||||
network_init(ethernet_buf, &default_net_info);
|
||||
while (1)
|
||||
{
|
||||
loopback_udps(SOCKET_ID, ethernet_buf, local_port);
|
||||
}
|
||||
}
|
||||
18
User/user_main/user_main.h
Normal file
18
User/user_main/user_main.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef __USER_MAIN_H__
|
||||
#define __USER_MAIN_H__
|
||||
|
||||
#include "wizchip_conf.h" // 加入這行以識別 wiz_NetInfo 型別
|
||||
|
||||
// 透過 extern 將網路配置參數暴露給 main.c 使用
|
||||
extern wiz_NetInfo default_net_info;
|
||||
#define SOCKET_ID 0
|
||||
#define ETHERNET_BUF_MAX_SIZE (1024 * 2)
|
||||
|
||||
/**
|
||||
* @brief User Run Program
|
||||
* @param none
|
||||
* @return none
|
||||
*/
|
||||
|
||||
void user_run(void);
|
||||
#endif
|
||||
Reference in New Issue
Block a user