未验证 提交 c377c4be 编写于 作者: V vandoul 提交者: GitHub

[nxp][lpc55sxx] add status to lpc_i2c_bus in drv_i2c for lpc55sxx. (#6935)

添加一个status,判断I2C执行结果来修复i2c传输始终正确的BUG。
上级 1b3d287c
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2019-07-15 Magicoe The first version for LPC55S6x * 2019-07-15 Magicoe The first version for LPC55S6x
* 2023-02-17 Vandoul Add status to lpc_i2c_bus.
*/ */
#include <rtthread.h> #include <rtthread.h>
...@@ -41,6 +42,7 @@ struct lpc_i2c_bus ...@@ -41,6 +42,7 @@ struct lpc_i2c_bus
uint32_t instance; uint32_t instance;
uint32_t baud; uint32_t baud;
char *device_name; char *device_name;
uint32_t status;
}; };
...@@ -63,6 +65,7 @@ struct lpc_i2c_bus lpc_obj[] = ...@@ -63,6 +65,7 @@ struct lpc_i2c_bus lpc_obj[] =
static void i2c_mst_dma_callback(I2C_Type *base, i2c_master_dma_handle_t *handle, status_t status, void *userData) static void i2c_mst_dma_callback(I2C_Type *base, i2c_master_dma_handle_t *handle, status_t status, void *userData)
{ {
struct lpc_i2c_bus *lpc_i2c = (struct lpc_i2c_bus*)userData; struct lpc_i2c_bus *lpc_i2c = (struct lpc_i2c_bus*)userData;
lpc_i2c->status = status;
rt_sem_release(lpc_i2c->sem); rt_sem_release(lpc_i2c->sem);
} }
...@@ -121,6 +124,10 @@ static rt_ssize_t lpc_i2c_xfer(struct rt_i2c_bus_device *bus, ...@@ -121,6 +124,10 @@ static rt_ssize_t lpc_i2c_xfer(struct rt_i2c_bus_device *bus,
return i; return i;
} }
rt_sem_take(lpc_i2c->sem, RT_WAITING_FOREVER); rt_sem_take(lpc_i2c->sem, RT_WAITING_FOREVER);
if(lpc_i2c->status != kStatus_Success)
{
break;
}
} }
} }
ret = i; ret = i;
......
project.uvguix.*
DebugConfig
EventRecorderStub.scvd
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册