luat_netdrv.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef LUAT_NETDRV_H
  2. #define LUAT_NETDRV_H
  3. #include "lwip/pbuf.h"
  4. typedef void (*luat_netdrv_dataout_cb)(void* userdata, struct pbuf* pb, int flags);
  5. typedef int (*luat_netdrv_bootup_cb)(void* userdata);
  6. typedef int (*luat_netdrv_ready_cb)(void* userdata);
  7. typedef int (*luat_netdrv_dhcp_set)(void* userdata, int enable);
  8. typedef struct luat_netdrv {
  9. int32_t id;
  10. struct netif* netif;
  11. luat_netdrv_dataout_cb dataout;
  12. luat_netdrv_bootup_cb boot;
  13. luat_netdrv_ready_cb ready;
  14. luat_netdrv_dhcp_set dhcp;
  15. void* userdata;
  16. }luat_netdrv_t;
  17. enum {
  18. LUAT_NETDRV_TP_NATIVE,
  19. LUAT_NETDRV_TP_CH390H,
  20. LUAT_NETDRV_TP_W5100,
  21. LUAT_NETDRV_TP_W5500,
  22. LUAT_NETDRV_TP_SPINET,
  23. LUAT_NETDRV_TP_UARTNET,
  24. LUAT_NETDRV_TP_USB
  25. };
  26. typedef struct luat_netdrv_conf
  27. {
  28. int32_t id;
  29. int32_t impl;
  30. uint8_t spiid;
  31. uint8_t cspin;
  32. uint8_t rstpin;
  33. uint8_t irqpin;
  34. }luat_netdrv_conf_t;
  35. typedef struct luat_netdrv_statics_item
  36. {
  37. uint64_t counter;
  38. uint64_t bytes;
  39. }luat_netdrv_statics_item_t;
  40. typedef struct luat_netdrv_statics
  41. {
  42. luat_netdrv_statics_item_t in;
  43. luat_netdrv_statics_item_t out;
  44. luat_netdrv_statics_item_t drop;
  45. }luat_netdrv_statics_t;
  46. luat_netdrv_t* luat_netdrv_setup(luat_netdrv_conf_t *conf);
  47. int luat_netdrv_dhcp(int32_t id, int32_t enable);
  48. int luat_netdrv_ready(int32_t id);
  49. int luat_netdrv_register(int32_t id, luat_netdrv_t* drv);
  50. int luat_netdrv_mac(int32_t id, const char* new, char* old);
  51. #endif