STM8s error

Getting this error when running a simple code of SPI communication between 2 boards.

CODE:

#include "stm8s.h"
#include "stm8s_gpio.h"
#include "stm8s_spi.h"
#include "stm8s_clk.h"
 
 
void GPIO_setup(void);
void clock_setup(void);
 
 
 
void GPIO_setup(void)
{ GPIO_DeInit(GPIOA);
  
GPIO_DeInit(GPIOC);
 
 
  GPIO_Init(GPIOA, GPIO_PIN_3, GPIO_MODE_OUT_PP_HIGH_SLOW);// led pin 
 
GPIO_Init(GPIOC, GPIO_PIN_4, GPIO_MODE_OUT_PP_LOW_FAST);//NSS
  GPIO_Init(GPIOC, 0x20, 0xE0);//sck pin 5
  GPIO_Init(GPIOC, GPIO_PIN_6, GPIO_MODE_OUT_PP_LOW_FAST);//mosi pin 6
  GPIO_Init(GPIOC, GPIO_PIN_7, GPIO_MODE_IN_PU_NO_IT);//miso pin 7
  
  
}
 
void clock_setup(void)
{
    CLK_DeInit();
                
    CLK_HSECmd(DISABLE);
    CLK_LSICmd(DISABLE);
    CLK_HSICmd(ENABLE);
    while(CLK_GetFlagStatus(CLK_FLAG_HSIRDY) == FALSE);
                
    CLK_ClockSwitchCmd(ENABLE);
    CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);//00
    CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV2);//0x80
                
    CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSI,DISABLE, CLK_CURRENTCLOCKSTATE_ENABLE);
    CLK_PeripheralClockConfig(CLK_PCKENR1_SPI,ENABLE);
  
  
  
}
 
 
void main()
{
clock_setup();
GPIO_setup();
 
SPI_DeInit();
SPI_Init(SPI_FIRSTBIT_MSB, 
               SPI_BAUDRATEPRESCALER_256, 
               SPI_MODE_MASTER, SPI_CLOCKPOLARITY_LOW, 
               SPI_CLOCKPHASE_1EDGE , 
SPI_DATADIRECTION_2LINES_FULLDUPLEX, 
               SPI_NSS_SOFT,0x00);
SPI_Cmd(ENABLE);
 
 
while(SPI_GetFlagStatus(SPI_FLAG_BSY));
    GPIO_WriteLow(GPIOC,GPIO_PIN_4);//NSS
                
    SPI_SendData(0x08);
    while(!SPI_GetFlagStatus(SPI_FLAG_TXE));
 
    GPIO_WriteHigh(GPIOC,GPIO_PIN_4);//NSS
 
}

 

 

ERROR:

#error clnk Debug\spi.lkf:54 Debug\stm8s_clk.o: symbol _SPI multiply defined (Debug\main.o)
#error clnk Debug\spi.lkf:55 Debug\stm8s_gpio.o: symbol _SPI multiply defined (Debug\main.o)
#error clnk Debug\spi.lkf:56 Debug\stm8s_spi.o: symbol _SPI multiply defined (Debug\main.o)
 The command: "clnk -m Debug\spi.map -l"C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Lib"  -o Debug\spi.sm8 Debug\spi.lkf " has failed, the returned value is: 1
exit code=1.

 

 

Could anyone cn help. Tried all the solution currently available on net.

 

Hi...

It is saying that _SPI is defined in multiple places. Check If all those header files are actually needed or not.

  Joined February 12, 2018      696
Monday at 02:11 PM