thanks!
I'm sorry, I'm not all that familiar with callbacks... I'll dig into it. Is it comparable to what would be called an interrupt routine?
Na, it's not like interrupts, it's just like a function being called, like if you made a function yourself and then called it.
Except in this case the thing calling that function you made is not in your program it's in a different C file (WCHNET library) that's written by someone else.
But the person who wrote WCHNET does not know if you, a user of that library, need to use a function for this task or not.
They cannot hard code a call to an external function if they don't know if you want one or not. So instead they give you a way to tell the library "hey, I want to you call my function X when Y occurs, and here's the memory address of the function".
Normally this is called registering the callback. You are passing a pointer (that points to your function) into the library's code so it can call that function when it needs to.
In the main loop, there's "WCHNET_MainTask();" , that seems to be defined in eth_driver.c
WCHNET_MainTask() gives the WCHNET library it's ability to run it's own code by inserting itself into the main program loop.
Practically everything Ethernet related happens inside that function or its sub functions.
I'm still bit puzzled how/when that "WCHNET_CreateUdpSocket" gets executed.
Not sure what you mean by that
WCHNET_CreateUdpSocket() gets executed by you in your main.c function just before the while(1) loop to setup a UDP socket.