tool.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef __TOOL_H__
  2. #define __TOOL_H__
  3. #include "arm_math.h"
  4. #include <stdbool.h>
  5. #include <stdint.h>
  6. #include <string.h>
  7. #include <setjmp.h>
  8. #include "sdk_common.h"
  9. #include "SEGGER_RTT.h"
  10. #include "usr_config.h"
  11. /*
  12. (5)
  13.    #pragma pack(push, 1)
  14.    struct {
  15.       signed int Sine1;
  16.     signed int Sine2;
  17.      signed int Sine3;
  18.      } acValBuffer;
  19.    #pragma pack(pop)
  20.     上面是你要发送的结构体,自己定义。
  21.   (6)在你要发送的地方赋值并发送,例如中断:
  22.       acValBuffer.Sine1 = Test_Counter1;
  23.   acValBuffer.Sine2 = Test_Counter2;
  24.   acValBuffer.Sine2 = Test_Counter3;
  25.     SEGGER_RTT_Write(JS_RTT_Channel, &acValBuffer, sizeof(acValBuffer));
  26.   (7)下面是重点!!!官方没有提到的。例如我想发四个数,两个int型,两个short型。
  27.       #pragma pack(push, 1)
  28.       struct {
  29.           signed int Sine1;
  30.         signed int Sine2;
  31.          short Sine3;
  32.          short Sine4;
  33.       } acValBuffer;
  34.        #pragma pack(pop)
  35.   那么对应的初始化要改为"JScope_I4I4I4"这个参数就要改成"JScope_I4I4I2I2“
  36. */
  37. #pragma pack(push, 1)
  38. typedef struct {
  39. signed int Sine1;
  40. signed int Sine2;
  41. signed int Sine3;
  42. signed int Sine4;
  43. signed int Sine5;
  44. signed int Sine6;
  45. }acValBuffer_t;
  46. #pragma pack(pop)
  47. #define CHECK_TIMECONSUMING_START uint32_t cnt1 = 0, cnt2 = 0; \
  48. static char string[100]; \
  49. cnt1 = NRF_RTC0->COUNTER
  50. #define CHECK_TIMECONSUMING_END cnt2 = NRF_RTC0->COUNTER; \
  51. sprintf(string,"=====>time consuming:%02f us\r\n",(cnt2-cnt1)/32.768 * 1000); \
  52. SEGGER_RTT_printf(0,"%s",string)
  53. extern acValBuffer_t acValBuffer;
  54. void JS_RTT_Init(void);
  55. void JS_RTT_Print(signed int Sine1,signed int Sine2,signed int Sine3);
  56. void JS_RTT_Print_06(signed int Sine1,signed int Sine2,signed int Sine3,signed int Sine4,signed int Sine5,signed int Sine6);
  57. float32_t CoefficientVariation(double *p_array, uint32_t len);
  58. void Tool_Init(void);
  59. #endif