diff --git a/components/drivers/sdio/SConscript b/components/drivers/sdio/SConscript index 55aac473e..dfe7075a5 100644 --- a/components/drivers/sdio/SConscript +++ b/components/drivers/sdio/SConscript @@ -12,6 +12,6 @@ sd.c # The set of source files associated with this SConscript file. path = [cwd] -group = DefineGroup('Drivers', src, depend = ['RT_USING_MMCSD'], CPPPATH = path) +group = DefineGroup('DeviceDrivers', src, depend = ['RT_USING_MMCSD'], CPPPATH = path) Return('group') diff --git a/components/drivers/sdio/mmcsd_core.c b/components/drivers/sdio/mmcsd_core.c index b30123331..620a26fd3 100644 --- a/components/drivers/sdio/mmcsd_core.c +++ b/components/drivers/sdio/mmcsd_core.c @@ -48,7 +48,20 @@ void mmcsd_req_complete(struct rt_mmcsd_host *host) void mmcsd_send_request(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req) { - req->cmd->data = req->data; + req->cmd->err = 0; + req->cmd->mrq = req; + if (req->data) + { + req->cmd->data = req->data; + req->data->err = 0; + req->data->mrq = req; + if (req->stop) + { + req->data->stop = req->stop; + req->stop->err = 0; + req->stop->mrq = req; + } + } host->ops->request(host, req); rt_sem_take(&host->sem_ack, RT_WAITING_FOREVER); } diff --git a/components/drivers/sdio/mmcsd_core.h b/components/drivers/sdio/mmcsd_core.h index 078a0edf9..1e2c9f08b 100644 --- a/components/drivers/sdio/mmcsd_core.h +++ b/components/drivers/sdio/mmcsd_core.h @@ -39,6 +39,12 @@ struct rt_mmcsd_data { #define DATA_DIR_WRITE (1 << 0) #define DATA_DIR_READ (1 << 1) #define DATA_STREAM (1 << 2) + + unsigned int bytes_xfered; + + struct rt_mmcsd_cmd *stop; /* stop command */ + struct rt_mmcsd_req *mrq; /* associated request */ + rt_uint32_t timeout_ns; rt_uint32_t timeout_clks; }; @@ -89,9 +95,11 @@ struct rt_mmcsd_cmd { */ #define cmd_type(cmd) ((cmd)->flags & CMD_MASK) + rt_int32_t retries; /* max number of retries */ rt_int32_t err; struct rt_mmcsd_data *data; + struct rt_mmcsd_req *mrq; /* associated request */ }; struct rt_mmcsd_req { @@ -190,7 +198,7 @@ rt_inline rt_uint32_t fls(rt_uint32_t val) return bit; } -#if !defined(__GNUC__) +#if !defined(__GNUC__) || defined(__CC_ARM) rt_inline rt_uint32_t ffs(rt_uint32_t x) { int r = 1; diff --git a/components/drivers/sdio/sd.c b/components/drivers/sdio/sd.c index 67fd39287..f454b8108 100644 --- a/components/drivers/sdio/sd.c +++ b/components/drivers/sdio/sd.c @@ -281,7 +281,7 @@ err1: static rt_err_t mmcsd_app_cmd(struct rt_mmcsd_host *host, struct rt_mmcsd_card *card) { rt_err_t err; - struct rt_mmcsd_cmd cmd; + struct rt_mmcsd_cmd cmd = {0}; cmd.cmd_code = APP_CMD; diff --git a/components/drivers/spi/SConscript b/components/drivers/spi/SConscript index 930ebbee8..666545250 100644 --- a/components/drivers/spi/SConscript +++ b/components/drivers/spi/SConscript @@ -3,6 +3,6 @@ from building import * cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd + '/../include'] -group = DefineGroup('Drivers', src, depend = ['RT_USING_SPI'], CPPPATH = CPPPATH) +group = DefineGroup('DeviceDrivers', src, depend = ['RT_USING_SPI'], CPPPATH = CPPPATH) Return('group')