fixed doubly definition of wait_() routines

This commit is contained in:
Markus Fröschle
2013-01-21 13:13:33 +00:00
parent d76aae85ee
commit b5fdfc1244
5 changed files with 15 additions and 42 deletions

View File

@@ -29,9 +29,7 @@
#define BAS_TYPES_H_
#ifndef __cplusplus
typedef int bool;
#define TRUE 1
#define FALSE 0
#include <stdbool.h>
#endif /* __cplusplus */

View File

@@ -29,10 +29,10 @@
#include <bas_types.h>
typedef uint32_t (*checker_func)(void);
typedef bool (*checker_func)(void);
extern __inline__ void wait(uint32_t) __attribute__((always_inline));
extern __inline__ uint32_t waitfor(uint32_t us, checker_func condition) __attribute__((always_inline));
extern __inline__ bool waitfor(uint32_t us, checker_func condition) __attribute__((always_inline));
/*
* 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.
@@ -48,7 +48,7 @@ extern __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
*/
extern __inline__ uint32_t waitfor(uint32_t us, checker_func condition)
extern __inline__ bool waitfor(uint32_t us, checker_func condition)
{
uint32_t target = MCF_SLT_SCNT(0) - (us * 132);
uint32_t res;
@@ -58,6 +58,6 @@ extern __inline__ uint32_t waitfor(uint32_t us, checker_func condition)
if ((res = (*condition)()))
return res;
} while (MCF_SLT_SCNT(0) > target);
return 0;
return false;
}
#endif /* _WAIT_H_ */

View File

@@ -56,23 +56,23 @@ extern uint8_t _EMUTOS_SIZE[];
/*
* check if it is possible to transfer data to PIC
*/
static inline uint32_t pic_txready(void)
static inline bool pic_txready(void)
{
if (MCF_PSC3_PSCSR & MCF_PSC_PSCSR_TXRDY)
return TRUE;
return true;
return FALSE;
return true;
}
/*
* check if it is possible to receive data from PIC
*/
static inline uint32_t pic_rxready(void)
static inline bool pic_rxready(void)
{
if (MCF_PSC3_PSCSR & MCF_PSC_PSCSR_RXRDY)
return TRUE;
return true;
return FALSE;
return false;
}
void write_pic_byte(uint8_t value)

View File

@@ -138,7 +138,7 @@ static void xmit_spi_multi(const uint8_t *buff, uint32_t btx)
#endif
static uint32_t card_ready(void)
static bool card_ready(void)
{
uint8_t d;

View File

@@ -31,6 +31,7 @@
#include "sysinit.h"
#include "bas_printf.h"
#include "bas_types.h"
#include "wait.h"
extern void xprintf_before_copy(const char *fmt, ...);
#define xprintf xprintf_before_copy
@@ -41,32 +42,6 @@ extern void flush_and_invalidate_caches_before_copy(void);
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
* the number of useconds to wait for hardcoded in their name.
*/
inline __attribute__((always_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 __attribute__((always_inline)) bool waitfor(uint32_t us, int (*condition)(void))
{
uint32_t target = MCF_SLT_SCNT(0) - (us * 132);
do
{
if ((*condition)())
return TRUE;
} while (MCF_SLT_SCNT(0) > target);
return FALSE;
}
/*
* init SLICE TIMER 0
* all = 32.538 sec = 30.736mHz
@@ -519,9 +494,9 @@ void test_upd720101(void)
static bool i2c_transfer_finished(void)
{
if (MCF_I2C_I2SR & MCF_I2C_I2SR_IIF)
return TRUE;
return true;
return FALSE;
return false;
}
static void wait_i2c_transfer_finished(void)