cancel
Showing results for 
Search instead for 
Did you mean: 

Using HAL outside of main.c

Rusty Jones
Associate

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

1 REPLY 1
S.Ma
Principal

#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.