cancel
Showing results for 
Search instead for 
Did you mean: 

Hello. I want to use GPIO with STM8S003,

MAnsa.1
Associate II

after add

stm8s_gpio.c and stm8s_gpio.h and build project, the compiler(Cosmic) tell error

#error cpstm8 main.c:25(15+3) bad struct/union operand

#error cpstm8 main.c:34(14+3) bad struct/union op

3 REPLIES 3
MAnsa.1
Associate II

#error cpstm8 main.c:25(8+5) GPIOA undefined

it's look like somethings not define to project.

here is remaining part

Help please.

Code:

25:  sw = GPIOA->IDR & 0x06; 

34:  if ((GPIOA->IDR & 0x02) == 0) 

 sw = GPIOA->IDR & 0x06; 

WRost.1
Associate II

Have you included <stm8s.h> ?

when i include stm8s.h

it show error like this.....

#error cpstm8 ..\..\..\data manual\stm8s103f3_spl-master\stm8s103f3_spl-master\stm8s103f3_spl-master\inc\stm8s.h:211(26+6) redeclared typedef int8_t

#error cpstm8 ..\..\..\data manual\stm8s103f3_spl-master\stm8s103f3_spl-master\stm8s103f3_spl-master\inc\stm8s.h:212(26+7) redeclared typedef int16_t

#error cpstm8 ..\..\..\data manual\stm8s103f3_spl-master\stm8s103f3_spl-master\stm8s103f3_spl-master\inc\stm8s.h:213(26+7) redeclared typedef int32_t

#error cpstm8 ..\..\..\data manual\stm8s103f3_spl-master\stm8s103f3_spl-master\stm8s103f3_spl-master\inc\stm8s.h:216(26+7) redeclared typedef uint8_t

#error cpstm8 ..\..\..\data manual\stm8s103f3_spl-master\stm8s103f3_spl-master\stm8s103f3_spl-master\inc\stm8s.h:217(26+8) redeclared typedef uint16_t

#error cpstm8 ..\..\..\data manual\stm8s103f3_spl-master\stm8s103f3_spl-master\stm8s103f3_spl-master\inc\stm8s.h:218(26+8) redeclared typedef uint32_t

#error cpstm8 main.c:9(13+12) missing )

#error cpstm8 main.c:9(23) missing )

#error cpstm8 main.c:27(2+10) GPIO_Pin_1 undefined

9: unsigned int PBSW,PBSW1;

27: PBSW = GPIOA->IDR & 0x02;

/*!< Signed integer types */

211; typedef  signed char   int8_t;

212: typedef  signed short  int16_t;

213: typedef  signed long   int32_t;

/*!< Unsigned integer types */

216: typedef unsigned char   uint8_t;

217: typedef unsigned short  uint16_t;

218: typedef unsigned long   uint32_t;

line 211-218 are available in stm8s.h file