tao_z
2021-07-10 9051da0184cf839037f1370c729b27bf065b9c95
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
#include "SEGGER_RTT_Conf.h"
#include "SEGGER_RTT.h"
#include "SysCfg.h"
#include "gd32e23x.h"
#include "pwm.h"
#include "motor.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++);
    }
}
 
static void RTT_KeyValue(uint32_t key)
{
    switch (key)
    {
    case 0:
        /* code */
        break;
    case 'd':
    case 'D':
        RttDataOutPutFlag = !RttDataOutPutFlag;
        SEGGER_RTT_printf(0, "Index:\tTemp\tBase\tCP\tleakCurr\tCurr\tAC_Vot\tState\tError\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':
        timer_channel_output_mode_config(TIMER0, MOTOR_OUT_CH_W, TIMER_OC_MODE_PWM0);
        timer_channel_output_state_config(TIMER0, MOTOR_OUT_CH_W, TIMER_CCX_ENABLE);
        break;
    case 's':
        timer_channel_output_state_config(TIMER0, MOTOR_OUT_CH_W, TIMER_CCX_DISABLE);
        break;
    default:
        break;`
    }
}