My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. #ifdef __cplusplus
  24. extern "C" { /* C-declarations for C++ */
  25. #endif
  26. #include "../../inc/MarlinConfigPre.h"
  27. #include <math.h>
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #define UART_RX_BUFFER_SIZE 1024
  31. #define UART_FIFO_BUFFER_SIZE 1024
  32. #define ESP_WIFI 0x02
  33. #define AP_MODEL 0x01
  34. #define STA_MODEL 0x02
  35. #define WIFI_DECODE_TYPE 1
  36. #define IP_DHCP_FLAG 1
  37. #define WIFI_AP_NAME "TP-LINK_MKS"
  38. #define WIFI_KEY_CODE "makerbase"
  39. #define IP_ADDR "192.168.3.100"
  40. #define IP_MASK "255.255.255.0"
  41. #define IP_GATE "192.168.3.1"
  42. #define IP_DNS "192.168.3.1"
  43. #define AP_IP_DHCP_FLAG 1
  44. #define AP_IP_ADDR "192.168.3.100"
  45. #define AP_IP_MASK "255.255.255.0"
  46. #define AP_IP_GATE "192.168.3.1"
  47. #define AP_IP_DNS "192.168.3.1"
  48. #define IP_START_IP "192.168.3.1"
  49. #define IP_END_IP "192.168.3.255"
  50. #define UDISKBUFLEN 1024
  51. typedef enum{
  52. udisk_buf_empty = 0,
  53. udisk_buf_full,
  54. } UDISK_DATA_BUFFER_STATE;
  55. #define TRANS_RCV_FIFO_BLOCK_NUM 8
  56. typedef struct {
  57. unsigned char *bufferAddr[TRANS_RCV_FIFO_BLOCK_NUM];
  58. unsigned char *p;
  59. UDISK_DATA_BUFFER_STATE state[TRANS_RCV_FIFO_BLOCK_NUM];
  60. unsigned char read_cur;
  61. unsigned char write_cur;
  62. } WIFI_DMA_RCV_FIFO;
  63. typedef struct {
  64. uint8_t flag; // 0x0: no error; 0x01: error
  65. uint32_t start_tick; //error start time
  66. uint32_t now_tick;
  67. } WIFI_TRANS_ERROR;
  68. extern volatile WIFI_TRANS_ERROR wifiTransError;
  69. typedef struct {
  70. char ap_name[32]; //wifi-name
  71. char keyCode[64]; //wifi password
  72. int decodeType;
  73. int baud;
  74. int mode;
  75. } WIFI_PARA;
  76. typedef struct {
  77. char state;
  78. char hostUrl[96];
  79. int port;
  80. char id[21];
  81. } CLOUD_PARA;
  82. typedef struct {
  83. char dhcp_flag;
  84. char ip_addr[16];
  85. char mask[16];
  86. char gate[16];
  87. char dns[16];
  88. char dhcpd_flag;
  89. char dhcpd_ip[16];
  90. char dhcpd_mask[16];
  91. char dhcpd_gate[16];
  92. char dhcpd_dns[16];
  93. char start_ip_addr[16];
  94. char end_ip_addr[16];
  95. } IP_PARA;
  96. typedef enum {
  97. WIFI_NOT_CONFIG,
  98. WIFI_CONFIG_MODE,
  99. WIFI_CONFIG_DHCP,
  100. WIFI_CONFIG_AP,
  101. WIFI_CONFIG_IP_INF,
  102. WIFI_CONFIG_DNS,
  103. WIFI_CONFIG_TCP,
  104. WIFI_CONFIG_SERVER,
  105. WIFI_CONFIG_REMOTE_PORT,
  106. WIFI_CONFIG_BAUD,
  107. WIFI_CONFIG_COMMINT,
  108. WIFI_CONFIG_OK,
  109. WIFI_GET_IP_OK,
  110. WIFI_RECONN,
  111. WIFI_CONNECTED,
  112. WIFI_WAIT_TRANS_START,
  113. WIFI_TRANS_FILE,
  114. WIFI_CONFIG_DHCPD,
  115. WIFI_COFIG_DHCPD_IP,
  116. WIFI_COFIG_DHCPD_DNS,
  117. WIFI_EXCEPTION,
  118. } WIFI_STATE;
  119. typedef enum {
  120. TRANSFER_IDLE,
  121. TRANSFERING,
  122. TRANSFER_STORE,
  123. } TRANSFER_STATE;
  124. extern volatile TRANSFER_STATE esp_state;
  125. typedef struct {
  126. char buf[20][80];
  127. int rd_index;
  128. int wt_index;
  129. } QUEUE;
  130. typedef enum {
  131. WIFI_PARA_SET, // 0x0:net parameter
  132. WIFI_PRINT_INF, // 0x1:print message
  133. WIFI_TRANS_INF, // 0x2:Pass through information
  134. WIFI_EXCEP_INF, // 0x3:Exception information
  135. WIFI_CLOUD_CFG, // 0x4:cloud config
  136. WIFI_CLOUD_UNBIND, // 0x5:Unbind ID
  137. } WIFI_RET_TYPE;
  138. typedef struct {
  139. uint32_t uart_read_point;
  140. uint32_t uart_write_point;
  141. uint8_t uartTxBuffer[UART_FIFO_BUFFER_SIZE];
  142. } SZ_USART_FIFO;
  143. #define WIFI_GCODE_BUFFER_LEAST_SIZE 96
  144. #define WIFI_GCODE_BUFFER_SIZE (WIFI_GCODE_BUFFER_LEAST_SIZE * 3)
  145. typedef struct {
  146. uint8_t wait_tick;
  147. uint8_t Buffer[WIFI_GCODE_BUFFER_SIZE];
  148. uint32_t r;
  149. uint32_t w;
  150. } WIFI_GCODE_BUFFER;
  151. extern volatile WIFI_STATE wifi_link_state;
  152. extern WIFI_PARA wifiPara;
  153. extern IP_PARA ipPara;
  154. extern CLOUD_PARA cloud_para;
  155. extern WIFI_GCODE_BUFFER espGcodeFifo;
  156. extern uint32_t getWifiTick();
  157. extern uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick);
  158. extern void mks_esp_wifi_init();
  159. extern int cfg_cloud_flag;
  160. extern int send_to_wifi(char *buf, int len);
  161. extern void wifi_looping();
  162. extern int raw_send_to_wifi(char *buf, int len);
  163. extern int package_to_wifi(WIFI_RET_TYPE type,char *buf, int len);
  164. extern void get_wifi_list_command_send();
  165. extern void get_wifi_commands();
  166. extern int readWifiBuf(int8_t *buf, int32_t len);
  167. extern int storeRcvData(int32_t len);
  168. #ifdef __cplusplus
  169. } /* C-declarations for C++ */
  170. #endif