This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

急!急! CCS中添加按键程序



目前,我添加的按键程序如下:

void key_control(void)
{
    key_s1  = HAL_readGpio(halHandle, (GPIO_Number_e)HAL_keyGpio_1);
    key_s2  = HAL_readGpio(halHandle, (GPIO_Number_e)HAL_keyGpio_2);
    key_s3  = HAL_readGpio(halHandle, (GPIO_Number_e)HAL_keyGpio_3);
    if(HAL_readGpio(halHandle, (GPIO_Number_e)HAL_keyGpio_x) ==LOW)
    {
        usDelay(50);
        if(HAL_readGpio(halHandle, (GPIO_Number_e)HAL_keyGpio_x)==LOW)
        {
            while(HAL_readGpio(halHandle, (GPIO_Number_e)HAL_keyGpio_x)==LOW);
            return LOW;
        }
        else
        return HIGH;
    }
    else
        return HIGH;
    while(1)
    {
        if(key_s1==LOW)
            {
             gMotorVars.SpeedRef_krpm = 0.8;
            }
        if(key_s2==LOW)
            {
                gMotorVars.SpeedRef_krpm = -0.8;
            }
        while(1)
        {
            if(key_s3==LOW)
               {
                  gMotorVars.SpeedRef_krpm = 0.8;
                  usDelay(500);
                  gMotorVars.SpeedRef_krpm = -0.8;
                  usDelay(500);
               }
        }
    }
}
遇到的问题,如下:
1、无法用按键进行正反的切换
2、在CCS的监视窗口中,基准速度为1800ramp,这部分的程序在哪里?在main.h中,已经设为0,但在监视窗口中还是1800ramp,为什么?