From 4a654414e3fb346f67a66f829db94a72b9aa27a9 Mon Sep 17 00:00:00 2001 From: SimpleInit <63694297@qq.com> Date: Wed, 26 Aug 2020 21:00:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D"response+1"=E5=AF=BC?= =?UTF-8?q?=E8=87=B4STM32=20HAL=E5=BA=93SPI=E5=86=85=E5=AD=98=E9=9D=9E?= =?UTF-8?q?=E5=AF=B9=E9=BD=90=E8=AE=BF=E9=97=AE=E7=9A=84hard=20fault?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drivers/spi/spi_msd.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/components/drivers/spi/spi_msd.c b/components/drivers/spi/spi_msd.c index a109fd9488..272c21c179 100644 --- a/components/drivers/spi/spi_msd.c +++ b/components/drivers/spi/spi_msd.c @@ -233,6 +233,17 @@ static rt_err_t _send_cmd( } else if (type == response_r2) { + #if defined(__CORTEX_M) && __CORTEX_M == 0 + /* initial message */ + message.send_buf = RT_NULL; + message.recv_buf = recv_buffer; + message.length = 1; + message.cs_take = message.cs_release = 0; + + /* transfer message */ + device->bus->ops->xfer(device, &message); + response[1] = recv_buffer[0]; + #else /* initial message */ message.send_buf = RT_NULL; message.recv_buf = response + 1; @@ -241,9 +252,24 @@ static rt_err_t _send_cmd( /* transfer message */ device->bus->ops->xfer(device, &message); + #endif } else if ((type == response_r3) || (type == response_r7)) { + #if defined(__CORTEX_M) && __CORTEX_M == 0 + /* initial message */ + message.send_buf = RT_NULL; + message.recv_buf = recv_buffer; + message.length = 4; + message.cs_take = message.cs_release = 0; + + /* transfer message */ + device->bus->ops->xfer(device, &message); + response[1] = recv_buffer[0]; + response[2] = recv_buffer[1]; + response[3] = recv_buffer[2]; + response[4] = recv_buffer[3]; + #else /* initial message */ message.send_buf = RT_NULL; message.recv_buf = response + 1; @@ -252,6 +278,7 @@ static rt_err_t _send_cmd( /* transfer message */ device->bus->ops->xfer(device, &message); + #endif } else {