Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

arm - Stm Cube IDE ERROR : Comparison error for function

I am experimenting with the STM32f407vg board through the STMBUBEIDE program.

First of all, I prepare my own library file and make the settings in the interrupt section.

What if the reason I can't get rid of this error?

First of all, I have a griodriver.c file for my src file. And my definition in it:

  uint8_t portcode = GPIO_BASE_ADDR_TO_CODE (pGPIOHandle-> pGPIOx);

Then I write my function so that this comes back.

 uint16_t GPIO_BASE_ADDR_TO_CODE(*x)
    {
        if(x==GPIOA)        { return 0; }
        else if(x==GPIOB)   { return 1; }
        else if(x==GPIOC)   { return 2; }
        else if(x==GPIOD)   { return 3; }
        else if(x==GPIOE)   { return 4; }
        else if(x==GPIOF)   { return 5; }
        else if(x==GPIOG)   { return 6; }

    }

If I remove the pointer inside the loop, I get a comparison between pointer and interger error.

Whenever I compile I get an error.

My error says this for the function: This is warnings error.

     Description    Resource    Path    Location    Type
     implicit declaration of function 'GPIO_BASE_ADDR_TO_CODE'; did you mean 'GPIOJ_BASEADDR'? 
      [- Wimplicit-function-declaration]    stm32f407xx_gpio_driver.c   /stm32f407xx/drivers/Src     
      line 253  C/C++ Problem

But there are 2 other errors I get as ERROR. enter image description here

enter image description here

First:

          1. ERROR:  Description    Resource    Path    Location    Type
          make: *** [drivers/Src/subdir.mk:18: drivers/Src/stm32f407xx_gpio_driver.o]            
         Error 1    stm32f407xx         C/C++ Problem

SEcond:

               Description  Resource    Path    Location    Type
              expected declaration specifiers or '...' before '*' token stm32f407xx_gpio_driver.c    
              /stm32f407xx/drivers/Src  line 168    C/C++ Problem

Error Screen:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

When I change this part like a below,

 uint16_t GPIO_BASE_ADDR_TO_CODE(uint8_t x)
    {
        if( x==GPIOA)   { return 0; }
        else if(x==GPIOB)   { return 1; }
        else if(x==GPIOC)   { return 2; }
        else if(x==GPIOD)   { return 3; }
        else if(x==GPIOE)   { return 4; }
        else if(x==GPIOF)   { return 5; }
        else if(x==GPIOG)   { return 6; }

        return 0;

    }

My errors change like that : enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...