tool.h 1.9 KB

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