tao_z
2021-07-14 82e38738a4d532cc3d56cbf80c1a4093f23cdd6a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "SEGGER_RTT_Conf.h"
#include "SEGGER_RTT.h"
#include "SysCfg.h"
#include "gd32e23x.h"
#include "pwm.h"
#include "motor.h"
#include "bldc_ctrl.h"
static uint32_t RttDataOutPutFlag = 0;
static void RTT_KeyValue(uint32_t key);
extern void RTT_TaskInit(void)
{
    // /* ÅäÖÃͨµÀ0£¬ÉÏÐÐÅäÖã¨STM32->RTT ViewerÈí¼þ£© */
    // SEGGER_RTT_ConfigUpBuffer(0, "RTTUP", NULL, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP);
 
    // /* ÅäÖÃͨµÀ0£¬ÏÂÐÐÅäÖã¨RTT ViewerÈí¼þ->STM32£© */
    // SEGGER_RTT_ConfigDownBuffer(0, "RTTDOWN", NULL, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP);
    SEGGER_RTT_Init();
    RttDataOutPutFlag = 0;
}
 
extern void RTT_Task10ms(void *p)
{
    static uint32_t output_index = 0;
    uint32_t GetKey = 0;
    if (SEGGER_RTT_HasKey()) /* ÅжϽÓÊÕ»º³åÇøÖÐÊÇ·ñÓÐÊý¾Ý */
    {
        GetKey = SEGGER_RTT_GetKey(); /* ´Ó½ÓÊÜ»º³åÇøÖÐÈ¡³öÒ»¸ö×Ö·û */
        RTT_KeyValue(GetKey);
        // SEGGER_RTT_SetTerminal(1);
    }
    if (0 != RttDataOutPutFlag)
    {
        // SEGGER_RTT_printf(0, "%d\n", output_index++);
        output_index = (uint32_t)get_motor_speed();
        SEGGER_RTT_printf(0, "motor speed is:%d!\n", output_index);
    }
}
 
static void RTT_KeyValue(uint32_t key)
{
    switch (key)
    {
    case 0:
        /* code */
        break;
    case 'd':
    case 'D':
        RttDataOutPutFlag = !RttDataOutPutFlag;
        SEGGER_RTT_printf(0, "RTT Output data stop or start!\n");
        break;
    case 'v':
    case 'V':
        SEGGER_RTT_printf(0, "Software Version is :%s\n\r", &SOFTWARE_VERSION);
        SEGGER_RTT_printf(0, "Hardware Version is :%s\n\r", &HARDWARE_VERSION);
        break;
    case 'p':
    case 'P':
        SEGGER_RTT_printf(0, "Software PartNum is :%s\n\r", &SOFTWARE_PN);
        SEGGER_RTT_printf(0, "Hardware PartNum is :%s\n\r", &HARDWAR_PN);
        break;
    case 't':
    case 'T':
        SEGGER_RTT_printf(0, "Software Compile time is :%s %s\n\r", &COMPILE_DATE, &COMPILE_TIME);
        break;
    case 'o':
    case 'O':
        set_bldcm_speed(2000);
        set_bldcm_enable();
        break;
    case 's':
    case 'S':
        set_bldcm_disable();
        break;
    default:
        break;
    }
}