eth_worker.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. typedef struct EthWorker EthWorker;
  3. typedef enum {
  4. EthWorkerStateNotInited = 0,
  5. EthWorkerStateModuleInit,
  6. EthWorkerStateModulePowerOn,
  7. EthWorkerStateModuleConnect,
  8. EthWorkerStateMACInit,
  9. EthWorkerStateStaticIp,
  10. EthWorkerStateDHCP,
  11. EthWorkerStatePing,
  12. EthWorkerStateStop,
  13. } EthWorkerState;
  14. typedef enum {
  15. EthWorkerSubstateInProcess = 0,
  16. EthWorkerSubStateSuccess,
  17. EthWorkerSubStateError,
  18. } EthWorkerSubState;
  19. typedef enum {
  20. EthCustomEventUpdate = 0,
  21. EthCustomEventModuleInit,
  22. EthCustomEventModuleError,
  23. EthCustomEventModulePowerOn,
  24. EthCustomEventModuleConnect,
  25. EthCustomEventMACInit,
  26. EthCustomEventStaticIp,
  27. EthCustomEventDHCP,
  28. EthCustomEventPing,
  29. EthCustomEventTCP2UART,
  30. EthCustomEventTCP2CLI,
  31. EthCustomEventSaved,
  32. } EthCustomEvent;
  33. typedef void (*EthWorkerCallback)(EthCustomEvent event, void* context);
  34. EthWorker* eth_worker_alloc();
  35. EthWorkerState eth_worker_get_state(EthWorker* eth_worker);
  36. void eth_worker_free(EthWorker* eth_worker);
  37. void eth_worker_start(
  38. EthWorker* eth_worker,
  39. EthWorkerState state,
  40. EthWorkerCallback callback,
  41. void* context);
  42. void eth_worker_stop(EthWorker* eth_worker);
  43. void eth_worker_dhcp(EthWorker* eth_worker);
  44. void eth_worker_w5500(EthWorker* eth_worker);