Merge pull request #34 from armfly/origin/armfly

多路模式烧录,最后发软件复位指令时需要忽略错误标志
This commit is contained in:
armfly 2020-10-19 17:19:38 +08:00 committed by GitHub
commit 708420de8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 102 additions and 51 deletions

View File

@ -1,3 +1,10 @@
----------------------------------------------------------------------------
2020-10-19 V1.34
1. 修改net_udp.c中lua_udp_SendBuf()函数遇到0x0A就立即发送解决PC软件显示log不全问题
2. V1.33 emmc磁盘文件有误machine_if.lua和prog_lib.lun需要更新
3. 多路模式烧录,最后发复位指令时需要忽略错误标志
4. i2c操作的函数lua接口api汇总到一个函数i2c_bus(), 第1个形参用字符串表示操作指令
----------------------------------------------------------------------------
2020-10-18 V1.33
1. 增加新唐N76E003芯片脱机烧录

View File

@ -153,24 +153,7 @@
<Name></Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>236</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134438950</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\..\User\segger\HardFaultHandlerMDK\SEGGER_HardFaultHandler.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\output\../../User/segger/HardFaultHandlerMDK/SEGGER_HardFaultHandler.c\236</Expression>
</Bp>
</Breakpoint>
<Breakpoint/>
<WatchWindow1>
<Ww>
<count>0</count>
@ -248,7 +231,7 @@
<Group>
<GroupName>App</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -520,7 +503,7 @@
<Group>
<GroupName>BSP</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -960,7 +943,7 @@
<Group>
<GroupName>MDK-ARM</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -3356,7 +3339,7 @@
<Group>
<GroupName>Lua_IF</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>

View File

@ -68,7 +68,7 @@ __Vectors DCD __initial_sp ; Top of Stack
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0x00000133 ; Reserved H7-TOOL APP 固件版本
DCD 0x00000134 ; Reserved H7-TOOL APP 固件版本
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved

View File

@ -299,3 +299,5 @@ uint8_t i2c_CheckDevice(uint8_t _Address)
}
return 1; /* I2C总线异常 */
}
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/

View File

@ -4,31 +4,72 @@
#include "lua_if.h"
#include "bsp.h"
static int lua_I2C_Start(lua_State* L);
static int lua_I2C_Stop(lua_State* L);
static int lua_I2C_SendBytes(lua_State* L);
static int lua_I2C_ReciveBytes(lua_State* L);
static int lua_I2C_BusCmd(lua_State* L);
void lua_i2c_RegisterFun(void)
{
//将指定的函数注册为Lua的全局函数变量其中第一个字符串参数为Lua代码
//在调用C函数时使用的全局函数名第二个参数为实际C函数的指针。
lua_register(g_Lua, "i2c_start", lua_I2C_Start);
lua_register(g_Lua, "i2c_stop", lua_I2C_Stop);
lua_register(g_Lua, "i2c_send", lua_I2C_SendBytes);
lua_register(g_Lua, "i2c_recive", lua_I2C_ReciveBytes);
lua_register(g_Lua, "i2c_bus", lua_I2C_BusCmd);
}
static int lua_I2C_Start(lua_State* L)
static int lua_I2C_BusCmd(lua_State* L)
{
i2c_Start();
return 1;
}
const char *StrCmd;
size_t len;
static int lua_I2C_Stop(lua_State* L)
{
i2c_Stop();
return 1;
if (lua_type(L, 1) == LUA_TSTRING) /* 判断第1个参数 */
{
StrCmd = luaL_checklstring(L, 1, &len); /* 1是参数的位置 len是string的长度 */
}
else
{
return 0;
}
if (strcmp(StrCmd, "init") == 0)
{
bsp_InitI2C();
return 0;
}
else if (strcmp(StrCmd, "start") == 0)
{
i2c_Start();
return 0;
}
else if (strcmp(StrCmd, "stop") == 0)
{
i2c_Stop();
return 0;
}
else if (strcmp(StrCmd, "check") == 0)
{
uint16_t addr;
uint8_t ack;
if (lua_type(L, 2) == LUA_TNUMBER) /* 判断第1个参数 */
{
addr = luaL_checknumber(L, 2);
ack = i2c_CheckDevice(addr);
lua_pushnumber(L, ack);
return 1;
}
lua_pushnumber(L, 1); /* 1表示总线无应答 */
return 1;
}
else if (strcmp(StrCmd, "send") == 0)
{
return lua_I2C_SendBytes(L);
}
else if (strcmp(StrCmd, "i2c_recive") == 0)
{
return lua_I2C_ReciveBytes(L);
}
return 0;
}
/*
@ -90,7 +131,7 @@ static int lua_I2C_ReciveBytes(lua_State* L)
if (len == 0 || len > LUA_READ_LEN_MAX)
{
lua_pushnumber(L, 0); /* 返回值 */
return 0;
return 1;
}
for (i = 0; i < len; i++)
@ -108,15 +149,8 @@ static int lua_I2C_ReciveBytes(lua_State* L)
}
}
//lua_pushnumber(L, 1); /* 返回值 */
// strcpy(s_lua_read_buf, "s_lua_read_buf");
lua_pushlstring(L, (char *)s_lua_read_buf, len);
return 1;
}
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/

View File

@ -1264,6 +1264,13 @@ static int h7_reset(lua_State* L)
/* 硬件复位 */
if (g_gMulSwd.MultiMode > 0) /* 多路模式 */
{
/* V1.34 备份错误标志 */
uint8_t Bak[4];
Bak[0] = g_gMulSwd.Error[0];
Bak[1] = g_gMulSwd.Error[1];
Bak[2] = g_gMulSwd.Error[2];
Bak[3] = g_gMulSwd.Error[3];
MUL_swd_set_target_reset(1);
@ -1280,6 +1287,11 @@ static int h7_reset(lua_State* L)
MUL_swd_set_target_reset(0);
osDelay(delay);
g_gMulSwd.Error[0] = Bak[0];
g_gMulSwd.Error[1] = Bak[1];
g_gMulSwd.Error[2] = Bak[2];
g_gMulSwd.Error[3] = Bak[3];
}
else
{

View File

@ -125,12 +125,25 @@ void udp_print_send(void)
void lua_udp_SendBuf(uint8_t *_buf, uint16_t _len, uint16_t _port)
{
uint16_t i;
uint8_t nowsend = 0;
for (i = 0; i < _len; i++)
{
udp_print_put(_buf[i]);
if (_buf[i] == 0x0A)
{
nowsend = 1;
}
}
if (nowsend == 1)
{
udp_print_send();
}
else
{
bsp_StartHardTimer(3, 5000, udp_print_send);
}
bsp_StartHardTimer(3, 5000, udp_print_send);
}
/*