I haven't found any solution on internet and this is why I am asking here.
My Led_TypeDef variable is undefined in MyDriverConfig.h. First, I have definded in MyApplications.h:
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MYAPPLICATIONS_H
#define __MYAPPLICATIONS_H
#ifdef __cplusplus
extern "C" {
#endif
#include "main.h"
typedef enum
{
LED1 = 0,
LED_GREEN = LED1
} Led_TypeDef;
#define LEDn 1
#define LED1_PIN GPIO_PIN_0
#define LED1_GPIO_PORT GPIOB
#define LED1_GPIO_CLK_ENABLE() __GPIOA_CLK_ENABLE()
#define LED1_GPIO_CLK_DISABLE() __GPIOA_CLK_DISABLE()
#define LEDx_GPIO_CLK_ENABLE(__INDEX__) (((__INDEX__) == 0) ? LED1_GPIO_CLK_ENABLE() : 0)
#define LEDx_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? LED1_GPIO_CLK_DISABLE() : 0)
void LED_On(Led_TypeDef Led);
void LED_Off(Led_TypeDef Led);
void LED_Toggle(Led_TypeDef Led);
void MCU_Configuration(void);
#endif /* __MYAPPLICATIONS_H */
Then, in MyConfigDriver.h:
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MYCONFIG_H
#define __MYCONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
#include "main.h"
void SystemClock_Config(void);
void MX_LED_Init(Led_TypeDef Led);
void MX_CAN_Init(void);
void MX_I2C1_Init(void);
void MX_SPI1_Init(void);
void MX_USART2_UART_Init(void);
#endif /* __MYCONFIG_H */
I thought it was well definded because my main.h included all:
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H
#include "stm32f0xx_hal.h"
#include "MyDriverConfig.h"
#include "MyApplications.h"
#endif /* __MAIN_H */
These are errors I get:
MyApplications.c
Error[Pe020]: identifier "Led_TypeDef" is undefined C:\Inc\MyDriverConfig.h 24
Error while running C/C++ Compiler
main.c
Error[Pe020]: identifier "Led_TypeDef" is undefined C:\Inc\MyDriverConfig.h 24
Error while running C/C++ Compiler
Total number of errors: 2 Total number of warnings: 0
When I include MyApplication.h in MyDriverConfig.h I get this:
Updating build tree...
MyApplications.c
Error[Pe020]: identifier "Led_TypeDef" is undefined C:\Users\Inc\MyDriverConfig.h 25
Error while running C/C++ Compiler
main.c
MyDriverConfig.c
Total number of errors: 1
Total number of warnings: 0
I don't understand why I have two errors when I am not including MyApplications while I use Led_TypDef once in MyDriverConfig.h.
I also have tried to add extern Led_TypeDef Led; in MyApplication.h without any results.
Ok, thank you. For people who could be interested this way is working well:
Now in MyDriverConfig.h
Then, in MyDriverConfig.c
Then, In MyApplications.h
And finaly in MyApplications.c
Code is not perfect because there are still some circular includes : stm32f0xx_hal.h but it is compiling well.