瀏覽代碼

update:I2C的hold时间拉长

alienwalker 3 年之前
父節點
當前提交
14a945f6f2
共有 2 個文件被更改,包括 4 次插入2 次删除
  1. 2 0
      application/include/luat_conf_bsp.h
  2. 2 2
      bsp/air105/hal/core_i2c.c

+ 2 - 0
application/include/luat_conf_bsp.h

@@ -216,4 +216,6 @@ extern unsigned int gLVFlashTime;
 #define LUAT_RT_RET_TYPE int
 #define LUAT_RT_RET	0
 #define LUAT_RT_CB_PARAM void *pdata, void *param
+
+#define __LUAT_C_CODE_IN_RAM__ __attribute__((section (".RamFunc")))
 #endif

+ 2 - 2
bsp/air105/hal/core_i2c.c

@@ -202,8 +202,8 @@ void I2C_MasterSetup(uint8_t I2CID, uint32_t Speed)
 	uint32_t Cnt = ((SystemCoreClock >> 3) / Speed);
 	I2C->IC_ENABLE = 0;
 	while(I2C->IC_ENABLE_STATUS & I2C_IC_ENABLE_STATUS_IC_EN){;}
-	I2C->IC_SDA_HOLD = 5;
-	I2C->IC_SDA_SETUP = Cnt/3;
+	I2C->IC_SDA_HOLD = Cnt >> 2;
+	I2C->IC_SDA_SETUP = Cnt >> 2;
 	switch(Speed)
 	{
 	case 100000: