shell.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef __SHELL_H__
  2. #define __SHELL_H__
  3. #include <rtthread.h>
  4. #define FINSH_USING_HISTORY
  5. #ifndef FINSH_THREAD_PRIORITY
  6. #define FINSH_THREAD_PRIORITY 20
  7. #endif
  8. #ifndef FINSH_THREAD_STACK_SIZE
  9. #define FINSH_THREAD_STACK_SIZE 2048
  10. #endif
  11. #define FINSH_CMD_SIZE 80
  12. #define FINSH_OPTION_ECHO 0x01
  13. #define FINSH_PROMPT "finsh>>"
  14. #ifdef FINSH_USING_HISTORY
  15. enum input_stat
  16. {
  17. WAIT_NORMAL,
  18. WAIT_SPEC_KEY,
  19. WAIT_FUNC_KEY,
  20. };
  21. #ifndef FINSH_HISTORY_LINES
  22. #define FINSH_HISTORY_LINES 5
  23. #endif
  24. #endif
  25. struct finsh_shell
  26. {
  27. struct rt_semaphore rx_sem;
  28. enum input_stat stat;
  29. rt_uint8_t echo_mode:1;
  30. rt_uint8_t use_history:1;
  31. #ifdef FINSH_USING_HISTORY
  32. rt_uint8_t current_history;
  33. rt_uint16_t history_count;
  34. char cmd_history[FINSH_HISTORY_LINES][FINSH_CMD_SIZE];
  35. #endif
  36. struct finsh_parser parser;
  37. char line[FINSH_CMD_SIZE];
  38. rt_uint8_t line_position;
  39. rt_device_t device;
  40. };
  41. void finsh_set_echo(rt_uint32_t enable);
  42. rt_uint32_t finsh_get_echo(void);
  43. void finsh_set_device(const char* device_name);
  44. #endif