Merge pull request #4689 from mysterywolf/simulator-sd_sim
[bug][bsp][simulator] 修复sd_sim.c编译报错的问题,使用rt_dgb代替老旧的debug输出方式
This commit is contained in:
commit
53cfba8725
|
@ -13,11 +13,9 @@
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include <dfs.h>
|
#include <dfs.h>
|
||||||
|
|
||||||
#ifdef DEBUG
|
#define DBG_TAG "sd.sim"
|
||||||
# define SD_TRACE rt_kprintf
|
#define DBG_LVL DBG_INFO
|
||||||
#else
|
#include <rtdbg.h>
|
||||||
# define SD_TRACE(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SDCARD_SIM "sd.bin"
|
#define SDCARD_SIM "sd.bin"
|
||||||
#define SDCARD_SIZE (16*1024*1024) //16M
|
#define SDCARD_SIZE (16*1024*1024) //16M
|
||||||
|
@ -59,7 +57,7 @@ static rt_size_t rt_sdcard_read(rt_device_t device, rt_off_t position, void *buf
|
||||||
struct sdcard_device *sd;
|
struct sdcard_device *sd;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
SD_TRACE("sd read: pos %d, size %d\n", position, size);
|
LOG_I("sd read: pos %d, size %d", position, size);
|
||||||
|
|
||||||
rt_mutex_take(lock, RT_WAITING_FOREVER);
|
rt_mutex_take(lock, RT_WAITING_FOREVER);
|
||||||
sd = SDCARD_DEVICE(device);
|
sd = SDCARD_DEVICE(device);
|
||||||
|
@ -73,7 +71,7 @@ static rt_size_t rt_sdcard_read(rt_device_t device, rt_off_t position, void *buf
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
SD_TRACE("sd read errors!\n");
|
LOG_E("sd read errors!");
|
||||||
rt_mutex_release(lock);
|
rt_mutex_release(lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +85,7 @@ static rt_size_t rt_sdcard_write(rt_device_t device, rt_off_t position, const vo
|
||||||
struct sdcard_device *sd;
|
struct sdcard_device *sd;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
SD_TRACE("sst write: pos %d, size %d\n", position, size);
|
LOG_I("sst write: pos %d, size %d", position, size);
|
||||||
|
|
||||||
rt_mutex_take(lock, RT_WAITING_FOREVER);
|
rt_mutex_take(lock, RT_WAITING_FOREVER);
|
||||||
sd = SDCARD_DEVICE(device);
|
sd = SDCARD_DEVICE(device);
|
||||||
|
@ -101,7 +99,7 @@ static rt_size_t rt_sdcard_write(rt_device_t device, rt_off_t position, const vo
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
SD_TRACE("sd write errors!\n");
|
LOG_E("sd write errors!");
|
||||||
rt_mutex_release(lock);
|
rt_mutex_release(lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +141,7 @@ rt_err_t rt_hw_sdcard_init(const char *spi_device_name)
|
||||||
device = &(sd->parent);
|
device = &(sd->parent);
|
||||||
|
|
||||||
lock = rt_mutex_create("lock", RT_IPC_FLAG_FIFO);
|
lock = rt_mutex_create("lock", RT_IPC_FLAG_FIFO);
|
||||||
if (lock == RT_NULL)
|
if (lock == RT_NULL)
|
||||||
{
|
{
|
||||||
LOG_E("Create mutex in rt_hw_sdcard_init failed!");
|
LOG_E("Create mutex in rt_hw_sdcard_init failed!");
|
||||||
return -RT_ERROR;
|
return -RT_ERROR;
|
||||||
|
@ -168,7 +166,7 @@ rt_err_t rt_hw_sdcard_init(const char *spi_device_name)
|
||||||
ptr = (unsigned char *) malloc(1024 * 1024);
|
ptr = (unsigned char *) malloc(1024 * 1024);
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
{
|
{
|
||||||
SD_TRACE("malloc error, no memory!\n");
|
LOG_E("malloc error, no memory!");
|
||||||
return RT_ERROR;
|
return RT_ERROR;
|
||||||
}
|
}
|
||||||
memset(ptr, 0x0, 1024 * 1024);
|
memset(ptr, 0x0, 1024 * 1024);
|
||||||
|
|
Loading…
Reference in New Issue