Skip to main content
Visitor II
May 23, 2022
Question

Why getting such error though code looks error free ? #error cpstm8 ..\..\src\main.c:350(0+6) misplaced local declaration #error cpstm8 ..\..\src\main.c:411 static function monitor_express_open_input_button undefined

  • May 23, 2022
  • 2 replies
  • 1585 views

static bool isEOBtnPressed = FALSE;

static bool isECBtnPressed = FALSE;

static void monitor_d_input_button(void); /*PB1 pin as input pin pull-up mode*/

static void monitor_o_input_button(void);/*PB2 pin as inputpin pu;;-up mode*/

static void monitor_c_input_button(void);/*PB3 pin as inputpin pu;;-up mode*/

static void monitor_e_o_input_button(void);/*PB4 pin as inputpin pu;;-up mode*/

static void monitor_e_c_input_button(void);/*PB5 pin as inputpin pu;;-up mode*/

static void monitor_d_input_button(void)

{

static bool isDefON = FALSE;

volatile bool btnState = !GPIO_ReadInputPin(GPIOB, (GPIO_Pin_TypeDef)GPIO_PIN_1);

if(btnState != isDefON)

{

if(!isDefON)

{

def_timer_tick = 0;

isDefON = FALSE;

}/*btnpressed and defrost is already on and time is less than 10min*/

else if(btnState && isDefON && (def_timer_tick < 600000))

{

isDefON = FALSE;

}

if(isDefON && (def_timer_tick >= 600000))

{

isDefON = FALSE;

}

}

static void monitor_e_o_input_button(void)

{

volatile bool btnState = FALSE;

btnState = !GPIO_ReadInputPin(GPIOB,(GPIO_Pin_TypeDef)GPIO_PIN_4);

if(btnState && (isEOBtnPressed ==FALSE))

{

isEOBtnPressed = FALSE;

}

else if (!btnState)

{

isEOBtnPressed = FALSE;

}

}

static void monitor_e_c_input_button(void)

{

volatile bool btnState = !GPIO_ReadInputPin(GPIOB, (GPIO_Pin_TypeDef)GPIO_PIN_5);

if(btnState && !isECBtnPressed)

{

isECBtnPressed = FALSE;

}

else if(!btnState)

{

isECBtnPressed = FALSE;

}

}

static void monitor_o_input_button(void)

{

volatile bool btnState = !GPIO_ReadInputPin(GPIOB, (GPIO_Pin_TypeDef)GPIO_PIN_2);

if(btnState)

{

/*send command and make close command 0*/

}

else

{

/* make command to 0 and send*/

}

}

static void monitor_c_input_button(void)

{

/*read defrost button input*/

volatile bool btnState = !GPIO_ReadInputPin(GPIOB, (GPIO_Pin_TypeDef)GPIO_PIN_3);

if(btnState)

{

/*send command and make close command 0*/

}

else

{

/*make close command to 0 and send*/

}

}

    This topic has been closed for replies.

    2 replies

    Graduate
    May 23, 2022

    Hi AAnsa,

    It would be nice to have the piece of code associated with the error, and the line numbers of the code.

    But from what we can see here, there is a missing '}' at the end of your function "static void monitor_d_input_button(void)".

    It is more obvious when the code is indented :

    static void monitor_d_input_button(void)
    {
     static bool isDefON = FALSE;
     
     volatile bool btnState = !GPIO_ReadInputPin(GPIOB, (GPIO_Pin_TypeDef)GPIO_PIN_1);
     
     if(btnState != isDefON)
     {
     if(!isDefON)
     {
     def_timer_tick = 0;
     isDefON = FALSE;
     }/*btnpressed and defrost is already on and time is less than 10min*/
     else if(btnState && isDefON && (def_timer_tick < 600000))
     {
     isDefON = FALSE;
     }
     
     if(isDefON && (def_timer_tick >= 600000))
     {
     isDefON = FALSE;
     }
     }
     
    static void monitor_e_o_input_button(void)
    {

    I hope it helps,

    Bastien

    Visitor II
    May 23, 2022

    Yes you are right, missing } was cause error.