nr_micro_shell_port.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * *****************************************************************************
  3. * MIT License
  4. *
  5. * Copyright (C) 2025 Ji Youzhou. or its affiliates. All Rights Reserved.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8. * of this software and associated documentation files (the "Software"), to deal
  9. * in the Software without restriction, including without limitation the rights
  10. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. * copies of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in all
  15. * copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  23. * SOFTWARE.
  24. ***********************************************************************************/
  25. #ifndef __NR_MICRO_SHELL_PORT_H__
  26. #define __NR_MICRO_SHELL_PORT_H__
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #include <stdio.h>
  31. #include <stdint.h>
  32. /* Required configuration macros */
  33. #define shell_putc(x) putchar((x))
  34. /* Optional configuration macros */
  35. #define NR_SHELL_MAX_LINE_SZ 80 /* Maximum command line length */
  36. #define NR_SHELL_PROMPT "nr@dev" /* Command prompt string */
  37. #define NR_SHELL_MAX_PARAM_NUM 16 /* Maximum number of parameters per command */
  38. #define NR_SHELL_CMD_WR /* Enable write command support */
  39. #define NR_SHELL_CMD_RD /* Enable read command support */
  40. #define NR_SHELL_CMD_HEX2DEC /* Enable hexadecimal to decimal conversion */
  41. #define NR_SHELL_CMD_TIME /* Enable time cmd */
  42. #define NR_SHELL_SHOW_LOGO /* Enable shell logo display */
  43. #define NR_SHELL_AUTO_COMPLETE_SUPPORT /* Enable command auto-completion feature */
  44. #define NR_SHELL_HISTORY_CMD_SUPPORT /* Enable command history feature */
  45. #define NR_SHELL_HISTORY_CMD_NUM 5 /* Number of commands to keep in history */
  46. #define NR_SHELL_HISTORY_CMD_SZ 64 /* Maximum size of each history command */
  47. uint64_t get_sys_timestamp_ns(void);
  48. #define shell_get_ts_ns() get_sys_timestamp_ns() /* Macro to get current system timestamp */
  49. #define NR_SHELL_DEBUG /* Enable debug logging functionality for the shell */
  50. #ifdef NR_SHELL_DEBUG
  51. extern FILE *dbug_log;
  52. extern FILE *key_rec_log;
  53. #define DLOG(fmt, ...) fprintf(dbug_log, "[%ldns] %s %d: " fmt "\n", get_sys_timestamp_ns(), __func__, __LINE__, ##__VA_ARGS__)
  54. #define KEY_RECORD(c) fprintf(key_rec_log, "%x ", c)
  55. void nr_shell_debug_log_init(void);
  56. #endif
  57. #ifdef __cplusplus
  58. }
  59. #endif
  60. #endif /* __NR_MICRO_SHELL_PORT_H__ */
  61. /******************* (C) COPYRIGHT 2025 Ji Youzhou *********************************/