esp_ssc.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef __ESP_SSC_H__
  14. #define __ESP_SSC_H__
  15. #include <stdint.h>
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. #define CMD_T_ASYNC 0x01
  20. #define CMD_T_SYNC 0x02
  21. typedef struct cmd_s {
  22. char *cmd_str;
  23. uint8_t flag;
  24. uint8_t id;
  25. void (* cmd_func)(void);
  26. void (* cmd_callback)(void *arg);
  27. } ssc_cmd_t;
  28. #define MAX_LINE_N 127
  29. typedef enum {
  30. SSC_BR_9600 = 9600,
  31. SSC_BR_19200 = 19200,
  32. SSC_BR_38400 = 38400,
  33. SSC_BR_57600 = 57600,
  34. SSC_BR_74880 = 74880,
  35. SSC_BR_115200 = 115200,
  36. SSC_BR_230400 = 230400,
  37. SSC_BR_460800 = 460800,
  38. SSC_BR_921600 = 921600
  39. } SscBaudRate;
  40. /** \defgroup SSC_APIs SSC APIs
  41. * @brief SSC APIs
  42. *
  43. * SSC means simple serial command.
  44. * SSC APIs allows users to define their own command, users can refer to spiffs_test/test_main.c.
  45. *
  46. */
  47. /** @addtogroup SSC_APIs
  48. * @{
  49. */
  50. /**
  51. * @brief Initial the ssc function.
  52. *
  53. * @attention param is no use, just compatible with ESP8266, default bandrate is 115200
  54. *
  55. * @param SscBaudRate bandrate : baud rate
  56. *
  57. * @return null
  58. */
  59. void ssc_attach(SscBaudRate bandrate);
  60. /**
  61. * @brief Get the length of the simple serial command.
  62. *
  63. * @param null
  64. *
  65. * @return length of the command.
  66. */
  67. int ssc_param_len(void);
  68. /**
  69. * @brief Get the simple serial command string.
  70. *
  71. * @param null
  72. *
  73. * @return the command.
  74. */
  75. char *ssc_param_str(void);
  76. /**
  77. * @brief Parse the simple serial command (ssc).
  78. *
  79. * @param char *pLine : [input] the ssc string
  80. * @param char *argv[] : [output] parameters of the ssc
  81. *
  82. * @return the number of parameters.
  83. */
  84. int ssc_parse_param(char *pLine, char *argv[]);
  85. /**
  86. * @brief Register the user-defined simple serial command (ssc) set.
  87. *
  88. * @param ssc_cmd_t *cmdset : the ssc set
  89. * @param uint8 cmdnum : number of commands
  90. * @param void (* help)(void) : callback of user-guide
  91. *
  92. * @return null
  93. */
  94. void ssc_register(ssc_cmd_t *cmdset, uint8_t cmdnum, void (* help)(void));
  95. /**
  96. * @}
  97. */
  98. #ifdef __cplusplus
  99. }
  100. #endif
  101. #endif /* __ESP_SSC_H__ */