/* IMPORTANT NOTE
==============
This configuration is valid only when MCO pin is used as RMII clock source.
To output a 50 MHz clock signal on the MCO pin, the following conditions
must be respected:
– 25 MHz external crystal connected to OSCIN/OSCOUT pins
– RCC_PLLCFGR PLL factors configured as follows:
PLLMx = 4, PLLNx = 64, PLLP = 4.
This leads to a system clock of 100 MHz.
– Then set the MCO prescaler to 2 in the RCC_CFGR register to configure
the system clock to 50 MHz.
*/
/* Create a new UDP control block */
upcb = udp_new();
if (upcb)
{
/* Bind the upcb to the UDP_PORT port */
/* Using IP_ADDR_ANY allow the upcb to be used by any local interface */
err = udp_bind(upcb, IP_ADDR_ANY, UDP_SERVER_PORT);
if(err == ERR_OK)
{
/* Set a receive callback for the upcb */
udp_recv(upcb, udp_echoserver_receive_callback, NULL);
}
}
}
/**
* @brief This function is called when an UDP datagrm has been received on the port UDP_PORT.
* @param arg user supplied argument (udp_pcb.recv_arg)
* @param pcb the udp_pcb which received data
* @param p the packet buffer that was received
* @param addr the remote IP address from which the packet was received
* @param port the remote port from which the packet was received
* @retval None
*/
void udp_echoserver_receive_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
{
/* Connect to the remote client */
udp_connect(upcb, addr, UDP_CLIENT_PORT);
/* Tell the client that we have accepted it */
udp_send(upcb, p);
/* free the UDP connection, so we can accept new clients */
udp_disconnect(upcb);