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

添加一个status,判断I2C执行结果来修复i2c传输始终正确的BUG。
This commit is contained in:
vandoul 2023-02-20 12:09:27 +08:00 committed by GitHub
parent 1b3d287cee
commit c377c4bea3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -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
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[] =
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,
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;

View File

@ -0,0 +1,3 @@
project.uvguix.*
DebugConfig
EventRecorderStub.scvd