declared wait()-routines as inline void volatile since gcc decided to optimize out them sometimes. Do we need __attribute__(always_inline) ?

This commit is contained in:
Markus Fröschle
2012-11-18 10:10:38 +00:00
parent 3101237277
commit 0b5e4aca81
3 changed files with 15 additions and 7 deletions

View File

@@ -19,8 +19,8 @@ extern void sd_card_idle();
extern int sd_card_init(); extern int sd_card_init();
/* wait...() routines moved to sysinit.c */ /* wait...() routines moved to sysinit.c */
extern inline void wait(uint32_t us); extern inline void wait(volatile uint32_t us);
extern inline bool waitfor(uint32_t us,int (*condition)(void)); extern inline volatile bool waitfor(volatile uint32_t us,int (*condition)(void));
/* Symbols from the linker script */ /* Symbols from the linker script */
extern uint8_t _STRAM_END[]; extern uint8_t _STRAM_END[];

View File

@@ -6,7 +6,9 @@
#include <MCF5475.h> #include <MCF5475.h>
#include "bas_printf.h" #include "bas_printf.h"
extern void wait(uint32_t value); extern void wait(volatile uint32_t value);
#ifdef _NOT_USED_ /* disabled assembler routines */
void sd_card_idle(void) void sd_card_idle(void)
{ {
@@ -37,6 +39,7 @@ int sd_card_init(void)
return ret; return ret;
} }
#endif /* _NOT_USED_ */
uint32_t sd_com(uint32_t command) uint32_t sd_com(uint32_t command)
{ {
@@ -51,7 +54,7 @@ uint32_t sd_com(uint32_t command)
return ret; return ret;
} }
void sd_init(void) void sd_card_init(void)
{ {
uint32_t ret; uint32_t ret;
int i; int i;
@@ -89,7 +92,6 @@ void sd_init(void)
wait(10000); wait(10000);
MCF_DSPI_DMCR = 0x800d3c00; MCF_DSPI_DMCR = 0x800d3c00;
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++)
{ {
ret = sd_com(0x082000ff); ret = sd_com(0x082000ff);
@@ -107,8 +109,14 @@ void sd_init(void)
ret = sd_com(0x082000ff); ret = sd_com(0x082000ff);
} }
MCF_DSPI_DMCR = 0x800d3c00;
wait(10000); wait(10000);
xprintf("finished\r\n"); xprintf("finished\r\n");
} }
void sd_card_idle(void)
{
}

View File

@@ -26,7 +26,7 @@ extern volatile long _VRAM; /* start address of video ram from linker script */
* wait for the specified number of us on slice timer 0. Replaces the original routines that had * 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. * the number of useconds to wait for hardcoded in their name.
*/ */
inline void wait(uint32_t us) inline volatile void wait(uint32_t us)
{ {
uint32_t target = MCF_SLT_SCNT(0) - (us * 132); uint32_t target = MCF_SLT_SCNT(0) - (us * 132);
@@ -37,7 +37,7 @@ inline void wait(uint32_t us)
* the same as above, with a checker function which gets called while * the same as above, with a checker function which gets called while
* busy waiting and allows for an early return if it returns true * busy waiting and allows for an early return if it returns true
*/ */
inline bool waitfor(uint32_t us, int (*condition)(void)) inline volatile bool waitfor(volatile uint32_t us, int (*condition)(void))
{ {
uint32_t target = MCF_SLT_SCNT(0) - (us * 132); uint32_t target = MCF_SLT_SCNT(0) - (us * 132);