Hello, Dears First I say,I'm afraid I don't have good skills writing in English.
Please see my code. I defined my inline function code at seva.c file. This is the seva.c file
#include "seva.h" ... ... __inline void delay_ms(uint32_t ms) { register uint32_t i = ms; for ( ; i ; --i ) { delay_us(250); delay_us(250); delay_us(250); delay_us(250); } } __inline void delay_us(uint32_t us ) { register uint32_t i = us; for (; i; --i) { __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); } } ... ...
and I declare function prototypes at seva.h file. seva.h
... ... __inline delay_us(uint32_t us); __inline delay_ms(uint32_t ms);
when I try to call these delay functions in main.c file. main.c
#include "seva.h" ... ... void main(void) { P04 = 1; delay_us(100); P04 = 0; }
As you guess, It cause L6218E error. and I found http://www.keil.com/forum/13177/ this column. I defined every my inline code from seva.c to seva.h file. and It works well(means no compile error).
But there is one thing still confused.. See, Next code. seva.c
... ... __inline void delay_loop1( ) { register uint32_t i = 500; for (; i; --i) { __NOP(); } } ... ...
seva.h
... ... __inline void delay_loop1(void); ... ...
and I call this function at main.c file like above. but It doesn't have any comfiler errors. As I think, the difference delay_loop1 function and delay_ms function is only whether has parameter or not.
please tell me why delay_loop1 function compile without error, and why inline function has parameter occur errors.
Did you understand what I try to saying? I think I wrote too difficult.
Thanks for reading.
View all questions in Keil forum