diff --git a/SD_CARD/BaS_gcc/Makefile b/SD_CARD/BaS_gcc/Makefile index f1a25d9..374bb6c 100644 --- a/SD_CARD/BaS_gcc/Makefile +++ b/SD_CARD/BaS_gcc/Makefile @@ -32,6 +32,7 @@ CFLAGS=-mcpu=5474\ -Wall\ -g\ -Wno-multichar\ + -Winline\ -Os\ -fomit-frame-pointer\ -fno-strict-aliasing\ diff --git a/SD_CARD/BaS_gcc/include/wait.h b/SD_CARD/BaS_gcc/include/wait.h index 8735bab..ba8c81b 100644 --- a/SD_CARD/BaS_gcc/include/wait.h +++ b/SD_CARD/BaS_gcc/include/wait.h @@ -29,8 +29,31 @@ #include -extern inline void wait(uint32_t us); -extern inline uint32_t waitfor(uint32_t us, uint32_t (*condition)(void)); +/* + * wait for the specified number of us on slice timer 0. Replaces the original routines that had + * the number of useconds to wait for hardcoded in their name. + */ +extern __inline__ void wait(uint32_t us) +{ + uint32_t target = MCF_SLT_SCNT(0) - (us * 132); + while (MCF_SLT_SCNT(0) > target); +} +/* + * the same as above, with a checker function which gets called while + * busy waiting and allows for an early return if it returns true + */ +extern __inline__ uint32_t waitfor(uint32_t us, uint32_t (*condition)(void)) +{ + uint32_t target = MCF_SLT_SCNT(0) - (us * 132); + uint32_t res; + + do + { + if ((res = (*condition)())) + return res; + } while (MCF_SLT_SCNT(0) > target); + return 0; +} #endif /* _WAIT_H_ */ diff --git a/SD_CARD/BaS_gcc/sources/wait.c b/SD_CARD/BaS_gcc/sources/wait.c index 11b6895..dad5970 100644 --- a/SD_CARD/BaS_gcc/sources/wait.c +++ b/SD_CARD/BaS_gcc/sources/wait.c @@ -30,30 +30,4 @@ #include -/* - * wait for the specified number of us on slice timer 0. Replaces the original routines that had - * the number of useconds to wait for hardcoded in their name. - */ -inline void wait(uint32_t us) -{ - uint32_t target = MCF_SLT_SCNT(0) - (us * 132); - while (MCF_SLT_SCNT(0) > target); -} - -/* - * the same as above, with a checker function which gets called while - * busy waiting and allows for an early return if it returns true - */ -inline uint32_t waitfor(uint32_t us, uint32_t (*condition)(void)) -{ - uint32_t target = MCF_SLT_SCNT(0) - (us * 132); - uint32_t res; - - do - { - if ((res = (*condition)())) - return res; - } while (MCF_SLT_SCNT(0) > target); - return 0; -}