diff --git a/SD_CARD/BaS_gcc/include/sysinit.h b/SD_CARD/BaS_gcc/include/sysinit.h index 9439c0f..a69f05a 100644 --- a/SD_CARD/BaS_gcc/include/sysinit.h +++ b/SD_CARD/BaS_gcc/include/sysinit.h @@ -28,8 +28,7 @@ #ifndef __SYSINIT_H__ #define __SYSINIT_H__ #include - -extern inline bool waitfor(uint32_t us, int (*condition)(void)); +#include /* adresses where FPGA data lives in flash */ #define FPGA_FLASH_DATA ((uint8_t *) 0xe0700000L) diff --git a/SD_CARD/BaS_gcc/include/wait.h b/SD_CARD/BaS_gcc/include/wait.h index 44141f6..8735bab 100644 --- a/SD_CARD/BaS_gcc/include/wait.h +++ b/SD_CARD/BaS_gcc/include/wait.h @@ -30,7 +30,7 @@ #include extern inline void wait(uint32_t us); -extern inline bool waitfor(uint32_t us, int (*condition)(void)); +extern inline uint32_t waitfor(uint32_t us, uint32_t (*condition)(void)); #endif /* _WAIT_H_ */ diff --git a/SD_CARD/BaS_gcc/sources/BaS.c b/SD_CARD/BaS_gcc/sources/BaS.c index 8901384..821bb6d 100644 --- a/SD_CARD/BaS_gcc/sources/BaS.c +++ b/SD_CARD/BaS_gcc/sources/BaS.c @@ -52,7 +52,7 @@ extern uint8_t _EMUTOS_SIZE[]; /* * check if it is possible to transfer data to PIC */ -static inline bool pic_txready(void) +static inline uint32_t pic_txready(void) { if (MCF_PSC3_PSCSR & MCF_PSC_PSCSR_TXRDY) return TRUE; @@ -63,7 +63,7 @@ static inline bool pic_txready(void) /* * check if it is possible to receive data from PIC */ -static inline bool pic_rxready(void) +static inline uint32_t pic_rxready(void) { if (MCF_PSC3_PSCSR & MCF_PSC_PSCSR_RXRDY) return TRUE; diff --git a/SD_CARD/BaS_gcc/sources/mmcbb.c b/SD_CARD/BaS_gcc/sources/mmcbb.c index 691177e..8525325 100644 --- a/SD_CARD/BaS_gcc/sources/mmcbb.c +++ b/SD_CARD/BaS_gcc/sources/mmcbb.c @@ -157,7 +157,7 @@ static void xmit_spi_multi(const uint8_t *buff, uint32_t btx) #endif -static int card_ready(void) +static uint32_t card_ready(void) { uint8_t d; @@ -231,7 +231,7 @@ static void power_on (void) /* Enable SSP module and attach it to I/O pads */ #endif CS_HIGH(); /* Set CS# high */ #endif /* _NOT_USED_ */ - for (Timer1 = 10; Timer1; ) ; /* 10ms */ + wait(10 * 1000); /* 10ms */ } diff --git a/SD_CARD/BaS_gcc/sources/sysinit.c b/SD_CARD/BaS_gcc/sources/sysinit.c index 1c788f6..6d3c847 100644 --- a/SD_CARD/BaS_gcc/sources/sysinit.c +++ b/SD_CARD/BaS_gcc/sources/sysinit.c @@ -495,7 +495,7 @@ void test_upd720101(void) xprintf("finished\r\n"); } -static bool i2c_transfer_finished(void) +static uint32_t i2c_transfer_finished(void) { if (MCF_I2C_I2SR & MCF_I2C_I2SR_IIF) return TRUE; @@ -509,7 +509,7 @@ static void wait_i2c_transfer_finished(void) MCF_I2C_I2SR &= ~MCF_I2C_I2SR_IIF; /* clear interrupt bit (byte transfer finished */ } -static bool i2c_bus_free(void) +static uint32_t i2c_bus_free(void) { return (MCF_I2C_I2SR & MCF_I2C_I2SR_IBB); } diff --git a/SD_CARD/BaS_gcc/sources/wait.c b/SD_CARD/BaS_gcc/sources/wait.c index 97fb530..11b6895 100644 --- a/SD_CARD/BaS_gcc/sources/wait.c +++ b/SD_CARD/BaS_gcc/sources/wait.c @@ -45,14 +45,15 @@ inline void wait(uint32_t us) * 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 bool waitfor(uint32_t us, int (*condition)(void)) +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 ((*condition)()) - return TRUE; + if ((res = (*condition)())) + return res; } while (MCF_SLT_SCNT(0) > target); - return FALSE; + return 0; }