preparing to get rid of timer interrupt routines in fatfs module
This commit is contained in:
@@ -28,8 +28,7 @@
|
||||
#ifndef __SYSINIT_H__
|
||||
#define __SYSINIT_H__
|
||||
#include <bas_types.h>
|
||||
|
||||
extern inline bool waitfor(uint32_t us, int (*condition)(void));
|
||||
#include <wait.h>
|
||||
|
||||
/* adresses where FPGA data lives in flash */
|
||||
#define FPGA_FLASH_DATA ((uint8_t *) 0xe0700000L)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <bas_types.h>
|
||||
|
||||
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_ */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user