RyanW5500Store.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #ifndef __RyanW5500Store__
  2. #define __RyanW5500Store__
  3. #ifdef __cplusplus
  4. extern "C"
  5. {
  6. #endif
  7. #define DBG_ENABLE
  8. #define DBG_SECTION_NAME ("RyanW5500")
  9. #define DBG_LEVEL LOG_LVL_WARNING
  10. #define DBG_COLOR
  11. #include <stdio.h>
  12. #include <stdint.h>
  13. #include <string.h>
  14. #include <stdlib.h>
  15. #include "ulog.h"
  16. #include "sal.h"
  17. #include "platformTimer.h"
  18. #include "platformW5500Hardware.h"
  19. #include "wizchip_conf.h"
  20. #include "wizchip_socket.h"
  21. #include "wizchip_dhcp.h"
  22. #include "wizchip_dns.h"
  23. #include "w5500.h"
  24. #include "RyanList.h"
  25. #include "RyanW5500.h"
  26. #include "RyanW5500Socket.h"
  27. #ifndef delay
  28. #define delay(ms) rt_thread_mdelay(ms)
  29. #endif
  30. #define RyanW5500SetErrno(err) \
  31. do \
  32. { \
  33. if (err) \
  34. errno = (err); \
  35. } while (0)
  36. #define RyanW5500Check(EX, ErrorCode) RyanW5500CheckCode(EX, ErrorCode, NULL)
  37. #define RyanW5500CheckCode(EX, ErrorCode, code) \
  38. if (!(EX)) \
  39. { \
  40. LOG_D("%s:%d ErrorCode: %d, strError: %s", \
  41. __FILE__, __LINE__, ErrorCode, strerror(ErrorCode)); \
  42. RyanW5500SetErrno(ErrorCode); \
  43. { \
  44. code \
  45. } \
  46. }
  47. // WIZnet套接字魔术词
  48. #define WIZ_SOCKET_MAGIC 0x3120
  49. // WIZnet 套接字地址系列
  50. #ifndef AF_WIZ
  51. #define AF_WIZ 46
  52. #endif
  53. #define RyanW5500MaxSocketNum (_WIZCHIP_SOCK_NUM_)
  54. #define netDevDHCP (1 << 2)
  55. #define netDevSetDevInfo (1 << 3)
  56. // event标志
  57. // 前8bit用于socket通道数据解析
  58. #define RyanW5500IRQBit (1 << RyanW5500MaxSocketNum)
  59. #define RyanW5500SnIMR (Sn_IR_RECV | Sn_IR_DISCON | Sn_IR_CON) // Sn_IMR
  60. #define RyanW5500IMR (IR_CONFLICT | IR_UNREACH | IR_PPPoE | IR_MP) // IMR (中断屏蔽寄存器)
  61. // 定义枚举类型
  62. // 定义结构体类型
  63. typedef struct
  64. {
  65. char *netdevName; // netDev名称
  66. uint32_t netDevFlag;
  67. rt_timer_t W5500TimerHandle;
  68. rt_event_t W5500EventHandle; // 事件标志组,用于中断通知和socket状态通知
  69. rt_mutex_t socketMutexHandle; // socket锁
  70. rt_mutex_t W5500SpiMutexHandle; // spi锁
  71. rt_thread_t w5500TaskHandle; // W5500线程
  72. } RyanW5500Entry_t;
  73. /* extern variables-----------------------------------------------------------*/
  74. extern wiz_NetInfo gWIZNETINFO;
  75. extern RyanW5500Entry_t RyanW5500Entry;
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. #endif