tool.h 1.8 KB

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