I am initializing an extern variable in a herder file and then use it in (.c) file but when i compile my code i get an warning that says: no previous extern declaration for non-static variable. Here is my code:
enter code here
/*led.h
extern int iStep = +1;
static void SetLEDPort2Output(void);
void LEDPortIni(void);
void LEDSet(unsigned char Value);
void PB10IntIni(void);
void TIM3IntIni(void);
void EXTI15_10_IRQHandler(void);
void TIM3_IRQHandler(void); */
/*led.c
#include <stm32f10x.h>
#include "led.h"
int iStep;
#define CHECKBIT(Var, Nr) (Var & (1<<Nr))
#define CLR_PORTBIT(PORT, BIT) {PORT->BRR |= (1<<BIT);}
#define SET_PORTBIT(PORT, BIT) {PORT->BSRR |= (1<<BIT);}
#define COPY_PORTBIT(Var, Nr, PORT, BIT) {if(CHECKBIT(Var, Nr)) SET_PORTBIT(PORT, BIT)\
else CLR_PORTBIT(PORT, BIT)}
typedef struct
{
GPIO_TypeDef* aGPIO[7];
unsigned int aPIN[7];
} PORT;
static PORT LEDPort =
{{GPIOA, GPIOA, GPIOA, GPIOA, GPIOA, GPIOA, GPIOA},
{ 0, 1, 2, 3, 4, 5, 6}};
void EXTI15_10_IRQHandler(void)
{
if(GPIOB->IDR & (0x1<<10))
iStep = +1;
else
iStep = -1;
EXTI->PR |= (0x1<<10);
}
void TIM3_IRQHandler(void)
{
const unsigned char out[] = {0x1, 0x3, 0x6, 0xC, 0x18, 0x30, 0x60, 0x40};
static int i = 0;
i = (i + iStep) & 7;
LEDSet(out[i]);
} */
I am not using that variable in the main function.