|
@@ -10,6 +10,10 @@
|
|
|
|
|
|
#include "drivers/dev_spi.h"
|
|
|
|
|
|
+extern rt_err_t spi_bus_register(struct rt_spi_bus *bus,
|
|
|
+ const char *name,
|
|
|
+ const struct rt_spi_ops *ops);
|
|
|
+
|
|
|
rt_err_t rt_qspi_configure(struct rt_qspi_device *device, struct rt_qspi_configuration *cfg)
|
|
|
{
|
|
|
RT_ASSERT(device != RT_NULL);
|
|
@@ -67,21 +71,15 @@ rt_err_t rt_qspi_configure(struct rt_qspi_device *device, struct rt_qspi_configu
|
|
|
|
|
|
rt_err_t rt_qspi_bus_register(struct rt_spi_bus *bus, const char *name, const struct rt_spi_ops *ops)
|
|
|
{
|
|
|
- rt_err_t result = RT_EOK;
|
|
|
-
|
|
|
- result = rt_spi_bus_register(bus, name, ops);
|
|
|
- if(result == RT_EOK)
|
|
|
- {
|
|
|
- /* set SPI bus to qspi modes */
|
|
|
- bus->mode = RT_SPI_BUS_MODE_QSPI;
|
|
|
- }
|
|
|
+ /* set SPI bus to qspi modes */
|
|
|
+ bus->mode = RT_SPI_BUS_MODE_QSPI;
|
|
|
|
|
|
- return result;
|
|
|
+ return spi_bus_register(bus, name, ops);
|
|
|
}
|
|
|
|
|
|
-rt_size_t rt_qspi_transfer_message(struct rt_qspi_device *device, struct rt_qspi_message *message)
|
|
|
+rt_ssize_t rt_qspi_transfer_message(struct rt_qspi_device *device, struct rt_qspi_message *message)
|
|
|
{
|
|
|
- rt_err_t result;
|
|
|
+ rt_ssize_t result;
|
|
|
|
|
|
RT_ASSERT(device != RT_NULL);
|
|
|
RT_ASSERT(message != RT_NULL);
|
|
@@ -130,7 +128,7 @@ __exit:
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-rt_err_t rt_qspi_send_then_recv(struct rt_qspi_device *device, const void *send_buf, rt_size_t send_length, void *recv_buf, rt_size_t recv_length)
|
|
|
+rt_ssize_t rt_qspi_send_then_recv(struct rt_qspi_device *device, const void *send_buf, rt_size_t send_length, void *recv_buf, rt_size_t recv_length)
|
|
|
{
|
|
|
RT_ASSERT(send_buf);
|
|
|
RT_ASSERT(recv_buf);
|
|
@@ -139,7 +137,7 @@ rt_err_t rt_qspi_send_then_recv(struct rt_qspi_device *device, const void *send_
|
|
|
struct rt_qspi_message message;
|
|
|
unsigned char *ptr = (unsigned char *)send_buf;
|
|
|
rt_size_t count = 0;
|
|
|
- rt_err_t result = 0;
|
|
|
+ rt_ssize_t result = 0;
|
|
|
|
|
|
message.instruction.content = ptr[0];
|
|
|
message.instruction.qspi_lines = 1;
|
|
@@ -208,7 +206,7 @@ rt_err_t rt_qspi_send_then_recv(struct rt_qspi_device *device, const void *send_
|
|
|
{
|
|
|
result = -RT_EIO;
|
|
|
}
|
|
|
- else
|
|
|
+ else if (result > 0)
|
|
|
{
|
|
|
result = recv_length;
|
|
|
}
|
|
@@ -216,7 +214,7 @@ rt_err_t rt_qspi_send_then_recv(struct rt_qspi_device *device, const void *send_
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-rt_err_t rt_qspi_send(struct rt_qspi_device *device, const void *send_buf, rt_size_t length)
|
|
|
+rt_ssize_t rt_qspi_send(struct rt_qspi_device *device, const void *send_buf, rt_size_t length)
|
|
|
{
|
|
|
RT_ASSERT(send_buf);
|
|
|
RT_ASSERT(length != 0);
|
|
@@ -224,7 +222,7 @@ rt_err_t rt_qspi_send(struct rt_qspi_device *device, const void *send_buf, rt_si
|
|
|
struct rt_qspi_message message;
|
|
|
unsigned char *ptr = (unsigned char *)send_buf;
|
|
|
rt_size_t count = 0;
|
|
|
- rt_err_t result = 0;
|
|
|
+ rt_ssize_t result = 0;
|
|
|
|
|
|
message.instruction.content = ptr[0];
|
|
|
message.instruction.qspi_lines = 1;
|
|
@@ -294,7 +292,7 @@ rt_err_t rt_qspi_send(struct rt_qspi_device *device, const void *send_buf, rt_si
|
|
|
{
|
|
|
result = -RT_EIO;
|
|
|
}
|
|
|
- else
|
|
|
+ else if (result > 0)
|
|
|
{
|
|
|
result = length;
|
|
|
}
|