You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
4.7 KiB

3 years ago
  1. /**
  2. ****************************************************************************************************
  3. * @file usmart.h
  4. * @author (ALIENTEK)
  5. * @version V3.5
  6. * @date 2020-12-20
  7. * @brief USMART
  8. *
  9. * USMART是由ALIENTEK开发的一个灵巧的串口调试互交组件, ,
  10. * ,.,((10/16,)
  11. * ),10, .
  12. * V2.1hex和dec两个指令..
  13. * ,:
  14. * "hex 100" HEX 0X64.
  15. * "dec 0X64" DEC 100.
  16. * @note
  17. * USMART资源占用情况@MDK 3.80A@2.0
  18. * FLASH:4K~K字节(USMART_USE_HELP和USMART_USE_WRFUNS设置)
  19. * SRAM:72()
  20. * SRAM计算公式: SRAM=PARM_LEN+72-4 PARM_LEN必须大于等于4.
  21. * 100.
  22. * @license Copyright (c) 2020-2032, 广
  23. ****************************************************************************************************
  24. * @attention
  25. *
  26. * 线:www.yuanzige.com
  27. * :www.openedv.com
  28. * :www.alientek.com
  29. * :openedv.taobao.com
  30. *
  31. *
  32. *
  33. * V3.4USMART文件夹下的:readme.txt
  34. *
  35. * V3.4 20200324
  36. * 1, usmart_port.c和usmart_port.h,USMART的移植,便
  37. * 2, : uint8_t, uint16_t, uint32_t
  38. * 3, usmart_reset_runtime为usmart_timx_reset_time
  39. * 4, usmart_get_runtime为usmart_timx_get_time
  40. * 5, usmart_scan函数实现方式,usmart_get_input_string获取数据流
  41. * 6, printf函数为USMART_PRINTF宏定义
  42. * 7, ,,便
  43. *
  44. * V3.5 20201220
  45. * 1AC6编译器
  46. ****************************************************************************************************
  47. */
  48. #ifndef __USMART_H
  49. #define __USMART_H
  50. #include "./USMART/usmart_port.h"
  51. #define USMART_OK 0 /* 无错误 */
  52. #define USMART_FUNCERR 1 /* 函数错误 */
  53. #define USMART_PARMERR 2 /* 参数错误 */
  54. #define USMART_PARMOVER 3 /* 参数溢出 */
  55. #define USMART_NOFUNCFIND 4 /* 未找到匹配函数 */
  56. #define SP_TYPE_DEC 0 /* 10进制参数显示 */
  57. #define SP_TYPE_HEX 1 /* 16进制参数显示 */
  58. /* 函数名列表 */
  59. struct _m_usmart_nametab
  60. {
  61. void *func; /* 函数指针 */
  62. const char *name; /* 函数名(查找串) */
  63. };
  64. /* usmart控制管理器 */
  65. struct _m_usmart_dev
  66. {
  67. struct _m_usmart_nametab *funs; /* 函数名指针 */
  68. void (*init)(uint16_t tclk); /* 初始化 */
  69. uint8_t (*cmd_rec)(char *str); /* 识别函数名及参数 */
  70. void (*exe)(void); /* 执行 */
  71. void (*scan)(void); /* 扫描 */
  72. uint8_t fnum; /* 函数数量 */
  73. uint8_t pnum; /* 参数数量 */
  74. uint8_t id; /* 函数id */
  75. uint8_t sptype; /* 参数显示类型(非字符串参数):0,10进制;1,16进制; */
  76. uint16_t parmtype; /* 参数的类型 */
  77. uint8_t plentbl[MAX_PARM]; /* 每个参数的长度暂存表 */
  78. uint8_t parm[PARM_LEN]; /* 函数的参数 */
  79. uint8_t runtimeflag; /* 0,不统计函数执行时间;1,统计函数执行时间,注意:此功能必须在USMART_ENTIMX_SCAN使能的时候,才有用 */
  80. uint32_t runtime; /* 运行时间,单位:0.1ms,最大延时时间为定时器CNT值的2倍*0.1ms */
  81. };
  82. extern struct _m_usmart_nametab usmart_nametab[]; /* 在usmart_config.c里面定义 */
  83. extern struct _m_usmart_dev usmart_dev; /* 在usmart_config.c里面定义 */
  84. void usmart_init(uint16_t tclk); /* 初始化 */
  85. uint8_t usmart_cmd_rec(char*str); /* 识别 */
  86. void usmart_exe(void); /* 执行 */
  87. void usmart_scan(void); /* 扫描 */
  88. uint32_t read_addr(uint32_t addr); /* 读取指定地址的值 */
  89. void write_addr(uint32_t addr,uint32_t val);/* 在指定地址写入指定的值 */
  90. #endif