Skip to main content
Rusty Jones
Associate
February 13, 2019
Question

Using HAL outside of main.c

  • February 13, 2019
  • 1 reply
  • 2161 views

Ok, another noob question....

I can use the following line of code in the main.c with no issues

#define Green_LED_OFF HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET); // Green off

But when I want to use it in another .c file such as foo.c I get the error "

'GPIOA' undeclared (first use in this function)"   , additionally is says 'GPIO_PIN_RESET' and 'GPIO_PIN_8' are undeclared as well. How do I instruct the foo.c file to understand the HAL instructions?

Thanks

Rusty

This topic has been closed for replies.

1 reply

S.Ma
Principal
February 13, 2019

#define replaces text in the source code.

GPIOA, GPIO_PIN_8, GPIO_PIN-RESET are also defined in different H files.

Grab all the #include at the top of main and paste them in the other source file.

The unelegant crude way.