Good day!
I am writing a project for stm32f407vet6, the essence is simple - exchange over ethernet between the board and the upper level. I tried to use the LWIP stack, but the board does not start with it the first time and the ping does not pass every time....
Therefore, I want to try to connect a simpler uip stack, but I don't know how to do it correctly, what steps to take. There are fewer guides on the Internet about this than for lwip, and for dp83848 physics - not at all. Maybe someone has a ready-made project, the simplest, or someone knows the specific steps? I will be glad of any hints, sources.
If for more specific questions - how is the sending of data on eth at the lowest level? To make the question more clear:
For other physics, in its driver there is a function enc28j60_send_packet((uint8_t *) uip_buf, uip_lan);
And for my dp83848 there is no such function.
How to properly implement sending eth frames with it? How to initialize correctly?
I tried to build the project in CubeMX, connected ethernet and TIM6 there. Then I connected the uip library to Keil. In main, I wrote the following code:
int main(void)
{
uip_ip4addr_t addrm;
uip_ip4addr_t addrt;
struct uip_udp_conn *c;
uip_ipaddr(&addrt, 192,168,1,1);
uip_ipaddr(&addrm, 1192,168,1,123);
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_ETH_Init();
MX_TIM6_Init();
hello_world_init();
c = uip_udp_new(&addrt, HTONS(12345));
uip_connect(&addrt, HTONS(12345));
HAL_TIM_Base_Start_IT (&htim6);
while (1)
{
uip_udp_conn = c;
uip_appdata = &my_udp_buf;
uip_udp_packet_send(c, uip_appdata, strlen(uip_appdata) );//Im trying it first
uip_send(uip_appdata, my_udp_buf_len);//then it
uip_udp_packet_send(c,uip_appdata, 8 );//then it
uip_udp_packet_sendto(c,uip_appdata, 8 , &addrm, 12345 );//and it last
}}
```
void
uip_udp_packet_sendto(struct uip_udp_conn *c, const void *data, int len,
const uip_ipaddr_t *toaddr, uint16_t toport)
{
uip_ipaddr_t curaddr;
uint16_t curport;
if(toaddr != NULL) {
/* Save current IP addr/port. */
uip_ipaddr_copy(&curaddr, &c->ripaddr);
curport = c->rport;
/* Load new IP addr/port */
uip_ipaddr_copy(&c->ripaddr, toaddr);
c->rport = toport;
uip_udp_packet_send(c, data, len);
/* Restore old IP addr/port */
uip_ipaddr_copy(&c->ripaddr, &curaddr);
c->rport = curport;
}
}
void
uip_udp_packet_send(struct uip_udp_conn *c, const void *data, int len)
{
if(data != NULL && len <= (UIP_BUFSIZE - (UIP_LLH_LEN + UIP_IPUDPH_LEN))) {
uip_udp_conn = c;
uip_len = len;
memmove(&uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN], data, len);
uip_process(UIP_UDP_SEND_CONN);
}}