factor out busy_wait_us()
This commit is contained in:
parent
35929c0f8a
commit
37ebcd3be7
|
@ -9,6 +9,7 @@ __attribute__((unused)) static void flush_cpu_icache(void){}; /* FIXME: do some
|
|||
__attribute__((unused)) static void flush_cpu_dcache(void){}; /* FIXME: do something useful here! */
|
||||
void flush_l2_cache(void);
|
||||
void busy_wait(unsigned int ms);
|
||||
void busy_wait_us(unsigned int us);
|
||||
|
||||
#include <csr-defs.h>
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void)
|
|||
void flush_l2_cache(void);
|
||||
|
||||
void busy_wait(unsigned int ms);
|
||||
void busy_wait_us(unsigned int us);
|
||||
|
||||
#define csrr(reg) ({ unsigned long __tmp; \
|
||||
asm volatile ("csrr %0, " #reg : "=r"(__tmp)); \
|
||||
|
|
|
@ -27,6 +27,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void)
|
|||
void flush_l2_cache(void);
|
||||
|
||||
void busy_wait(unsigned int ms);
|
||||
void busy_wait_us(unsigned int us);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ static inline void flush_cpu_dcache(void){}; /* FIXME: do something useful here!
|
|||
void flush_l2_cache(void);
|
||||
|
||||
void busy_wait(unsigned int ms);
|
||||
void busy_wait_us(unsigned int us);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ __attribute__((unused)) static void flush_cpu_icache(void){}; /* FIXME: do somet
|
|||
__attribute__((unused)) static void flush_cpu_dcache(void){}; /* FIXME: do something useful here! */
|
||||
void flush_l2_cache(void);
|
||||
void busy_wait(unsigned int ms);
|
||||
void busy_wait_us(unsigned int us);
|
||||
|
||||
#include <csr-defs.h>
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void)
|
|||
void flush_l2_cache(void);
|
||||
|
||||
void busy_wait(unsigned int ms);
|
||||
void busy_wait_us(unsigned int us);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void){}; /* No instruction
|
|||
void flush_l2_cache(void);
|
||||
|
||||
void busy_wait(unsigned int ms);
|
||||
void busy_wait_us(unsigned int us);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void){}; /* FIXME: do somet
|
|||
void flush_l2_cache(void);
|
||||
|
||||
void busy_wait(unsigned int ms);
|
||||
void busy_wait_us(unsigned int us);
|
||||
|
||||
#include <csr-defs.h>
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void){}; /* No instruction
|
|||
void flush_l2_cache(void);
|
||||
|
||||
void busy_wait(unsigned int ms);
|
||||
void busy_wait_us(unsigned int us);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void)
|
|||
void flush_l2_cache(void);
|
||||
|
||||
void busy_wait(unsigned int ms);
|
||||
void busy_wait_us(unsigned int us);
|
||||
|
||||
#define csrr(reg) ({ unsigned long __tmp; \
|
||||
asm volatile ("csrr %0, " #reg : "=r"(__tmp)); \
|
||||
|
|
|
@ -27,6 +27,7 @@ __attribute__((unused)) static void flush_cpu_dcache(void)
|
|||
void flush_l2_cache(void);
|
||||
|
||||
void busy_wait(unsigned int ms);
|
||||
void busy_wait_us(unsigned int us);
|
||||
|
||||
#include <csr-defs.h>
|
||||
|
||||
|
|
|
@ -24,3 +24,13 @@ void busy_wait(unsigned int ms)
|
|||
timer0_update_value_write(1);
|
||||
while(timer0_value_read()) timer0_update_value_write(1);
|
||||
}
|
||||
|
||||
void busy_wait_us(unsigned int us)
|
||||
{
|
||||
timer0_en_write(0);
|
||||
timer0_reload_write(0);
|
||||
timer0_load_write(CONFIG_CLOCK_FREQUENCY/1000000*us);
|
||||
timer0_en_write(1);
|
||||
timer0_update_value_write(1);
|
||||
while(timer0_value_read()) timer0_update_value_write(1);
|
||||
}
|
||||
|
|
|
@ -42,16 +42,6 @@ unsigned int sdcard_response[SD_CMD_RESPONSE_SIZE/4];
|
|||
/* SDCard command helpers */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
static void busy_wait_us(unsigned int us)
|
||||
{
|
||||
timer0_en_write(0);
|
||||
timer0_reload_write(0);
|
||||
timer0_load_write(CONFIG_CLOCK_FREQUENCY/1000000*us);
|
||||
timer0_en_write(1);
|
||||
timer0_update_value_write(1);
|
||||
while(timer0_value_read()) timer0_update_value_write(1);
|
||||
}
|
||||
|
||||
int sdcard_wait_cmd_done(void) {
|
||||
unsigned int cmdevt;
|
||||
while (1) {
|
||||
|
|
|
@ -123,16 +123,6 @@ static void spisdcardread_bytes(uint8_t* buf, uint16_t n) {
|
|||
/* SPI SDCard blocks Xfer functions */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
static void busy_wait_us(unsigned int us)
|
||||
{
|
||||
timer0_en_write(0);
|
||||
timer0_reload_write(0);
|
||||
timer0_load_write(CONFIG_CLOCK_FREQUENCY/1000000*us);
|
||||
timer0_en_write(1);
|
||||
timer0_update_value_write(1);
|
||||
while(timer0_value_read()) timer0_update_value_write(1);
|
||||
}
|
||||
|
||||
static uint8_t spisdcardreceive_block(uint8_t *buf) {
|
||||
uint16_t i;
|
||||
uint32_t timeout;
|
||||
|
|
Loading…
Reference in New Issue