网络自适应
This commit is contained in:
1 parent
a589e89e33
commit
0f40dd8b17
59 files changed
+5365
-981
No files matched your search
@@ -9,6 +9,7 @@
|
||||
#include "data.h"
|
||||
#include "easyflash.h"
|
||||
#include <string.h>
|
||||
#include <elog.h>
|
||||
|
||||
|
||||
ALIGN (RT_ALIGN_SIZE)
|
||||
@@ -28,6 +29,7 @@ static void thread_entry (void * argument)
|
||||
g_DebugDrv.rxdone = cfg_rx_done;
|
||||
rt_kprintf ("%s was start!\r\n", __FILE__);
|
||||
rt_kprintf ("config input\r\n");
|
||||
elog_stop();
|
||||
g_ifconfig = 1;
|
||||
char * p;
|
||||
char key[32], value[32];
|
||||
@@ -95,7 +97,7 @@ static void thread_entry (void * argument)
|
||||
rt_thread_delay (10);
|
||||
}
|
||||
shell_recover();
|
||||
g_ifconfig = 0;
|
||||
elog_start();
|
||||
rt_kprintf ("config exit\r\n");
|
||||
}
|
||||
|
||||
|
||||
+11
-6
@@ -16,11 +16,13 @@
|
||||
#define DIS_CASCII_IP 0x1080 // 远程地址
|
||||
#define DIS_CASCII_PORT 0x1090 // 远程端口
|
||||
#define DIS_CASCII_PASS 0x10A0 // 登录密码
|
||||
#define DIS_CASCII_SLTYPE 0x10B0 // 闸门类型
|
||||
#define DIS_CNUM_SLSPEED 0x10C0 // 闸门速度
|
||||
|
||||
#define DIS_CNUM_1PROT 0x10B0 // 一级保护
|
||||
#define DIS_CNUM_2PROT 0x10C0 // 二级保护
|
||||
#define DIS_CNUM_SLHEIGHT 0x10D0 // 闸门高度
|
||||
#define DIS_CNUM_SLLOAD 0x10E0 // 荷重仪类型
|
||||
#define DIS_CNUM_SLLOADKEY 0x10F0 //荷重仪
|
||||
#define DIS_CNUM_PROTK 0x10E0 // 荷重仪类型
|
||||
|
||||
#define DIS_CNUM_SLLOADKEY 0x10F0 // 闸门荷重
|
||||
|
||||
|
||||
|
||||
@@ -40,6 +42,7 @@
|
||||
#define DIS_CNUM_DBG_VOL 0x11A0 //母线电压
|
||||
#define DIS_CNUM_DBG_CUR 0x11B0 //当前电流
|
||||
#define DIS_CNUM_DBG_ERR 0x11C0 //报警代码
|
||||
#define DIS_CNUM_MAX_OPEN 0x11D0 // 开度提闸界面 最大开度
|
||||
|
||||
|
||||
// 按钮
|
||||
@@ -51,7 +54,7 @@
|
||||
#define DIS_CMD_BTN_PA 0X2050 // 菜单 参数设置
|
||||
#define DIS_CMD_BTN_DB 0X2070 // 菜单 设备调试
|
||||
#define DIS_CMD_BTN_ST 0X2080 // 菜单 设备状态
|
||||
// #define DIS_CMD_BTN_STOP 0X2090 // 急停
|
||||
|
||||
|
||||
#define DIS_CMD_BTN_DUP 0X20B0 // 调试 上
|
||||
#define DIS_CMD_BTN_DDOWN 0X20C0 // 调试 下
|
||||
@@ -60,7 +63,8 @@
|
||||
#define DIS_CMD_BTN_SETMAX 0X20F0 // 菜单 设为最大
|
||||
#define DIS_CMD_BTN_FACT 0X2100 // 菜单 恢复出厂设置
|
||||
#define DIS_CMD_BTN_REST 0X2110 // 菜单 重启
|
||||
#define DIS_CMD_BTN_SETMIN 0X2120 // 菜单 设为最小
|
||||
#define DIS_CMD_BTN_SETMIN 0X2120 // 菜单 设为最
|
||||
#define DIS_CMD_BTN_CLREXC 0X2130 // 菜单 解除报警
|
||||
|
||||
// 动态图标
|
||||
|
||||
@@ -84,6 +88,7 @@
|
||||
#define DIS_TYPE_SWPAGE 0x03
|
||||
#define DIS_TYPE_WD_BYTES 0x04
|
||||
#define DIS_TYPE_WD_ICON 0x05
|
||||
#define DIS_TYPE_WD_AUDIO 0x06
|
||||
|
||||
#define DIS_STE_INVALID 0 // 无效的
|
||||
#define DIS_STE_SUCCSEE 1 // 成功 绿色
|
||||
|
||||
+260
-28
@@ -15,6 +15,10 @@ ALIGN (RT_ALIGN_SIZE)
|
||||
static char thread_stack[4096];
|
||||
static struct rt_thread display_thread;
|
||||
|
||||
#if !defined(LOG_TAG)
|
||||
#define LOG_TAG "lcd"
|
||||
#endif
|
||||
#include <elog.h>
|
||||
|
||||
static rt_timer_t timer;
|
||||
|
||||
@@ -26,6 +30,8 @@ static struct
|
||||
int identity;
|
||||
} s_driver;
|
||||
|
||||
|
||||
static void dis_write_usrpwd (char *pass);
|
||||
static void view_rx_done (void)
|
||||
{
|
||||
rt_event_send (gUartEvents, EVENT_UART_VIEW_RX);
|
||||
@@ -126,6 +132,18 @@ static int DisPreparePacket (DisDataType_t ddtt, char *buf, int maxLen)
|
||||
break;
|
||||
|
||||
}
|
||||
case DIS_TYPE_WD_AUDIO:
|
||||
{
|
||||
buf[tx_size++] = 0x82;
|
||||
buf[tx_size++] = 0x00; // 寄存器地址高位
|
||||
buf[tx_size++] = 0xA0; // 寄存器地址高位
|
||||
|
||||
buf[tx_size++] = (char)ddtt.Int.Int; // 寄存器数据高位
|
||||
buf[tx_size++] = 0x01; // 寄存器数据高位
|
||||
buf[tx_size++] = 0x40; // 寄存器数据高位
|
||||
buf[tx_size++] = 0x00; // 寄存器数据高位
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -164,6 +182,10 @@ static void disctrl_handle (char *data, int length)
|
||||
}
|
||||
case DIS_CMD_BTN_DUP: // 调试界面上升
|
||||
{
|
||||
if (s_driver.identity == 0) // 用户无此权限
|
||||
{
|
||||
break;
|
||||
}
|
||||
mail.Type = MAIL_SLUICE_SUP;
|
||||
mail.index = 0;
|
||||
rt_mb_send (gSluiceMail, * ( (uint32_t*) &mail));
|
||||
@@ -171,6 +193,10 @@ static void disctrl_handle (char *data, int length)
|
||||
}
|
||||
case DIS_CMD_BTN_DDOWN: // 调试界面下降
|
||||
{
|
||||
if (s_driver.identity == 0) // 用户无此权限
|
||||
{
|
||||
break;
|
||||
}
|
||||
mail.Type = MAIL_SLUICE_SDW;
|
||||
mail.index = 0;
|
||||
rt_mb_send (gSluiceMail, * ( (uint32_t*) &mail));
|
||||
@@ -178,9 +204,10 @@ static void disctrl_handle (char *data, int length)
|
||||
}
|
||||
case DIS_CMD_BTN_DSTOP: // 调试界面停止
|
||||
{
|
||||
mail.Type = MAIL_SLUICE_STP;
|
||||
mail.index = 0;
|
||||
rt_mb_send (gSluiceMail, * ( (uint32_t*) &mail));
|
||||
OsSendMail(gSluiceMail,MAIL_SLUICE_STP,0);
|
||||
// mail.Type = MAIL_SLUICE_STP;
|
||||
// mail.index = 0;
|
||||
// rt_mb_send (gSluiceMail, * ( (uint32_t*) &mail));
|
||||
break;
|
||||
}
|
||||
case DIS_CMD_BTN_DUNLOCK: // 调试界面解锁
|
||||
@@ -226,7 +253,7 @@ static void disctrl_handle (char *data, int length)
|
||||
break;
|
||||
}
|
||||
// 5A A5 0A 83 10 30 03 30 31 32 33 FF FF
|
||||
case DIS_CNUM_PASS:
|
||||
case DIS_CNUM_PASS: // 登录成功
|
||||
{
|
||||
if ( (rt_memcmp (&data[index], (char *) s_driver.userpwd, 6) == 0)) // 用户密码
|
||||
{
|
||||
@@ -235,18 +262,24 @@ static void disctrl_handle (char *data, int length)
|
||||
ddtt.Int.Int = 0x0004;
|
||||
tx_size = DisPreparePacket (ddtt, txbuf, 100);
|
||||
MX_UART_PutBuffer (&g_ViewDrv, txbuf, tx_size);
|
||||
OsSendMail(gViewMail,MAIL_VIEW_AUDIO,MAIL_AUDIO_LOGIN_SUC) ;
|
||||
}
|
||||
if ( (rt_memcmp (&data[index], (char *) s_driver.syspwd, 6) == 0)) // 用户密码
|
||||
else if ( (rt_memcmp (&data[index], (char *) s_driver.syspwd, 6) == 0)) // 用户密码
|
||||
{
|
||||
s_driver.identity = 1;
|
||||
ddtt.type = DIS_TYPE_SWPAGE;
|
||||
ddtt.Int.Int = 0x0004;
|
||||
tx_size = DisPreparePacket (ddtt, txbuf, 100);
|
||||
MX_UART_PutBuffer (&g_ViewDrv, txbuf, tx_size);
|
||||
OsSendMail(gViewMail,MAIL_VIEW_AUDIO,MAIL_AUDIO_LOGIN_ADM) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
OsSendMail(gViewMail,MAIL_VIEW_AUDIO,MAIL_AUDIO_LOGIN_FIL) ;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 设置提闸开度
|
||||
// 输入提闸开度
|
||||
case DIS_CNUM_SLSET:
|
||||
{
|
||||
a = (uint16_t) data[index + 2] * 256 + (uint16_t) data[index + 3];
|
||||
@@ -258,6 +291,17 @@ static void disctrl_handle (char *data, int length)
|
||||
//rt_event_send (gCtrlEvents, EVENT_CTRL_SET_OPT_SLU);
|
||||
break;
|
||||
}
|
||||
// case DIS_CNUM_SLSET:
|
||||
// {
|
||||
// a = (uint16_t) data[index + 2] * 256 + (uint16_t) data[index + 3];
|
||||
// SluiceData[0].sopen = a * 10;
|
||||
// //SluiceData[gMqttDrv.rx_index].sopen = datak / 10;
|
||||
// mail.Type = MAIL_SLUICE_OPT;
|
||||
// mail.index = 0;
|
||||
// rt_mb_send (gSluiceMail, * ( (uint32_t*) &mail));
|
||||
// //rt_event_send (gCtrlEvents, EVENT_CTRL_SET_OPT_SLU);
|
||||
// break;
|
||||
// }
|
||||
// 83 10 70 05 30 30 30 31 30 30 30 31 FF FF
|
||||
case DIS_CASCII_DEVID: // 设置设备编码
|
||||
{
|
||||
@@ -272,27 +316,29 @@ static void disctrl_handle (char *data, int length)
|
||||
}
|
||||
case DIS_CASCII_PASS:
|
||||
{
|
||||
char password[7] = {0};
|
||||
if (s_driver.identity == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
// if (s_user_role != 1)
|
||||
// break;
|
||||
// if (length != 12)
|
||||
// {
|
||||
|
||||
if (length != 12)
|
||||
{
|
||||
// DisWritePass (SysInfo.LoginPass, QUEUE);
|
||||
// return;
|
||||
// }
|
||||
return;
|
||||
}
|
||||
// // 校验密码的合法性,只能出现数字
|
||||
// for (int i = 0; i < 6; i++)
|
||||
// {
|
||||
// if (data[index + i] > '9' || data[index + i] < '0')
|
||||
// {
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (data[index + i] > '9' || data[index + i] < '0')
|
||||
{
|
||||
//DisWritePass (SysInfo.LoginPass, QUEUE);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// SysSetLoginPass ( (char *) &data[index], length - 6);
|
||||
return;
|
||||
}
|
||||
}
|
||||
rt_memcpy(password,&data[index],6);
|
||||
ef_set_env("user_pass",password) ;
|
||||
dis_write_usrpwd(password);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -319,6 +365,63 @@ static void disctrl_handle (char *data, int length)
|
||||
ef_set_env ("max_open", setstr);
|
||||
break;
|
||||
}
|
||||
case DIS_CNUM_1PROT: // 修改1级保护
|
||||
{
|
||||
if (s_driver.identity == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
union
|
||||
{
|
||||
uint32_t Int;
|
||||
uint8_t Byte[4];
|
||||
} Int;
|
||||
Int.Byte[3] = data[index++];
|
||||
Int.Byte[2] = data[index++];
|
||||
Int.Byte[1] = data[index++];
|
||||
Int.Byte[0] = data[index++];
|
||||
rt_sprintf (setstr, "%d", Int.Int);
|
||||
ef_set_env ("curr1", setstr);
|
||||
break;
|
||||
}
|
||||
case DIS_CNUM_2PROT: // 修改1级保护
|
||||
{
|
||||
if (s_driver.identity == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
union
|
||||
{
|
||||
uint32_t Int;
|
||||
uint8_t Byte[4];
|
||||
} Int;
|
||||
Int.Byte[3] = data[index++];
|
||||
Int.Byte[2] = data[index++];
|
||||
Int.Byte[1] = data[index++];
|
||||
Int.Byte[0] = data[index++];
|
||||
rt_sprintf (setstr, "%d", Int.Int);
|
||||
ef_set_env ("curr2", setstr);
|
||||
break;
|
||||
}
|
||||
case DIS_CNUM_PROTK: // 修改1级保护
|
||||
{
|
||||
if (s_driver.identity == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
union
|
||||
{
|
||||
uint32_t Int;
|
||||
uint8_t Byte[4];
|
||||
} Int;
|
||||
Int.Byte[3] = data[index++];
|
||||
Int.Byte[2] = data[index++];
|
||||
Int.Byte[1] = data[index++];
|
||||
Int.Byte[0] = data[index++];
|
||||
rt_sprintf (setstr, "%d", Int.Int);
|
||||
ef_set_env ("openk", setstr);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -353,6 +456,18 @@ static void dis_write_ttflow (uint32_t ttflow)
|
||||
MX_UART_PutBuffer (&g_ViewDrv, tx_buf, p);
|
||||
}
|
||||
|
||||
// 更新电流
|
||||
static void dis_write_current (float current)
|
||||
{
|
||||
DisDataType_t ddtt;
|
||||
char tx_buf[128], p;
|
||||
ddtt.Addr.addr = DIS_CNUM_DBG_CUR;
|
||||
ddtt.type = DIS_TYPE_WD_FLOAT;
|
||||
ddtt.Float.Float = current;
|
||||
p = DisPreparePacket (ddtt, tx_buf, 128);
|
||||
MX_UART_PutBuffer (&g_ViewDrv, tx_buf, p);
|
||||
}
|
||||
|
||||
// 更新瞬时流量
|
||||
static void dis_write_mmflow (float mmFlow)
|
||||
{
|
||||
@@ -389,6 +504,33 @@ void dis_write_open (float open)
|
||||
MX_UART_PutBuffer (&g_ViewDrv, tx_buf, p);
|
||||
}
|
||||
|
||||
// 更新闸门开度 到调试界面
|
||||
void dis_write_open2debug (int open)
|
||||
{
|
||||
DisDataType_t ddtt;
|
||||
char tx_buf[128], p;
|
||||
ddtt.Addr.addr = DIS_CNUM_DBG_OPEN;
|
||||
ddtt.type = DIS_TYPE_WD_INT;
|
||||
ddtt.Int.Int = open;
|
||||
p = DisPreparePacket (ddtt, tx_buf, 128);
|
||||
MX_UART_PutBuffer (&g_ViewDrv, tx_buf, p);
|
||||
}
|
||||
|
||||
|
||||
// 播报语音 参数,第几段音频
|
||||
|
||||
void dis_write_audio (int k)
|
||||
{
|
||||
DisDataType_t ddtt;
|
||||
char tx_buf[128], p;
|
||||
//ddtt.Addr.addr = DIS_CNUM_SLGET;
|
||||
ddtt.type = DIS_TYPE_WD_AUDIO;
|
||||
ddtt.Int.Int = k;
|
||||
p = DisPreparePacket (ddtt, tx_buf, 128);
|
||||
elog_hexdump("lcd",16,tx_buf,p);
|
||||
MX_UART_PutBuffer (&g_ViewDrv, tx_buf, p);
|
||||
}
|
||||
|
||||
// 更新闸门荷重
|
||||
void dis_write_load (float load)
|
||||
{
|
||||
@@ -426,9 +568,52 @@ void dis_write_slmaxopen (uint32_t ecode)
|
||||
ddtt.Int.Int = ecode;
|
||||
p = DisPreparePacket (ddtt, tx_buf, 128);
|
||||
MX_UART_PutBuffer (&g_ViewDrv, tx_buf, p);
|
||||
|
||||
ddtt.Addr.addr = DIS_CNUM_MAX_OPEN;
|
||||
ddtt.type = DIS_TYPE_WD_INT;
|
||||
ddtt.Int.Int = ecode/10;
|
||||
p = DisPreparePacket (ddtt, tx_buf, 128);
|
||||
MX_UART_PutBuffer (&g_ViewDrv, tx_buf, p);
|
||||
//DIS_CNUM_MAX_OPEN
|
||||
}
|
||||
|
||||
|
||||
// 更新一级保护
|
||||
void dis_write_1prot (uint32_t data)
|
||||
{
|
||||
DisDataType_t ddtt;
|
||||
char tx_buf[128], p;
|
||||
ddtt.Addr.addr = DIS_CNUM_1PROT;
|
||||
ddtt.type = DIS_TYPE_WD_INT;
|
||||
ddtt.Int.Int = data;
|
||||
p = DisPreparePacket (ddtt, tx_buf, 128);
|
||||
MX_UART_PutBuffer (&g_ViewDrv, tx_buf, p);
|
||||
}
|
||||
|
||||
// 更新二级保护
|
||||
void dis_write_2prot (uint32_t data)
|
||||
{
|
||||
DisDataType_t ddtt;
|
||||
char tx_buf[128], p;
|
||||
ddtt.Addr.addr = DIS_CNUM_2PROT;
|
||||
ddtt.type = DIS_TYPE_WD_INT;
|
||||
ddtt.Int.Int = data;
|
||||
p = DisPreparePacket (ddtt, tx_buf, 128);
|
||||
MX_UART_PutBuffer (&g_ViewDrv, tx_buf, p);
|
||||
}
|
||||
|
||||
// 更新二级保护
|
||||
void dis_write_openk (uint32_t data)
|
||||
{
|
||||
DisDataType_t ddtt;
|
||||
char tx_buf[128], p;
|
||||
ddtt.Addr.addr = DIS_CNUM_PROTK;
|
||||
ddtt.type = DIS_TYPE_WD_INT;
|
||||
ddtt.Int.Int = data;
|
||||
p = DisPreparePacket (ddtt, tx_buf, 128);
|
||||
MX_UART_PutBuffer (&g_ViewDrv, tx_buf, p);
|
||||
}
|
||||
|
||||
// 发送给屏幕设备编号
|
||||
// 参数1:设备编号
|
||||
// 参数2:是否通过队列写入
|
||||
@@ -503,7 +688,7 @@ void dis_write_net_ste (int ste)
|
||||
}
|
||||
|
||||
// 修改电机状态
|
||||
void dis_write_motor_ste (int ste, int isqueue)
|
||||
void dis_write_motor_ste (int ste)
|
||||
{
|
||||
DisDataType_t ddtt;
|
||||
char tx_buf[128], p;
|
||||
@@ -551,12 +736,24 @@ void diw_write_load_ste (int ste)
|
||||
}
|
||||
|
||||
|
||||
void dis_write_err (int err)
|
||||
{
|
||||
DisDataType_t ddtt;
|
||||
char tx_buf[128], p;
|
||||
ddtt.type = DIS_TYPE_WD_INT;
|
||||
ddtt.Addr.addr = DIS_CNUM_DBG_ERR;
|
||||
ddtt.Int.Int = err;
|
||||
p = DisPreparePacket (ddtt, tx_buf, 128);
|
||||
MX_UART_PutBuffer (&g_ViewDrv, tx_buf, p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void thread_entry (void * argument)
|
||||
{
|
||||
char tx_buf[128], p;
|
||||
DisDataType_t ddtt;
|
||||
rt_kprintf ("%s was start!\r\n", __FILE__);
|
||||
log_i ("display was start!");
|
||||
g_ViewDrv.rxdone = view_rx_done;
|
||||
g_ViewDrv.BaudRate = 115200;
|
||||
MX_UART_Init (&g_ViewDrv);
|
||||
@@ -571,6 +768,15 @@ static void thread_entry (void * argument)
|
||||
s_driver.identity = 0;
|
||||
s = ef_get_env ("max_open");
|
||||
int32_t max_open = atoi (s);
|
||||
|
||||
s = ef_get_env ("curr1");
|
||||
int32_t curr1 = atoi (s);
|
||||
|
||||
s = ef_get_env ("curr2");
|
||||
int32_t curr2 = atoi (s);
|
||||
|
||||
s = ef_get_env ("openk");
|
||||
int32_t openk = atoi (s);
|
||||
// 载入参数
|
||||
dis_write_divice_id ( (char *) s_driver.device_id);
|
||||
dis_write_ipaddr ("mqtt.zyjzjs.cn");
|
||||
@@ -582,6 +788,14 @@ static void thread_entry (void * argument)
|
||||
dis_write_net_ste (0);
|
||||
dis_write_load (0);
|
||||
dis_write_code (SluiceData[0].ecode);
|
||||
dis_write_audio(0);
|
||||
|
||||
dis_write_1prot (curr1);
|
||||
|
||||
// 更新二级保护
|
||||
dis_write_2prot (curr2);
|
||||
// 更新二级保护
|
||||
dis_write_openk (openk) ;
|
||||
rt_timer_start (timer);
|
||||
while (1)
|
||||
{
|
||||
@@ -591,14 +805,26 @@ static void thread_entry (void * argument)
|
||||
{
|
||||
case MAIL_VIEW_FLUSH:
|
||||
// 刷新闸门开度
|
||||
|
||||
|
||||
//
|
||||
dis_write_open ( (float) SluiceData[0].gopen / 10);
|
||||
dis_write_load (0);
|
||||
dis_write_mmflow (0);
|
||||
dis_write_mmspeed (0);
|
||||
dis_write_ttflow (0);
|
||||
// dis_write_load ((float)WaterData[0].thisLevel/10); // 荷重或者压力
|
||||
dis_write_mmflow ((float)WaterData[0].thisFlow/100/3600);
|
||||
dis_write_mmspeed ((float)WaterData[0].thisLevel/100);
|
||||
dis_write_ttflow (WaterData[0].ttWater/100);
|
||||
dis_write_code (SluiceData[0].ecode);
|
||||
dis_write_motor_ste(1);
|
||||
dis_write_current ((float)SluiceData[0].currt/100);
|
||||
dis_write_open2debug(SluiceData[0].gopen);
|
||||
dis_write_load((float)SluiceData[0].lload/1000);
|
||||
dis_write_err(SluiceData[0].error); // SluiceData[i].error
|
||||
// dis_write_open ( (float)WaterData[0].thisLevel/1000);
|
||||
// dis_write_load ((float)WaterData[1].thisLevel/1000); // 荷重或者压力
|
||||
// dis_write_mmspeed ((float)WaterData[2].thisLevel/1000);
|
||||
// dis_write_audio(2);
|
||||
break;
|
||||
case MAIL_VIEW_READSL:
|
||||
case MAIL_VIEW_READSL: // 读取闸门开度
|
||||
ddtt.type = DIS_TYPE_RD;
|
||||
ddtt.Addr.addr = DIS_CNUM_SLSET;
|
||||
ddtt.Len = 2;
|
||||
@@ -608,14 +834,19 @@ static void thread_entry (void * argument)
|
||||
case MAIL_VIEW_LOGIN: // 登录
|
||||
|
||||
break;
|
||||
case MAIL_VIEW_NET_STE:
|
||||
case MAIL_VIEW_NET_STE: // 刷新网络状态
|
||||
ddtt.type = DIS_TYPE_WD_ICON;
|
||||
ddtt.Addr.addr = DIS_CSTE_NET;
|
||||
ddtt.Int.Int = mail.index;
|
||||
p = DisPreparePacket (ddtt, tx_buf, 128);
|
||||
MX_UART_PutBuffer (&g_ViewDrv, tx_buf, p);
|
||||
break;
|
||||
case MAIL_VIEW_AUDIO:
|
||||
dis_write_audio(mail.index);
|
||||
break;
|
||||
default:
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -625,6 +856,7 @@ static void thread_entry (void * argument)
|
||||
|
||||
if (RT_EOK == rt_event_recv (gUartEvents, EVENT_UART_VIEW_RX, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 300, RT_NULL)) // 数据接受失败,上报异常状态
|
||||
{
|
||||
elog_hexdump("lcd",16,g_ViewDrv.rx_buffer,g_ViewDrv.rx_size);
|
||||
for (int i = 0; i < g_ViewDrv.rx_size; i++)
|
||||
{
|
||||
if (g_ViewDrv.rx_buffer[i] == 0x5A)
|
||||
|
||||
+19
-4
@@ -35,6 +35,11 @@ ALIGN (RT_ALIGN_SIZE)
|
||||
static char thread_stack[2048];
|
||||
static struct rt_thread os_app;
|
||||
|
||||
#if !defined(LOG_TAG)
|
||||
#define LOG_TAG "os_app"
|
||||
#endif
|
||||
#include <elog.h>
|
||||
|
||||
static rt_timer_t locktimer;
|
||||
static void locktimerouter (void* parameter)
|
||||
{
|
||||
@@ -81,10 +86,10 @@ static void thread_entry (void *parameter)
|
||||
uint32_t id1 = HAL_GetUIDw0();
|
||||
uint32_t id2 = HAL_GetUIDw1();
|
||||
uint32_t id3 = HAL_GetUIDw2();
|
||||
rt_kprintf ("ID:%X %X %X\r\n", id1, id2, id3);
|
||||
rt_kprintf ("Version:%s,%s\r\n",__DATE__,__TIME__);
|
||||
rt_kprintf ("os-app running !\r\n");
|
||||
|
||||
log_i ("ID:%08X %08X %08X", id1, id2, id3);
|
||||
log_i ("Version:%s,%s",__DATE__,__TIME__);
|
||||
log_i ("os-app running !");
|
||||
//netWorkAesInit();
|
||||
while (1)
|
||||
{
|
||||
rt_thread_mdelay (500);
|
||||
@@ -127,4 +132,14 @@ void OsShellTask (void * argument)
|
||||
|
||||
|
||||
|
||||
void OsSendMail(rt_mailbox_t box,uint16_t type,uint16_t index)
|
||||
{
|
||||
TypeIndexMail_t mail;
|
||||
mail.Type = type;
|
||||
mail.index = index;
|
||||
rt_mb_send (box, * ( (uint32_t*) &mail));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+23
-4
@@ -90,6 +90,9 @@ void MJEth1ThreadStart (void);
|
||||
void UpgradeThreadStart (void);
|
||||
void RtcThreadStart (void);
|
||||
|
||||
|
||||
void OsSendMail(rt_mailbox_t box,uint16_t type,uint16_t index);
|
||||
|
||||
#define EVENT_CTRL_SET_OPT_SLU (1U<< 0) // 发送开度控制到提闸线程
|
||||
#define EVENT_CTRL_SET_STP_SLU (1U<< 1) // 发送停止控制到提闸线程
|
||||
#define EVENT_CTRL_SET_SUP_SLU (1U<< 2) // 发送上升控制到提闸线程
|
||||
@@ -124,16 +127,19 @@ void RtcThreadStart (void);
|
||||
#define EVENT_TRIG_COMM_RST (1U << 7) // MQTT 发送数据
|
||||
#define EVENT_TRIG_UPGRADE_RX (1U << 8) // MQTT 接受到数据
|
||||
#define EVENT_TRIG_NETMODE_TX2 (1U << 9) // 通过网络模块向通道2发送数据
|
||||
#define EVENT_TRIG_CAT1_SHUT (1U << 10) // 通过4G 模块关机
|
||||
#define EVENT_TRIG_ETH_SHUT (1U << 11) // 通过Eth 模块关机
|
||||
|
||||
|
||||
#define MAIL_COMM_HEART 0
|
||||
#define MAIL_COMM_REGIST 1
|
||||
#define MAIL_COMM_STAND 2
|
||||
#define MAIL_COMM_SLUICE 3
|
||||
#define MAIL_COMM_UPACK 4 // 提闸的ACK
|
||||
#define MAIL_COMM_SLACK 5 // 其他的ACK
|
||||
#define MAIL_COMM_READPARA 6 // 读取参数
|
||||
#define MAIL_COMM_ACK 7 // 读取参数
|
||||
#define MAIL_COMM_READPARA 4 // 读取参数
|
||||
#define MAIL_COMM_UPACK 5 // 升级的ACK
|
||||
#define MAIL_COMM_SLACK 6 // 提闸的ACK
|
||||
#define MAIL_COMM_WRACK 7 // 修改参数ACK
|
||||
#define MAIL_COMM_FACACK 8 // 出厂设置ACK
|
||||
|
||||
#define MAIL_SLUICE_OPT 0
|
||||
#define MAIL_SLUICE_STP 1
|
||||
@@ -146,12 +152,25 @@ void RtcThreadStart (void);
|
||||
#define MAIL_CT_SDW 2 // 下降
|
||||
#define MAIL_CT_STP 3 // 停止
|
||||
|
||||
#define MAIL_AUDIO_WEL 0 // 执行
|
||||
#define MAIL_AUDIO_LOAD 1 // 下降
|
||||
#define MAIL_AUDIO_OPEN 2 // 上升
|
||||
#define MAIL_AUDIO_UP 3 // 停止
|
||||
#define MAIL_AUDIO_DOWN 4 // 停止
|
||||
#define MAIL_AUDIO_STOP 5 // 停止
|
||||
#define MAIL_AUDIO_LOGIN_SUC 6 // 停止
|
||||
#define MAIL_AUDIO_LOGIN_FIL 7 // 停止
|
||||
#define MAIL_AUDIO_LOGIN_ADM 8 // 停止
|
||||
|
||||
|
||||
#define MAIL_VIEW_LOGIN 1 // 登录成功 需要跳转页面
|
||||
#define MAIL_VIEW_FLUSH 2 // 刷新界面显示
|
||||
#define MAIL_VIEW_READSL 3 // 读取闸门开度
|
||||
#define MAIL_VIEW_COD_STE 4 // 更新编码器状态
|
||||
#define MAIL_VIEW_NET_STE 5 // 更新网络状态
|
||||
#define MAIL_VIEW_SLU_STE 6 // 更新闸门状态
|
||||
#define MAIL_VIEW_AUDIO 7 // 播放语音
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+155
-34
@@ -2,54 +2,175 @@
|
||||
#include "math.h"
|
||||
#include "easyflash.h"
|
||||
#include "stdlib.h"
|
||||
#include "cjson.h"
|
||||
#include "rtthread.h"
|
||||
#include "user_config.h"
|
||||
|
||||
|
||||
#if !defined(LOG_TAG)
|
||||
#define LOG_TAG "simu"
|
||||
#endif
|
||||
#include <elog.h>
|
||||
|
||||
static const ParShallInfo_t ParShallTale[] =
|
||||
{
|
||||
{.w = 0, .c = 0, .m = 0},
|
||||
{.w = 0.152, .c = 0.381, .m = 1.58 , .minLeve = 0.03, .maxLeve = 0.45, .minFlow = 1.5 / 1000, .maxFlow = 100 / 1000},
|
||||
{.w = 0.25, .c = 0.561, .m = 1.513 , .minLeve = 0.03, .maxLeve = 0.60, .minFlow = 3.0 / 1000, .maxFlow = 250 / 1000},
|
||||
{.w = 0.30, .c = 0.679, .m = 1.521 , .minLeve = 0.03, .maxLeve = 0.75, .minFlow = 3.5 / 1000, .maxFlow = 400 / 1000},
|
||||
{.w = 0.45, .c = 1.038, .m = 1.537 , .minLeve = 0.03, .maxLeve = 0.75, .minFlow = 4.5 / 1000, .maxFlow = 630 / 1000},
|
||||
{.w = 0.60, .c = 1.403, .m = 1.548 , .minLeve = 0.05, .maxLeve = 0.75, .minFlow = 12.5 / 1000, .maxFlow = 850 / 1000},
|
||||
{.w = 0.75, .c = 1.772, .m = 1.557 , .minLeve = 0.06, .maxLeve = 0.75, .minFlow = 25.0 / 1000, .maxFlow = 1100 / 1000},
|
||||
{.w = 0.90, .c = 2.147, .m = 1.565 , .minLeve = 0.06, .maxLeve = 0.75, .minFlow = 30.0 / 1000, .maxFlow = 1250 / 1000},
|
||||
{.w = 1.00, .c = 2.397, .m = 1.569 , .minLeve = 0.06, .maxLeve = 0.80, .minFlow = 30.0 / 1000, .maxFlow = 1500 / 1000},
|
||||
{.w = 1.20, .c = 2.904, .m = 1.577 , .minLeve = 0.06, .maxLeve = 0.80, .minFlow = 35.0 / 1000, .maxFlow = 2000 / 1000},
|
||||
{.w = 1.50, .c = 3.668, .m = 1.586 , .minLeve = 0.06, .maxLeve = 0.80, .minFlow = 45.0 / 1000, .maxFlow = 2500 / 1000},
|
||||
{.w = 1.80, .c = 4.440, .m = 1.593 , .minLeve = 0.08, .maxLeve = 0.80, .minFlow = 80.0 / 1000, .maxFlow = 3000 / 1000},
|
||||
{.w = 2.10, .c = 5.222, .m = 1.599 , .minLeve = 0.08, .maxLeve = 0.80, .minFlow = 95.0 / 1000, .maxFlow = 3600 / 1000},
|
||||
{.w = 2.40, .c = 6.004, .m = 1.605 , .minLeve = 0.08, .maxLeve = 0.80, .minFlow = 100.0 / 1000,.maxFlow = 4000 / 1000},
|
||||
|
||||
{.w = 3.05, .c = 7.463, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.07, .minFlow = 0.16, .maxFlow = 8.28},
|
||||
{.w = 3.66, .c = 8.859, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.37, .minFlow = 0.19, .maxFlow = 14.68},
|
||||
{.w = 4.57, .c = 10.96, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.67, .minFlow = 0.23, .maxFlow = 25.04},
|
||||
{.w = 6.10, .c = 14.45, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.31, .maxFlow = 37.97},
|
||||
|
||||
{.w = 7.62, .c = 17.94, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.38, .maxFlow = 47.16},
|
||||
{.w = 9.14, .c = 21.44, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.46, .maxFlow = 56.33},
|
||||
{.w = 12.19, .c = 28.43, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.60, .maxFlow = 74.70},
|
||||
{.w = 15.24, .c = 35.41, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.75, .maxFlow = 93.04},
|
||||
|
||||
} ;
|
||||
|
||||
// 两点法计算k,b
|
||||
//uint16_t math_k(uint32_t x0,uint32_t y0,uint32_t x1,uint32_t y1)
|
||||
//{
|
||||
// uint16_t k;
|
||||
// k = (y0-x0)/(y1-x1);
|
||||
// return k;
|
||||
//}
|
||||
double math_k(double x0,double y0,double x1,double y1)
|
||||
{
|
||||
double k;
|
||||
k = (y1-y0)/(x1-x0);
|
||||
return k;
|
||||
}
|
||||
|
||||
//uint16_t math_k(uint32_t x0,uint32_t y0,uint32_t x1,uint32_t y1)
|
||||
//{
|
||||
// uint16_t k;
|
||||
// k = (y0-x0)/(y1-x1);
|
||||
// return k;
|
||||
//}
|
||||
double math_b(double k,double x,double y)
|
||||
{
|
||||
double b;
|
||||
b = y - (k*x);
|
||||
return b;
|
||||
}
|
||||
|
||||
//WaterLeveInfo_t Info = {
|
||||
// .Y[0] = 2,
|
||||
//};
|
||||
|
||||
// k=(y2-y1)/(x2-x1)
|
||||
|
||||
typedef struct SimflowPara_t
|
||||
{
|
||||
double leve[11];
|
||||
double flow[11];
|
||||
int pallid ;
|
||||
}SimflowPara_t;
|
||||
|
||||
// 水位流量关系表
|
||||
//uint16_t WaterLeveCalc(int leve,int Open)
|
||||
//{
|
||||
// for (int i =0;i< 100;i++)
|
||||
// {
|
||||
// if (LeveInfo.X[i] > Open)
|
||||
// {
|
||||
// for (int j =0;j < 100;i++)
|
||||
// {
|
||||
// if (LeveInfo.Key[i].Y[j] >leve)
|
||||
// {
|
||||
// return LeveInfo.Key[i].Key[j];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return 0;
|
||||
//}
|
||||
static SimflowPara_t g_para = {
|
||||
.leve = {0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1},
|
||||
.flow = {0,0.036,0.105,0.200,0.317,0.454,0.713,0.897,0.955,1.015,1.025},
|
||||
.pallid = 7
|
||||
};
|
||||
|
||||
|
||||
|
||||
int32_t ParShallCalc(int index,double leve)
|
||||
// 水位流量关系表初始化
|
||||
void SimuFlowInit(void)
|
||||
{
|
||||
char *p ;
|
||||
double flow = 0;
|
||||
flow = ParShallTale[index].c * pow(leve,ParShallTale[index].m);
|
||||
return (int32_t )(flow *100);
|
||||
p = ef_get_env ("parshall");
|
||||
g_para.pallid = atoi (p); // 巴歇尔流量计槽号
|
||||
|
||||
rt_kprintf("parshall:%d\r\n",g_para.pallid);
|
||||
|
||||
#ifdef SYK_06_18_SM
|
||||
ef_set_env ("simu_flow","1");
|
||||
ef_set_env("level","[0.1,0.18,0.26,0.34,0.42,0.5,0.58,0.66,0.74,0.8]");
|
||||
ef_set_env("flow","[0.031,0.081,0.149,0.233,0.33,0.44,0.562,0.695,0.84,0.955]");
|
||||
#endif
|
||||
|
||||
#ifdef SYK_08_18_SM
|
||||
ef_set_env ("simu_flow","1");
|
||||
ef_set_env("level","[0.1,0.18,0.26,0.34,0.42,0.5,0.58,0.66,0.74,0.8]");
|
||||
ef_set_env("flow","[0.043,0.113,0.206,0.32,0.453,0.603,0.769,0.951,1.147,1.304]");
|
||||
#endif
|
||||
|
||||
#ifdef SYK_10_18_SM
|
||||
ef_set_env ("simu_flow","1");
|
||||
ef_set_env("level","[0.1,0.18,0.26,0.34,0.42,0.5,0.58,0.66,0.74,0.8]");
|
||||
ef_set_env("flow","[0.058,0.146,0.261,0.397,0.553,0.728,0.918,1.125,1.346,1.522]");
|
||||
#endif
|
||||
cJSON *root = NULL;
|
||||
// 水位表
|
||||
p = ef_get_env ("level") ;
|
||||
root = cJSON_Parse (p);
|
||||
int size = cJSON_GetArraySize (root);
|
||||
if(size != 10)
|
||||
{
|
||||
cJSON_Delete (root);
|
||||
return ;
|
||||
}
|
||||
for (int i = 1; i < 11; i++)
|
||||
{
|
||||
g_para.leve[i] = cJSON_GetNumberValue (cJSON_GetArrayItem (root, i-1)); // 接入设备类型
|
||||
}
|
||||
// 流量表
|
||||
p = ef_get_env ("flow") ;
|
||||
root = cJSON_Parse (p);
|
||||
size = cJSON_GetArraySize (root);
|
||||
if(size != 10)
|
||||
{
|
||||
cJSON_Delete (root);
|
||||
return ;
|
||||
}
|
||||
for (int i = 1; i < 11; i++)
|
||||
{
|
||||
g_para.flow[i] = cJSON_GetNumberValue (cJSON_GetArrayItem (root, i-1)); // 接入设备类型
|
||||
}
|
||||
cJSON_Delete (root);
|
||||
rt_kprintf("leve( mm):");
|
||||
for (int i =0; i< 11;i++)
|
||||
{
|
||||
rt_kprintf("%6d,",(int)(g_para.leve[i] * 1000));
|
||||
}
|
||||
rt_kprintf("\r\nflow(dm3):");
|
||||
for (int i =0; i< 11;i++)
|
||||
{
|
||||
rt_kprintf("%6d,",(int)(g_para.flow[i]*1000));
|
||||
}
|
||||
rt_kprintf("\r\n");
|
||||
}
|
||||
|
||||
// 水位流量关系表 单位cm
|
||||
int32_t WaterLeveCalc(double leve)
|
||||
{
|
||||
double k,b;
|
||||
double flow;
|
||||
if((leve == 0) ||(leve >= g_para.leve[10]) )
|
||||
return 0;
|
||||
for (int i =0;i< 11;i++)
|
||||
{
|
||||
if (leve < g_para.leve[i])
|
||||
{
|
||||
k = math_k((double)g_para.leve[i-1],(double)g_para.flow[i-1],(double)g_para.leve[i],(double)g_para.flow[i]) ;
|
||||
b = math_b(k,(double)g_para.leve[i],(double)g_para.flow[i]);
|
||||
flow = k *leve +b;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (int32_t )(flow *1000);
|
||||
}
|
||||
|
||||
|
||||
int32_t ParShallCalc(double leve)
|
||||
{
|
||||
char * p;
|
||||
double flow = 0;
|
||||
flow = ParShallTale[g_para.pallid].c * pow(leve,ParShallTale[g_para.pallid].m);
|
||||
return (int32_t )(flow *1000);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#ifndef _SIM_FLOW_H
|
||||
#define _SIM_FLOW_H
|
||||
int32_t ParShallCalc(int index,double leve);
|
||||
|
||||
void SimuFlowInit(void);
|
||||
int32_t ParShallCalc(double leve);
|
||||
int32_t WaterLeveCalc(double leve);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+19
-99
@@ -1,5 +1,6 @@
|
||||
#include "data.h"
|
||||
#include <rtthread.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
|
||||
@@ -9,14 +10,19 @@
|
||||
******************************************/
|
||||
volatile const char _makeData[] = __DATE__; //12字节,编译日期
|
||||
volatile const char _makeTime[] = __TIME__; //9字节
|
||||
volatile const char cBootv[] = "Ver3.0.0"; //获取时添加上面两个时间信息,最大长度64字节
|
||||
//第一个字节环境变量修改时增加序号 第二个字节
|
||||
volatile const char cBootv[] = "Ver5.0.11"; //
|
||||
char _versionTemp[64];
|
||||
int g_cat1_log_enable = 0 ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<<<<<<< HEAD
|
||||
const StrIndex_t cDownDataType[] =
|
||||
{
|
||||
|
||||
{"run",DownRun} ,
|
||||
{"stop",DownStop} ,
|
||||
{"open",DownOpen} ,
|
||||
@@ -28,28 +34,13 @@ const StrIndex_t cDownDataType[] =
|
||||
{"config",DownConfig},
|
||||
{"read",DownRead} ,
|
||||
{"fact",DownFact}
|
||||
=======
|
||||
const StrIndex_t cDownDataType[] =
|
||||
{
|
||||
{"run",DownRun} ,
|
||||
{"stop",DownStop} ,
|
||||
{"open",DownOpen} ,
|
||||
{"close",DownClose} ,
|
||||
{"reg_ans",DownRegistAns} ,
|
||||
{"heart_ans",DownHeartAns},
|
||||
{"update",DownUpdate},
|
||||
{"reboot",DownReboot},
|
||||
{"config",DownConfig},
|
||||
{"read",DownRead} ,
|
||||
{"fact",DownFact}
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
const StrIndex_t cSiteType[] =
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
{"sluice",SiteSluice} ,
|
||||
{"flow",SiteFlow} ,
|
||||
{"press",SiteSee} ,
|
||||
@@ -57,33 +48,17 @@ const StrIndex_t cSiteType[] =
|
||||
{"trans",SiteServer} ,
|
||||
{"level",SiteLevel},
|
||||
{"skew",SiteSkew} //测斜仪
|
||||
=======
|
||||
{"sluice",SiteSluice} ,
|
||||
{"flow",SiteFlow} ,
|
||||
{"press",SiteSee} ,
|
||||
{"auto",SiteColl} , // 自动化采集站
|
||||
{"trans",SiteServer} ,
|
||||
{"level",SiteLevel},
|
||||
{"skew",SiteSkew} //测斜仪
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
};
|
||||
|
||||
|
||||
const StrIndex_t cMotorType[] =
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
|
||||
{"mg1000",MT_MG_1000} ,
|
||||
{"qh100", MT_QH_V100} ,
|
||||
{"qh200", MT_QH_V200} ,
|
||||
{"zs100", MT_ZS_V100} ,
|
||||
{"jz200", MT_JZ_V200} , // 金志 4-20 ma
|
||||
=======
|
||||
{"mg1000",MT_MG_1000} ,
|
||||
{"qh100", MT_QH_V100} ,
|
||||
{"qh200", MT_QH_V200} ,
|
||||
{"zs100", MT_ZS_V100} ,
|
||||
{"jz200", MT_JZ_V200} , // 金志 4-20 ma
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
{"dy100", MT_DY_V100}, // 大禹锥型阀
|
||||
{"kg100", MT_KG_V100}, // 开关量模块
|
||||
{"kr100", MT_KR_V100}, // 闸位计
|
||||
@@ -93,7 +68,7 @@ const StrIndex_t cMotorType[] =
|
||||
|
||||
const StrIndex_t c4851Type[] =
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
|
||||
{"mg1000", ST_MG_1000},
|
||||
{"qh100", ST_QH_V100},
|
||||
{"qh200", ST_QH_V200},
|
||||
@@ -102,14 +77,7 @@ const StrIndex_t c4851Type[] =
|
||||
{"kg100", ST_KG_V100},
|
||||
{"at100", ST_AT_V100},
|
||||
{"kr100", ST_KR_V100},
|
||||
=======
|
||||
{"mg1000",ST_MG_1000} ,
|
||||
{"qh100",ST_QH_V100} ,
|
||||
{"qh200",ST_QH_V200} ,
|
||||
{"dy100",ST_DY_V100} ,
|
||||
{"kg100",ST_KG_V100} ,
|
||||
{"at100",ST_AT_V100} ,
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
|
||||
};
|
||||
|
||||
const StrIndex_t cU485Type[] =
|
||||
@@ -118,7 +86,7 @@ const StrIndex_t cU485Type[] =
|
||||
};
|
||||
|
||||
// 485 2 通道
|
||||
<<<<<<< HEAD
|
||||
|
||||
const StrIndex_t c4852Type[] =
|
||||
{
|
||||
{"rds600", ST_RDS_600},
|
||||
@@ -127,49 +95,12 @@ const StrIndex_t c4852Type[] =
|
||||
{"zkjszk", ST_ZK_JSZK},
|
||||
{"djx100", ST_DJX_100},
|
||||
{"rds300", ST_RDS_300},
|
||||
{"mi600", ST_MI_600} // 测斜仪
|
||||
=======
|
||||
const StrIndex_t c4852Type[] =
|
||||
{
|
||||
{"rds600",ST_RDS_600} ,
|
||||
{"tds300",ST_TDS_300} ,
|
||||
{"ht100",ST_HT_V100} ,
|
||||
{"zkjszk",ST_ZK_JSZK},
|
||||
{"djx100",ST_DJX_100},
|
||||
{"rds300",ST_RDS_300},
|
||||
{"mi600",ST_MI_600} // 测斜仪
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
{"mi600", ST_MI_600}, // 测斜仪
|
||||
{"ht200", ST_HT_V200} // 华天压力计
|
||||
};
|
||||
|
||||
|
||||
const ParShallInfo_t ParShallTale[] =
|
||||
{
|
||||
{.w = 0, .c = 0, .m = 0},
|
||||
{.w = 0.152, .c = 0.381, .m = 1.58 , .minLeve = 0.03, .maxLeve = 0.45, .minFlow = 1.5 / 1000, .maxFlow = 100 / 1000},
|
||||
{.w = 0.25, .c = 0.561, .m = 1.513 , .minLeve = 0.03, .maxLeve = 0.60, .minFlow = 3.0 / 1000, .maxFlow = 250 / 1000},
|
||||
{.w = 0.30, .c = 0.679, .m = 1.521 , .minLeve = 0.03, .maxLeve = 0.75, .minFlow = 3.5 / 1000, .maxFlow = 400 / 1000},
|
||||
{.w = 0.45, .c = 1.038, .m = 1.537 , .minLeve = 0.03, .maxLeve = 0.75, .minFlow = 4.5 / 1000, .maxFlow = 630 / 1000},
|
||||
{.w = 0.60, .c = 1.403, .m = 1.548 , .minLeve = 0.05, .maxLeve = 0.75, .minFlow = 12.5 / 1000, .maxFlow = 850 / 1000},
|
||||
{.w = 0.75, .c = 1.772, .m = 1.557 , .minLeve = 0.06, .maxLeve = 0.75, .minFlow = 25.0 / 1000, .maxFlow = 1100 / 1000},
|
||||
{.w = 0.90, .c = 2.147, .m = 1.565 , .minLeve = 0.06, .maxLeve = 0.75, .minFlow = 30.0 / 1000, .maxFlow = 1250 / 1000},
|
||||
{.w = 1.00, .c = 2.397, .m = 1.569 , .minLeve = 0.06, .maxLeve = 0.80, .minFlow = 30.0 / 1000, .maxFlow = 1500 / 1000},
|
||||
{.w = 1.20, .c = 2.904, .m = 1.577 , .minLeve = 0.06, .maxLeve = 0.80, .minFlow = 35.0 / 1000, .maxFlow = 2000 / 1000},
|
||||
{.w = 1.50, .c = 3.668, .m = 1.586 , .minLeve = 0.06, .maxLeve = 0.80, .minFlow = 45.0 / 1000, .maxFlow = 2500 / 1000},
|
||||
{.w = 1.80, .c = 4.440, .m = 1.593 , .minLeve = 0.08, .maxLeve = 0.80, .minFlow = 80.0 / 1000, .maxFlow = 3000 / 1000},
|
||||
{.w = 2.10, .c = 5.222, .m = 1.599 , .minLeve = 0.08, .maxLeve = 0.80, .minFlow = 95.0 / 1000, .maxFlow = 3600 / 1000},
|
||||
{.w = 2.40, .c = 6.004, .m = 1.605 , .minLeve = 0.08, .maxLeve = 0.80, .minFlow = 100.0 / 1000, .maxFlow = 4000 / 1000},
|
||||
|
||||
{.w = 3.05, .c = 7.463, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.07, .minFlow = 0.16, .maxFlow = 8.28},
|
||||
{.w = 3.66, .c = 8.859, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.37, .minFlow = 0.19, .maxFlow = 14.68},
|
||||
{.w = 4.57, .c = 10.96, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.67, .minFlow = 0.23, .maxFlow = 25.04},
|
||||
{.w = 6.10, .c = 14.45, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.31, .maxFlow = 37.97},
|
||||
|
||||
{.w = 7.62, .c = 17.94, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.38, .maxFlow = 47.16},
|
||||
{.w = 9.14, .c = 21.44, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.46, .maxFlow = 56.33},
|
||||
{.w = 12.19, .c = 28.43, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.60, .maxFlow = 74.70},
|
||||
{.w = 15.24, .c = 35.41, .m = 1.6 , .minLeve = 0.09, .maxLeve = 1.83, .minFlow = 0.75, .maxFlow = 93.04},
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
@@ -179,14 +110,11 @@ WaterData_t WaterData[WATER_COUTN];
|
||||
InclinometerData_t IncData[6]; // 测斜仪数据
|
||||
|
||||
SysData_t SysData;
|
||||
<<<<<<< HEAD
|
||||
|
||||
SOFTRTC_t g_SoftRtc =
|
||||
{
|
||||
23, 10, 1, 0, 0, 0
|
||||
=======
|
||||
SOFTRTC_t g_SoftRtc = {
|
||||
23,10,1,0,0,0
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
|
||||
};
|
||||
|
||||
uint32_t g_ifconfig = 0;
|
||||
@@ -208,10 +136,8 @@ int cMotorGetType (char * str)
|
||||
|
||||
int c4851GetType (char * str)
|
||||
{
|
||||
rt_kprintf ("485 option count:%d\r\n", sizeof (c4851Type) / sizeof (StrIndex_t)) ;
|
||||
for (int i = 0; i < sizeof (c4851Type) / sizeof (StrIndex_t); i++)
|
||||
{
|
||||
rt_kprintf ("%s,%s\r\n", str, c4851Type[i].str) ;
|
||||
if (rt_memcmp (str, c4851Type[i].str, rt_strlen (str)) == 0)
|
||||
{
|
||||
return c4851Type[i].index;
|
||||
@@ -278,19 +204,13 @@ int cSiteType2Index (char * str)
|
||||
/**********************************************
|
||||
获取boot版本信息
|
||||
**********************************************/
|
||||
<<<<<<< HEAD
|
||||
|
||||
void *GetVersion(void)
|
||||
{
|
||||
int i = rt_sprintf(_versionTemp,"%s-%s %s",cBootv, _makeData, _makeTime);
|
||||
_versionTemp[i] = 0;
|
||||
return (void*)_versionTemp;
|
||||
=======
|
||||
void *GetVersion(void)
|
||||
{
|
||||
int i = rt_sprintf(_versionTemp,"%s-%s %s",cBootv, _makeData, _makeTime);
|
||||
_versionTemp[i] = 0;
|
||||
return (void*)_versionTemp;
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+29
-29
@@ -1,13 +1,26 @@
|
||||
#ifndef _DATA_H
|
||||
#define _DATA_H
|
||||
#include <stdint.h>
|
||||
#include "user_config.h"
|
||||
|
||||
|
||||
#ifdef USER_MINLE_CHAN2
|
||||
|
||||
|
||||
#define SLUICE_COUTN 1// 当前处理几口闸
|
||||
#define SUBTOPIC_COUNT 2 // 订阅topic 数量
|
||||
|
||||
#else
|
||||
|
||||
#define SLUICE_COUTN 1// 当前处理几口闸
|
||||
#define SUBTOPIC_COUNT 1 // 订阅topic 数量
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define WATER_COUTN 6// 当前接入n个流量计
|
||||
|
||||
#define SUBTOPIC_COUNT 1 // 订阅topic 数量
|
||||
|
||||
#define SLUCIE_EXEC_COUNT 20// 闸门异常时间
|
||||
|
||||
|
||||
@@ -25,6 +38,7 @@
|
||||
|
||||
extern uint32_t g_ifconfig;
|
||||
extern uint32_t g_ifupdate;
|
||||
extern int g_cat1_log_enable ;
|
||||
|
||||
typedef struct StrIndex_t
|
||||
{
|
||||
@@ -70,6 +84,8 @@ typedef struct SluiceData_t
|
||||
int32_t rload; // 右荷重 单位 kg
|
||||
int32_t ecode; // 编码器原始数据
|
||||
int32_t currt; // 设备电流
|
||||
int32_t error; // 错误编码
|
||||
int32_t state; // 状态
|
||||
} SluiceData_t;
|
||||
|
||||
|
||||
@@ -86,6 +102,7 @@ typedef struct SysData_t
|
||||
int scram; // 急停被按下
|
||||
char fileName[64]; // 文件名
|
||||
int fileSize; // 文件大小
|
||||
|
||||
} SysData_t;
|
||||
|
||||
typedef struct SOFTRTC_t
|
||||
@@ -96,11 +113,9 @@ typedef struct SOFTRTC_t
|
||||
uint8_t hour;
|
||||
uint8_t minutes;
|
||||
uint8_t second;
|
||||
<<<<<<< HEAD
|
||||
|
||||
}SOFTRTC_t;
|
||||
=======
|
||||
}SOFTRTC_t;
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -122,11 +137,9 @@ typedef struct WaterData_t
|
||||
int32_t thisSpeed; // 流速
|
||||
int32_t thisPress; // 压力
|
||||
int32_t thisTemp; // 温度
|
||||
<<<<<<< HEAD
|
||||
|
||||
int retry ; // 重试次数
|
||||
=======
|
||||
int retry ; // 重试次数
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
|
||||
} WaterData_t;
|
||||
|
||||
|
||||
@@ -173,6 +186,7 @@ typedef enum S4852Type_t
|
||||
ST_DJX_100, // 丁家峡闸门 读取开度
|
||||
ST_RDS_300, // 雷达流量计
|
||||
ST_MI_600, // 鹦鸽嘴测斜仪
|
||||
ST_HT_V200, // 华天压力计
|
||||
} S4852Type_t;
|
||||
|
||||
|
||||
@@ -194,11 +208,9 @@ typedef enum SiteType_t
|
||||
SiteServer, // 串口服务器
|
||||
SiteLevel, // 水位站
|
||||
SiteSkew // 测斜仪
|
||||
<<<<<<< HEAD
|
||||
|
||||
} SiteType_t;
|
||||
=======
|
||||
}SiteType_t;
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
|
||||
|
||||
|
||||
typedef enum DownDataType_t
|
||||
@@ -214,11 +226,8 @@ typedef enum DownDataType_t
|
||||
DownConfig = 8, // 修改参数
|
||||
DownRead = 9, // 读取参数
|
||||
DownFact = 10, // 读取参数
|
||||
<<<<<<< HEAD
|
||||
} DownDataType_t;
|
||||
=======
|
||||
}DownDataType_t;
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -236,19 +245,13 @@ typedef struct TypeIndexMail_t
|
||||
|
||||
extern SluiceData_t SluiceData[SLUICE_COUTN];
|
||||
extern WaterData_t WaterData[WATER_COUTN];
|
||||
<<<<<<< HEAD
|
||||
|
||||
extern InclinometerData_t IncData[6];
|
||||
extern SysData_t SysData;
|
||||
extern const WaterLeveInfo_t LeveInfo;
|
||||
extern const ParShallInfo_t ParShallTale[];
|
||||
extern SOFTRTC_t g_SoftRtc;
|
||||
=======
|
||||
extern InclinometerData_t IncData[6];
|
||||
extern SysData_t SysData;
|
||||
extern const WaterLeveInfo_t LeveInfo;
|
||||
extern const ParShallInfo_t ParShallTale[];
|
||||
extern SOFTRTC_t g_SoftRtc;
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
|
||||
|
||||
|
||||
int cMotorGetType (char * str);
|
||||
@@ -269,11 +272,8 @@ int cDownType2Index (char * str);
|
||||
int cSiteType2Index (char * str);
|
||||
|
||||
|
||||
<<<<<<< HEAD
|
||||
void *GetVersion (void);
|
||||
=======
|
||||
void *GetVersion(void);
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+8
-18
@@ -14,38 +14,30 @@ DIState_t MX_Din_Pull (int chann)
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
|
||||
ret = (DIState_t) HAL_GPIO_ReadPin (DI2_GPIO_Port, DI2_Pin);
|
||||
=======
|
||||
ret = (DIState_t)HAL_GPIO_ReadPin (DI2_GPIO_Port, DI2_Pin);
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
break;
|
||||
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
|
||||
ret = (DIState_t) HAL_GPIO_ReadPin (DI3_GPIO_Port, DI3_Pin);
|
||||
=======
|
||||
ret = (DIState_t)HAL_GPIO_ReadPin (DI3_GPIO_Port, DI3_Pin);
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
break;
|
||||
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
|
||||
ret = (DIState_t) HAL_GPIO_ReadPin (DI4_GPIO_Port, DI4_Pin);
|
||||
=======
|
||||
ret = (DIState_t)HAL_GPIO_ReadPin (DI4_GPIO_Port, DI4_Pin);
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
break;
|
||||
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
|
||||
ret = (DIState_t) HAL_GPIO_ReadPin (DI5_GPIO_Port, DI5_Pin);
|
||||
=======
|
||||
ret = (DIState_t)HAL_GPIO_ReadPin (DI5_GPIO_Port, DI5_Pin);
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
@@ -56,5 +48,3 @@ DIState_t MX_Din_Pull (int chann)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
+1
-4
@@ -5,11 +5,8 @@ typedef enum DIState_t
|
||||
{
|
||||
DI_HIGH = 1,
|
||||
DI_LOW = 0
|
||||
<<<<<<< HEAD
|
||||
|
||||
}DIState_t;
|
||||
=======
|
||||
}DIState_t;
|
||||
>>>>>>> 3a537f633c99d30fa3fe5d01105f6525a48d3d72
|
||||
|
||||
void DiInit (void);
|
||||
DIState_t MX_Din_Pull (int chann);
|
||||
|
||||
@@ -4,3 +4,4 @@
|
||||
void MX_Dout_Push (int index, int pwm);
|
||||
|
||||
#endif
|
||||
|
||||
+58
-27
@@ -14,7 +14,7 @@
|
||||
|
||||
|
||||
#if !defined(LOG_TAG)
|
||||
#define LOG_TAG "CAT1"
|
||||
#define LOG_TAG "cat1"
|
||||
#endif
|
||||
#include <elog.h>
|
||||
|
||||
@@ -26,15 +26,19 @@ static char tcprxbbuff[1200];
|
||||
static char tcptxbbuff[1200];
|
||||
|
||||
|
||||
netDrv_t g_cat1Drv =
|
||||
|
||||
|
||||
|
||||
netDrvInfo_t g_cat1Drv =
|
||||
{
|
||||
0, // 信号值
|
||||
"", // iccid
|
||||
Init, // 状态
|
||||
tcprxbbuff, // 接受缓存
|
||||
0, // 接受数据长度
|
||||
tcptxbbuff, // 发送数据缓存
|
||||
0, // 发送数据长度
|
||||
.Csq = 0, // 信号值
|
||||
.Iccid = "", // iccid
|
||||
.State = Init, // 状态
|
||||
.rxbuff = tcprxbbuff, // 接受缓存
|
||||
.rx_size = 0, // 接受数据长度
|
||||
.txbuff = tcptxbbuff, // 发送数据缓存
|
||||
.tx_size = 0,
|
||||
.IsEnable = 1, // 发送数据长度
|
||||
|
||||
};
|
||||
|
||||
@@ -48,7 +52,7 @@ static void ec200_resp_csq_callback (char * data, uint16_t length)
|
||||
p = strstr (data, "+CSQ:");
|
||||
p = p + 6;
|
||||
g_cat1Drv.Csq = atoi (p);
|
||||
rt_kprintf ("CSQ: <<< <%d>\r\n", g_cat1Drv.Csq);
|
||||
log_i ("CSQ: <<< <%d>", g_cat1Drv.Csq);
|
||||
}
|
||||
|
||||
// 校准时间程序
|
||||
@@ -75,7 +79,7 @@ static void ec200_resp_qlts_callback (char * data, uint16_t length)
|
||||
p = p + 3; // p
|
||||
k[5] = atoi (p); // 秒
|
||||
k[5] = (k[5] + (k[5] / 10) * 6) ;
|
||||
rt_kprintf ("20%02x-%02x-%02x %02x:%02x:%02x\r\n", k[0], k[1], k[2], k[3], k[4], k[5]);
|
||||
log_i ("DateTime:20%02x-%02x-%02x %02x:%02x:%02x", k[0], k[1], k[2], k[3], k[4], k[5]);
|
||||
|
||||
}
|
||||
|
||||
@@ -87,7 +91,7 @@ static void ec200_resp_iccid_callback (char * data, uint16_t length)
|
||||
p = p + 8;
|
||||
rt_memset (SysData.iccid, 0, 32);
|
||||
rt_memcpy (SysData.iccid, p, 20);
|
||||
rt_kprintf ("ICCID: <<< <%d> [%s]\r\n", length, SysData.iccid);
|
||||
log_i ("ICCID: [%s]", SysData.iccid);
|
||||
}
|
||||
|
||||
static void ec200_resp_qird_callback (char * data, uint16_t length)
|
||||
@@ -115,6 +119,9 @@ static void ec200_resp_qird_callback (char * data, uint16_t length)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// type 0 无需打包 1 需要重新打包
|
||||
const struct
|
||||
{
|
||||
@@ -158,14 +165,20 @@ static CommRet_T cat1_sendcmd_and_responce (int time, char * tx, int size, char
|
||||
{
|
||||
MX_UART_Clear (&g_GSMDrv);
|
||||
MX_UART_PutBuffer (&g_GSMDrv, tx, size);
|
||||
//rt_kprintf ("%.*s", size, tx) ;
|
||||
if (g_cat1_log_enable == 1)
|
||||
{
|
||||
elog_hexdump ("cat1tx", 16, tx, size);
|
||||
}
|
||||
//timeout = cat1list[i].waitms;
|
||||
int timeout = time;
|
||||
while (timeout--)
|
||||
{
|
||||
if (RT_EOK == rt_event_recv (gUartEvents, EVENT_UART_GSM_RX, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 0, RT_NULL))
|
||||
if (RT_EOK == rt_event_recv (gUartEvents, EVENT_UART_GSM_RX, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 3, RT_NULL))
|
||||
{
|
||||
//rt_kprintf ("[%.*s]", g_GSMDrv.rx_size, g_GSMDrv.rx_buffer) ;
|
||||
if (g_cat1_log_enable == 1)
|
||||
{
|
||||
elog_hexdump ("cat1rx", 16, g_GSMDrv.rx_buffer, g_GSMDrv.rx_size) ;
|
||||
}
|
||||
if (NULL != rt_strstr ( (char *) g_GSMDrv.rx_buffer, ack))
|
||||
{
|
||||
if (call != NULL)
|
||||
@@ -176,7 +189,7 @@ static CommRet_T cat1_sendcmd_and_responce (int time, char * tx, int size, char
|
||||
}
|
||||
MX_UART_Clear (&g_GSMDrv);
|
||||
}
|
||||
rt_thread_mdelay (1);
|
||||
//rt_thread_mdelay (3);
|
||||
}
|
||||
return RetErr; // 超时
|
||||
}
|
||||
@@ -200,15 +213,22 @@ static void thread_entry (void * argument)
|
||||
rt_sprintf (at_cmd, "AT+QIOPEN=1,0,\"TCP\",\"%s\",%d,0,0\r", ipaddr, ipport);
|
||||
g_GSMDrv.rxdone = cat1_rx_done;
|
||||
g_GSMDrv.BaudRate = 115200;
|
||||
MX_UART_Init (&g_GSMDrv);
|
||||
// 启动4G 模块电源
|
||||
// 拉高4G 模块复位
|
||||
while (1)
|
||||
{
|
||||
CAT1RST:
|
||||
HAL_GPIO_WritePin (GSM_PW_GPIO_Port, GSM_PW_Pin, GPIO_PIN_RESET); // 关闭4G 模块电源
|
||||
// 初始化串口,打开模块电源
|
||||
g_cat1Drv.State = Init;
|
||||
MX_UART_Init (&g_GSMDrv);
|
||||
HAL_GPIO_WritePin (GSM_PW_GPIO_Port, GSM_PW_Pin, GPIO_PIN_RESET); // 关闭4G 模块电源
|
||||
if (g_cat1Drv.IsEnable == false)
|
||||
{
|
||||
rt_thread_delay (3000);
|
||||
goto CAT1RST;
|
||||
}
|
||||
//MX_UART_Init (&g_GSMDrv);
|
||||
|
||||
rt_thread_mdelay (3000);
|
||||
HAL_GPIO_WritePin (GSM_PW_GPIO_Port, GSM_PW_Pin, GPIO_PIN_SET); // 开启4G
|
||||
rt_thread_mdelay (100);
|
||||
@@ -216,7 +236,8 @@ CAT1RST:
|
||||
HAL_GPIO_WritePin (GSM_RST_GPIO_Port, GSM_RST_Pin, GPIO_PIN_RESET);
|
||||
rt_thread_mdelay (100);
|
||||
HAL_GPIO_WritePin (GSM_RST_GPIO_Port, GSM_RST_Pin, GPIO_PIN_SET);
|
||||
rt_thread_mdelay (8000);
|
||||
rt_thread_mdelay (10000);
|
||||
log_d ("cat.1 init complete");
|
||||
for (int i = 0; i < MAXSETP; i++)
|
||||
{
|
||||
retry = cat1list[i].retry;
|
||||
@@ -231,22 +252,27 @@ CAT1RST:
|
||||
retry--;
|
||||
if (retry <= 0)
|
||||
{
|
||||
rt_kprintf ("Join Faild%d \r\n", i);
|
||||
log_i ("Join Faild");
|
||||
goto CAT1RST;
|
||||
}
|
||||
}
|
||||
// 关机
|
||||
if (RT_EOK == rt_event_recv (gTrigEvents, EVENT_TRIG_CAT1_SHUT, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, RT_WAITING_NO, RT_NULL)) // 需要发
|
||||
{
|
||||
goto CAT1RST;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rt_kprintf ("Join Success \r\n");
|
||||
log_i ("Join Success ");
|
||||
rt_sprintf (at_cmd, "AT+QIOPEN=1,0,\"TCP\",\"%s\",%d,0,0\r", ipaddr, ipport);
|
||||
if (cat1_sendcmd_and_responce (15000, at_cmd, strlen (at_cmd), "+QIOPEN: 0,0", NULL) == RetSucc)
|
||||
{
|
||||
g_cat1Drv.State = Conn;
|
||||
rt_kprintf ("Net is ready \r\n");
|
||||
log_i ("connected %s:%d success", ipaddr, ipport);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf ("Net is Error \r\n");
|
||||
log_i ("connected server error");
|
||||
goto CAT1RST;
|
||||
}
|
||||
|
||||
@@ -261,12 +287,12 @@ CAT1RST:
|
||||
rt_thread_mdelay (10);
|
||||
if (cat1_sendcmd_and_responce (1000, at_cmd, strlen (at_cmd), ">", NULL) != RetSucc)
|
||||
{
|
||||
rt_kprintf ("NET:+CME:ERROR QISEND\r\n");
|
||||
log_i ("NET:+CME:ERROR QISEND\r\n");
|
||||
goto CAT1RST;
|
||||
}
|
||||
if (cat1_sendcmd_and_responce (3000, g_cat1Drv.txbuff, g_cat1Drv.tx_size, "SEND OK", NULL) != RetSucc)
|
||||
{
|
||||
rt_kprintf ("NET:+CME:ERROR QPUSH\r\n");
|
||||
log_i ("NET:+CME:ERROR QPUSH\r\n");
|
||||
goto CAT1RST;
|
||||
}
|
||||
}
|
||||
@@ -275,7 +301,12 @@ CAT1RST:
|
||||
rt_thread_mdelay (300);
|
||||
if (cat1_sendcmd_and_responce (1000, "AT+QIRD=0,1500\r\n", strlen ("AT+QIRD=0,1500\r\n"), "+QIRD:", ec200_resp_qird_callback) != RetSucc)
|
||||
{
|
||||
rt_kprintf ("NET:+CME:ERROR QIRD\r\n");
|
||||
log_i ("NET:+CME:ERROR QIRD\r\n");
|
||||
goto CAT1RST;
|
||||
}
|
||||
// 关机
|
||||
if (RT_EOK == rt_event_recv (gTrigEvents, EVENT_TRIG_CAT1_SHUT, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, RT_WAITING_NO, RT_NULL)) // 需要发
|
||||
{
|
||||
goto CAT1RST;
|
||||
}
|
||||
// // 通过通道2上报数据
|
||||
|
||||
+24
-25
@@ -28,23 +28,24 @@ static char tx_buffer[512];
|
||||
static char rx_buffer[512];
|
||||
|
||||
|
||||
// static int isenable = 0;
|
||||
|
||||
netDrv_t g_dtuDrv =
|
||||
|
||||
netDrvInfo_t g_dtuDrv =
|
||||
{
|
||||
0, // 信号值
|
||||
"", // iccid
|
||||
Init, // 状态
|
||||
tx_buffer, // 接受缓存
|
||||
0, // 接受数据长度
|
||||
rx_buffer, // 发送数据缓存
|
||||
0, // 发送数据长度
|
||||
.Csq = 0, // 信号值
|
||||
.Iccid = "", // iccid
|
||||
.State = Init, // 状态
|
||||
.txbuff = tx_buffer, // 接受缓存
|
||||
.rx_size = 0, // 接受数据长度
|
||||
.rxbuff = rx_buffer, // 发送数据缓存
|
||||
.IsEnable = 0, // 发送数据长度
|
||||
};
|
||||
|
||||
|
||||
static void net_data_rxdone (void)
|
||||
{
|
||||
rt_event_send (gUartEvents, EVENT_UART_ETH1_RX);
|
||||
//rt_kprintf("net_data_rxdone\r\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -52,13 +53,19 @@ static void thread_entry (void * argument)
|
||||
{
|
||||
rt_kprintf ("%s was start!\r\n", __FILE__);
|
||||
g_ETH1Drv.rxdone = net_data_rxdone;
|
||||
// MX_UART_Init(&g_ETH1Drv);
|
||||
MX_UART_Init (&g_ETH1Drv);
|
||||
while (1)
|
||||
{
|
||||
MODE_RST:
|
||||
g_dtuDrv.State = Init;
|
||||
MX_UART_Init (&g_ETH1Drv);
|
||||
HAL_GPIO_WritePin (ETH_RST_GPIO_Port, ETH_RST_Pin, GPIO_PIN_RESET);
|
||||
g_dtuDrv.State = Init;
|
||||
if (g_dtuDrv.IsEnable == 0)
|
||||
{
|
||||
rt_thread_delay (3000);
|
||||
goto MODE_RST;
|
||||
}
|
||||
//MX_UART_Init (&g_ETH1Drv);
|
||||
// HAL_GPIO_WritePin (ETH_RST_GPIO_Port, ETH_RST_Pin, GPIO_PIN_RESET);
|
||||
rt_thread_mdelay (1000);
|
||||
HAL_GPIO_WritePin (ETH_RST_GPIO_Port, ETH_RST_Pin, GPIO_PIN_SET);
|
||||
rt_thread_mdelay (1000);
|
||||
@@ -70,24 +77,12 @@ MODE_RST:
|
||||
// 准备要上报数据
|
||||
if (RT_EOK == rt_event_recv (gTrigEvents, EVENT_TRIG_NETMODE_TX1, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, RT_WAITING_NO, RT_NULL)) //
|
||||
{
|
||||
//rt_kprintf("MODE_RST\r\n");
|
||||
MX_UART_PutBuffer (&g_ETH1Drv, g_dtuDrv.txbuff, g_dtuDrv.tx_size);
|
||||
// rt_kprintf("tx\r\n");
|
||||
// for(int i =0; i <g_dtuDrv.tx_size;i++ )
|
||||
// {
|
||||
// rt_kprintf("%02X ",g_dtuDrv.txbuff[i]);
|
||||
// }
|
||||
// rt_kprintf("\r\n");
|
||||
|
||||
}
|
||||
// 接受到数据
|
||||
if (RT_EOK == rt_event_recv (gUartEvents, EVENT_UART_ETH1_RX, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 0, RT_NULL))
|
||||
{
|
||||
// rt_kprintf ("ETH1Rx:%d\r\n", g_ETH1Drv.rx_size);
|
||||
// for (int i = 0; i < g_ETH1Drv.rx_size; i++)
|
||||
// {
|
||||
// rt_kprintf ("%02X ", g_ETH1Drv.rx_buffer[i]);
|
||||
// }
|
||||
// rt_kprintf ("\r\n");
|
||||
rt_memcpy (g_dtuDrv.rxbuff, g_ETH1Drv.rx_buffer, g_ETH1Drv.rx_size);
|
||||
g_dtuDrv.rx_size = g_ETH1Drv.rx_size;
|
||||
rt_event_send (gTrigEvents, EVENT_TRIG_NETMODE_RX1) ;
|
||||
@@ -97,6 +92,10 @@ MODE_RST:
|
||||
{
|
||||
goto MODE_RST;
|
||||
}
|
||||
if (RT_EOK == rt_event_recv (gTrigEvents, EVENT_TRIG_ETH_SHUT, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, RT_WAITING_NO, RT_NULL))
|
||||
{
|
||||
goto MODE_RST;
|
||||
}
|
||||
rt_thread_delay (100);
|
||||
// 读取IO 状态
|
||||
}
|
||||
|
||||
+183
-69
@@ -1,26 +1,63 @@
|
||||
#include "jsonpacket.h"
|
||||
|
||||
#include "cjson.h"
|
||||
#include <string.h>
|
||||
#include <rtthread.h>
|
||||
#include "data.h"
|
||||
#include "jsonpacket.h"
|
||||
#include <easyflash.h>
|
||||
#include <stdlib.h>
|
||||
#include "netdrv.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define PROTO_VER "FF_V3.0"
|
||||
|
||||
extern char config_list[16][32];
|
||||
extern int config_list_size;
|
||||
static char number_str[32];
|
||||
|
||||
|
||||
void * GetNumber (double k, int s)
|
||||
{
|
||||
//static char buff[32] = {0};
|
||||
rt_memset (number_str, 0, 32);
|
||||
switch (s)
|
||||
{
|
||||
case 0:
|
||||
sprintf (number_str, "%f", k);
|
||||
break;
|
||||
case 1:
|
||||
sprintf (number_str, "%.1f", k);
|
||||
break;
|
||||
case 2:
|
||||
sprintf (number_str, "%.2f", k);
|
||||
break;
|
||||
case 3:
|
||||
sprintf (number_str, "%.3f", k);
|
||||
break;
|
||||
case 4:
|
||||
sprintf (number_str, "%.4f", k);
|
||||
break;
|
||||
case 5:
|
||||
sprintf (number_str, "%.5f", k);
|
||||
break;
|
||||
case 6:
|
||||
sprintf (number_str, "%.6f", k);
|
||||
break;
|
||||
}
|
||||
return (void*) number_str;
|
||||
}
|
||||
|
||||
|
||||
// 5 分钟流量站数据上报
|
||||
int Json5MinFlowDataPacket (uint8_t * buffer)
|
||||
{
|
||||
char *result, * packMsg = (char *) buffer;
|
||||
cJSON *root = NULL;
|
||||
char *json, * packMsg = (char *) buffer;
|
||||
cJSON *root = NULL , *result = NULL;
|
||||
double dbl[6] = {3.14, 3.12, 3.33, 3.20, 3.12, 3.20};
|
||||
int length;
|
||||
char * p;
|
||||
root = cJSON_CreateObject();
|
||||
result = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject (root, "func", cJSON_CreateString ("stand")); // 功能码
|
||||
p = ef_get_env ("site_type");
|
||||
cJSON_AddItemToObject (root, "site_type", cJSON_CreateString (p)); // 表示流量计
|
||||
@@ -42,7 +79,7 @@ int Json5MinFlowDataPacket (uint8_t * buffer)
|
||||
dbl[i] = WaterData[i].thisSpeed;
|
||||
}
|
||||
cJSON * ArrNumSpeed = cJSON_CreateDoubleArray (dbl, 6);
|
||||
cJSON_AddItemToObject (root, "thisspeed", ArrNumSpeed);
|
||||
cJSON_AddItemToObject (result, "thisspeed", ArrNumSpeed);
|
||||
|
||||
// 瞬时流量
|
||||
for (int i = 0; i < 6; i++)
|
||||
@@ -50,7 +87,7 @@ int Json5MinFlowDataPacket (uint8_t * buffer)
|
||||
dbl[i] = WaterData[i].thisFlow;
|
||||
}
|
||||
cJSON * ArrNumFlow = cJSON_CreateDoubleArray (dbl, 6);
|
||||
cJSON_AddItemToObject (root, "thisflow", ArrNumFlow);
|
||||
cJSON_AddItemToObject (result, "thisflow", ArrNumFlow);
|
||||
|
||||
// 累计流量
|
||||
for (int i = 0; i < 6; i++)
|
||||
@@ -58,7 +95,7 @@ int Json5MinFlowDataPacket (uint8_t * buffer)
|
||||
dbl[i] = WaterData[i].ttWater;
|
||||
}
|
||||
cJSON * ArrNumTtflow = cJSON_CreateDoubleArray (dbl, 6);
|
||||
cJSON_AddItemToObject (root, "ttflow", ArrNumTtflow);
|
||||
cJSON_AddItemToObject (result, "ttflow", ArrNumTtflow);
|
||||
|
||||
// 当前水位
|
||||
for (int i = 0; i < 6; i++)
|
||||
@@ -66,14 +103,14 @@ int Json5MinFlowDataPacket (uint8_t * buffer)
|
||||
dbl[i] = (double) WaterData[i].thisLevel / 100;
|
||||
}
|
||||
cJSON * ArrNumLeve = cJSON_CreateDoubleArray (dbl, 6);
|
||||
cJSON_AddItemToObject (root, "thisLeve", ArrNumLeve);
|
||||
cJSON_AddItemToObject (result, "thisLeve", ArrNumLeve);
|
||||
// 当前压力
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
dbl[i] = WaterData[i].thisPress;
|
||||
}
|
||||
cJSON * ArrNumPress = cJSON_CreateDoubleArray (dbl, 6);
|
||||
cJSON_AddItemToObject (root, "thispress", ArrNumPress);
|
||||
cJSON_AddItemToObject (result, "thispress", ArrNumPress);
|
||||
|
||||
// 当前温度
|
||||
for (int i = 0; i < 6; i++)
|
||||
@@ -81,7 +118,7 @@ int Json5MinFlowDataPacket (uint8_t * buffer)
|
||||
dbl[i] = WaterData[i].ttWater;
|
||||
}
|
||||
cJSON * ArrNumTemp = cJSON_CreateDoubleArray (dbl, 6);
|
||||
cJSON_AddItemToObject (root, "thistemp", ArrNumTemp);
|
||||
cJSON_AddItemToObject (result, "thistemp", ArrNumTemp);
|
||||
|
||||
// 当前测斜方向
|
||||
for (int i = 0; i < 6; i++)
|
||||
@@ -89,7 +126,7 @@ int Json5MinFlowDataPacket (uint8_t * buffer)
|
||||
dbl[i] = IncData[i].dir;
|
||||
}
|
||||
cJSON * ArrNumIncDir = cJSON_CreateDoubleArray (dbl, 6);
|
||||
cJSON_AddItemToObject (root, "thisincdir", ArrNumIncDir);
|
||||
cJSON_AddItemToObject (result, "thisincdir", ArrNumIncDir);
|
||||
|
||||
// 当前测斜数据
|
||||
for (int i = 0; i < 6; i++)
|
||||
@@ -97,120 +134,139 @@ int Json5MinFlowDataPacket (uint8_t * buffer)
|
||||
dbl[i] = IncData[i].data;
|
||||
}
|
||||
cJSON * ArrNumIncData = cJSON_CreateDoubleArray (dbl, 6);
|
||||
cJSON_AddItemToObject (root, "thisincdata", ArrNumIncData);
|
||||
|
||||
cJSON_AddItemToObject (result, "thisincdata", ArrNumIncData);
|
||||
cJSON_AddItemToObject (root, "result", result);
|
||||
//---------------------------------------------以下不准修改
|
||||
result = cJSON_PrintUnformatted (root);
|
||||
strcpy (packMsg, result);
|
||||
cJSON_free (result);
|
||||
json = cJSON_PrintUnformatted (root);
|
||||
strcpy (packMsg, json);
|
||||
cJSON_free (json);
|
||||
cJSON_Delete (root);
|
||||
length = rt_strlen (packMsg);
|
||||
return length;
|
||||
}
|
||||
// 5分钟闸门站数据上报
|
||||
int JsonRegistDataPacket (uint8_t * buffer)
|
||||
{
|
||||
char *result, * packMsg = (char *) buffer;
|
||||
cJSON *root = NULL;
|
||||
char * p;
|
||||
int length;
|
||||
root = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject (root, "func", cJSON_CreateString ("regist")); // 功能码
|
||||
p = ef_get_env ("site_type");
|
||||
cJSON_AddItemToObject (root, "site_type", cJSON_CreateString (p)); // 表示流量计
|
||||
cJSON_AddItemToObject (root, "pver", cJSON_CreateString (PROTO_VER)); // 表示流量计
|
||||
cJSON_AddItemToObject (root, "iccid", cJSON_CreateString (SysData.iccid)); // 表示流量计
|
||||
cJSON_AddItemToObject (root, "ver", cJSON_CreateString (VERSION)); // 表示流量计
|
||||
p = ef_get_env ("net_drv");
|
||||
cJSON_AddItemToObject (root, "netdrv", cJSON_CreateString (p)); // 表示流量计
|
||||
p = ef_get_env ("iap_app_filename");
|
||||
//uint32_t max_open = atoi (p);
|
||||
cJSON_AddItemToObject (root, "filename", cJSON_CreateString (p)); // 表示电池电压
|
||||
//// 闸门站注册包上报
|
||||
//int JsonRegistDataPacket (uint8_t * buffer)
|
||||
//{
|
||||
// char *result, * packMsg = (char *) buffer;
|
||||
// cJSON *root = NULL;
|
||||
// char * p;
|
||||
// int length;
|
||||
// root = cJSON_CreateObject();
|
||||
// cJSON_AddItemToObject (root, "func", cJSON_CreateString ("regist")); // 功能码
|
||||
// p = ef_get_env ("site_type");
|
||||
// cJSON_AddItemToObject (root, "site_type", cJSON_CreateString (p)); // 表示流量计
|
||||
// cJSON_AddItemToObject (root, "pver", cJSON_CreateString (PROTO_VER)); // 表示流量计
|
||||
// cJSON_AddItemToObject (root, "iccid", cJSON_CreateString (SysData.iccid)); // 表示流量计
|
||||
// cJSON_AddItemToObject (root, "ver", cJSON_CreateString (VERSION)); // 表示流量计
|
||||
// p = ef_get_env ("net_drv");
|
||||
// cJSON_AddItemToObject (root, "netdrv", cJSON_CreateString (p)); // 表示流量计
|
||||
// p = ef_get_env ("iap_app_filename");
|
||||
// //uint32_t max_open = atoi (p);
|
||||
// cJSON_AddItemToObject (root, "filename", cJSON_CreateString (p)); // 表示电池电压
|
||||
|
||||
//---------------------------------------------以下不准修改
|
||||
result = cJSON_PrintUnformatted (root);
|
||||
strcpy (packMsg, result);
|
||||
cJSON_free (result);
|
||||
cJSON_Delete (root);
|
||||
length = rt_strlen (packMsg);
|
||||
return length;
|
||||
}
|
||||
// //---------------------------------------------以下不准修改
|
||||
// result = cJSON_PrintUnformatted (root);
|
||||
// strcpy (packMsg, result);
|
||||
// cJSON_free (result);
|
||||
// cJSON_Delete (root);
|
||||
// length = rt_strlen (packMsg);
|
||||
// return length;
|
||||
//}
|
||||
|
||||
|
||||
// 5分钟闸门站数据上报
|
||||
// 一、均匀时段报(上行)
|
||||
int Json5MinSluiceDataPacket (uint8_t * buffer)
|
||||
{
|
||||
char *result, * packMsg = (char *) buffer;
|
||||
cJSON *root = NULL;
|
||||
char *json, * packMsg = (char *) buffer;
|
||||
cJSON *root = NULL, *result = NULL;
|
||||
char * p;
|
||||
int length;
|
||||
root = cJSON_CreateObject();
|
||||
result = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject (root, "func", cJSON_CreateString ("stand")); // 功能码
|
||||
p = ef_get_env ("site_type");
|
||||
cJSON_AddItemToObject (root, "site_type", cJSON_CreateString (p)); // 表示流量计
|
||||
cJSON_AddItemToObject (root, "pver", cJSON_CreateString (PROTO_VER)); // 表示流量计
|
||||
cJSON_AddItemToObject (root, "iccid", cJSON_CreateString (SysData.iccid)); // 表示流量计
|
||||
cJSON_AddItemToObject (root, "ver", cJSON_CreateString (VERSION)); // 表示流量计
|
||||
p = ef_get_env ("net_drv");
|
||||
cJSON_AddItemToObject (root, "netdrv", cJSON_CreateString (p)); // 表示流量计
|
||||
cJSON_AddItemToObject (root, "ver", cJSON_CreateString (GetVersion())); // 表示流量计
|
||||
//p = ef_get_env ("net_drv");
|
||||
if (g_net_drv == Cat1) //
|
||||
{
|
||||
cJSON_AddItemToObject (root, "netdrv", cJSON_CreateString ("gsm")); // 表示流量计
|
||||
}
|
||||
else
|
||||
{
|
||||
cJSON_AddItemToObject (root, "netdrv", cJSON_CreateString ("eth")); // 表示流量计
|
||||
}
|
||||
p = ef_get_env ("iap_app_filename");
|
||||
//uint32_t max_open = atoi (p);
|
||||
cJSON_AddItemToObject (root, "filename", cJSON_CreateString (p)); // 表示电池电压
|
||||
|
||||
// 添加闸门相关数据
|
||||
// 闸门当前开度
|
||||
cJSON_AddItemToObject (root, "thisopen", cJSON_CreateNumber (SluiceData[0].gopen)); // 表示电池电压
|
||||
cJSON_AddItemToObject (result, "thisopen", cJSON_CreateNumber (SluiceData[0].gopen)); // 表示电池电压
|
||||
// 闸门最大开度
|
||||
p = ef_get_env ("max_open");
|
||||
uint32_t max_open = atoi (p);
|
||||
cJSON_AddItemToObject (root, "maxopen", cJSON_CreateNumber (max_open));
|
||||
cJSON_AddItemToObject (result, "maxopen", cJSON_CreateNumber (max_open));
|
||||
// 闸门A路荷重
|
||||
cJSON_AddItemToObject (root, "aload", cJSON_CreateNumber (SluiceData[0].lload));
|
||||
cJSON_AddItemToObject (result, "aload", cJSON_CreateNumber (SluiceData[0].lload));
|
||||
// 闸门B路荷重
|
||||
cJSON_AddItemToObject (root, "bload", cJSON_CreateNumber (SluiceData[0].rload));
|
||||
cJSON_AddItemToObject (result, "bload", cJSON_CreateNumber (SluiceData[0].rload));
|
||||
// 闸前水位
|
||||
cJSON_AddItemToObject (root, "thisleve", cJSON_CreateNumber (WaterData[0].thisLevel));
|
||||
cJSON_AddItemToObject (result, "thisleve", cJSON_CreateString (GetNumber ( (float) WaterData[0].thisLevel / 100, 2)));
|
||||
// 闸门瞬时流速
|
||||
cJSON_AddItemToObject (root, "thisspeed", cJSON_CreateNumber (WaterData[0].thisSpeed));
|
||||
cJSON_AddItemToObject (result, "thisspeed", cJSON_CreateString (GetNumber ( (float) WaterData[0].thisSpeed / 100, 2)));
|
||||
// 闸门累计流量
|
||||
cJSON_AddItemToObject (root, "thisflow", cJSON_CreateNumber (WaterData[0].thisFlow));
|
||||
cJSON_AddItemToObject (result, "thisflow", cJSON_CreateString (GetNumber ( (float) WaterData[0].thisFlow / 100, 2)));
|
||||
// 闸门瞬时流量
|
||||
cJSON_AddItemToObject (root, "ttflow", cJSON_CreateNumber (WaterData[0].ttWater));
|
||||
cJSON_AddItemToObject (result, "ttflow", cJSON_CreateString (GetNumber ( (float) WaterData[0].ttWater / 100, 2)));
|
||||
// 闸门启动电流
|
||||
cJSON_AddItemToObject (root, "current", cJSON_CreateNumber (SluiceData[0].currt));
|
||||
cJSON_AddItemToObject (result, "current", cJSON_CreateNumber (SluiceData[0].currt));
|
||||
// 闸门编码器最大值
|
||||
p = ef_get_env ("max_ecode");
|
||||
uint32_t max_code = atoi (p);
|
||||
|
||||
cJSON_AddItemToObject (root, "maxecode", cJSON_CreateNumber (max_code));
|
||||
cJSON_AddItemToObject (result, "maxecode", cJSON_CreateNumber (max_code));
|
||||
p = ef_get_env ("min_ecode");
|
||||
uint32_t min_code = atoi (p);
|
||||
// 闸门编码器最小值
|
||||
cJSON_AddItemToObject (root, "minecode", cJSON_CreateNumber (min_code));
|
||||
cJSON_AddItemToObject (result, "minecode", cJSON_CreateNumber (min_code));
|
||||
cJSON_AddItemToObject (root, "result", result);
|
||||
//---------------------------------------------以下不准修改
|
||||
result = cJSON_PrintUnformatted (root);
|
||||
strcpy (packMsg, result);
|
||||
cJSON_free (result);
|
||||
json = cJSON_PrintUnformatted (root);
|
||||
strcpy (packMsg, json);
|
||||
cJSON_free (json);
|
||||
//cJSON_Delete (result);
|
||||
cJSON_Delete (root);
|
||||
|
||||
length = rt_strlen (packMsg);
|
||||
return length;
|
||||
}
|
||||
|
||||
// 心跳包,需要应答
|
||||
// 二、心跳数据上报(上行)
|
||||
int JsonHeartDatapacket (uint8_t * buffer)
|
||||
{
|
||||
char *result, * packMsg = (char *) buffer;
|
||||
cJSON *root = NULL;
|
||||
int length;
|
||||
char *p;
|
||||
int state[4];
|
||||
root = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject (root, "func", cJSON_CreateString ("heart")); // 功能码
|
||||
p = ef_get_env ("site_type");
|
||||
cJSON_AddItemToObject (root, "site_type", cJSON_CreateString (p)); // 表示流量计
|
||||
cJSON_AddItemToObject (root, "ecdState", cJSON_CreateNumber (SysData.ecdState)); // 编码器状态
|
||||
cJSON_AddItemToObject (root, "flowState", cJSON_CreateNumber (SysData.flowState)); // 流量计状态
|
||||
cJSON_AddItemToObject (root, "ldState", cJSON_CreateNumber (SysData.ldState)); // 荷重仪状态
|
||||
cJSON_AddItemToObject (root, "scram", cJSON_CreateNumber (SysData.scram)); // 荷重仪状态
|
||||
state[0] = SluiceData[0].error;
|
||||
state[1] = SluiceData[0].state;
|
||||
state[2] = 0;
|
||||
state[3] = 0;
|
||||
cJSON * ArrNumPress = cJSON_CreateIntArray (state, 4);
|
||||
cJSON_AddItemToObject (root, "state", ArrNumPress);
|
||||
|
||||
//cJSON_AddItemToObject (root, "state", cJSON_CreateNumber (SysData.ecdState)); // 编码器状态
|
||||
// cJSON_AddItemToObject (root, "flowState", cJSON_CreateNumber (SysData.flowState)); // 流量计状态
|
||||
// cJSON_AddItemToObject (root, "ldState", cJSON_CreateNumber (SysData.ldState)); // 荷重仪状态
|
||||
// cJSON_AddItemToObject (root, "scram", cJSON_CreateNumber (SysData.scram)); // 荷重仪状态
|
||||
//---------------------------------------------以下不准修改
|
||||
result = cJSON_PrintUnformatted (root);
|
||||
strcpy (packMsg, result);
|
||||
@@ -220,7 +276,47 @@ int JsonHeartDatapacket (uint8_t * buffer)
|
||||
return length;
|
||||
}
|
||||
|
||||
// 四、下行命令应答(上行)
|
||||
|
||||
int JsonAckDownload (uint8_t* buffer, DownDataType_t dn)
|
||||
{
|
||||
char *result, * packMsg = (char *) buffer;
|
||||
cJSON *root = NULL;
|
||||
int length;
|
||||
char *p;
|
||||
root = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject (root, "func", cJSON_CreateString ("ack")); // 功能码
|
||||
switch (dn)
|
||||
{
|
||||
case DownUpdate:
|
||||
cJSON_AddItemToObject (root, "type", cJSON_CreateString ("update")); // 表示流量计
|
||||
cJSON_AddItemToObject (root, "state", cJSON_CreateString ("ok")); // 表示流量计
|
||||
break;
|
||||
case DownConfig:
|
||||
cJSON_AddItemToObject (root, "type", cJSON_CreateString ("config")); // 表示流量计
|
||||
cJSON_AddItemToObject (root, "state", cJSON_CreateString ("ok")); // 表示流量计
|
||||
break;
|
||||
case DownRun:
|
||||
cJSON_AddItemToObject (root, "type", cJSON_CreateString ("run")); // 表示流量计
|
||||
cJSON_AddItemToObject (root, "state", cJSON_CreateString ("ok")); // 表示流量计
|
||||
break;
|
||||
case DownFact:
|
||||
cJSON_AddItemToObject (root, "type", cJSON_CreateString ("fact")); // 表示流量计
|
||||
cJSON_AddItemToObject (root, "state", cJSON_CreateString ("ok")); // 表示流量计
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//---------------------------------------------以下不准修改
|
||||
result = cJSON_PrintUnformatted (root);
|
||||
strcpy (packMsg, result);
|
||||
cJSON_free (result);
|
||||
cJSON_Delete (root);
|
||||
length = rt_strlen (packMsg);
|
||||
return length;
|
||||
}
|
||||
|
||||
// 十一、读取参数应答(上行)
|
||||
int JsonConfigReadDataPacket (uint8_t* buffer)
|
||||
{
|
||||
char *result, * packMsg = (char *) buffer;
|
||||
@@ -246,8 +342,26 @@ int JsonConfigReadDataPacket(uint8_t* buffer)
|
||||
return length;
|
||||
}
|
||||
|
||||
int JsonAckSuccPacket(char * buffer)
|
||||
|
||||
|
||||
// 十四 、设备预警(上行)
|
||||
// shangbao
|
||||
int JsonWarning (char * buffer, char * type, int k)
|
||||
{
|
||||
rt_sprintf(buffer,"{\"state\":\"ok\"}");
|
||||
char *result, * packMsg = (char *) buffer;
|
||||
cJSON *root = NULL;
|
||||
int length;
|
||||
char *p;
|
||||
root = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject (root, "func", cJSON_CreateString ("warn")); // 功能码
|
||||
cJSON_AddItemToObject (root, "type", cJSON_CreateString ("load")); // 表示流量计
|
||||
cJSON_AddItemToObject (root, "data", cJSON_CreateNumber (k)); // 表示流量计
|
||||
//---------------------------------------------以下不准修改
|
||||
result = cJSON_PrintUnformatted (root);
|
||||
strcpy (packMsg, result);
|
||||
cJSON_free (result);
|
||||
cJSON_Delete (root);
|
||||
length = rt_strlen (packMsg);
|
||||
return length;
|
||||
}
|
||||
|
||||
@@ -3,16 +3,52 @@
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
// 5 分钟数据上报
|
||||
|
||||
////typedef enum AckType_t
|
||||
////{
|
||||
//// AckUpdate = 0,
|
||||
//// AckRun = 0,
|
||||
////}
|
||||
|
||||
|
||||
//// 5 分钟数据上报
|
||||
//int Json5MinFlowDataPacket (uint8_t * buffer);
|
||||
|
||||
//// 注册包数据 需要应答
|
||||
//int JsonRegistDataPacket (uint8_t * buffer);
|
||||
//// 心跳包,需要应答
|
||||
//int JsonHeartDatapacket (uint8_t * buffer);
|
||||
|
||||
//int Json5MinSluiceDataPacket (uint8_t * buffer);
|
||||
|
||||
//int JsonConfigReadDataPacket (uint8_t* buffer);
|
||||
|
||||
//int JsonAckSuccPacket (char * buffer,char * type,int k);
|
||||
|
||||
|
||||
|
||||
|
||||
// 5 分钟流量站数据上报
|
||||
int Json5MinFlowDataPacket (uint8_t * buffer);
|
||||
|
||||
// 注册包数据 需要应答
|
||||
int JsonRegistDataPacket (uint8_t * buffer);
|
||||
// 心跳包,需要应答
|
||||
int JsonHeartDatapacket (uint8_t * buffer);
|
||||
|
||||
// 一、均匀时段报(上行)
|
||||
int Json5MinSluiceDataPacket (uint8_t * buffer);
|
||||
|
||||
// 二、心跳数据上报(上行)
|
||||
int JsonHeartDatapacket (uint8_t * buffer);
|
||||
|
||||
// 四、下行命令应答(上行)
|
||||
|
||||
int JsonAckDownload (uint8_t* buffer, DownDataType_t dn);
|
||||
|
||||
// 十一、读取参数应答(上行)
|
||||
int JsonConfigReadDataPacket (uint8_t* buffer);
|
||||
int JsonAckSuccPacket(char * buffer);
|
||||
|
||||
|
||||
// 十四 、设备预警(上行)
|
||||
// shangbao
|
||||
int JsonWarning (char * buffer, char * type, int k);
|
||||
|
||||
|
||||
#endif
|
||||
+36
-27
@@ -1,3 +1,4 @@
|
||||
#include "data.h"
|
||||
#include "jsonunpack.h"
|
||||
#include "cjson.h"
|
||||
#include <string.h>
|
||||
@@ -5,10 +6,17 @@
|
||||
#include "data.h"
|
||||
#include <easyflash.h>
|
||||
#include <stdlib.h>
|
||||
#include "data.h"
|
||||
|
||||
#include "os-app.h"
|
||||
#include "main.h"
|
||||
|
||||
|
||||
|
||||
#if !defined(LOG_TAG)
|
||||
#define LOG_TAG "json"
|
||||
#endif
|
||||
#include <elog.h>
|
||||
|
||||
char config_list[16][32] = {NULL};
|
||||
int config_list_size = 0;
|
||||
// 用于远程出厂设置时保留配置
|
||||
@@ -25,29 +33,21 @@ void JsonUnPacket (int index, char *buff)
|
||||
root = cJSON_Parse (packMsg);
|
||||
DownDataType_t type = (DownDataType_t) 0;
|
||||
char * p, *key, *value;
|
||||
int list_size;
|
||||
int list_size, data;
|
||||
TypeIndexMail_t mail;
|
||||
p = cJSON_GetStringValue (cJSON_GetObjectItem (root, "type"));
|
||||
type = (DownDataType_t) cDownType2Index (p);
|
||||
rt_kprintf("down :%s<%d>\r\n",p,type);
|
||||
log_i ("down :%s<%d>\r\n", p, type);
|
||||
switch (type)
|
||||
{
|
||||
case DownRun : // 开度提闸
|
||||
|
||||
// rt_kprintf ("open:%u mm/10\r\n", datak);
|
||||
|
||||
// //SluiceData[gMqttDrv.rx_index].opt = 1; // 执行操作闸门
|
||||
// SluiceData[gMqttDrv.rx_index - 1].sopen = datak / 10;
|
||||
// mail.Type = MAIL_SLUICE_OPT;
|
||||
// mail.index = gMqttDrv.rx_index - 1;
|
||||
// rt_mb_send (gSluiceMail, * ( (uint32_t*) &mail));
|
||||
|
||||
// // 回复应答
|
||||
// mail.Type = MAIL_COMM_SLACK;
|
||||
// mail.index = gMqttDrv.rx_index;
|
||||
// rt_mb_send (gTCommMail, * ( (uint32_t*) &mail));
|
||||
data = cJSON_GetNumberValue (cJSON_GetObjectItem (root, "data"));
|
||||
SluiceData[0].sopen = data; // 执行操作闸门
|
||||
OsSendMail (gSluiceMail, MAIL_SLUICE_OPT, 0); // 操作0号闸门
|
||||
OsSendMail (gTCommMail, MAIL_COMM_SLACK, 0); // 操作0号闸门
|
||||
break;
|
||||
case DownStop :
|
||||
OsSendMail (gSluiceMail, MAIL_SLUICE_STP, 0);
|
||||
break;
|
||||
case DownOpen :
|
||||
break;
|
||||
@@ -58,21 +58,26 @@ void JsonUnPacket (int index, char *buff)
|
||||
case DownHeartAns :
|
||||
break;
|
||||
case DownUpdate :
|
||||
if (index != 0)
|
||||
break;
|
||||
rt_memset (SysData.fileName, 0, 32);
|
||||
p = cJSON_GetStringValue (cJSON_GetObjectItem (root, "file"));
|
||||
rt_sprintf (SysData.fileName, "%s", p) ;
|
||||
// 启动升级线程
|
||||
// 回复应答
|
||||
mail.Type = MAIL_COMM_UPACK;
|
||||
mail.index = index + 1; // 0通道用来升级的通道
|
||||
OsSendMail (gTCommMail, MAIL_COMM_UPACK, index + 1); // 操作0号闸门
|
||||
rt_mb_send (gTCommMail, * ( (uint32_t*) &mail));
|
||||
rt_thread_mdelay (2000); // 等待2s 进入升级线程
|
||||
UpgradeThreadStart();
|
||||
break;
|
||||
case DownReboot :
|
||||
if (index != 0)
|
||||
break;
|
||||
HAL_NVIC_SystemReset();
|
||||
break;
|
||||
case DownConfig: // 设置参数
|
||||
if (index != 0)
|
||||
break;
|
||||
// 读取参数列表
|
||||
list = cJSON_GetObjectItem (root, "list");
|
||||
list_size = cJSON_GetArraySize (list);
|
||||
@@ -85,11 +90,14 @@ void JsonUnPacket (int index, char *buff)
|
||||
ef_set_env (key, value);
|
||||
}
|
||||
}
|
||||
mail.Type = MAIL_COMM_ACK;
|
||||
mail.index = index + 1; // 0通道用来升级的通道
|
||||
rt_mb_send (gTCommMail, * ( (uint32_t*) &mail));
|
||||
OsSendMail (gTCommMail, MAIL_COMM_WRACK, index + 1); // 操作0号闸门
|
||||
// mail.Type = MAIL_COMM_ACK;
|
||||
// mail.index = index + 1; // 0通道用来升级的通道
|
||||
// rt_mb_send (gTCommMail, * ( (uint32_t*) &mail));
|
||||
break;
|
||||
case DownRead: // 读取参数
|
||||
if (index != 0)
|
||||
break;
|
||||
list = cJSON_GetObjectItem (root, "list");
|
||||
config_list_size = cJSON_GetArraySize (list);
|
||||
for (int i = 0; i < config_list_size; i++)
|
||||
@@ -97,12 +105,15 @@ void JsonUnPacket (int index, char *buff)
|
||||
key = cJSON_GetStringValue (cJSON_GetArrayItem (list, i));
|
||||
rt_sprintf (config_list[i], "%s", key);
|
||||
}
|
||||
mail.Type = MAIL_COMM_READPARA;
|
||||
mail.index = index + 1; // 0通道用来升级的通道
|
||||
rt_mb_send (gTCommMail, * ( (uint32_t*) &mail));
|
||||
OsSendMail (gTCommMail, MAIL_COMM_READPARA, index + 1); // 操作0号闸门
|
||||
// mail.Type = MAIL_COMM_READPARA;
|
||||
// mail.index = index + 1; // 0通道用来升级的通道
|
||||
// rt_mb_send (gTCommMail, * ( (uint32_t*) &mail));
|
||||
// 读取参数列表
|
||||
break;
|
||||
case DownFact:
|
||||
if (index != 0)
|
||||
break;
|
||||
p = ef_get_env ("device_id");
|
||||
rt_sprintf (backdevice_id, "%s", p);
|
||||
p = ef_get_env ("net_drv") ;
|
||||
@@ -110,9 +121,7 @@ void JsonUnPacket (int index, char *buff)
|
||||
ef_env_set_default();
|
||||
ef_set_env ("device_id", backdevice_id) ;
|
||||
ef_set_env ("net_drv", backnetdrv) ;
|
||||
mail.Type = MAIL_COMM_ACK;
|
||||
mail.index = index + 1; // 0通道用来升级的通道
|
||||
rt_mb_send (gTCommMail, * ( (uint32_t*) &mail));
|
||||
OsSendMail (gTCommMail, MAIL_COMM_FACACK, index + 1); // 操作0号闸门
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
+48
-28
@@ -79,19 +79,23 @@ char client_id_str[64] = {NULL};
|
||||
static char device_id[32] = {NULL}; // 设备编码
|
||||
static char user_topic[32] = {NULL}; // topic
|
||||
|
||||
static char mqtt_user[32] = {NULL}; // 设备编码
|
||||
static char mqtt_pass[32] = {NULL}; // topic
|
||||
|
||||
static void net_data_rxdone (void)
|
||||
{
|
||||
rt_event_send (gUartEvents, EVENT_UART_ETH1_RX);
|
||||
}
|
||||
|
||||
static int timerout_timer = 0;
|
||||
static int MQTT_timerout_timer = 0;
|
||||
static void timerouter (void * parameter)
|
||||
{
|
||||
timerout_timer ++;
|
||||
if (timerout_timer > 90) // 超过90s 没有收到数据,重启网络
|
||||
MQTT_timerout_timer ++;
|
||||
if (MQTT_timerout_timer > 90) // 超过90s 没有收到数据,重启网络
|
||||
{
|
||||
rt_event_send (gTrigEvents, EVENT_TRIG_MQTT_RST);
|
||||
timerout_timer = 0;
|
||||
rt_event_send (gTrigEvents, EVENT_TRIG_MQTT_RST);//WXY 此处加切换网络
|
||||
netdrv_switch();
|
||||
MQTT_timerout_timer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +105,7 @@ static void thread_entry (void * argument)
|
||||
|
||||
int count = 0;
|
||||
// 初始化串口驱动
|
||||
rt_kprintf ("%s was start!\r\n", __FILE__);
|
||||
log_i ("mqtt was start!");
|
||||
timer = rt_timer_create ("timer", timerouter, RT_NULL, 1000, RT_TIMER_FLAG_PERIODIC); // 异常检测定时器
|
||||
// 读取配置文件
|
||||
char * p = ef_get_env ("device_id");
|
||||
@@ -109,22 +113,29 @@ static void thread_entry (void * argument)
|
||||
p = ef_get_env ("mqtt_topic");
|
||||
rt_memcpy (user_topic, p, strlen (p));
|
||||
|
||||
int id = rand() % 1000;
|
||||
//int id = rand() % 1000;
|
||||
rt_sprintf (client_id_str, "GID_SLUICE_V2_220000%s", device_id) ;
|
||||
rt_kprintf ("clinet:%s\r\n", client_id_str);
|
||||
log_i ("client_id:%s", client_id_str);
|
||||
connectData.clientID.cstring = client_id_str;
|
||||
connectData.keepAliveInterval = 120;
|
||||
connectData.cleansession = 1;
|
||||
connectData.username.cstring = "admin";
|
||||
connectData.password.cstring = "admin";
|
||||
|
||||
p = ef_get_env ("mqtt_user");
|
||||
rt_memcpy (mqtt_user, p, strlen (p));
|
||||
|
||||
p = ef_get_env ("mqtt_pass");
|
||||
rt_memcpy (mqtt_pass, p, strlen (p));
|
||||
|
||||
connectData.username.cstring = mqtt_user;
|
||||
connectData.password.cstring = mqtt_pass;
|
||||
rt_sprintf (sub_topic_str[0], "device/%s/tx/220000%s", "update", device_id);
|
||||
rt_sprintf (pub_topic_str[0], "device/%s/rx/220000%s", "update", device_id);
|
||||
// 读取设备编码
|
||||
rt_sprintf (sub_topic_str[1], "device/%s/tx/220000%s", user_topic, device_id);
|
||||
rt_sprintf (pub_topic_str[1], "device/%s/rx/220000%s", user_topic, device_id);
|
||||
#if (SUBTOPIC_COUNT > 1)
|
||||
rt_sprintf (sub_topic_str[2], "device/%s/tx/2200002308170002", user_topic);
|
||||
rt_sprintf (pub_topic_str[2], "device/%s/rx/2200002308170002", user_topic);
|
||||
rt_sprintf (sub_topic_str[2], "device/%s/tx/220000%s", "minle",device_id);
|
||||
rt_sprintf (pub_topic_str[2], "device/%s/rx/220000%s", "minle",device_id);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < SUBTOPIC_COUNT + 1; i++)
|
||||
@@ -137,18 +148,20 @@ static void thread_entry (void * argument)
|
||||
while (1)
|
||||
{
|
||||
MQTTINIT:
|
||||
if (g_netDrv->State != Conn)
|
||||
|
||||
if (g_netDrv->State != Conn) // 等待网络模块注册成功
|
||||
{
|
||||
//rt_kprintf ("mqtt tcp-connected fail\r\n");
|
||||
rt_thread_delay (1000); // 延迟3s 等待模块连接TCP 服务成功
|
||||
goto MQTTINIT;
|
||||
}
|
||||
// 链接MQTT 服务器
|
||||
rt_kprintf ("mqtt connected\r\n");
|
||||
log_i ("connect to mqtt server");
|
||||
mqtt_buflen = MQTTSerialize_connect (mqtt_buffer, MQTT_BUFF_LENGTH, &connectData);
|
||||
netdrv_service_tx (mqtt_buffer, mqtt_buflen);
|
||||
if (RT_EOK != rt_event_recv (gTrigEvents, EVENT_TRIG_NETMODE_RX1, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 10000, RT_NULL))
|
||||
{
|
||||
netdrv_reset();// 切换到mqtt 驱动
|
||||
goto MQTTINIT;
|
||||
}
|
||||
rt_thread_mdelay (10);
|
||||
@@ -157,26 +170,31 @@ MQTTINIT:
|
||||
unsigned char sessionPresent, connack_rc;
|
||||
if (MQTTDeserialize_connack (&sessionPresent, &connack_rc, mqtt_buffer, MQTT_BUFF_LENGTH) != 1 || connack_rc != 0)
|
||||
{
|
||||
rt_kprintf ("Unable to connect, return code %d\n", connack_rc);
|
||||
log_i ("Unable to connect, return code %d\n", connack_rc);
|
||||
rt_thread_delay (3000);
|
||||
netdrv_clear();
|
||||
netdrv_reset();// 切换到mqtt 驱动
|
||||
goto MQTTINIT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf ("mqtt error");
|
||||
log_i ("mqtt error");
|
||||
netdrv_clear();
|
||||
rt_thread_mdelay (3000);
|
||||
// netdrv_switch();// 切换到mqtt 驱动
|
||||
goto MQTTINIT;
|
||||
}
|
||||
netdrv_clear();
|
||||
rt_kprintf ("connect to mqtt successful\n");
|
||||
log_i ("connect to mqtt successful");
|
||||
// 订阅topic
|
||||
mqtt_buflen = MQTTSerialize_subscribe (mqtt_buffer, MQTT_BUFF_LENGTH, 0, message_id++, SUBTOPIC_COUNT + 1, subtopic, qos);
|
||||
netdrv_service_tx (mqtt_buffer, mqtt_buflen);
|
||||
if (RT_EOK != rt_event_recv (gTrigEvents, EVENT_TRIG_NETMODE_RX1, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 10000, RT_NULL))
|
||||
{
|
||||
netdrv_clear();
|
||||
netdrv_reset();// 切换到mqtt 驱动
|
||||
rt_thread_mdelay (3000);
|
||||
goto MQTTINIT;
|
||||
}
|
||||
if (MQTTPacket_read (mqtt_buffer, MQTT_BUFF_LENGTH, netdrv_getdata) == SUBACK) /* wait for suback */
|
||||
@@ -187,8 +205,10 @@ MQTTINIT:
|
||||
MQTTDeserialize_suback (&submsgid, 1, &subcount, &granted_qos, mqtt_buffer, MQTT_BUFF_LENGTH);
|
||||
if (granted_qos != 0)
|
||||
{
|
||||
rt_kprintf ("granted qos != 0, %d\n", granted_qos);
|
||||
log_i ("granted qos != 0, %d\n", granted_qos);
|
||||
netdrv_clear();
|
||||
netdrv_reset();// 切换到mqtt 驱动
|
||||
rt_thread_mdelay (3000);
|
||||
goto MQTTINIT;
|
||||
}
|
||||
}
|
||||
@@ -197,11 +217,12 @@ MQTTINIT:
|
||||
rt_kprintf ("sub topic faild\r\n");
|
||||
rt_thread_delay (1000);
|
||||
netdrv_clear();
|
||||
netdrv_reset();
|
||||
goto MQTTINIT;
|
||||
}
|
||||
netdrv_clear();
|
||||
|
||||
rt_kprintf ("subtopic topic %s\r\n", subtopic[0].cstring);
|
||||
log_i ("subtopic topic [%s]", subtopic[1].cstring);
|
||||
rt_event_send (gTrigEvents, EVENT_TRIG_MQTT_SUB);
|
||||
netdrv_clear();
|
||||
rt_thread_delay (500);
|
||||
@@ -226,16 +247,14 @@ MQTTINIT:
|
||||
&payload_in, &payloadlen_in, mqtt_buffer, MQTT_BUFF_LENGTH);
|
||||
rt_memcpy (gMqttDrv.rxbuff, payload_in, payloadlen_in) ;
|
||||
gMqttDrv.rx_size = payloadlen_in;
|
||||
//rt_memcpy(gMqttDrv.topic,receivedTopic.lenstring.data,receivedTopic.lenstring.len);
|
||||
|
||||
|
||||
for (int var = 0; var < SUBTOPIC_COUNT + 1; ++var)
|
||||
{
|
||||
if (rt_memcmp (subtopic[var].cstring, receivedTopic.lenstring.data, receivedTopic.lenstring.len) == 0)
|
||||
{
|
||||
gMqttDrv.rx_index = var;
|
||||
rt_kprintf ("recv from :%d,%*.s\r\n", gMqttDrv.rx_index, receivedTopic.lenstring.len, receivedTopic.lenstring.data);
|
||||
break;
|
||||
log_i ("recv from :%d", gMqttDrv.rx_index);
|
||||
// break;
|
||||
}
|
||||
}
|
||||
if (gMqttDrv.rx_index == 0) // 0 通道为升级通道
|
||||
@@ -246,7 +265,7 @@ MQTTINIT:
|
||||
{
|
||||
rt_event_send (gTrigEvents, EVENT_TRIG_COMM_RX);
|
||||
}
|
||||
timerout_timer = 0;
|
||||
MQTT_timerout_timer = 0;
|
||||
}
|
||||
netdrv_clear();
|
||||
}
|
||||
@@ -258,7 +277,8 @@ MQTTINIT:
|
||||
}
|
||||
if (RT_EOK == rt_event_recv (gTrigEvents, EVENT_TRIG_MQTT_RST, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, 0, RT_NULL))
|
||||
{
|
||||
rt_kprintf ("mqtt conn lost\r\n");
|
||||
log_i ("mqtt conn lost by timeout");
|
||||
//netdrv_switch();// 切换到mqtt 驱动
|
||||
netdrv_reset();
|
||||
State = DISC;
|
||||
rt_event_send (gTrigEvents, EVENT_TRIG_COMM_RST);
|
||||
@@ -267,7 +287,8 @@ MQTTINIT:
|
||||
// 网络链接丢失
|
||||
if (g_netDrv->State != Conn)
|
||||
{
|
||||
rt_kprintf ("mqtt conn lost\r\n");
|
||||
log_i ("mqtt conn lost by network\r\n");
|
||||
//netdrv_switch();// 切换到mqtt 驱动
|
||||
netdrv_reset();
|
||||
State = DISC;
|
||||
rt_event_send (gTrigEvents, EVENT_TRIG_COMM_RST);
|
||||
@@ -283,7 +304,6 @@ MQTTINIT:
|
||||
|
||||
void MQTT_SendData (void)
|
||||
{
|
||||
|
||||
// topic_index = index;
|
||||
//// rt_memcpy(mqtt_payload,data,size);
|
||||
//// mqtt_payload_size = size ;
|
||||
@@ -313,7 +333,7 @@ void MQTTThreadStart (void)
|
||||
|
||||
void shell_mqtt_time (void)
|
||||
{
|
||||
rt_kprintf ("lost_timer:%u\r\n", timerout_timer) ;
|
||||
rt_kprintf ("lost_timer:%u\r\n", MQTT_timerout_timer) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+139
-65
@@ -9,80 +9,116 @@
|
||||
#include "netdrv.h"
|
||||
#include "dtu-board.h"
|
||||
|
||||
extern netDrv_t g_cat1Drv;
|
||||
extern netDrv_t g_MJEth1Drv;
|
||||
extern netDrv_t g_dtuDrv;
|
||||
|
||||
#if !defined(LOG_TAG)
|
||||
#define LOG_TAG "netdrv"
|
||||
#endif
|
||||
#include <elog.h>
|
||||
|
||||
extern netDrvInfo_t g_cat1Drv;
|
||||
extern netDrvInfo_t g_MJEth1Drv;
|
||||
extern netDrvInfo_t g_dtuDrv;
|
||||
|
||||
|
||||
netDrv_t * g_netDrv;
|
||||
netDrvInfo_t * g_netDrv;
|
||||
|
||||
|
||||
|
||||
static int mysock = 0;
|
||||
static int offset = 0;
|
||||
netDrv_t g_net_drv = Cat1;// 0选择4G 上网 1:选择eth上网
|
||||
|
||||
|
||||
|
||||
|
||||
// 使用4G 模块上网
|
||||
static void netdrv_openCat1 (void)
|
||||
{
|
||||
g_dtuDrv.IsEnable = 0; // 打开4G
|
||||
g_cat1Drv.IsEnable = 1;
|
||||
g_netDrv = &g_cat1Drv; // 0 选择 dtu 上网
|
||||
rt_event_send (gTrigEvents, EVENT_TRIG_ETH_SHUT) ;
|
||||
}
|
||||
// 使用Eth 模块上网
|
||||
static void netdrv_openDtu (void)
|
||||
{
|
||||
g_dtuDrv.IsEnable = 1; // 打开4G
|
||||
g_cat1Drv.IsEnable = 0;
|
||||
g_netDrv = &g_dtuDrv; // 0 选择 dtu 上网
|
||||
// 通知4g模块关机
|
||||
rt_event_send (gTrigEvents, EVENT_TRIG_CAT1_SHUT) ;
|
||||
|
||||
}
|
||||
|
||||
void netdrv_init (void)
|
||||
{
|
||||
char * drv = ef_get_env ("net_drv"); // 读取网络类型
|
||||
if (rt_memcmp ("dtu", drv, 3) == 0) // 驱动程序位DTU模式,就是不通过本地配置,直接透传
|
||||
{
|
||||
g_netDrv = &g_dtuDrv;
|
||||
DTUThreadStart();
|
||||
}
|
||||
else if (rt_memcmp ("ec200", drv, 4) == 0)
|
||||
{
|
||||
g_netDrv = &g_cat1Drv;
|
||||
|
||||
CAT1ThreadStart();
|
||||
if (g_net_drv == Dtu) // 4G 模块
|
||||
{
|
||||
netdrv_openDtu();
|
||||
}
|
||||
// else if (rt_memcmp ("eth", drv, 3) == 0)
|
||||
// {
|
||||
// g_netDrv = &g_MJEth1Drv;
|
||||
// MJEth1ThreadStart();
|
||||
// }
|
||||
else
|
||||
{
|
||||
|
||||
netdrv_openCat1();
|
||||
}
|
||||
DTUThreadStart(); // 启动线程
|
||||
CAT1ThreadStart(); // 启动线程
|
||||
}
|
||||
|
||||
|
||||
void netdrv_service_tx (uint8_t * data, int length)
|
||||
{
|
||||
char * drv = ef_get_env ("net_drv"); // 读取网络类型
|
||||
if (rt_memcmp ("dtu", drv, 3) == 0) // 驱动程序位DTU模式,就是不通过本地配置,直接透传
|
||||
|
||||
if (g_net_drv == Dtu)
|
||||
{
|
||||
dtu_service_tx ( (char *) data, length);
|
||||
}
|
||||
else if (rt_memcmp ("ec200", drv, 4) == 0)
|
||||
else
|
||||
{
|
||||
cat1_service_tx ( (char *) data, length);
|
||||
}
|
||||
else if (rt_memcmp ("eth", drv, 3) == 0)
|
||||
{
|
||||
}
|
||||
|
||||
// 切换网络驱动
|
||||
void netdrv_switch (void)
|
||||
{
|
||||
if (g_net_drv == Dtu)
|
||||
{
|
||||
log_i ("net work drv switch to cat1");
|
||||
netdrv_openCat1();
|
||||
g_net_drv = Cat1 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
log_i ("net work drv switch to dtu");
|
||||
netdrv_openDtu();
|
||||
g_net_drv = Dtu ;
|
||||
}
|
||||
}
|
||||
|
||||
void netdrv_reset (void)
|
||||
{
|
||||
char * drv = ef_get_env ("net_drv"); // 读取网络类型
|
||||
if (rt_memcmp ("dtu", drv, 3) == 0) // 驱动程序位DTU模式,就是不通过本地配置,直接透传
|
||||
// char * drv = ef_get_env ("net_drv"); // 读取网络类型
|
||||
// if (rt_memcmp ("dtu", drv, 3) == 0) // 驱动程序位DTU模式,就是不通过本地配置,直接透传
|
||||
// {
|
||||
// dtu_netreset();
|
||||
// }
|
||||
// else if (rt_memcmp ("ec200", drv, 4) == 0)
|
||||
// {
|
||||
// //cat1_service_tx ( (char *) data, length);
|
||||
// }
|
||||
// else if (rt_memcmp ("eth", drv, 3) == 0)
|
||||
// {
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
if (g_net_drv == Dtu)
|
||||
{
|
||||
dtu_netreset();
|
||||
}
|
||||
else if (rt_memcmp ("ec200", drv, 4) == 0)
|
||||
{
|
||||
//cat1_service_tx ( (char *) data, length);
|
||||
}
|
||||
else if (rt_memcmp ("eth", drv, 3) == 0)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -94,23 +130,47 @@ void netdrv_reset (void)
|
||||
int netdrv_getdata (unsigned char* buf, int count)
|
||||
{
|
||||
int tsize = 0;
|
||||
char * drv = ef_get_env ("net_drv"); // 读取网络类型
|
||||
if (rt_memcmp ("dtu", drv, 3) == 0) // 驱动程序位DTU模式,就是不通过本地配置,直接透传
|
||||
{
|
||||
if (offset + count > g_netDrv->rx_size)
|
||||
{
|
||||
tsize = g_netDrv->rx_size - offset;
|
||||
rt_memcpy (buf, &g_netDrv->rxbuff[offset], tsize);
|
||||
}
|
||||
else
|
||||
{
|
||||
tsize = count;
|
||||
rt_memcpy (buf, &g_netDrv->rxbuff[offset], tsize);
|
||||
}
|
||||
// char * drv = ef_get_env ("net_drv"); // 读取网络类型
|
||||
// if (rt_memcmp ("dtu", drv, 3) == 0) // 驱动程序位DTU模式,就是不通过本地配置,直接透传
|
||||
// {
|
||||
// if (offset + count > g_netDrv->rx_size)
|
||||
// {
|
||||
// tsize = g_netDrv->rx_size - offset;
|
||||
// rt_memcpy (buf, &g_netDrv->rxbuff[offset], tsize);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// tsize = count;
|
||||
// rt_memcpy (buf, &g_netDrv->rxbuff[offset], tsize);
|
||||
// }
|
||||
|
||||
}
|
||||
else if (rt_memcmp ("ec200", drv, 4) == 0)
|
||||
// }
|
||||
// else if (rt_memcmp ("ec200", drv, 4) == 0)
|
||||
// {
|
||||
// if (offset + count > g_netDrv->rx_size)
|
||||
// {
|
||||
// tsize = g_netDrv->rx_size - offset;
|
||||
// rt_memcpy (buf, &g_netDrv->rxbuff[offset], tsize);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// tsize = count;
|
||||
// rt_memcpy (buf, &g_netDrv->rxbuff[offset], tsize);
|
||||
// }
|
||||
// }
|
||||
// else if (rt_memcmp ("eth", drv, 3) == 0)
|
||||
// {
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
|
||||
if (g_net_drv == Dtu)
|
||||
{
|
||||
//dtu_netreset();
|
||||
if (offset + count > g_netDrv->rx_size)
|
||||
{
|
||||
tsize = g_netDrv->rx_size - offset;
|
||||
@@ -122,13 +182,18 @@ int netdrv_getdata (unsigned char* buf, int count)
|
||||
rt_memcpy (buf, &g_netDrv->rxbuff[offset], tsize);
|
||||
}
|
||||
}
|
||||
else if (rt_memcmp ("eth", drv, 3) == 0)
|
||||
else
|
||||
{
|
||||
|
||||
if (offset + count > g_netDrv->rx_size)
|
||||
{
|
||||
tsize = g_netDrv->rx_size - offset;
|
||||
rt_memcpy (buf, &g_netDrv->rxbuff[offset], tsize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
tsize = count;
|
||||
rt_memcpy (buf, &g_netDrv->rxbuff[offset], tsize);
|
||||
}
|
||||
}
|
||||
offset += count;
|
||||
return tsize;
|
||||
@@ -138,19 +203,28 @@ int netdrv_getdata (unsigned char* buf, int count)
|
||||
int netdrv_clear (void)
|
||||
{
|
||||
|
||||
char * drv = ef_get_env ("net_drv"); // 读取网络类型
|
||||
if (rt_memcmp ("dtu", drv, 3) == 0) // 驱动程序位DTU模式,就是不通过本地配置,直接透传
|
||||
// char * drv = ef_get_env ("net_drv"); // 读取网络类型
|
||||
// if (rt_memcmp ("dtu", drv, 3) == 0) // 驱动程序位DTU模式,就是不通过本地配置,直接透传
|
||||
// {
|
||||
// MX_UART_Clear (&g_ETH1Drv);
|
||||
|
||||
// }
|
||||
// else if (rt_memcmp ("ec200", drv, 4) == 0)
|
||||
// {
|
||||
// //rt_memcpy(buf, &g_cat1Drv.rxbuff[offset], count);
|
||||
// }
|
||||
// else if (rt_memcmp ("eth", drv, 3) == 0)
|
||||
// {
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
if (g_net_drv == Dtu)
|
||||
{
|
||||
MX_UART_Clear (&g_ETH1Drv);
|
||||
|
||||
}
|
||||
else if (rt_memcmp ("ec200", drv, 4) == 0)
|
||||
{
|
||||
//rt_memcpy(buf, &g_cat1Drv.rxbuff[offset], count);
|
||||
}
|
||||
else if (rt_memcmp ("eth", drv, 3) == 0)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+19
-8
@@ -10,7 +10,13 @@ typedef enum netDrvState_t
|
||||
Idle // 空闲
|
||||
} netDrvState_t;
|
||||
|
||||
typedef struct netDrv_t
|
||||
typedef enum netDrv_t
|
||||
{
|
||||
Dtu = 0,
|
||||
Cat1 = 1
|
||||
} netDrv_t;
|
||||
|
||||
typedef struct netDrvInfo_t
|
||||
{
|
||||
int Csq;
|
||||
char Iccid[20];
|
||||
@@ -19,7 +25,10 @@ typedef struct netDrv_t
|
||||
int rx_size; // 接受到的tcp 数据缓存
|
||||
char * txbuff; // 发送的TCP 数据缓存
|
||||
int tx_size;
|
||||
} netDrv_t;
|
||||
int IsEnable;
|
||||
} netDrvInfo_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef enum CommRet_T
|
||||
@@ -28,14 +37,16 @@ typedef enum CommRet_T
|
||||
RetErr
|
||||
} CommRet_T;
|
||||
|
||||
extern netDrv_t * g_netDrv;;
|
||||
extern netDrvInfo_t * g_netDrv;
|
||||
extern netDrv_t g_net_drv ;// 0选择4G 上网 1:选择eth上网
|
||||
|
||||
|
||||
void netdrv_service_tx (uint8_t * data, int length);
|
||||
int netdrv_getdata (uint8_t* buf, int count);
|
||||
int netdrv_clear (void);
|
||||
void netdrv_init (void);
|
||||
void netdrv_reset (void); // 网络链接失败,通知驱动重新启动网络模块
|
||||
extern void netdrv_service_tx (uint8_t * data, int length);
|
||||
extern int netdrv_getdata (uint8_t* buf, int count);
|
||||
extern int netdrv_clear (void);
|
||||
extern void netdrv_init (void);
|
||||
extern void netdrv_reset (void); // 网络链接失败,通知驱动重新启动网络模块
|
||||
extern void netdrv_switch (void);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,82 @@
|
||||
#include <stdint.h>
|
||||
#include "aes.h"
|
||||
#include <rtthread.h>
|
||||
|
||||
/*!
|
||||
* AES computation context variable
|
||||
*/
|
||||
static aes_context AesContext;
|
||||
/*!
|
||||
* Encryption aBlock and sBlock
|
||||
*/
|
||||
static uint8_t aBlock[] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
static uint8_t sBlock[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
|
||||
void LoRaMacPayloadEncrypt (const uint8_t *buffer, uint16_t size, const uint8_t *key, uint8_t *encBuffer)
|
||||
{
|
||||
uint16_t i;
|
||||
uint8_t bufferIndex = 0;
|
||||
uint16_t ctr = 1;
|
||||
|
||||
rt_memset (AesContext.ksch, '\0', 240);
|
||||
aes_set_key (key, 16, &AesContext);
|
||||
|
||||
// aBlock[5] = dir;
|
||||
|
||||
// aBlock[6] = ( address ) & 0xFF;
|
||||
// aBlock[7] = ( address >> 8 ) & 0xFF;
|
||||
// aBlock[8] = ( address >> 16 ) & 0xFF;
|
||||
// aBlock[9] = ( address >> 24 ) & 0xFF;
|
||||
|
||||
// aBlock[10] = ( sequenceCounter ) & 0xFF;
|
||||
// aBlock[11] = ( sequenceCounter >> 8 ) & 0xFF;
|
||||
// aBlock[12] = ( sequenceCounter >> 16 ) & 0xFF;
|
||||
// aBlock[13] = ( sequenceCounter >> 24 ) & 0xFF;
|
||||
|
||||
while (size >= 16)
|
||||
{
|
||||
aBlock[15] = ( (ctr) & 0xFF);
|
||||
ctr++;
|
||||
aes_encrypt (aBlock, sBlock, &AesContext);
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
encBuffer[bufferIndex + i] = buffer[bufferIndex + i] ^ sBlock[i];
|
||||
}
|
||||
size -= 16;
|
||||
bufferIndex += 16;
|
||||
}
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
aBlock[15] = ( (ctr) & 0xFF);
|
||||
aes_encrypt (aBlock, sBlock, &AesContext);
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
encBuffer[bufferIndex + i] = buffer[bufferIndex + i] ^ sBlock[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LoRaMacPayloadDecrypt (const uint8_t *buffer, uint16_t size, const uint8_t *key, uint32_t address, uint8_t dir, uint32_t sequenceCounter, uint8_t *decBuffer)
|
||||
{
|
||||
LoRaMacPayloadEncrypt (buffer, size, key, decBuffer);
|
||||
}
|
||||
|
||||
|
||||
void netWorkAesInit (void)
|
||||
{
|
||||
char data[128] = {"8989098989098989"}, data1[128];
|
||||
char key[] = {"8989098989890989"};
|
||||
aes_set_key (key, 16, &AesContext);
|
||||
LoRaMacPayloadEncrypt (data, 16, key, data1) ;
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
rt_kprintf ("%02x", data1[i]);
|
||||
}
|
||||
rt_kprintf ("\r\n");
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef _NEETWORK_CRYPTO_H
|
||||
#define _NEETWORK_CRYPTO_H
|
||||
|
||||
void netWorkAesInit (void);
|
||||
|
||||
|
||||
#endif
|
||||
+14
-7
@@ -10,6 +10,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
static int g_syn_number = 0;
|
||||
|
||||
|
||||
@@ -35,7 +36,6 @@ int PacketHeader (uint8_t func, char * data, int length, char * txbuff)
|
||||
txbuff[tx_size++] = 0x00;
|
||||
txbuff[tx_size++] = length;// 长度
|
||||
txbuff[tx_size++] = _651_STX;
|
||||
//dbg_printf ("sizeof (_651_U_Header_t):%d\r\n", tx_size);
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
@@ -99,6 +99,14 @@ int PakcetTimerUp (int k, char * tx_data)
|
||||
|
||||
tx_data[tx_size++] = 0xFF; // 要素1 闸前水位
|
||||
tx_data[tx_size++] = 0x39; // 要素1 闸前水位
|
||||
#ifdef USER_UNREAL_DATA // 使用虚拟数据上报
|
||||
WaterData[0].thisSpeed = rand() % 36 / 10;
|
||||
WaterData[0].thisFlow = rand() % 36 / 10;
|
||||
WaterData[0].ttWater = 32567;
|
||||
SluiceData[0].gopen = 835;
|
||||
SluiceData[0].lload = 250;
|
||||
WaterData[0].thisLevel = rand() % 36 / 10;
|
||||
#endif
|
||||
|
||||
intk.data = WaterData[0].thisSpeed * 100;
|
||||
tx_data[tx_size++] = intk.byte[3];
|
||||
@@ -117,13 +125,13 @@ int PakcetTimerUp (int k, char * tx_data)
|
||||
tx_data[tx_size++] = intk.byte[2];
|
||||
tx_data[tx_size++] = intk.byte[1];
|
||||
tx_data[tx_size++] = intk.byte[0];
|
||||
intk.data = SluiceData[k].gopen * 10;
|
||||
intk.data = SluiceData[0].gopen * 10;
|
||||
tx_data[tx_size++] = intk.byte[3];
|
||||
tx_data[tx_size++] = intk.byte[2];
|
||||
tx_data[tx_size++] = intk.byte[1];
|
||||
tx_data[tx_size++] = intk.byte[0];
|
||||
|
||||
intk.data = (SluiceData[k].lload + SluiceData[k].rload) * 10;
|
||||
intk.data = (SluiceData[0].lload + SluiceData[0].rload) * 10;
|
||||
tx_data[tx_size++] = intk.byte[3];
|
||||
tx_data[tx_size++] = intk.byte[2];
|
||||
tx_data[tx_size++] = intk.byte[1];
|
||||
@@ -137,14 +145,14 @@ int PakcetTimerUp (int k, char * tx_data)
|
||||
tx_data[tx_size++] = intk.byte[0];
|
||||
|
||||
// 要素7 电池电压
|
||||
intk.data = 0 * 100;
|
||||
intk.data = 12.3 * 100;
|
||||
tx_data[tx_size++] = intk.byte[3];
|
||||
tx_data[tx_size++] = intk.byte[2];
|
||||
tx_data[tx_size++] = intk.byte[1];
|
||||
tx_data[tx_size++] = intk.byte[0];
|
||||
|
||||
// 要素8 机箱温度
|
||||
intk.data = 0 * 100;
|
||||
intk.data = 25.6 * 100;
|
||||
tx_data[tx_size++] = intk.byte[3];
|
||||
tx_data[tx_size++] = intk.byte[2];
|
||||
tx_data[tx_size++] = intk.byte[1];
|
||||
@@ -171,8 +179,7 @@ int PacketSluiceUp (int k, char * tx_data)
|
||||
tx_data[tx_size++] = 0x01;
|
||||
tx_data[tx_size++] = 0x01;
|
||||
// // 闸门开度
|
||||
intk.data = SluiceData[k].gopen * 10;
|
||||
rt_kprintf("gopen:%d\r\n");
|
||||
intk.data = SluiceData[0].gopen * 10;
|
||||
tx_data[tx_size++] = intk.byte[3];
|
||||
tx_data[tx_size++] = intk.byte[2];
|
||||
tx_data[tx_size++] = intk.byte[1];
|
||||
|
||||
+188
-34
@@ -1,6 +1,10 @@
|
||||
#include "usart-board.h"
|
||||
#include "usart.h"
|
||||
|
||||
#include <rtthread.h>
|
||||
#if !defined(LOG_TAG)
|
||||
#define LOG_TAG "uart"
|
||||
#endif
|
||||
#include <elog.h>
|
||||
|
||||
#define UART_LPUART1_BUFF_SIZE 256 // 4853
|
||||
#define UART_LPUART2_BUFF_SIZE 2400 // gsm
|
||||
@@ -23,6 +27,11 @@ static char s_uart5_buff[UART_UART5_BUFF_SIZE];
|
||||
static char s_uart6_buff[UART_UART6_BUFF_SIZE];
|
||||
|
||||
|
||||
#define RXBUFFERSIZE 2400
|
||||
uint8_t aDmaLp2RxBuffer[RXBUFFERSIZE];
|
||||
uint8_t aDmaU4RxBuffer [RXBUFFERSIZE];
|
||||
|
||||
|
||||
extern UART_HandleTypeDef hlpuart1;
|
||||
extern UART_HandleTypeDef hlpuart2;
|
||||
extern UART_HandleTypeDef huart1;
|
||||
@@ -208,6 +217,7 @@ void MX_UART_Init (UartDrv_t *drv)
|
||||
Error_Handler();
|
||||
}
|
||||
__HAL_UART_ENABLE_IT (&hlpuart1, UART_IT_RXNE);
|
||||
__HAL_UART_ENABLE_IT (&hlpuart1, UART_IT_ORE);
|
||||
break;
|
||||
}
|
||||
case G0_LPUART2 : // GSM
|
||||
@@ -238,7 +248,16 @@ void MX_UART_Init (UartDrv_t *drv)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
__HAL_UART_ENABLE_IT (&hlpuart2, UART_IT_RXNE);
|
||||
|
||||
//__HAL_UART_ENABLE_IT (&hlpuart2, UART_IT_RXNE);
|
||||
__HAL_UART_ENABLE_IT(&hlpuart2, UART_IT_IDLE);
|
||||
__HAL_UART_ENABLE_IT (&hlpuart2, UART_IT_ORE);
|
||||
// __HAL_UART_ENABLE_IT (&hlpuart2, UART_IT_NE);
|
||||
// __HAL_UART_ENABLE_IT (&hlpuart2, UART_IT_FE);
|
||||
if (HAL_UART_Receive_DMA (&hlpuart2, (uint8_t *) aDmaLp2RxBuffer, RXBUFFERSIZE) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
break;
|
||||
case G0_UART1 : // 4853
|
||||
huart1.Instance = USART1;
|
||||
@@ -300,6 +319,7 @@ void MX_UART_Init (UartDrv_t *drv)
|
||||
}
|
||||
// 使能串口接受中断,用于接受数据
|
||||
__HAL_UART_ENABLE_IT (&huart2, UART_IT_RXNE);
|
||||
__HAL_UART_ENABLE_IT (&huart2, UART_IT_ORE);
|
||||
break;
|
||||
case G0_UART3: // 4852
|
||||
huart3.Instance = USART3;
|
||||
@@ -329,6 +349,7 @@ void MX_UART_Init (UartDrv_t *drv)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
__HAL_UART_ENABLE_IT (&huart3, UART_IT_ORE);
|
||||
__HAL_UART_ENABLE_IT (&huart3, UART_IT_RXNE);
|
||||
break;
|
||||
case G0_UART4: // ETH1
|
||||
@@ -348,7 +369,13 @@ void MX_UART_Init (UartDrv_t *drv)
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN USART4_Init 2 */
|
||||
__HAL_UART_ENABLE_IT (&huart4, UART_IT_RXNE);
|
||||
//__HAL_UART_ENABLE_IT (&huart4, UART_IT_RXNE);
|
||||
__HAL_UART_ENABLE_IT(&huart4, UART_IT_IDLE);
|
||||
__HAL_UART_ENABLE_IT (&huart4, UART_IT_ORE);
|
||||
if (HAL_UART_Receive_DMA (&huart4, (uint8_t *) aDmaU4RxBuffer, RXBUFFERSIZE) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
break;
|
||||
case G0_UART5: // 4851
|
||||
huart5.Instance = USART5;
|
||||
@@ -367,6 +394,7 @@ void MX_UART_Init (UartDrv_t *drv)
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN USART5_Init 2 */
|
||||
__HAL_UART_ENABLE_IT (&huart5, UART_IT_ORE);
|
||||
__HAL_UART_ENABLE_IT (&huart5, UART_IT_RXNE);
|
||||
break;
|
||||
case G0_UART6: // View
|
||||
@@ -386,6 +414,7 @@ void MX_UART_Init (UartDrv_t *drv)
|
||||
Error_Handler();
|
||||
}
|
||||
__HAL_UART_ENABLE_IT (&huart6, UART_IT_RXNE);
|
||||
__HAL_UART_ENABLE_IT (&huart6, UART_IT_ORE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -393,22 +422,34 @@ void MX_UART_Init (UartDrv_t *drv)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MX_UART_IRQHandle (void)
|
||||
void MX_UART2_LPUART2_IRQHandle (void)
|
||||
{
|
||||
uint8_t ret;
|
||||
if (USART3->ISR & (1 << 5)) // ´®¿Ú2
|
||||
// if (LPUART2->ISR & USART_ISR_RXNE_RXFNE)
|
||||
// {
|
||||
//
|
||||
// ret = LPUART2->RDR;
|
||||
// if (g_GSMDrv.rx_buffer != NULL)
|
||||
// {
|
||||
// g_GSMDrv.rx_buffer[g_GSMDrv.rx_size++] = ret;
|
||||
// g_GSMDrv.rx_timer = 30; // 30ms
|
||||
// if (g_GSMDrv.rx_size > UART_LPUART2_BUFF_SIZE)
|
||||
// g_GSMDrv.rx_size = 0;
|
||||
// }
|
||||
// } debug
|
||||
|
||||
if (LPUART2->ISR & USART_ISR_ORE)
|
||||
{
|
||||
ret = USART3->RDR;
|
||||
if (g_U4852Drv.rx_buffer != NULL)
|
||||
// rt_kprintf("ore:l2\r\n");
|
||||
__HAL_UART_CLEAR_FLAG(&hlpuart2, UART_CLEAR_OREF);
|
||||
}
|
||||
if (USART2->ISR & USART_ISR_ORE)
|
||||
{
|
||||
g_U4852Drv.rx_buffer[g_U4852Drv.rx_size++] = ret;
|
||||
g_U4852Drv.rx_timer = 30; // 30ms
|
||||
if (g_U4852Drv.rx_size > UART_UART3_BUFF_SIZE)
|
||||
g_U4852Drv.rx_size = 0;
|
||||
//rt_kprintf("ore:2\r\n");
|
||||
__HAL_UART_CLEAR_FLAG(&huart2, UART_CLEAR_OREF);
|
||||
}
|
||||
}
|
||||
if (USART2->ISR & (1 << 5)) // ´®¿Ú2
|
||||
|
||||
if (USART2->ISR & USART_ISR_RXNE_RXFNE) // 串口2
|
||||
{
|
||||
ret = USART2->RDR;
|
||||
if (g_DebugDrv.rx_buffer != NULL)
|
||||
@@ -419,18 +460,87 @@ void MX_UART_IRQHandle (void)
|
||||
g_DebugDrv.rx_size = 0;
|
||||
}
|
||||
}
|
||||
if (USART4->ISR & (1 << 5))
|
||||
}
|
||||
|
||||
// 串口空闲终端处理函数
|
||||
void MX_UART2_LPUART2_IDLE_IRQHandle(void)
|
||||
{
|
||||
ret = USART4->RDR;
|
||||
if (g_ETH1Drv.rx_buffer != NULL)
|
||||
uint16_t ret;
|
||||
|
||||
if (LPUART2->ISR & USART_ISR_IDLE) // 串口空闲中断
|
||||
{
|
||||
ret = UART_LPUART2_BUFF_SIZE - __HAL_DMA_GET_COUNTER(hlpuart2.hdmarx); // 接收到数据的长度
|
||||
if (ret > 0)
|
||||
{
|
||||
rt_memcpy(g_GSMDrv.rx_buffer,aDmaLp2RxBuffer,ret);
|
||||
g_GSMDrv.rx_size = ret;
|
||||
//g_GSMDrv.rxdone();
|
||||
}
|
||||
else
|
||||
{
|
||||
g_GSMDrv.rx_size = 0;
|
||||
}
|
||||
g_GSMDrv.rxdone();
|
||||
__HAL_UART_CLEAR_FLAG(&hlpuart2, UART_CLEAR_IDLEF);
|
||||
// 处理DMA 数据
|
||||
}
|
||||
// 处理DMA 数据
|
||||
}
|
||||
|
||||
void MX_UART_IDLE_IRQHandle(void)
|
||||
{
|
||||
uint16_t ret;
|
||||
|
||||
if (USART4->ISR & USART_ISR_IDLE) // 串口空闲中断
|
||||
{
|
||||
|
||||
ret = UART_UART4_BUFF_SIZE - __HAL_DMA_GET_COUNTER(huart4.hdmarx); // 接收到数据的长度
|
||||
//log_i("MX_UART_IDLE_IRQHandle:%d",ret);
|
||||
if (ret > 0)
|
||||
{
|
||||
rt_memcpy(g_ETH1Drv.rx_buffer,aDmaU4RxBuffer,ret);
|
||||
g_ETH1Drv.rx_size = ret;
|
||||
//g_ETH1Drv.rxdone();
|
||||
}
|
||||
else
|
||||
{
|
||||
g_ETH1Drv.rx_buffer[g_ETH1Drv.rx_size++] = ret;
|
||||
g_ETH1Drv.rx_timer = 30; // 30ms
|
||||
if (g_ETH1Drv.rx_size > UART_UART4_BUFF_SIZE)
|
||||
g_ETH1Drv.rx_size = 0;
|
||||
}
|
||||
g_ETH1Drv.rxdone();
|
||||
__HAL_UART_CLEAR_FLAG(&huart4, UART_CLEAR_IDLEF);
|
||||
// 处理DMA 数据
|
||||
}
|
||||
if (USART5->ISR & (1 << 5))
|
||||
// 处理DMA 数据
|
||||
}
|
||||
|
||||
|
||||
void MX_UART_IRQHandle (void)
|
||||
{
|
||||
uint8_t ret;
|
||||
|
||||
if (USART3->ISR & USART_ISR_RXNE_RXFNE) // 串口2
|
||||
{
|
||||
ret = USART3->RDR;
|
||||
if (g_U4852Drv.rx_buffer != NULL)
|
||||
{
|
||||
g_U4852Drv.rx_buffer[g_U4852Drv.rx_size++] = ret;
|
||||
g_U4852Drv.rx_timer = 30; // 30ms
|
||||
if (g_U4852Drv.rx_size > UART_UART3_BUFF_SIZE)
|
||||
g_U4852Drv.rx_size = 0;
|
||||
}
|
||||
}
|
||||
// if (USART4->ISR & USART_ISR_RXNE_RXFNE)
|
||||
// {
|
||||
// ret = USART4->RDR;
|
||||
// if (g_ETH1Drv.rx_buffer != NULL)
|
||||
// {
|
||||
// g_ETH1Drv.rx_buffer[g_ETH1Drv.rx_size++] = ret;
|
||||
// g_ETH1Drv.rx_timer = 30; // 30ms
|
||||
// if (g_ETH1Drv.rx_size > UART_UART4_BUFF_SIZE)
|
||||
// g_ETH1Drv.rx_size = 0;
|
||||
// }
|
||||
// }
|
||||
if (USART5->ISR & USART_ISR_RXNE_RXFNE)
|
||||
{
|
||||
ret = USART5->RDR;
|
||||
if (g_U4851Drv.rx_buffer != NULL)
|
||||
@@ -441,9 +551,10 @@ void MX_UART_IRQHandle (void)
|
||||
g_U4851Drv.rx_size = 0;
|
||||
}
|
||||
}
|
||||
if (USART6->ISR & (1 << 5))
|
||||
if (USART6->ISR & USART_ISR_RXNE_RXFNE)
|
||||
{
|
||||
ret = USART6->RDR;
|
||||
|
||||
if (g_ViewDrv.rx_buffer != NULL)
|
||||
{
|
||||
g_ViewDrv.rx_buffer[g_ViewDrv.rx_size++] = ret;
|
||||
@@ -453,7 +564,8 @@ void MX_UART_IRQHandle (void)
|
||||
}
|
||||
}
|
||||
|
||||
if (LPUART1->ISR & (1 << 5))
|
||||
|
||||
if (LPUART1->ISR & USART_ISR_RXNE_RXFNE)
|
||||
{
|
||||
ret = LPUART1->RDR;
|
||||
if (g_ETH2Drv.rx_buffer != NULL)
|
||||
@@ -464,27 +576,66 @@ void MX_UART_IRQHandle (void)
|
||||
g_ETH2Drv.rx_size = 0;
|
||||
}
|
||||
}
|
||||
if (USART3->ISR & USART_ISR_ORE)
|
||||
{
|
||||
//rt_kprintf("ore:3\r\n");
|
||||
__HAL_UART_CLEAR_FLAG(&huart3, UART_CLEAR_OREF);
|
||||
}
|
||||
if (USART4->ISR & USART_ISR_ORE)
|
||||
{
|
||||
//rt_kprintf("ore:4\r\n");
|
||||
__HAL_UART_CLEAR_FLAG(&huart4, UART_CLEAR_OREF);
|
||||
}
|
||||
if (USART6->ISR & USART_ISR_ORE)
|
||||
{
|
||||
//rt_kprintf("ore:6\r\n");
|
||||
__HAL_UART_CLEAR_FLAG(&huart6, UART_CLEAR_OREF);
|
||||
}
|
||||
if (USART5->ISR & USART_ISR_ORE)
|
||||
{
|
||||
//rt_kprintf("ore:5\r\n");
|
||||
__HAL_UART_CLEAR_FLAG(&huart5, UART_CLEAR_OREF);
|
||||
}
|
||||
if (LPUART1->ISR & USART_ISR_ORE)
|
||||
{
|
||||
//rt_kprintf("ore:l1\r\n");
|
||||
__HAL_UART_CLEAR_FLAG(&hlpuart1, UART_CLEAR_OREF);
|
||||
}
|
||||
|
||||
if (LPUART2->ISR & (1 << 5))
|
||||
{
|
||||
ret = LPUART2->RDR;
|
||||
if (g_GSMDrv.rx_buffer != NULL)
|
||||
{
|
||||
g_GSMDrv.rx_buffer[g_GSMDrv.rx_size++] = ret;
|
||||
g_GSMDrv.rx_timer = 30; // 30ms
|
||||
if (g_GSMDrv.rx_size > UART_LPUART2_BUFF_SIZE)
|
||||
g_GSMDrv.rx_size = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MX_UART_Clear (UartDrv_t * drv)
|
||||
{
|
||||
if (drv->Id == G0_LPUART2)
|
||||
{
|
||||
if (HAL_UART_AbortReceive(&hlpuart2) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_UART_Receive_DMA (&hlpuart2, (uint8_t *) aDmaLp2RxBuffer, RXBUFFERSIZE) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
else if (drv->Id == G0_UART4)
|
||||
{
|
||||
if (HAL_UART_AbortReceive(&huart4) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_UART_Receive_DMA (&huart4, (uint8_t *) aDmaU4RxBuffer, RXBUFFERSIZE) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
else {
|
||||
drv->rx_size = 0;
|
||||
drv->rx_timer = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MX_UART_PutChar (UartDrv_t * drv, char ch)
|
||||
{
|
||||
switch (drv->Id)
|
||||
@@ -518,6 +669,9 @@ void MX_UART_PutChar (UartDrv_t * drv, char ch)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void MX_UART_PutBuffer (UartDrv_t * drv, char *buff, int size)
|
||||
{
|
||||
for (int i = 0; i < size; i++)
|
||||
|
||||
+87
-46
@@ -20,8 +20,14 @@
|
||||
#include "jsonpacket.h"
|
||||
#include "jsonunpack.h"
|
||||
#include <stdlib.h>
|
||||
#include "user_config.h"
|
||||
|
||||
|
||||
#if !defined(LOG_TAG)
|
||||
#define LOG_TAG "network"
|
||||
#endif
|
||||
#include <elog.h>
|
||||
|
||||
ALIGN (RT_ALIGN_SIZE)
|
||||
static char thread_stack[4096];
|
||||
static struct rt_thread netapp_thread;
|
||||
@@ -35,14 +41,14 @@ extern MqttDrv_t gMqttDrv;
|
||||
static rt_timer_t timer;
|
||||
|
||||
|
||||
static uint32_t g_net_5min_timer[SLUICE_COUTN] = {0};
|
||||
static uint32_t g_net_1min_timer[SLUICE_COUTN] = {0};
|
||||
static uint32_t g_net_5min_timer[SUBTOPIC_COUNT] = {0};
|
||||
static uint32_t g_net_1min_timer[SUBTOPIC_COUNT] = {0};
|
||||
|
||||
|
||||
static void timerouter (void * parameter)
|
||||
{
|
||||
TypeIndexMail_t mail;
|
||||
for (int i = 0; i < SLUICE_COUTN; i++)
|
||||
for (int i = 0; i < SUBTOPIC_COUNT; i++)
|
||||
{
|
||||
if (g_net_1min_timer[i] == 1)
|
||||
{
|
||||
@@ -71,7 +77,7 @@ const static char upinfo[][10] = {"heart", "regist", "stand", "sluice", "upack",
|
||||
|
||||
static void thread_entry (void * argument)
|
||||
{
|
||||
rt_kprintf ("%s was start!\r\n", __FILE__);
|
||||
log_i ("network was start!");
|
||||
TypeIndexMail_t mail;
|
||||
timer = rt_timer_create ("timer", timerouter, RT_NULL, 1000, RT_TIMER_FLAG_PERIODIC);
|
||||
// 读取网络驱动类型
|
||||
@@ -89,18 +95,17 @@ static void thread_entry (void * argument)
|
||||
//site_type
|
||||
char * p = ef_get_env ("site_type") ;
|
||||
int site_type = cSiteType2Index(p);
|
||||
rt_kprintf ("site_type:%d\r\n", site_type);
|
||||
log_i ("site_type:%d", site_type);
|
||||
|
||||
//CommTMail_t mail;
|
||||
// 注册网络驱动
|
||||
// 注册网络驱动
|
||||
while (1)
|
||||
{
|
||||
|
||||
INIT:
|
||||
if (RT_EOK == rt_event_recv (gTrigEvents, EVENT_TRIG_COMM_RST, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, RT_WAITING_NO, RT_NULL))
|
||||
{
|
||||
rt_kprintf ("net work lost\r\n");
|
||||
log_i ("net work lost");
|
||||
mail.Type = MAIL_VIEW_NET_STE;
|
||||
mail.index = DIS_STE_ERROR;
|
||||
rt_mb_send (gViewMail, * ( (uint32_t*) &mail));
|
||||
@@ -115,12 +120,12 @@ INIT:
|
||||
// 订阅成功
|
||||
if (RT_EOK == rt_event_recv (gTrigEvents, EVENT_TRIG_MQTT_SUB, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, RT_WAITING_NO, RT_NULL))
|
||||
{
|
||||
rt_kprintf ("netWork Sub Success\r\n");
|
||||
// 发送注册报
|
||||
mail.Type = MAIL_COMM_REGIST;
|
||||
mail.index = 1;
|
||||
rt_mb_send (gTCommMail, * ( (uint32_t *) &mail));
|
||||
for (int i = 0; i < SLUICE_COUTN; i++)
|
||||
log_i ("sub Success");
|
||||
// // 发送注册报
|
||||
// mail.Type = MAIL_COMM_REGIST;
|
||||
// mail.index = 1;
|
||||
// rt_mb_send (gTCommMail, * ( (uint32_t *) &mail));
|
||||
for (int i = 0; i < SUBTOPIC_COUNT; i++)
|
||||
{
|
||||
rt_timer_start (timer);
|
||||
g_net_1min_timer[i] = i * 10 + 5;
|
||||
@@ -132,7 +137,7 @@ INIT:
|
||||
}
|
||||
if (rt_mb_recv (gTCommMail, (rt_ubase_t *) &mail, RT_WAITING_NO) == RT_EOK)
|
||||
{
|
||||
rt_kprintf ("recv send mail: type:%s,index:%d\n", upinfo[mail.Type], mail.index);
|
||||
log_i ("send packet: type:%s,index:%d", upinfo[mail.Type], mail.index);
|
||||
if (g_ifupdate != 1)
|
||||
{
|
||||
switch (mail.Type)
|
||||
@@ -152,8 +157,8 @@ INIT:
|
||||
case MAIL_COMM_REGIST: // 注册报
|
||||
|
||||
#ifdef USER_JSON_PACKET // 使用Json格式数据包
|
||||
gMqttDrv.tx_size = JsonRegistDataPacket ((uint8_t *) gMqttDrv.txbuff);
|
||||
gMqttDrv.tx_index = mail.index;
|
||||
// gMqttDrv.tx_size = JsonRegistDataPacket ((uint8_t *) gMqttDrv.txbuff);
|
||||
// gMqttDrv.tx_index = mail.index; // 通道号
|
||||
#else
|
||||
// 心跳数据
|
||||
tx_size = PacketUpRegist (data);
|
||||
@@ -163,11 +168,13 @@ INIT:
|
||||
MQTT_SendData () ;
|
||||
break;
|
||||
case MAIL_COMM_SLUICE: // 闸门状态自报
|
||||
#ifndef USER_JSON_PACKET // 使用Json格式数据包
|
||||
tx_size = PacketSluiceUp (mail.index - 1, data);
|
||||
gMqttDrv.tx_size = PacketHeader (0x4E, data, tx_size, gMqttDrv.txbuff);
|
||||
gMqttDrv.tx_index = mail.index;
|
||||
MQTT_SendData () ;
|
||||
break;
|
||||
#endif
|
||||
case MAIL_COMM_STAND: // 5分钟标准包上报
|
||||
|
||||
#ifdef USER_JSON_PACKET // 使用Json格式数据包
|
||||
@@ -198,27 +205,17 @@ INIT:
|
||||
|
||||
MQTT_SendData () ;
|
||||
break;
|
||||
case MAIL_COMM_SLACK: // 提闸的应答
|
||||
tx_size = PacketSluiceAck (data);
|
||||
gMqttDrv.tx_size = PacketHeader (0x4E, data, tx_size, gMqttDrv.txbuff);
|
||||
gMqttDrv.tx_index = mail.index;
|
||||
MQTT_SendData();
|
||||
break;
|
||||
case MAIL_COMM_UPACK: // 升级的应答
|
||||
|
||||
#ifdef USER_JSON_PACKET // 使用Json格式数据包
|
||||
gMqttDrv.tx_size = JsonAckSuccPacket ((uint8_t *) gMqttDrv.txbuff);
|
||||
gMqttDrv.tx_index = mail.index;
|
||||
#else
|
||||
// 心跳数据
|
||||
tx_size = PacketAnsAck (data);
|
||||
gMqttDrv.tx_size = PacketHeader (0xE0, data, tx_size, gMqttDrv.txbuff);
|
||||
gMqttDrv.tx_index = mail.index;
|
||||
#endif
|
||||
// case MAIL_COMM_SLACK: // 提闸的应答
|
||||
// tx_size = PacketSluiceAck (data);
|
||||
// gMqttDrv.tx_size = PacketHeader (0x4E, data, tx_size, gMqttDrv.txbuff);
|
||||
// gMqttDrv.tx_index = mail.index;
|
||||
// MQTT_SendData();
|
||||
// break;
|
||||
|
||||
|
||||
MQTT_SendData();
|
||||
break;
|
||||
|
||||
// MQTT_SendData();
|
||||
// break;
|
||||
case MAIL_COMM_READPARA:
|
||||
#ifdef USER_JSON_PACKET // 使用Json格式数据包
|
||||
gMqttDrv.tx_size = JsonConfigReadDataPacket ((uint8_t *) gMqttDrv.txbuff);
|
||||
@@ -231,6 +228,54 @@ INIT:
|
||||
#endif
|
||||
MQTT_SendData();
|
||||
break;
|
||||
case MAIL_COMM_UPACK: // 升级的应答
|
||||
|
||||
#ifdef USER_JSON_PACKET // 使用Json格式数据包
|
||||
gMqttDrv.tx_size = JsonAckDownload ((uint8_t *) gMqttDrv.txbuff,DownUpdate);
|
||||
gMqttDrv.tx_index = mail.index;
|
||||
#else
|
||||
// 心跳数据
|
||||
tx_size = PacketAnsAck (data);
|
||||
gMqttDrv.tx_size = PacketHeader (0xE0, data, tx_size, gMqttDrv.txbuff);
|
||||
gMqttDrv.tx_index = mail.index;
|
||||
#endif
|
||||
break;
|
||||
case MAIL_COMM_SLACK: // 升级的应答
|
||||
|
||||
#ifdef USER_JSON_PACKET // 使用Json格式数据包
|
||||
gMqttDrv.tx_size = JsonAckDownload ((uint8_t *) gMqttDrv.txbuff,DownRun);
|
||||
gMqttDrv.tx_index = mail.index;
|
||||
#else
|
||||
// 心跳数据
|
||||
tx_size = PacketAnsAck (data);
|
||||
gMqttDrv.tx_size = PacketHeader (0xE0, data, tx_size, gMqttDrv.txbuff);
|
||||
gMqttDrv.tx_index = mail.index;
|
||||
#endif
|
||||
break;
|
||||
case MAIL_COMM_WRACK: // 升级的应答
|
||||
|
||||
#ifdef USER_JSON_PACKET // 使用Json格式数据包
|
||||
gMqttDrv.tx_size = JsonAckDownload ((uint8_t *) gMqttDrv.txbuff,DownConfig);
|
||||
gMqttDrv.tx_index = mail.index;
|
||||
#else
|
||||
// 心跳数据
|
||||
tx_size = PacketAnsAck (data);
|
||||
gMqttDrv.tx_size = PacketHeader (0xE0, data, tx_size, gMqttDrv.txbuff);
|
||||
gMqttDrv.tx_index = mail.index;
|
||||
#endif
|
||||
break;
|
||||
case MAIL_COMM_FACACK: // 升级的应答
|
||||
|
||||
#ifdef USER_JSON_PACKET // 使用Json格式数据包
|
||||
gMqttDrv.tx_size = JsonAckDownload ((uint8_t *) gMqttDrv.txbuff,DownFact);
|
||||
gMqttDrv.tx_index = mail.index;
|
||||
#else
|
||||
// 心跳数据
|
||||
tx_size = PacketAnsAck (data);
|
||||
gMqttDrv.tx_size = PacketHeader (0xE0, data, tx_size, gMqttDrv.txbuff);
|
||||
gMqttDrv.tx_index = mail.index;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -242,17 +287,12 @@ INIT:
|
||||
{
|
||||
|
||||
#ifdef USER_JSON_PACKET // 使用Json格式数据包
|
||||
// 这里-1的作用是将通道0 作为升级通道
|
||||
JsonUnPacket(gMqttDrv.rx_index - 1,gMqttDrv.rxbuff); // 第n个通道过来的数据
|
||||
// 解析数据
|
||||
#else
|
||||
|
||||
rxdata_decode_size = hexstr_to_hexbyte (gMqttDrv.rxbuff, rxdata_decode, gMqttDrv.rx_size);
|
||||
rt_kprintf ("<<<<<<<<<<<<rx_size:%d\r\n", rxdata_decode_size);
|
||||
for (int i = 0; i < rxdata_decode_size; i++)
|
||||
{
|
||||
rt_kprintf ("%02X ", rxdata_decode[i]);
|
||||
}
|
||||
rt_kprintf ("\r\n");
|
||||
elog_hexdump("recv",16,rxdata_decode,rxdata_decode_size);
|
||||
switch ( (int) rxdata_decode[10])
|
||||
{
|
||||
case 0x4E: // 控制闸门操作
|
||||
@@ -260,14 +300,14 @@ INIT:
|
||||
// 远程提闸
|
||||
datak = rxdata_decode[18];
|
||||
datak = (datak << 8) + rxdata_decode[19];
|
||||
rt_kprintf ("open:%u mm/10\r\n", datak);
|
||||
log_i ("chann: %d,open:%u mm\r\n",gMqttDrv.rx_index, datak/10);
|
||||
|
||||
//SluiceData[gMqttDrv.rx_index].opt = 1; // 执行操作闸门
|
||||
SluiceData[gMqttDrv.rx_index - 1].sopen = datak / 10;
|
||||
SluiceData[0].sopen = datak / 10;
|
||||
mail.Type = MAIL_SLUICE_OPT;
|
||||
mail.index = gMqttDrv.rx_index - 1;
|
||||
mail.index = gMqttDrv.rx_index-1; // 获取是从哪个通道来的数据
|
||||
rt_mb_send (gSluiceMail, * ( (uint32_t*) &mail));
|
||||
|
||||
log_i ("index:%u\r\n", mail.index);
|
||||
// 回复应答
|
||||
mail.Type = MAIL_COMM_SLACK;
|
||||
mail.index = gMqttDrv.rx_index;
|
||||
@@ -313,6 +353,7 @@ INIT:
|
||||
// 网络连接丢失
|
||||
rt_thread_mdelay (10);
|
||||
}
|
||||
//NETWORKEXIT:
|
||||
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -19,6 +19,10 @@ static char thread_stack[4096];
|
||||
static struct rt_thread probus_thread;
|
||||
|
||||
|
||||
#if !defined(LOG_TAG)
|
||||
#define LOG_TAG "pbus"
|
||||
#endif
|
||||
#include <elog.h>
|
||||
|
||||
|
||||
//uint16_t REG_DATA[REG_MAX] = {0x00};
|
||||
@@ -85,7 +89,7 @@ static void thread_entry (void * argument)
|
||||
int k = 0;
|
||||
uint8_t txbuff[128] = {0};
|
||||
int tx_size = 0;
|
||||
rt_kprintf ("%s was start!\r\n", __FILE__);
|
||||
log_i ("probus was start!");
|
||||
|
||||
g_ETH2Drv.rxdone = eth2_data_rxdone;
|
||||
g_ETH2Drv.BaudRate = 115200;
|
||||
@@ -103,15 +107,15 @@ static void thread_entry (void * argument)
|
||||
//reg_data.bload = SluiceData[0].rload;
|
||||
if (RT_EOK == rt_event_recv (gUartEvents, EVENT_UART_ETH2_RX, RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, RT_WAITING_NO, RT_NULL))
|
||||
{
|
||||
for (int i = 0; i < g_ETH2Drv.rx_size; i++)
|
||||
{
|
||||
rt_kprintf ("%02x", g_ETH2Drv.rx_buffer[i]);
|
||||
}
|
||||
// for (int i = 0; i < g_ETH2Drv.rx_size; i++)
|
||||
// {
|
||||
// rt_kprintf ("%02x", g_ETH2Drv.rx_buffer[i]);
|
||||
// }
|
||||
if (g_ETH2Drv.rx_size > 4)
|
||||
{
|
||||
k = ModbusSlaveHandle (&modbus_slave, (uint8_t *) g_ETH2Drv.rx_buffer, g_ETH2Drv.rx_size);
|
||||
//k = 2;
|
||||
rt_kprintf ("k:%d\r\n", k);
|
||||
//rt_kprintf ("k:%d\r\n", k);
|
||||
if (k == 0)
|
||||
{
|
||||
switch (modbus_slave.func)
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "gpio.h"
|
||||
#include <rtthread.h>
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
@@ -134,20 +133,6 @@ void MX_GPIO_Init (void)
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||
|
||||
// HAL_GPIO_WritePin (S4851_RT_GPIO_Port, S4851_RT_Pin, GPIO_PIN_SET);
|
||||
|
||||
//HAL_GPIO_WritePin(GPIOB, LOCK_Pin, GPIO_PIN_SET);
|
||||
|
||||
// HAL_GPIO_WritePin(ETH_RST_GPIO_Port, ETH_RST_Pin, GPIO_PIN_SET);
|
||||
// rt_kprintf("+++++++++++++++++++++\r\n");
|
||||
//// /*Configure GPIO pin Output Level */
|
||||
//HAL_GPIO_WritePin(GPIOA, ETH_PW_Pin|GSM_PW_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin (GPIOA, ETH_PW_Pin | GSM_PW_Pin, GPIO_PIN_RESET);
|
||||
|
||||
//
|
||||
/*Configure GPIO pin Output Level */
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
+1
-2
@@ -191,8 +191,7 @@ void HAL_TIM_PeriodElapsedCallback (TIM_HandleTypeDef *htim)
|
||||
/* USER CODE BEGIN Callback 0 */
|
||||
|
||||
/* USER CODE END Callback 0 */
|
||||
if (htim->Instance == TIM2)
|
||||
{
|
||||
if (htim->Instance == TIM2) {
|
||||
HAL_IncTick();
|
||||
}
|
||||
/* USER CODE BEGIN Callback 1 */
|
||||
|
||||
+16
-3
@@ -58,7 +58,8 @@
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
extern DMA_HandleTypeDef hdma_adc1;
|
||||
extern DMA_HandleTypeDef hdma_lpuart1_rx;
|
||||
extern DMA_HandleTypeDef hdma_lpuart2_rx;
|
||||
extern DMA_HandleTypeDef hdma_usart4_rx;
|
||||
extern UART_HandleTypeDef hlpuart1;
|
||||
extern UART_HandleTypeDef hlpuart2;
|
||||
extern UART_HandleTypeDef huart1;
|
||||
@@ -74,8 +75,13 @@ extern TIM_HandleTypeDef htim2;
|
||||
|
||||
/* USER CODE BEGIN EV */
|
||||
extern void MX_UART_IRQHandle (void);
|
||||
extern void MX_UART2_LPUART2_IRQHandle (void);
|
||||
extern void MX_UART_TickHandle (void);
|
||||
extern void main_Systick (void);
|
||||
void USART_ClearOtherIT(UART_HandleTypeDef *huart);
|
||||
void MX_UART2_LPUART2_IDLE_IRQHandle(void);
|
||||
|
||||
void MX_UART_IDLE_IRQHandle(void);
|
||||
/* USER CODE END EV */
|
||||
|
||||
/******************************************************************************/
|
||||
@@ -125,7 +131,8 @@ void DMA1_Channel2_3_IRQHandler (void)
|
||||
/* USER CODE BEGIN DMA1_Channel2_3_IRQn 0 */
|
||||
|
||||
/* USER CODE END DMA1_Channel2_3_IRQn 0 */
|
||||
HAL_DMA_IRQHandler (&hdma_lpuart1_rx);
|
||||
HAL_DMA_IRQHandler(&hdma_usart4_rx);
|
||||
HAL_DMA_IRQHandler(&hdma_lpuart2_rx);
|
||||
/* USER CODE BEGIN DMA1_Channel2_3_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA1_Channel2_3_IRQn 1 */
|
||||
@@ -230,7 +237,10 @@ void USART2_LPUART2_IRQHandler (void)
|
||||
/* USER CODE BEGIN USART2_LPUART2_IRQn 0 */
|
||||
|
||||
|
||||
MX_UART_IRQHandle();
|
||||
MX_UART2_LPUART2_IRQHandle();
|
||||
MX_UART2_LPUART2_IDLE_IRQHandle();
|
||||
|
||||
// MX_UART_IDLE_IRQHandle();
|
||||
/* USER CODE END USART2_LPUART2_IRQn 0 */
|
||||
HAL_UART_IRQHandler(&huart2);
|
||||
HAL_UART_IRQHandler(&hlpuart2);
|
||||
@@ -246,6 +256,7 @@ void USART3_4_5_6_LPUART1_IRQHandler (void)
|
||||
{
|
||||
/* USER CODE BEGIN USART3_4_5_6_LPUART1_IRQn 0 */
|
||||
MX_UART_IRQHandle();
|
||||
MX_UART_IDLE_IRQHandle();
|
||||
/* USER CODE END USART3_4_5_6_LPUART1_IRQn 0 */
|
||||
HAL_UART_IRQHandler(&huart3);
|
||||
HAL_UART_IRQHandler(&huart4);
|
||||
@@ -259,4 +270,6 @@ void USART3_4_5_6_LPUART1_IRQHandler (void)
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
|
||||
|
||||
/* USER CODE END 1 */
|
||||
+4
-6
@@ -132,12 +132,12 @@ void MX_TIM3_Init (void)
|
||||
}
|
||||
/* USER CODE BEGIN TIM3_Init 2 */
|
||||
|
||||
/* USER CODE END TIM3_Init 2 */
|
||||
HAL_TIM_MspPostInit (&htim3);
|
||||
HAL_TIM_PWM_Start (&htim3, TIM_CHANNEL_1);
|
||||
HAL_TIM_PWM_Start (&htim3, TIM_CHANNEL_2);
|
||||
HAL_TIM_PWM_Start (&htim3, TIM_CHANNEL_3);
|
||||
HAL_TIM_PWM_Start (&htim3, TIM_CHANNEL_4);
|
||||
/* USER CODE END TIM3_Init 2 */
|
||||
HAL_TIM_MspPostInit(&htim3);
|
||||
|
||||
}
|
||||
/* TIM6 init function */
|
||||
@@ -251,7 +251,7 @@ void MX_TIM15_Init (void)
|
||||
htim15.Init.Prescaler = 0;
|
||||
htim15.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim15.Init.Period = 65535;
|
||||
htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV4 ;
|
||||
htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim15.Init.RepetitionCounter = 0;
|
||||
htim15.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_PWM_Init(&htim15) != HAL_OK)
|
||||
@@ -265,7 +265,7 @@ void MX_TIM15_Init (void)
|
||||
Error_Handler();
|
||||
}
|
||||
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
||||
sConfigOC.Pulse = 3000;
|
||||
sConfigOC.Pulse = 0;
|
||||
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
|
||||
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||
@@ -295,8 +295,6 @@ void MX_TIM15_Init (void)
|
||||
|
||||
/* USER CODE END TIM15_Init 2 */
|
||||
HAL_TIM_MspPostInit(&htim15);
|
||||
HAL_TIM_PWM_Start (&htim15, TIM_CHANNEL_1);
|
||||
HAL_TIM_PWM_Start (&htim15, TIM_CHANNEL_2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+59
-23
@@ -37,7 +37,8 @@ UART_HandleTypeDef huart3;
|
||||
UART_HandleTypeDef huart4;
|
||||
UART_HandleTypeDef huart5;
|
||||
UART_HandleTypeDef huart6;
|
||||
DMA_HandleTypeDef hdma_lpuart1_rx;
|
||||
DMA_HandleTypeDef hdma_lpuart2_rx;
|
||||
DMA_HandleTypeDef hdma_usart4_rx;
|
||||
|
||||
/* LPUART1 init function */
|
||||
|
||||
@@ -391,24 +392,6 @@ void HAL_UART_MspInit (UART_HandleTypeDef* uartHandle)
|
||||
GPIO_InitStruct.Alternate = GPIO_AF1_LPUART1;
|
||||
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
|
||||
|
||||
/* LPUART1 DMA Init */
|
||||
/* LPUART1_RX Init */
|
||||
hdma_lpuart1_rx.Instance = DMA1_Channel2;
|
||||
hdma_lpuart1_rx.Init.Request = DMA_REQUEST_LPUART1_RX;
|
||||
hdma_lpuart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||
hdma_lpuart1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_lpuart1_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_lpuart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_lpuart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_lpuart1_rx.Init.Mode = DMA_NORMAL;
|
||||
hdma_lpuart1_rx.Init.Priority = DMA_PRIORITY_LOW;
|
||||
if (HAL_DMA_Init (&hdma_lpuart1_rx) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
__HAL_LINKDMA (uartHandle, hdmarx, hdma_lpuart1_rx);
|
||||
|
||||
/* LPUART1 interrupt Init */
|
||||
HAL_NVIC_SetPriority(USART3_4_5_6_LPUART1_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(USART3_4_5_6_LPUART1_IRQn);
|
||||
@@ -420,6 +403,7 @@ void HAL_UART_MspInit (UART_HandleTypeDef* uartHandle)
|
||||
{
|
||||
/* USER CODE BEGIN LPUART2_MspInit 0 */
|
||||
|
||||
__HAL_RCC_DMA1_CLK_ENABLE();
|
||||
/* USER CODE END LPUART2_MspInit 0 */
|
||||
|
||||
/** Initializes the peripherals clocks
|
||||
@@ -446,11 +430,36 @@ void HAL_UART_MspInit (UART_HandleTypeDef* uartHandle)
|
||||
GPIO_InitStruct.Alternate = GPIO_AF3_LPUART2;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/* LPUART2 DMA Init */
|
||||
/* LPUART2_RX Init */
|
||||
hdma_lpuart2_rx.Instance = DMA1_Channel3;
|
||||
hdma_lpuart2_rx.Init.Request = DMA_REQUEST_LPUART2_RX;
|
||||
hdma_lpuart2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||
hdma_lpuart2_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_lpuart2_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_lpuart2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_lpuart2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_lpuart2_rx.Init.Mode = DMA_NORMAL;
|
||||
hdma_lpuart2_rx.Init.Priority = DMA_PRIORITY_HIGH;
|
||||
if (HAL_DMA_Init(&hdma_lpuart2_rx) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
__HAL_LINKDMA(uartHandle,hdmarx,hdma_lpuart2_rx);
|
||||
|
||||
/* LPUART2 interrupt Init */
|
||||
HAL_NVIC_SetPriority(USART2_LPUART2_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(USART2_LPUART2_IRQn);
|
||||
/* USER CODE BEGIN LPUART2_MspInit 1 */
|
||||
|
||||
/* DMA1_Channel2_3_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(DMA1_Channel2_3_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA1_Channel2_3_IRQn);
|
||||
/* DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQn);
|
||||
|
||||
/* USER CODE END LPUART2_MspInit 1 */
|
||||
}
|
||||
else if(uartHandle->Instance==USART1)
|
||||
@@ -567,7 +576,7 @@ void HAL_UART_MspInit (UART_HandleTypeDef* uartHandle)
|
||||
else if(uartHandle->Instance==USART4)
|
||||
{
|
||||
/* USER CODE BEGIN USART4_MspInit 0 */
|
||||
|
||||
__HAL_RCC_DMA1_CLK_ENABLE();
|
||||
/* USER CODE END USART4_MspInit 0 */
|
||||
|
||||
/* USART4 clock enable */
|
||||
@@ -585,11 +594,35 @@ void HAL_UART_MspInit (UART_HandleTypeDef* uartHandle)
|
||||
GPIO_InitStruct.Alternate = GPIO_AF1_USART4;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/* USART4 DMA Init */
|
||||
/* USART4_RX Init */
|
||||
hdma_usart4_rx.Instance = DMA1_Channel2;
|
||||
hdma_usart4_rx.Init.Request = DMA_REQUEST_USART4_RX;
|
||||
hdma_usart4_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||
hdma_usart4_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_usart4_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_usart4_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
hdma_usart4_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
hdma_usart4_rx.Init.Mode = DMA_NORMAL;
|
||||
hdma_usart4_rx.Init.Priority = DMA_PRIORITY_LOW;
|
||||
if (HAL_DMA_Init(&hdma_usart4_rx) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
__HAL_LINKDMA(uartHandle,hdmarx,hdma_usart4_rx);
|
||||
|
||||
/* USART4 interrupt Init */
|
||||
HAL_NVIC_SetPriority(USART3_4_5_6_LPUART1_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(USART3_4_5_6_LPUART1_IRQn);
|
||||
/* USER CODE BEGIN USART4_MspInit 1 */
|
||||
|
||||
|
||||
HAL_NVIC_SetPriority(DMA1_Channel2_3_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA1_Channel2_3_IRQn);
|
||||
/* DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQn interrupt configuration */
|
||||
HAL_NVIC_SetPriority(DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQn);
|
||||
/* USER CODE END USART4_MspInit 1 */
|
||||
}
|
||||
else if(uartHandle->Instance==USART5)
|
||||
@@ -667,9 +700,6 @@ void HAL_UART_MspDeInit (UART_HandleTypeDef* uartHandle)
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOF, ETH2_TX_Pin|ETH2_RX_Pin);
|
||||
|
||||
/* LPUART1 DMA DeInit */
|
||||
HAL_DMA_DeInit (uartHandle->hdmarx);
|
||||
|
||||
/* LPUART1 interrupt Deinit */
|
||||
/* USER CODE BEGIN LPUART1:USART3_4_5_6_LPUART1_IRQn disable */
|
||||
/**
|
||||
@@ -697,6 +727,9 @@ void HAL_UART_MspDeInit (UART_HandleTypeDef* uartHandle)
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOC, GSM_TX_Pin|GSM_RX_Pin);
|
||||
|
||||
/* LPUART2 DMA DeInit */
|
||||
HAL_DMA_DeInit(uartHandle->hdmarx);
|
||||
|
||||
/* LPUART2 interrupt Deinit */
|
||||
/* USER CODE BEGIN LPUART2:USART2_LPUART2_IRQn disable */
|
||||
/**
|
||||
@@ -798,6 +831,9 @@ void HAL_UART_MspDeInit (UART_HandleTypeDef* uartHandle)
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOC, ETH1_TX_Pin|ETH1_RX_Pin);
|
||||
|
||||
/* USART4 DMA DeInit */
|
||||
HAL_DMA_DeInit(uartHandle->hdmarx);
|
||||
|
||||
/* USART4 interrupt Deinit */
|
||||
/* USER CODE BEGIN USART4:USART3_4_5_6_LPUART1_IRQn disable */
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
+42
-23
@@ -47,26 +47,44 @@ Dma.ADC1.0.SyncEnable=ENABLE
|
||||
Dma.ADC1.0.SyncPolarity=HAL_DMAMUX_SYNC_RISING
|
||||
Dma.ADC1.0.SyncRequestNumber=1
|
||||
Dma.ADC1.0.SyncSignalID=NONE
|
||||
Dma.LPUART1_RX.1.Direction=DMA_PERIPH_TO_MEMORY
|
||||
Dma.LPUART1_RX.1.EventEnable=DISABLE
|
||||
Dma.LPUART1_RX.1.Instance=DMA1_Channel2
|
||||
Dma.LPUART1_RX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.LPUART1_RX.1.MemInc=DMA_MINC_ENABLE
|
||||
Dma.LPUART1_RX.1.Mode=DMA_NORMAL
|
||||
Dma.LPUART1_RX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.LPUART1_RX.1.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.LPUART1_RX.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING
|
||||
Dma.LPUART1_RX.1.Priority=DMA_PRIORITY_LOW
|
||||
Dma.LPUART1_RX.1.RequestNumber=1
|
||||
Dma.LPUART1_RX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber
|
||||
Dma.LPUART1_RX.1.SignalID=NONE
|
||||
Dma.LPUART1_RX.1.SyncEnable=DISABLE
|
||||
Dma.LPUART1_RX.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT
|
||||
Dma.LPUART1_RX.1.SyncRequestNumber=1
|
||||
Dma.LPUART1_RX.1.SyncSignalID=NONE
|
||||
Dma.LPUART2_RX.1.Direction=DMA_PERIPH_TO_MEMORY
|
||||
Dma.LPUART2_RX.1.EventEnable=DISABLE
|
||||
Dma.LPUART2_RX.1.Instance=DMA1_Channel3
|
||||
Dma.LPUART2_RX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.LPUART2_RX.1.MemInc=DMA_MINC_ENABLE
|
||||
Dma.LPUART2_RX.1.Mode=DMA_NORMAL
|
||||
Dma.LPUART2_RX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.LPUART2_RX.1.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.LPUART2_RX.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING
|
||||
Dma.LPUART2_RX.1.Priority=DMA_PRIORITY_HIGH
|
||||
Dma.LPUART2_RX.1.RequestNumber=1
|
||||
Dma.LPUART2_RX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber
|
||||
Dma.LPUART2_RX.1.SignalID=NONE
|
||||
Dma.LPUART2_RX.1.SyncEnable=DISABLE
|
||||
Dma.LPUART2_RX.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT
|
||||
Dma.LPUART2_RX.1.SyncRequestNumber=1
|
||||
Dma.LPUART2_RX.1.SyncSignalID=NONE
|
||||
Dma.Request0=ADC1
|
||||
Dma.Request1=LPUART1_RX
|
||||
Dma.RequestsNb=2
|
||||
Dma.Request1=LPUART2_RX
|
||||
Dma.Request2=USART4_RX
|
||||
Dma.RequestsNb=3
|
||||
Dma.USART4_RX.2.Direction=DMA_PERIPH_TO_MEMORY
|
||||
Dma.USART4_RX.2.EventEnable=DISABLE
|
||||
Dma.USART4_RX.2.Instance=DMA1_Channel2
|
||||
Dma.USART4_RX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.USART4_RX.2.MemInc=DMA_MINC_ENABLE
|
||||
Dma.USART4_RX.2.Mode=DMA_NORMAL
|
||||
Dma.USART4_RX.2.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.USART4_RX.2.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.USART4_RX.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING
|
||||
Dma.USART4_RX.2.Priority=DMA_PRIORITY_LOW
|
||||
Dma.USART4_RX.2.RequestNumber=1
|
||||
Dma.USART4_RX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber
|
||||
Dma.USART4_RX.2.SignalID=NONE
|
||||
Dma.USART4_RX.2.SyncEnable=DISABLE
|
||||
Dma.USART4_RX.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT
|
||||
Dma.USART4_RX.2.SyncRequestNumber=1
|
||||
Dma.USART4_RX.2.SyncSignalID=NONE
|
||||
File.Version=6
|
||||
GPIO.groupedBy=Group By Peripherals
|
||||
KeepUserPlacement=false
|
||||
@@ -177,7 +195,7 @@ MxCube.Version=6.7.0
|
||||
MxDb.Version=DB.6.0.70
|
||||
NVIC.DMA1_Ch4_7_DMA2_Ch1_5_DMAMUX1_OVR_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true\:true
|
||||
NVIC.DMA1_Channel1_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true\:true
|
||||
NVIC.DMA1_Channel2_3_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true\:true
|
||||
NVIC.DMA1_Channel2_3_IRQn=true\:0\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
NVIC.ForceEnableDMAVector=true
|
||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false\:false
|
||||
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||
@@ -194,7 +212,7 @@ NVIC.TIM7_LPTIM2_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true\:true
|
||||
NVIC.TimeBase=TIM2_IRQn
|
||||
NVIC.TimeBaseIP=TIM2
|
||||
NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true\:true
|
||||
NVIC.USART2_LPUART2_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true\:true
|
||||
NVIC.USART2_LPUART2_IRQn=true\:0\:0\:true\:false\:true\:false\:true\:true\:true
|
||||
NVIC.USART3_4_5_6_LPUART1_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true\:true
|
||||
PA0.GPIOParameters=GPIO_Label
|
||||
PA0.GPIO_Label=ADC1
|
||||
@@ -443,7 +461,7 @@ ProjectManager.FreePins=false
|
||||
ProjectManager.HalAssertFull=true
|
||||
ProjectManager.HeapSize=0x2000
|
||||
ProjectManager.KeepUserCode=true
|
||||
ProjectManager.LastFirmware=true
|
||||
ProjectManager.LastFirmware=false
|
||||
ProjectManager.LibraryCopy=0
|
||||
ProjectManager.MainLocation=Core/Src
|
||||
ProjectManager.NoMain=false
|
||||
@@ -553,7 +571,8 @@ TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
|
||||
TIM3.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
|
||||
TIM3.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
|
||||
TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
|
||||
TIM3.IPParameters=Channel-PWM Generation4 CH4,Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Channel-PWM Generation3 CH3
|
||||
TIM3.IPParameters=Channel-PWM Generation4 CH4,Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Channel-PWM Generation3 CH3,Period
|
||||
TIM3.Period=640
|
||||
TIM6.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
|
||||
TIM6.IPParameters=Prescaler,AutoReloadPreload,Period
|
||||
TIM6.Period=10000
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.553091094">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.553091094" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="rtthread" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="${cross_rm} -rf" description="" id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.553091094" name="Debug" parent="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug">
|
||||
<folderInfo id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.553091094." name="/" resourcePath="">
|
||||
<toolChain id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.debug.1201710416" name="ARM Cross GCC" superClass="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.debug">
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.addtools.createflash.251260409" name="Create flash image" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.addtools.createflash" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.addtools.createlisting.1365878149" name="Create extended listing" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.addtools.createlisting" useByScannerDiscovery="false"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.addtools.printsize.709136944" name="Print size" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.addtools.printsize" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.1986446770" name="Optimization Level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength.1312975261" name="Message length (-fmessage-length=0)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar.1538128212" name="'char' is signed (-fsigned-char)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections.2136804218" name="Function sections (-ffunction-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.datasections.244767666" name="Data sections (-fdata-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.datasections" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level.1055848773" name="Debug level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level.default" valueType="enumerated"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.format.501941135" name="Debug format" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.format" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.format.dwarf2" valueType="enumerated"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.toolchain.name.1696308067" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.toolchain.name" useByScannerDiscovery="false" value="GNU Tools for ARM Embedded Processors" valueType="string"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.architecture.1558403188" name="Architecture" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.architecture" useByScannerDiscovery="false" value="ilg.gnuarmeclipse.managedbuild.cross.option.architecture.arm" valueType="enumerated"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.family.749415257" name="ARM family" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.family" useByScannerDiscovery="false" value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.mcpu.cortex-m4" valueType="enumerated"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.instructionset.2114153533" name="Instruction set" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.instructionset" useByScannerDiscovery="false" value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.instructionset.thumb" valueType="enumerated"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.prefix.1600865811" name="Prefix" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.prefix" useByScannerDiscovery="false" value="arm-none-eabi-" valueType="string"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.c.1109963929" name="C compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.c" useByScannerDiscovery="false" value="gcc" valueType="string"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.cpp.1040883831" name="C++ compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.cpp" useByScannerDiscovery="false" value="g++" valueType="string"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.ar.1678200391" name="Archiver" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.ar" useByScannerDiscovery="false" value="ar" valueType="string"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.objcopy.1171840296" name="Hex/Bin converter" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.objcopy" useByScannerDiscovery="false" value="objcopy" valueType="string"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.objdump.342604837" name="Listing generator" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.objdump" useByScannerDiscovery="false" value="objdump" valueType="string"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.size.898269225" name="Size command" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.size" useByScannerDiscovery="false" value="size" valueType="string"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.make.2016398076" name="Build command" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.make" useByScannerDiscovery="false" value="make" valueType="string"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.rm.1606171496" name="Remove command" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.rm" useByScannerDiscovery="false" value="rm" valueType="string"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.toolchain.id.540792084" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.toolchain.id" useByScannerDiscovery="false" value="1287942917" valueType="string"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.architecture.430121817" name="Architecture" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.architecture" useByScannerDiscovery="false" value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.arch.none" valueType="enumerated"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.fpu.abi.966735324" name="Float ABI" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.fpu.abi" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.fpu.abi.hard" valueType="enumerated"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.allwarn.1381561249" name="Enable all common warnings (-Wall)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.allwarn" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.target.other.2041717463" name="Other target flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.target.other" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.fpu.unit.1463655269" name="FPU Type" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.fpu.unit" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.fpu.unit.fpv4spd16" valueType="enumerated"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.1798638225" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/>
|
||||
<builder buildPath="${workspace_loc:/qemu-vexpress-a9}/Debug" cleanBuildTarget="mdk_clean" id="ilg.gnuarmeclipse.managedbuild.cross.builder.1736709688" incrementalBuildTarget="mdk_all" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="ilg.gnuarmeclipse.managedbuild.cross.builder"/>
|
||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.1810966071" name="GNU ARM Cross Assembler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler">
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.1072524326" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.include.paths.161242639" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.include.paths" useByScannerDiscovery="true" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}""/>
|
||||
</option>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.defs.1521934876" name="Defined symbols (-D)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.defs" useByScannerDiscovery="true"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.flags.1325367962" name="Assembler flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.flags" useByScannerDiscovery="false" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-mimplicit-it=thumb"/>
|
||||
</option>
|
||||
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input.1843333483" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.1570350559" name="GNU ARM Cross C Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths.634882052" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}/drivers}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}/libraries//CMSIS//Device//ST//STM32F4xx//Include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}/libraries//CMSIS//Include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}/libraries//CMSIS//RTOS//Template}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}/libraries//STM32F4xx_HAL_Driver//Inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}/libraries//STM32F4xx_HAL_Driver//Inc//Legacy}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}/applications}""/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.defs.100549972" name="Defined symbols (-D)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="SOC_FAMILY_STM32"/>
|
||||
<listOptionValue builtIn="false" value="SOC_SERIES_STM32F4"/>
|
||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||
<listOptionValue builtIn="false" value="STM32F411xE"/>
|
||||
</option>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.other.2133065240" name="Other compiler flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.other" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.files.714348818" name="Include files (-include)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
|
||||
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.992053063" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.869072473" name="Cross ARM C Linker" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker">
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.gcsections.1167322178" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.nostart.351692886" name="Do not use standard start files (-nostartfiles)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.nostart" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.nostdlibs.1009243715" name="No startup or default libs (-nostdlib)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.nostdlibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.nodeflibs.2016026082" name="Do not use default libraries (-nodefaultlibs)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.nodeflibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.usenewlibnano.923990336" name="Use newlib-nano (--specs=nano.specs)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.usenewlibnano" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option defaultValue="true" id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.shared.548869459" name="Shared (-shared)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.shared" useByScannerDiscovery="false" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.scriptfile.1818777301" name="Script files (-T)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.scriptfile" useByScannerDiscovery="false" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}//linkscripts//STM32F411RE//link.lds}""/>
|
||||
</option>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.libs.1135656995" name="Libraries (-l)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.libs" useByScannerDiscovery="false"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.paths.36884122" name="Library search path (-L)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.paths" useByScannerDiscovery="false"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.other.396049466" name="Other linker flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.other" useByScannerDiscovery="false" value="" valueType="string"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.cref.1645737861" name="Cross reference (-Xlinker --cref)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.cref" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.input.334732222" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.1601059928" name="GNU ARM Cross C++ Linker" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker">
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.gcsections.437759352" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.gcsections" value="true" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.scriptfile.1101974459" name="Script files (-T)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.scriptfile" useByScannerDiscovery="false" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}//linkscripts//STM32F411RE//link.lds}""/>
|
||||
</option>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.cref.2007675975" name="Cross reference (-Xlinker --cref)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.cref" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.usenewlibnano.2105838438" name="Use newlib-nano (--specs=nano.specs)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.usenewlibnano" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.libs.934137837" name="Libraries (-l)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.libs" useByScannerDiscovery="false"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.nostart.2118356996" name="Do not use standard start files (-nostartfiles)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.nostart" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.nodeflibs.1427884346" name="Do not use default libraries (-nodefaultlibs)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.nodeflibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.nostdlibs.1433863653" name="No startup or default libs (-nostdlib)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.nostdlibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.printgcsections.1387745410" name="Print removed sections (-Xlinker --print-gc-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.printgcsections" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.strip.1230158061" name="Omit all symbol information (-s)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.strip" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.printmap.1307581821" name="Print link map (-Xlinker --print-map)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.printmap" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.useprintffloat.960778920" name="Use float with nano printf (-u _printf_float)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.useprintffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.usescanffloat.637205035" name="Use float with nano scanf (-u _scanf_float)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.usescanffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.usenewlibnosys.1948314201" name="Do not use syscalls (--specs=nosys.specs)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.usenewlibnosys" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.verbose.273162112" name="Verbose (-v)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.paths.1399535143" name="Library search path (-L)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.paths" useByScannerDiscovery="false"/>
|
||||
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.input.262373798" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.archiver.506412204" name="GNU ARM Cross Archiver" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.archiver"/>
|
||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.createflash.1461589245" name="GNU ARM Cross Create Flash Image" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.createflash">
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createflash.choice.1937707052" name="Output file format (-O)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createflash.choice" useByScannerDiscovery="false" value="ilg.gnuarmeclipse.managedbuild.cross.option.createflash.choice.binary" valueType="enumerated"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.createlisting.82359725" name="GNU ARM Cross Create Listing" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.createlisting">
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.source.601724476" name="Display source (--source|-S)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.source" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.allheaders.692505279" name="Display all headers (--all-headers|-x)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.allheaders" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.demangle.97345172" name="Demangle names (--demangle|-C)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.demangle" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.linenumbers.1342893377" name="Display line numbers (--line-numbers|-l)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.linenumbers" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.wide.1533725981" name="Wide lines (--wide|-w)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.wide" value="true" valueType="boolean"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.printsize.1073550295" name="GNU ARM Cross Print Size" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.printsize">
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.format.946451386" name="Size format" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.format" useByScannerDiscovery="false"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.1302177015" name="GNU ARM Cross C++ Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.defs.704468062" name="Defined symbols (-D)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="SOC_FAMILY_STM32"/>
|
||||
<listOptionValue builtIn="false" value="SOC_SERIES_STM32F4"/>
|
||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||
<listOptionValue builtIn="false" value="STM32F411xE"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.paths.302877723" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}/drivers}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}/libraries//CMSIS//Device//ST//STM32F4xx//Include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}/libraries//CMSIS//Include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}/libraries//CMSIS//RTOS//Template}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}/libraries//STM32F4xx_HAL_Driver//Inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}/libraries//STM32F4xx_HAL_Driver//Inc//Legacy}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc://${ProjName}/applications}""/>
|
||||
</option>
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.files.343249373" name="Include files (-include)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.files" useByScannerDiscovery="true"/>
|
||||
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input.45918001" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="qemu-vexpress-a9.ilg.gnuarmeclipse.managedbuild.cross.target.elf.860020518" name="Executable" projectType="ilg.gnuarmeclipse.managedbuild.cross.target.elf"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.553091094;ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.553091094.;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.1570350559;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.992053063">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="Debug">
|
||||
<resource resourceType="PROJECT" workspacePath="/123"/>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings">
|
||||
<doc-comment-owner id="org.eclipse.cdt.ui.doxygen">
|
||||
<path value=""/>
|
||||
</doc-comment-owner>
|
||||
</storageModule>
|
||||
</cproject>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><projectDescription>
|
||||
<name>BareMetal</name>
|
||||
<comment />
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.rt-thread.studio.rttnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
<name>411_dap_demo</name>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="ilg.gnumcueclipse.debug.gdbjtag.pyocd.launchConfigurationType">
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.adapterName" value="DAP-LINK"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.binFlashStartAddress" value=""/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.doContinue" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.doDebugInRam" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.doFirstReset" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.doGdbServerAllocateConsole" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.doSecondReset" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.doStartGdbServer" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.enableSemihosting" value="true"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.firstResetType" value="init"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.gdbClientOtherCommands" value="set mem inaccessible-by-default off"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.gdbClientOtherOptions" value=""/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.gdbServerBusSpeed" value="1000000"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.gdbServerConnectionAddress" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.gdbServerDeviceName" value="unknown"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.gdbServerEnableSemihosting" value="false"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.gdbServerExecutable" value="${debugger_install_path}/${daplink_debugger_relative_path}\pyocd.exe"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.gdbServerFlashMode" value="0"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.gdbServerGdbPortNumber" value="3333"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.gdbServerOther" value=""/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.gdbServerTelnetPortNumber" value="4444"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.otherInitCommands" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.otherRunCommands" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.programMode" value="BIN"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.pyocd.secondResetType" value="halt"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="GNU MCU PyOCD"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="false"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="${rtt_gnu_gcc}/arm-none-eabi-gdb.exe"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="0"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/rtthread.elf"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="411_dap_demo"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/411_dap_demo"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.cdt.debug.core.sourceLocator"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_ENCODING" value="GBK"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="true"/>
|
||||
</launchConfiguration>
|
||||
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="ilg.gnumcueclipse.debug.gdbjtag.jlink.launchConfigurationType">
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.adapterName" value="J-Link"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.binFileStartAddress" value=""/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doConnectToRunning" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doContinue" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doDebugInRam" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doFirstReset" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doGdbServerAllocateConsole" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doGdbServerAllocateSemihostingConsole" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doGdbServerInitRegs" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doGdbServerLocalOnly" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doGdbServerSilent" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doGdbServerVerifyDownload" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doSecondReset" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doStartGdbServer" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.enableFlashBreakpoints" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.enableSemihosting" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.enableSemihostingIoclientGdbClient" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.enableSemihostingIoclientTelnet" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.enableSwo" value="true"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.eraseEndAddress" value=""/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.eraseMode" value="0"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.eraseStartAddress" value=""/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.firstResetSpeed" value="1000"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.firstResetType" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.flashDeviceName" value="unknown"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.flashDownloadHex" value="false"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbClientOtherCommands" value="set mem inaccessible-by-default off"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbClientOtherOptions" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerConnection" value="usb"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerConnectionAddress" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerDebugInterface" value="swd"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerDeviceEndianness" value="little"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerDeviceName" value="unknown"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerDeviceSpeed" value="1000"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerExecutable" value="${debugger_install_path}/${jlink_debugger_relative_path}\JLinkGDBServerCL.exe"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerGdbPortNumber" value="2331"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerLog" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerOther" value="-singlerun"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerRunAfterStopDebug" value="true"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerSwoPortNumber" value="2332"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerTelnetPortNumber" value="2333"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.interfaceSpeed" value="auto"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.jlinkExecutable" value="${debugger_install_path}/${jlink_debugger_relative_path}\JLink.exe"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.otherInitCommands" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.otherRunCommands" value=""/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.runAfterDownload" value="true"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.secondResetType" value=""/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.swoEnableTargetCpuFreq" value="0"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.swoEnableTargetPortMask" value="0x1"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.swoEnableTargetSwoFreq" value="0"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="GNU MCU J-Link"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
|
||||
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="2331"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="${rtt_gnu_gcc}/arm-none-eabi-gdb.exe"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="0"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/rtthread.elf"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="411_dap_demo"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/411_dap_demo"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.cdt.debug.core.sourceLocator"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_ENCODING" value="GBK"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="true"/>
|
||||
</launchConfiguration>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="ilg.gnumcueclipse.debug.gdbjtag.qemu.launchConfigurationType">
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.doContinue" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.doDebugInRam" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.doFirstReset" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.doSecondReset" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.doStartGdbServer" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.enableSemihosting" value="true"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.gdbClientOtherCommands" value="set mem inaccessible-by-default off "/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.gdbClientOtherOptions" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.gdbServerBoardModel" value="?"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.gdbServerCpuQuantity" value="1"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.gdbServerEnableNetwork" value="false"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.gdbServerExecutable" value="${debugger_install_path}/${qemu_debugger_relative_path}\qemu-system-arm.exe"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.gdbServerExtraQemuCmd" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.gdbServerSdcardMemory" value="64.0"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.gdbServerSerialPort" value="COM1"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.gdbServerStartup" value="${studio_install_path}/repo/Extract/Debugger_Support_Packages/RealThread/QEMU/4.2.0.4/qemu-system-arm.exe -M ? -sd sd.bin -nographic -S -s"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.gdbServerTapName" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.otherInitCommands" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.qemu.otherRunCommands" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="GNU MCU QEMU"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
|
||||
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="1234"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="${cross_prefix}gdb${cross_suffix}"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="0"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/rtthread.elf"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="411_dap_demo"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/411_dap_demo"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.cdt.debug.core.sourceLocator"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_ENCODING" value="GBK"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="true"/>
|
||||
</launchConfiguration>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.rtthread.studio.debug.gdbjtag.stlink.launchConfigurationType">
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.connectMode" value="NORMAL"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.debugInterface" value="SWD"/>
|
||||
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.delay" value="3"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.flashVerify" value="false"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.genericDevice"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.otherDownloadOption" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.otherGdbserverOption" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
|
||||
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="61235"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.resetMode" value=" -hardRst"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.resetRun" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="${rtt_gnu_gcc}/arm-none-eabi-gdb.exe"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="0"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="remote"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/rtthread.elf"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="411_dap_demo"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/411_dap_demo"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.cdt.debug.core.sourceLocator"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_ENCODING" value="GBK"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="true"/>
|
||||
<stringAttribute key="org.rtthread.studio.debug.gdbjtag.stlink.adapterName" value="ST-LINK"/>
|
||||
<booleanAttribute key="org.rtthread.studio.debug.gdbjtag.stlink.doContinue" value="true"/>
|
||||
<stringAttribute key="org.rtthread.studio.debug.gdbjtag.stlink.gdbServerDeviceName" value="unknown"/>
|
||||
<stringAttribute key="org.rtthread.studio.debug.gdbjtag.stlink.gdbServerExecutable" value="${debugger_install_path}/${stlink_debugger_relative_path}/ST-LINK_gdbserver.exe"/>
|
||||
<stringAttribute key="org.rtthread.studio.debug.gdbjtag.stlink.stlinkGdbServer" value="${debugger_install_path}/${stlink_debugger_relative_path}/tools/bin/STM32_Programmer_CLI.exe"/>
|
||||
<booleanAttribute key="org.rtthread.studio.debug.gdbjtag.stlink.useRemoteTarget" value="true"/>
|
||||
</launchConfiguration>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project>
|
||||
<configuration id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.553091094" name="Debug">
|
||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-1248840411375756638" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT ARM Cross GCC Built-in Compiler Settings " parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
</extension>
|
||||
</configuration>
|
||||
</project>
|
||||
@@ -0,0 +1,146 @@
|
||||
{
|
||||
"global":{
|
||||
"use-micro-lib":true,
|
||||
"output-debug-info":true,
|
||||
"build-output-dir":"GB01VETx\\","list-output-dir":"./GB01VETx/\\",
|
||||
"mem-layout":{
|
||||
"rom":[
|
||||
{
|
||||
"name":"rom1",
|
||||
"checked":false,
|
||||
"address":"0x0",
|
||||
"size":"0x0",
|
||||
"is_entry":false
|
||||
},
|
||||
{
|
||||
"name":"rom2",
|
||||
"checked":false,
|
||||
"address":"0x0",
|
||||
"size":"0x0",
|
||||
"is_entry":false
|
||||
},
|
||||
{
|
||||
"name":"rom3",
|
||||
"checked":false,
|
||||
"address":"0x0",
|
||||
"size":"0x0",
|
||||
"is_entry":false
|
||||
},
|
||||
{
|
||||
"name":"irom1",
|
||||
"checked":true,
|
||||
"address":"0x8000000",
|
||||
"size":"0x80000",
|
||||
"is_entry":true
|
||||
},
|
||||
{
|
||||
"name":"irom2",
|
||||
"checked":false,
|
||||
"address":"0x0",
|
||||
"size":"0x0",
|
||||
"is_entry":false
|
||||
}
|
||||
],
|
||||
"ram":[
|
||||
{
|
||||
"name":"ram1",
|
||||
"checked":false,
|
||||
"noInit":false,
|
||||
"address":"0x0",
|
||||
"size":"0x0"
|
||||
},
|
||||
{
|
||||
"name":"ram2",
|
||||
"checked":false,
|
||||
"noInit":false,
|
||||
"address":"0x0",
|
||||
"size":"0x0"
|
||||
},
|
||||
{
|
||||
"name":"ram3",
|
||||
"checked":false,
|
||||
"noInit":false,
|
||||
"address":"0x0",
|
||||
"size":"0x0"
|
||||
},
|
||||
{
|
||||
"name":"iram1",
|
||||
"checked":true,
|
||||
"noInit":false,
|
||||
"address":"0x20000000",
|
||||
"size":"0x24000"
|
||||
},
|
||||
{
|
||||
"name":"iram2",
|
||||
"checked":false,
|
||||
"noInit":false,
|
||||
"address":"0x0",
|
||||
"size":"0x0"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"c/cpp":{
|
||||
"misc-controls":"",
|
||||
"optimization":4,
|
||||
"warnings":2,
|
||||
"include-list":[
|
||||
"../Core/Inc",
|
||||
"../Drivers/STM32G0xx_HAL_Driver/Inc",
|
||||
"../Drivers/STM32G0xx_HAL_Driver/Inc/Legacy",
|
||||
"../Drivers/CMSIS/Device/ST/STM32G0xx/Include",
|
||||
"../Drivers/CMSIS/Include",
|
||||
"../middleware/sfud/inc",
|
||||
"../middleware/nr_micro_shell/inc",
|
||||
"../middleware/xcmd/inc",
|
||||
"../middleware/easyflash/inc",
|
||||
"../App",
|
||||
"../middleware/easylogger/inc",
|
||||
"../Comm",
|
||||
"../middleware/fifo",
|
||||
"../middleware/at-command/include",
|
||||
"../middleware/softimer",
|
||||
"../RT-Thread",
|
||||
"../Middlewares/Third_Party/RealThread_RTOS/include/",
|
||||
"../Middlewares/Third_Party/RealThread_RTOS/bsp/_template/cubemx_config"
|
||||
],
|
||||
"define-list":[
|
||||
"USE_HAL_DRIVER",
|
||||
"STM32G0B1xx"
|
||||
],
|
||||
"split-load-and-store-multiple":false,
|
||||
"strict-ansi-c":false,
|
||||
"gnu-extensions":false,
|
||||
"c99-mode":true,
|
||||
"read-write-position-independent":false,
|
||||
"enum-container-always-int":false,
|
||||
"optimize-for-time":false,
|
||||
"read-only-position-independent":false,
|
||||
"one-elf-section-per-function":true,
|
||||
"execute-only-code":false,
|
||||
"plain-char-is-signed":false
|
||||
},
|
||||
"asm":{
|
||||
"misc-controls":"",
|
||||
"include-list":[
|
||||
|
||||
],
|
||||
"define-list":[
|
||||
|
||||
],
|
||||
"split-load-and-store-multiple":false,
|
||||
"thumb-mode":false,
|
||||
"no-warnings":false,
|
||||
"read-write-position-independent":false,
|
||||
"read-only-position-independent":false,
|
||||
"execute-only-code":false
|
||||
},
|
||||
"linker":{
|
||||
"linker-scatter-file":"",
|
||||
"misc-controls":"",
|
||||
"read-write-position-independent":false,
|
||||
"auto-gen-scatter-file":true,
|
||||
"read-only-position-independent":false,
|
||||
"not-search-std-libs":false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
eclipse.preferences.project.mdk.projectRoot="J\:\\add_by_zhangpeng\\Project\\SLUICE\\Sluice\\GB0VETx\\g0b1vetx-board\\MDK-ARM\\.rtt-studio"
|
||||
eclipse.preferences.project.mdk.uvprojxPath="J\:\\add_by_zhangpeng\\Project\\SLUICE\\Sluice\\GB0VETx\\g0b1vetx-board\\MDK-ARM\\GB01VETx.uvprojx"
|
||||
eclipse.preferences.version=1
|
||||
@@ -0,0 +1,9 @@
|
||||
#RT-Thread Studio Project Configuration
|
||||
#Fri May 26 08:53:27 CST 2023
|
||||
project_type=mdk
|
||||
output_project_path=J\:add_by_zhangpengProjectSLUICESluiceGB0VETxg0b1vetx-boardMDK-ARM.rtt-studio
|
||||
hardware_adapter=J-Link
|
||||
chip_name=STM32G0B1VE
|
||||
import_project_name=GB01VETx.uvprojx
|
||||
project_name=G0B1VETX_APP
|
||||
cfg_version=v3.0
|
||||
+23
-23
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
|
||||
|
||||
<SchemaVersion>1.0</SchemaVersion>
|
||||
@@ -104,16 +104,16 @@
|
||||
<bSchkAxf>0</bSchkAxf>
|
||||
<bTchkAxf>0</bTchkAxf>
|
||||
<nTsel>3</nTsel>
|
||||
<sDll></sDll>
|
||||
<sDllPa></sDllPa>
|
||||
<sDlgDll></sDlgDll>
|
||||
<sDlgPa></sDlgPa>
|
||||
<sIfile></sIfile>
|
||||
<tDll></tDll>
|
||||
<tDllPa></tDllPa>
|
||||
<tDlgDll></tDlgDll>
|
||||
<tDlgPa></tDlgPa>
|
||||
<tIfile></tIfile>
|
||||
<sDll />
|
||||
<sDllPa />
|
||||
<sDlgDll />
|
||||
<sDlgPa />
|
||||
<sIfile />
|
||||
<tDll />
|
||||
<tDllPa />
|
||||
<tDlgDll />
|
||||
<tDlgPa />
|
||||
<tIfile />
|
||||
<pMon>BIN\CMSIS_AGDI.dll</pMon>
|
||||
</DebugOpt>
|
||||
<TargetDriverDllRegistry>
|
||||
@@ -145,7 +145,7 @@
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ARMDBGFLAGS</Key>
|
||||
<Name></Name>
|
||||
<Name />
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
@@ -167,7 +167,7 @@
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>D:\Project\娴嬫帶涓€浣撻椄\GB01V\g0b1vetx-board\Core\Src\main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<ExecCommand />
|
||||
<Expression>\\GB01VETx\../Core/Src/main.c\88</Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
@@ -200,19 +200,19 @@
|
||||
<newCpu>0</newCpu>
|
||||
<uProt>0</uProt>
|
||||
</DebugFlag>
|
||||
<LintExecutable></LintExecutable>
|
||||
<LintConfigFile></LintConfigFile>
|
||||
<LintExecutable />
|
||||
<LintConfigFile />
|
||||
<bLintAuto>0</bLintAuto>
|
||||
<bAutoGenD>0</bAutoGenD>
|
||||
<LntExFlags>0</LntExFlags>
|
||||
<pMisraName></pMisraName>
|
||||
<pszMrule></pszMrule>
|
||||
<pSingCmds></pSingCmds>
|
||||
<pMultCmds></pMultCmds>
|
||||
<pMisraNamep></pMisraNamep>
|
||||
<pszMrulep></pszMrulep>
|
||||
<pSingCmdsp></pSingCmdsp>
|
||||
<pMultCmdsp></pMultCmdsp>
|
||||
<pMisraName />
|
||||
<pszMrule />
|
||||
<pSingCmds />
|
||||
<pMultCmds />
|
||||
<pMisraNamep />
|
||||
<pszMrulep />
|
||||
<pSingCmdsp />
|
||||
<pMultCmdsp />
|
||||
<DebugDescription>
|
||||
<Enable>1</Enable>
|
||||
<EnableFlashSeq>0</EnableFlashSeq>
|
||||
|
||||
+415
-284
File diff suppressed because it is too large.
Load diff
+1
-8
@@ -12,14 +12,13 @@
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "data.h"
|
||||
|
||||
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
|
||||
/*
|
||||
* Please modify RT_HEAP_SIZE if you enable RT_USING_HEAP
|
||||
* the RT_HEAP_SIZE max value = (sram size - ZI size), 1024 means 1024 bytes
|
||||
*/
|
||||
#define RT_HEAP_SIZE (30*1024)
|
||||
#define RT_HEAP_SIZE (15*1024)
|
||||
static rt_uint8_t rt_heap[RT_HEAP_SIZE];
|
||||
|
||||
RT_WEAK void *rt_heap_begin_get(void)
|
||||
@@ -94,11 +93,6 @@ INIT_BOARD_EXPORT(uart_init);
|
||||
|
||||
void rt_hw_console_output(const char *str)
|
||||
{
|
||||
|
||||
if (g_ifconfig == 1)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
rt_size_t i = 0, size = 0;
|
||||
char a = '\r';
|
||||
|
||||
@@ -114,7 +108,6 @@ void rt_hw_console_output(const char *str)
|
||||
}
|
||||
HAL_UART_Transmit(&UartHandle, (uint8_t *)(str + i), 1, 1);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/* RT-Thread config file */
|
||||
|
||||
#ifndef __RTTHREAD_CFG_H__
|
||||
@@ -156,4 +155,3 @@
|
||||
// <<< end of configuration section >>>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,23 @@ typedef union{
|
||||
char byte[2];
|
||||
}Int16Tobyte;
|
||||
|
||||
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint32_t val;
|
||||
uint8_t valBuf[4];
|
||||
} DSH_INT_U;
|
||||
|
||||
typedef union
|
||||
{
|
||||
float val;
|
||||
uint8_t valBuf[4];
|
||||
} DSH_FLOAT_U;
|
||||
|
||||
|
||||
|
||||
|
||||
float Bytes2Float (char * data);
|
||||
uint32_t Bytes2Int (char * data);
|
||||
int hexstr_to_hexbyte (char *src, char *obj, uint16_t length);
|
||||
|
||||
@@ -0,0 +1,936 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
LICENSE TERMS
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
1. source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
2. binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation;
|
||||
|
||||
3. the name of the copyright holder is not used to endorse products
|
||||
built using this software without specific written permission.
|
||||
|
||||
DISCLAIMER
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its properties, including, but not limited to, correctness
|
||||
and/or fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue 09/09/2006
|
||||
|
||||
This is an AES implementation that uses only 8-bit byte operations on the
|
||||
cipher state (there are options to use 32-bit types if available).
|
||||
|
||||
The combination of mix columns and byte substitution used here is based on
|
||||
that developed by Karl Malbrain. His contribution is acknowledged.
|
||||
*/
|
||||
|
||||
/* define if you have a fast memcpy function on your system */
|
||||
#if 0
|
||||
# define HAVE_MEMCPY
|
||||
# include <string.h>
|
||||
# if defined( _MSC_VER )
|
||||
# include <intrin.h>
|
||||
# pragma intrinsic( memcpy )
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* define if you have fast 32-bit types on your system */
|
||||
#if ( __CORTEX_M != 0 ) // if Cortex is different from M0/M0+
|
||||
# define HAVE_UINT_32T
|
||||
#endif
|
||||
|
||||
/* define if you don't want any tables */
|
||||
#if 1
|
||||
# define USE_TABLES
|
||||
#endif
|
||||
|
||||
/* On Intel Core 2 duo VERSION_1 is faster */
|
||||
|
||||
/* alternative versions (test for performance on your system) */
|
||||
#if 1
|
||||
# define VERSION_1
|
||||
#endif
|
||||
|
||||
#include "aes.h"
|
||||
|
||||
//#if defined( HAVE_UINT_32T )
|
||||
// typedef unsigned long uint32_t;
|
||||
//#endif
|
||||
|
||||
/* functions for finite field multiplication in the AES Galois field */
|
||||
|
||||
#define WPOLY 0x011b
|
||||
#define BPOLY 0x1b
|
||||
#define DPOLY 0x008d
|
||||
|
||||
#define f1(x) (x)
|
||||
#define f2(x) ((x << 1) ^ (((x >> 7) & 1) * WPOLY))
|
||||
#define f4(x) ((x << 2) ^ (((x >> 6) & 1) * WPOLY) ^ (((x >> 6) & 2) * WPOLY))
|
||||
#define f8(x) ((x << 3) ^ (((x >> 5) & 1) * WPOLY) ^ (((x >> 5) & 2) * WPOLY) \
|
||||
^ (((x >> 5) & 4) * WPOLY))
|
||||
#define d2(x) (((x) >> 1) ^ ((x) & 1 ? DPOLY : 0))
|
||||
|
||||
#define f3(x) (f2(x) ^ x)
|
||||
#define f9(x) (f8(x) ^ x)
|
||||
#define fb(x) (f8(x) ^ f2(x) ^ x)
|
||||
#define fd(x) (f8(x) ^ f4(x) ^ x)
|
||||
#define fe(x) (f8(x) ^ f4(x) ^ f2(x))
|
||||
|
||||
#if defined( USE_TABLES )
|
||||
|
||||
#define sb_data(w) { /* S Box data values */ \
|
||||
w(0x63), w(0x7c), w(0x77), w(0x7b), w(0xf2), w(0x6b), w(0x6f), w(0xc5),\
|
||||
w(0x30), w(0x01), w(0x67), w(0x2b), w(0xfe), w(0xd7), w(0xab), w(0x76),\
|
||||
w(0xca), w(0x82), w(0xc9), w(0x7d), w(0xfa), w(0x59), w(0x47), w(0xf0),\
|
||||
w(0xad), w(0xd4), w(0xa2), w(0xaf), w(0x9c), w(0xa4), w(0x72), w(0xc0),\
|
||||
w(0xb7), w(0xfd), w(0x93), w(0x26), w(0x36), w(0x3f), w(0xf7), w(0xcc),\
|
||||
w(0x34), w(0xa5), w(0xe5), w(0xf1), w(0x71), w(0xd8), w(0x31), w(0x15),\
|
||||
w(0x04), w(0xc7), w(0x23), w(0xc3), w(0x18), w(0x96), w(0x05), w(0x9a),\
|
||||
w(0x07), w(0x12), w(0x80), w(0xe2), w(0xeb), w(0x27), w(0xb2), w(0x75),\
|
||||
w(0x09), w(0x83), w(0x2c), w(0x1a), w(0x1b), w(0x6e), w(0x5a), w(0xa0),\
|
||||
w(0x52), w(0x3b), w(0xd6), w(0xb3), w(0x29), w(0xe3), w(0x2f), w(0x84),\
|
||||
w(0x53), w(0xd1), w(0x00), w(0xed), w(0x20), w(0xfc), w(0xb1), w(0x5b),\
|
||||
w(0x6a), w(0xcb), w(0xbe), w(0x39), w(0x4a), w(0x4c), w(0x58), w(0xcf),\
|
||||
w(0xd0), w(0xef), w(0xaa), w(0xfb), w(0x43), w(0x4d), w(0x33), w(0x85),\
|
||||
w(0x45), w(0xf9), w(0x02), w(0x7f), w(0x50), w(0x3c), w(0x9f), w(0xa8),\
|
||||
w(0x51), w(0xa3), w(0x40), w(0x8f), w(0x92), w(0x9d), w(0x38), w(0xf5),\
|
||||
w(0xbc), w(0xb6), w(0xda), w(0x21), w(0x10), w(0xff), w(0xf3), w(0xd2),\
|
||||
w(0xcd), w(0x0c), w(0x13), w(0xec), w(0x5f), w(0x97), w(0x44), w(0x17),\
|
||||
w(0xc4), w(0xa7), w(0x7e), w(0x3d), w(0x64), w(0x5d), w(0x19), w(0x73),\
|
||||
w(0x60), w(0x81), w(0x4f), w(0xdc), w(0x22), w(0x2a), w(0x90), w(0x88),\
|
||||
w(0x46), w(0xee), w(0xb8), w(0x14), w(0xde), w(0x5e), w(0x0b), w(0xdb),\
|
||||
w(0xe0), w(0x32), w(0x3a), w(0x0a), w(0x49), w(0x06), w(0x24), w(0x5c),\
|
||||
w(0xc2), w(0xd3), w(0xac), w(0x62), w(0x91), w(0x95), w(0xe4), w(0x79),\
|
||||
w(0xe7), w(0xc8), w(0x37), w(0x6d), w(0x8d), w(0xd5), w(0x4e), w(0xa9),\
|
||||
w(0x6c), w(0x56), w(0xf4), w(0xea), w(0x65), w(0x7a), w(0xae), w(0x08),\
|
||||
w(0xba), w(0x78), w(0x25), w(0x2e), w(0x1c), w(0xa6), w(0xb4), w(0xc6),\
|
||||
w(0xe8), w(0xdd), w(0x74), w(0x1f), w(0x4b), w(0xbd), w(0x8b), w(0x8a),\
|
||||
w(0x70), w(0x3e), w(0xb5), w(0x66), w(0x48), w(0x03), w(0xf6), w(0x0e),\
|
||||
w(0x61), w(0x35), w(0x57), w(0xb9), w(0x86), w(0xc1), w(0x1d), w(0x9e),\
|
||||
w(0xe1), w(0xf8), w(0x98), w(0x11), w(0x69), w(0xd9), w(0x8e), w(0x94),\
|
||||
w(0x9b), w(0x1e), w(0x87), w(0xe9), w(0xce), w(0x55), w(0x28), w(0xdf),\
|
||||
w(0x8c), w(0xa1), w(0x89), w(0x0d), w(0xbf), w(0xe6), w(0x42), w(0x68),\
|
||||
w(0x41), w(0x99), w(0x2d), w(0x0f), w(0xb0), w(0x54), w(0xbb), w(0x16) }
|
||||
|
||||
#define isb_data(w) { /* inverse S Box data values */ \
|
||||
w(0x52), w(0x09), w(0x6a), w(0xd5), w(0x30), w(0x36), w(0xa5), w(0x38),\
|
||||
w(0xbf), w(0x40), w(0xa3), w(0x9e), w(0x81), w(0xf3), w(0xd7), w(0xfb),\
|
||||
w(0x7c), w(0xe3), w(0x39), w(0x82), w(0x9b), w(0x2f), w(0xff), w(0x87),\
|
||||
w(0x34), w(0x8e), w(0x43), w(0x44), w(0xc4), w(0xde), w(0xe9), w(0xcb),\
|
||||
w(0x54), w(0x7b), w(0x94), w(0x32), w(0xa6), w(0xc2), w(0x23), w(0x3d),\
|
||||
w(0xee), w(0x4c), w(0x95), w(0x0b), w(0x42), w(0xfa), w(0xc3), w(0x4e),\
|
||||
w(0x08), w(0x2e), w(0xa1), w(0x66), w(0x28), w(0xd9), w(0x24), w(0xb2),\
|
||||
w(0x76), w(0x5b), w(0xa2), w(0x49), w(0x6d), w(0x8b), w(0xd1), w(0x25),\
|
||||
w(0x72), w(0xf8), w(0xf6), w(0x64), w(0x86), w(0x68), w(0x98), w(0x16),\
|
||||
w(0xd4), w(0xa4), w(0x5c), w(0xcc), w(0x5d), w(0x65), w(0xb6), w(0x92),\
|
||||
w(0x6c), w(0x70), w(0x48), w(0x50), w(0xfd), w(0xed), w(0xb9), w(0xda),\
|
||||
w(0x5e), w(0x15), w(0x46), w(0x57), w(0xa7), w(0x8d), w(0x9d), w(0x84),\
|
||||
w(0x90), w(0xd8), w(0xab), w(0x00), w(0x8c), w(0xbc), w(0xd3), w(0x0a),\
|
||||
w(0xf7), w(0xe4), w(0x58), w(0x05), w(0xb8), w(0xb3), w(0x45), w(0x06),\
|
||||
w(0xd0), w(0x2c), w(0x1e), w(0x8f), w(0xca), w(0x3f), w(0x0f), w(0x02),\
|
||||
w(0xc1), w(0xaf), w(0xbd), w(0x03), w(0x01), w(0x13), w(0x8a), w(0x6b),\
|
||||
w(0x3a), w(0x91), w(0x11), w(0x41), w(0x4f), w(0x67), w(0xdc), w(0xea),\
|
||||
w(0x97), w(0xf2), w(0xcf), w(0xce), w(0xf0), w(0xb4), w(0xe6), w(0x73),\
|
||||
w(0x96), w(0xac), w(0x74), w(0x22), w(0xe7), w(0xad), w(0x35), w(0x85),\
|
||||
w(0xe2), w(0xf9), w(0x37), w(0xe8), w(0x1c), w(0x75), w(0xdf), w(0x6e),\
|
||||
w(0x47), w(0xf1), w(0x1a), w(0x71), w(0x1d), w(0x29), w(0xc5), w(0x89),\
|
||||
w(0x6f), w(0xb7), w(0x62), w(0x0e), w(0xaa), w(0x18), w(0xbe), w(0x1b),\
|
||||
w(0xfc), w(0x56), w(0x3e), w(0x4b), w(0xc6), w(0xd2), w(0x79), w(0x20),\
|
||||
w(0x9a), w(0xdb), w(0xc0), w(0xfe), w(0x78), w(0xcd), w(0x5a), w(0xf4),\
|
||||
w(0x1f), w(0xdd), w(0xa8), w(0x33), w(0x88), w(0x07), w(0xc7), w(0x31),\
|
||||
w(0xb1), w(0x12), w(0x10), w(0x59), w(0x27), w(0x80), w(0xec), w(0x5f),\
|
||||
w(0x60), w(0x51), w(0x7f), w(0xa9), w(0x19), w(0xb5), w(0x4a), w(0x0d),\
|
||||
w(0x2d), w(0xe5), w(0x7a), w(0x9f), w(0x93), w(0xc9), w(0x9c), w(0xef),\
|
||||
w(0xa0), w(0xe0), w(0x3b), w(0x4d), w(0xae), w(0x2a), w(0xf5), w(0xb0),\
|
||||
w(0xc8), w(0xeb), w(0xbb), w(0x3c), w(0x83), w(0x53), w(0x99), w(0x61),\
|
||||
w(0x17), w(0x2b), w(0x04), w(0x7e), w(0xba), w(0x77), w(0xd6), w(0x26),\
|
||||
w(0xe1), w(0x69), w(0x14), w(0x63), w(0x55), w(0x21), w(0x0c), w(0x7d) }
|
||||
|
||||
#define mm_data(w) { /* basic data for forming finite field tables */ \
|
||||
w(0x00), w(0x01), w(0x02), w(0x03), w(0x04), w(0x05), w(0x06), w(0x07),\
|
||||
w(0x08), w(0x09), w(0x0a), w(0x0b), w(0x0c), w(0x0d), w(0x0e), w(0x0f),\
|
||||
w(0x10), w(0x11), w(0x12), w(0x13), w(0x14), w(0x15), w(0x16), w(0x17),\
|
||||
w(0x18), w(0x19), w(0x1a), w(0x1b), w(0x1c), w(0x1d), w(0x1e), w(0x1f),\
|
||||
w(0x20), w(0x21), w(0x22), w(0x23), w(0x24), w(0x25), w(0x26), w(0x27),\
|
||||
w(0x28), w(0x29), w(0x2a), w(0x2b), w(0x2c), w(0x2d), w(0x2e), w(0x2f),\
|
||||
w(0x30), w(0x31), w(0x32), w(0x33), w(0x34), w(0x35), w(0x36), w(0x37),\
|
||||
w(0x38), w(0x39), w(0x3a), w(0x3b), w(0x3c), w(0x3d), w(0x3e), w(0x3f),\
|
||||
w(0x40), w(0x41), w(0x42), w(0x43), w(0x44), w(0x45), w(0x46), w(0x47),\
|
||||
w(0x48), w(0x49), w(0x4a), w(0x4b), w(0x4c), w(0x4d), w(0x4e), w(0x4f),\
|
||||
w(0x50), w(0x51), w(0x52), w(0x53), w(0x54), w(0x55), w(0x56), w(0x57),\
|
||||
w(0x58), w(0x59), w(0x5a), w(0x5b), w(0x5c), w(0x5d), w(0x5e), w(0x5f),\
|
||||
w(0x60), w(0x61), w(0x62), w(0x63), w(0x64), w(0x65), w(0x66), w(0x67),\
|
||||
w(0x68), w(0x69), w(0x6a), w(0x6b), w(0x6c), w(0x6d), w(0x6e), w(0x6f),\
|
||||
w(0x70), w(0x71), w(0x72), w(0x73), w(0x74), w(0x75), w(0x76), w(0x77),\
|
||||
w(0x78), w(0x79), w(0x7a), w(0x7b), w(0x7c), w(0x7d), w(0x7e), w(0x7f),\
|
||||
w(0x80), w(0x81), w(0x82), w(0x83), w(0x84), w(0x85), w(0x86), w(0x87),\
|
||||
w(0x88), w(0x89), w(0x8a), w(0x8b), w(0x8c), w(0x8d), w(0x8e), w(0x8f),\
|
||||
w(0x90), w(0x91), w(0x92), w(0x93), w(0x94), w(0x95), w(0x96), w(0x97),\
|
||||
w(0x98), w(0x99), w(0x9a), w(0x9b), w(0x9c), w(0x9d), w(0x9e), w(0x9f),\
|
||||
w(0xa0), w(0xa1), w(0xa2), w(0xa3), w(0xa4), w(0xa5), w(0xa6), w(0xa7),\
|
||||
w(0xa8), w(0xa9), w(0xaa), w(0xab), w(0xac), w(0xad), w(0xae), w(0xaf),\
|
||||
w(0xb0), w(0xb1), w(0xb2), w(0xb3), w(0xb4), w(0xb5), w(0xb6), w(0xb7),\
|
||||
w(0xb8), w(0xb9), w(0xba), w(0xbb), w(0xbc), w(0xbd), w(0xbe), w(0xbf),\
|
||||
w(0xc0), w(0xc1), w(0xc2), w(0xc3), w(0xc4), w(0xc5), w(0xc6), w(0xc7),\
|
||||
w(0xc8), w(0xc9), w(0xca), w(0xcb), w(0xcc), w(0xcd), w(0xce), w(0xcf),\
|
||||
w(0xd0), w(0xd1), w(0xd2), w(0xd3), w(0xd4), w(0xd5), w(0xd6), w(0xd7),\
|
||||
w(0xd8), w(0xd9), w(0xda), w(0xdb), w(0xdc), w(0xdd), w(0xde), w(0xdf),\
|
||||
w(0xe0), w(0xe1), w(0xe2), w(0xe3), w(0xe4), w(0xe5), w(0xe6), w(0xe7),\
|
||||
w(0xe8), w(0xe9), w(0xea), w(0xeb), w(0xec), w(0xed), w(0xee), w(0xef),\
|
||||
w(0xf0), w(0xf1), w(0xf2), w(0xf3), w(0xf4), w(0xf5), w(0xf6), w(0xf7),\
|
||||
w(0xf8), w(0xf9), w(0xfa), w(0xfb), w(0xfc), w(0xfd), w(0xfe), w(0xff) }
|
||||
|
||||
static const uint8_t sbox[256] = sb_data(f1);
|
||||
|
||||
#if defined( AES_DEC_PREKEYED )
|
||||
static const uint8_t isbox[256] = isb_data(f1);
|
||||
#endif
|
||||
|
||||
static const uint8_t gfm2_sbox[256] = sb_data(f2);
|
||||
static const uint8_t gfm3_sbox[256] = sb_data(f3);
|
||||
|
||||
#if defined( AES_DEC_PREKEYED )
|
||||
static const uint8_t gfmul_9[256] = mm_data(f9);
|
||||
static const uint8_t gfmul_b[256] = mm_data(fb);
|
||||
static const uint8_t gfmul_d[256] = mm_data(fd);
|
||||
static const uint8_t gfmul_e[256] = mm_data(fe);
|
||||
#endif
|
||||
|
||||
#define s_box(x) sbox[(x)]
|
||||
#if defined( AES_DEC_PREKEYED )
|
||||
#define is_box(x) isbox[(x)]
|
||||
#endif
|
||||
#define gfm2_sb(x) gfm2_sbox[(x)]
|
||||
#define gfm3_sb(x) gfm3_sbox[(x)]
|
||||
#if defined( AES_DEC_PREKEYED )
|
||||
#define gfm_9(x) gfmul_9[(x)]
|
||||
#define gfm_b(x) gfmul_b[(x)]
|
||||
#define gfm_d(x) gfmul_d[(x)]
|
||||
#define gfm_e(x) gfmul_e[(x)]
|
||||
#endif
|
||||
#else
|
||||
|
||||
/* this is the high bit of x right shifted by 1 */
|
||||
/* position. Since the starting polynomial has */
|
||||
/* 9 bits (0x11b), this right shift keeps the */
|
||||
/* values of all top bits within a byte */
|
||||
|
||||
static uint8_t hibit(const uint8_t x)
|
||||
{ uint8_t r = (uint8_t)((x >> 1) | (x >> 2));
|
||||
|
||||
r |= (r >> 2);
|
||||
r |= (r >> 4);
|
||||
return (r + 1) >> 1;
|
||||
}
|
||||
|
||||
/* return the inverse of the finite field element x */
|
||||
|
||||
static uint8_t gf_inv(const uint8_t x)
|
||||
{ uint8_t p1 = x, p2 = BPOLY, n1 = hibit(x), n2 = 0x80, v1 = 1, v2 = 0;
|
||||
|
||||
if(x < 2)
|
||||
return x;
|
||||
|
||||
for( ; ; )
|
||||
{
|
||||
if(n1)
|
||||
while(n2 >= n1) /* divide polynomial p2 by p1 */
|
||||
{
|
||||
n2 /= n1; /* shift smaller polynomial left */
|
||||
p2 ^= (p1 * n2) & 0xff; /* and remove from larger one */
|
||||
v2 ^= (v1 * n2); /* shift accumulated value and */
|
||||
n2 = hibit(p2); /* add into result */
|
||||
}
|
||||
else
|
||||
return v1;
|
||||
|
||||
if(n2) /* repeat with values swapped */
|
||||
while(n1 >= n2)
|
||||
{
|
||||
n1 /= n2;
|
||||
p1 ^= p2 * n1;
|
||||
v1 ^= v2 * n1;
|
||||
n1 = hibit(p1);
|
||||
}
|
||||
else
|
||||
return v2;
|
||||
}
|
||||
}
|
||||
|
||||
/* The forward and inverse affine transformations used in the S-box */
|
||||
uint8_t fwd_affine(const uint8_t x)
|
||||
{
|
||||
#if defined( HAVE_UINT_32T )
|
||||
uint32_t w = x;
|
||||
w ^= (w << 1) ^ (w << 2) ^ (w << 3) ^ (w << 4);
|
||||
return 0x63 ^ ((w ^ (w >> 8)) & 0xff);
|
||||
#else
|
||||
return 0x63 ^ x ^ (x << 1) ^ (x << 2) ^ (x << 3) ^ (x << 4)
|
||||
^ (x >> 7) ^ (x >> 6) ^ (x >> 5) ^ (x >> 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t inv_affine(const uint8_t x)
|
||||
{
|
||||
#if defined( HAVE_UINT_32T )
|
||||
uint32_t w = x;
|
||||
w = (w << 1) ^ (w << 3) ^ (w << 6);
|
||||
return 0x05 ^ ((w ^ (w >> 8)) & 0xff);
|
||||
#else
|
||||
return 0x05 ^ (x << 1) ^ (x << 3) ^ (x << 6)
|
||||
^ (x >> 7) ^ (x >> 5) ^ (x >> 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define s_box(x) fwd_affine(gf_inv(x))
|
||||
#define is_box(x) gf_inv(inv_affine(x))
|
||||
#define gfm2_sb(x) f2(s_box(x))
|
||||
#define gfm3_sb(x) f3(s_box(x))
|
||||
#define gfm_9(x) f9(x)
|
||||
#define gfm_b(x) fb(x)
|
||||
#define gfm_d(x) fd(x)
|
||||
#define gfm_e(x) fe(x)
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( HAVE_MEMCPY )
|
||||
# define block_copy_nn(d, s, l) memcpy(d, s, l)
|
||||
# define block_copy(d, s) memcpy(d, s, N_BLOCK)
|
||||
#else
|
||||
# define block_copy_nn(d, s, l) copy_block_nn(d, s, l)
|
||||
# define block_copy(d, s) copy_block(d, s)
|
||||
#endif
|
||||
|
||||
static void copy_block( void *d, const void *s )
|
||||
{
|
||||
#if defined( HAVE_UINT_32T )
|
||||
((uint32_t*)d)[ 0] = ((uint32_t*)s)[ 0];
|
||||
((uint32_t*)d)[ 1] = ((uint32_t*)s)[ 1];
|
||||
((uint32_t*)d)[ 2] = ((uint32_t*)s)[ 2];
|
||||
((uint32_t*)d)[ 3] = ((uint32_t*)s)[ 3];
|
||||
#else
|
||||
((uint8_t*)d)[ 0] = ((uint8_t*)s)[ 0];
|
||||
((uint8_t*)d)[ 1] = ((uint8_t*)s)[ 1];
|
||||
((uint8_t*)d)[ 2] = ((uint8_t*)s)[ 2];
|
||||
((uint8_t*)d)[ 3] = ((uint8_t*)s)[ 3];
|
||||
((uint8_t*)d)[ 4] = ((uint8_t*)s)[ 4];
|
||||
((uint8_t*)d)[ 5] = ((uint8_t*)s)[ 5];
|
||||
((uint8_t*)d)[ 6] = ((uint8_t*)s)[ 6];
|
||||
((uint8_t*)d)[ 7] = ((uint8_t*)s)[ 7];
|
||||
((uint8_t*)d)[ 8] = ((uint8_t*)s)[ 8];
|
||||
((uint8_t*)d)[ 9] = ((uint8_t*)s)[ 9];
|
||||
((uint8_t*)d)[10] = ((uint8_t*)s)[10];
|
||||
((uint8_t*)d)[11] = ((uint8_t*)s)[11];
|
||||
((uint8_t*)d)[12] = ((uint8_t*)s)[12];
|
||||
((uint8_t*)d)[13] = ((uint8_t*)s)[13];
|
||||
((uint8_t*)d)[14] = ((uint8_t*)s)[14];
|
||||
((uint8_t*)d)[15] = ((uint8_t*)s)[15];
|
||||
#endif
|
||||
}
|
||||
|
||||
static void copy_block_nn( uint8_t * d, const uint8_t *s, uint8_t nn )
|
||||
{
|
||||
while( nn-- )
|
||||
//*((uint8_t*)d)++ = *((uint8_t*)s)++;
|
||||
*d++ = *s++;
|
||||
}
|
||||
|
||||
static void xor_block( void *d, const void *s )
|
||||
{
|
||||
#if defined( HAVE_UINT_32T )
|
||||
((uint32_t*)d)[ 0] ^= ((uint32_t*)s)[ 0];
|
||||
((uint32_t*)d)[ 1] ^= ((uint32_t*)s)[ 1];
|
||||
((uint32_t*)d)[ 2] ^= ((uint32_t*)s)[ 2];
|
||||
((uint32_t*)d)[ 3] ^= ((uint32_t*)s)[ 3];
|
||||
#else
|
||||
((uint8_t*)d)[ 0] ^= ((uint8_t*)s)[ 0];
|
||||
((uint8_t*)d)[ 1] ^= ((uint8_t*)s)[ 1];
|
||||
((uint8_t*)d)[ 2] ^= ((uint8_t*)s)[ 2];
|
||||
((uint8_t*)d)[ 3] ^= ((uint8_t*)s)[ 3];
|
||||
((uint8_t*)d)[ 4] ^= ((uint8_t*)s)[ 4];
|
||||
((uint8_t*)d)[ 5] ^= ((uint8_t*)s)[ 5];
|
||||
((uint8_t*)d)[ 6] ^= ((uint8_t*)s)[ 6];
|
||||
((uint8_t*)d)[ 7] ^= ((uint8_t*)s)[ 7];
|
||||
((uint8_t*)d)[ 8] ^= ((uint8_t*)s)[ 8];
|
||||
((uint8_t*)d)[ 9] ^= ((uint8_t*)s)[ 9];
|
||||
((uint8_t*)d)[10] ^= ((uint8_t*)s)[10];
|
||||
((uint8_t*)d)[11] ^= ((uint8_t*)s)[11];
|
||||
((uint8_t*)d)[12] ^= ((uint8_t*)s)[12];
|
||||
((uint8_t*)d)[13] ^= ((uint8_t*)s)[13];
|
||||
((uint8_t*)d)[14] ^= ((uint8_t*)s)[14];
|
||||
((uint8_t*)d)[15] ^= ((uint8_t*)s)[15];
|
||||
#endif
|
||||
}
|
||||
|
||||
static void copy_and_key( void *d, const void *s, const void *k )
|
||||
{
|
||||
#if defined( HAVE_UINT_32T )
|
||||
((uint32_t*)d)[ 0] = ((uint32_t*)s)[ 0] ^ ((uint32_t*)k)[ 0];
|
||||
((uint32_t*)d)[ 1] = ((uint32_t*)s)[ 1] ^ ((uint32_t*)k)[ 1];
|
||||
((uint32_t*)d)[ 2] = ((uint32_t*)s)[ 2] ^ ((uint32_t*)k)[ 2];
|
||||
((uint32_t*)d)[ 3] = ((uint32_t*)s)[ 3] ^ ((uint32_t*)k)[ 3];
|
||||
#elif 1
|
||||
((uint8_t*)d)[ 0] = ((uint8_t*)s)[ 0] ^ ((uint8_t*)k)[ 0];
|
||||
((uint8_t*)d)[ 1] = ((uint8_t*)s)[ 1] ^ ((uint8_t*)k)[ 1];
|
||||
((uint8_t*)d)[ 2] = ((uint8_t*)s)[ 2] ^ ((uint8_t*)k)[ 2];
|
||||
((uint8_t*)d)[ 3] = ((uint8_t*)s)[ 3] ^ ((uint8_t*)k)[ 3];
|
||||
((uint8_t*)d)[ 4] = ((uint8_t*)s)[ 4] ^ ((uint8_t*)k)[ 4];
|
||||
((uint8_t*)d)[ 5] = ((uint8_t*)s)[ 5] ^ ((uint8_t*)k)[ 5];
|
||||
((uint8_t*)d)[ 6] = ((uint8_t*)s)[ 6] ^ ((uint8_t*)k)[ 6];
|
||||
((uint8_t*)d)[ 7] = ((uint8_t*)s)[ 7] ^ ((uint8_t*)k)[ 7];
|
||||
((uint8_t*)d)[ 8] = ((uint8_t*)s)[ 8] ^ ((uint8_t*)k)[ 8];
|
||||
((uint8_t*)d)[ 9] = ((uint8_t*)s)[ 9] ^ ((uint8_t*)k)[ 9];
|
||||
((uint8_t*)d)[10] = ((uint8_t*)s)[10] ^ ((uint8_t*)k)[10];
|
||||
((uint8_t*)d)[11] = ((uint8_t*)s)[11] ^ ((uint8_t*)k)[11];
|
||||
((uint8_t*)d)[12] = ((uint8_t*)s)[12] ^ ((uint8_t*)k)[12];
|
||||
((uint8_t*)d)[13] = ((uint8_t*)s)[13] ^ ((uint8_t*)k)[13];
|
||||
((uint8_t*)d)[14] = ((uint8_t*)s)[14] ^ ((uint8_t*)k)[14];
|
||||
((uint8_t*)d)[15] = ((uint8_t*)s)[15] ^ ((uint8_t*)k)[15];
|
||||
#else
|
||||
block_copy(d, s);
|
||||
xor_block(d, k);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void add_round_key( uint8_t d[N_BLOCK], const uint8_t k[N_BLOCK] )
|
||||
{
|
||||
xor_block(d, k);
|
||||
}
|
||||
|
||||
static void shift_sub_rows( uint8_t st[N_BLOCK] )
|
||||
{ uint8_t tt;
|
||||
|
||||
st[ 0] = s_box(st[ 0]); st[ 4] = s_box(st[ 4]);
|
||||
st[ 8] = s_box(st[ 8]); st[12] = s_box(st[12]);
|
||||
|
||||
tt = st[1]; st[ 1] = s_box(st[ 5]); st[ 5] = s_box(st[ 9]);
|
||||
st[ 9] = s_box(st[13]); st[13] = s_box( tt );
|
||||
|
||||
tt = st[2]; st[ 2] = s_box(st[10]); st[10] = s_box( tt );
|
||||
tt = st[6]; st[ 6] = s_box(st[14]); st[14] = s_box( tt );
|
||||
|
||||
tt = st[15]; st[15] = s_box(st[11]); st[11] = s_box(st[ 7]);
|
||||
st[ 7] = s_box(st[ 3]); st[ 3] = s_box( tt );
|
||||
}
|
||||
|
||||
#if defined( AES_DEC_PREKEYED )
|
||||
|
||||
static void inv_shift_sub_rows( uint8_t st[N_BLOCK] )
|
||||
{ uint8_t tt;
|
||||
|
||||
st[ 0] = is_box(st[ 0]); st[ 4] = is_box(st[ 4]);
|
||||
st[ 8] = is_box(st[ 8]); st[12] = is_box(st[12]);
|
||||
|
||||
tt = st[13]; st[13] = is_box(st[9]); st[ 9] = is_box(st[5]);
|
||||
st[ 5] = is_box(st[1]); st[ 1] = is_box( tt );
|
||||
|
||||
tt = st[2]; st[ 2] = is_box(st[10]); st[10] = is_box( tt );
|
||||
tt = st[6]; st[ 6] = is_box(st[14]); st[14] = is_box( tt );
|
||||
|
||||
tt = st[3]; st[ 3] = is_box(st[ 7]); st[ 7] = is_box(st[11]);
|
||||
st[11] = is_box(st[15]); st[15] = is_box( tt );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( VERSION_1 )
|
||||
static void mix_sub_columns( uint8_t dt[N_BLOCK] )
|
||||
{ uint8_t st[N_BLOCK];
|
||||
block_copy(st, dt);
|
||||
#else
|
||||
static void mix_sub_columns( uint8_t dt[N_BLOCK], uint8_t st[N_BLOCK] )
|
||||
{
|
||||
#endif
|
||||
dt[ 0] = gfm2_sb(st[0]) ^ gfm3_sb(st[5]) ^ s_box(st[10]) ^ s_box(st[15]);
|
||||
dt[ 1] = s_box(st[0]) ^ gfm2_sb(st[5]) ^ gfm3_sb(st[10]) ^ s_box(st[15]);
|
||||
dt[ 2] = s_box(st[0]) ^ s_box(st[5]) ^ gfm2_sb(st[10]) ^ gfm3_sb(st[15]);
|
||||
dt[ 3] = gfm3_sb(st[0]) ^ s_box(st[5]) ^ s_box(st[10]) ^ gfm2_sb(st[15]);
|
||||
|
||||
dt[ 4] = gfm2_sb(st[4]) ^ gfm3_sb(st[9]) ^ s_box(st[14]) ^ s_box(st[3]);
|
||||
dt[ 5] = s_box(st[4]) ^ gfm2_sb(st[9]) ^ gfm3_sb(st[14]) ^ s_box(st[3]);
|
||||
dt[ 6] = s_box(st[4]) ^ s_box(st[9]) ^ gfm2_sb(st[14]) ^ gfm3_sb(st[3]);
|
||||
dt[ 7] = gfm3_sb(st[4]) ^ s_box(st[9]) ^ s_box(st[14]) ^ gfm2_sb(st[3]);
|
||||
|
||||
dt[ 8] = gfm2_sb(st[8]) ^ gfm3_sb(st[13]) ^ s_box(st[2]) ^ s_box(st[7]);
|
||||
dt[ 9] = s_box(st[8]) ^ gfm2_sb(st[13]) ^ gfm3_sb(st[2]) ^ s_box(st[7]);
|
||||
dt[10] = s_box(st[8]) ^ s_box(st[13]) ^ gfm2_sb(st[2]) ^ gfm3_sb(st[7]);
|
||||
dt[11] = gfm3_sb(st[8]) ^ s_box(st[13]) ^ s_box(st[2]) ^ gfm2_sb(st[7]);
|
||||
|
||||
dt[12] = gfm2_sb(st[12]) ^ gfm3_sb(st[1]) ^ s_box(st[6]) ^ s_box(st[11]);
|
||||
dt[13] = s_box(st[12]) ^ gfm2_sb(st[1]) ^ gfm3_sb(st[6]) ^ s_box(st[11]);
|
||||
dt[14] = s_box(st[12]) ^ s_box(st[1]) ^ gfm2_sb(st[6]) ^ gfm3_sb(st[11]);
|
||||
dt[15] = gfm3_sb(st[12]) ^ s_box(st[1]) ^ s_box(st[6]) ^ gfm2_sb(st[11]);
|
||||
}
|
||||
|
||||
#if defined( AES_DEC_PREKEYED )
|
||||
|
||||
#if defined( VERSION_1 )
|
||||
static void inv_mix_sub_columns( uint8_t dt[N_BLOCK] )
|
||||
{ uint8_t st[N_BLOCK];
|
||||
block_copy(st, dt);
|
||||
#else
|
||||
static void inv_mix_sub_columns( uint8_t dt[N_BLOCK], uint8_t st[N_BLOCK] )
|
||||
{
|
||||
#endif
|
||||
dt[ 0] = is_box(gfm_e(st[ 0]) ^ gfm_b(st[ 1]) ^ gfm_d(st[ 2]) ^ gfm_9(st[ 3]));
|
||||
dt[ 5] = is_box(gfm_9(st[ 0]) ^ gfm_e(st[ 1]) ^ gfm_b(st[ 2]) ^ gfm_d(st[ 3]));
|
||||
dt[10] = is_box(gfm_d(st[ 0]) ^ gfm_9(st[ 1]) ^ gfm_e(st[ 2]) ^ gfm_b(st[ 3]));
|
||||
dt[15] = is_box(gfm_b(st[ 0]) ^ gfm_d(st[ 1]) ^ gfm_9(st[ 2]) ^ gfm_e(st[ 3]));
|
||||
|
||||
dt[ 4] = is_box(gfm_e(st[ 4]) ^ gfm_b(st[ 5]) ^ gfm_d(st[ 6]) ^ gfm_9(st[ 7]));
|
||||
dt[ 9] = is_box(gfm_9(st[ 4]) ^ gfm_e(st[ 5]) ^ gfm_b(st[ 6]) ^ gfm_d(st[ 7]));
|
||||
dt[14] = is_box(gfm_d(st[ 4]) ^ gfm_9(st[ 5]) ^ gfm_e(st[ 6]) ^ gfm_b(st[ 7]));
|
||||
dt[ 3] = is_box(gfm_b(st[ 4]) ^ gfm_d(st[ 5]) ^ gfm_9(st[ 6]) ^ gfm_e(st[ 7]));
|
||||
|
||||
dt[ 8] = is_box(gfm_e(st[ 8]) ^ gfm_b(st[ 9]) ^ gfm_d(st[10]) ^ gfm_9(st[11]));
|
||||
dt[13] = is_box(gfm_9(st[ 8]) ^ gfm_e(st[ 9]) ^ gfm_b(st[10]) ^ gfm_d(st[11]));
|
||||
dt[ 2] = is_box(gfm_d(st[ 8]) ^ gfm_9(st[ 9]) ^ gfm_e(st[10]) ^ gfm_b(st[11]));
|
||||
dt[ 7] = is_box(gfm_b(st[ 8]) ^ gfm_d(st[ 9]) ^ gfm_9(st[10]) ^ gfm_e(st[11]));
|
||||
|
||||
dt[12] = is_box(gfm_e(st[12]) ^ gfm_b(st[13]) ^ gfm_d(st[14]) ^ gfm_9(st[15]));
|
||||
dt[ 1] = is_box(gfm_9(st[12]) ^ gfm_e(st[13]) ^ gfm_b(st[14]) ^ gfm_d(st[15]));
|
||||
dt[ 6] = is_box(gfm_d(st[12]) ^ gfm_9(st[13]) ^ gfm_e(st[14]) ^ gfm_b(st[15]));
|
||||
dt[11] = is_box(gfm_b(st[12]) ^ gfm_d(st[13]) ^ gfm_9(st[14]) ^ gfm_e(st[15]));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( AES_ENC_PREKEYED ) || defined( AES_DEC_PREKEYED )
|
||||
|
||||
/* Set the cipher key for the pre-keyed version */
|
||||
|
||||
return_type aes_set_key( const uint8_t key[], length_type keylen, aes_context ctx[1] )
|
||||
{
|
||||
uint8_t cc, rc, hi;
|
||||
|
||||
switch( keylen )
|
||||
{
|
||||
case 16:
|
||||
case 24:
|
||||
case 32:
|
||||
break;
|
||||
default:
|
||||
ctx->rnd = 0;
|
||||
return ( uint8_t )-1;
|
||||
}
|
||||
block_copy_nn(ctx->ksch, key, keylen);
|
||||
hi = (keylen + 28) << 2;
|
||||
ctx->rnd = (hi >> 4) - 1;
|
||||
for( cc = keylen, rc = 1; cc < hi; cc += 4 )
|
||||
{ uint8_t tt, t0, t1, t2, t3;
|
||||
|
||||
t0 = ctx->ksch[cc - 4];
|
||||
t1 = ctx->ksch[cc - 3];
|
||||
t2 = ctx->ksch[cc - 2];
|
||||
t3 = ctx->ksch[cc - 1];
|
||||
if( cc % keylen == 0 )
|
||||
{
|
||||
tt = t0;
|
||||
t0 = s_box(t1) ^ rc;
|
||||
t1 = s_box(t2);
|
||||
t2 = s_box(t3);
|
||||
t3 = s_box(tt);
|
||||
rc = f2(rc);
|
||||
}
|
||||
else if( keylen > 24 && cc % keylen == 16 )
|
||||
{
|
||||
t0 = s_box(t0);
|
||||
t1 = s_box(t1);
|
||||
t2 = s_box(t2);
|
||||
t3 = s_box(t3);
|
||||
}
|
||||
tt = cc - keylen;
|
||||
ctx->ksch[cc + 0] = ctx->ksch[tt + 0] ^ t0;
|
||||
ctx->ksch[cc + 1] = ctx->ksch[tt + 1] ^ t1;
|
||||
ctx->ksch[cc + 2] = ctx->ksch[tt + 2] ^ t2;
|
||||
ctx->ksch[cc + 3] = ctx->ksch[tt + 3] ^ t3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( AES_ENC_PREKEYED )
|
||||
|
||||
/* Encrypt a single block of 16 bytes */
|
||||
|
||||
return_type aes_encrypt( const uint8_t in[N_BLOCK], uint8_t out[N_BLOCK], const aes_context ctx[1] )
|
||||
{
|
||||
if( ctx->rnd )
|
||||
{
|
||||
uint8_t s1[N_BLOCK], r;
|
||||
copy_and_key( s1, in, ctx->ksch );
|
||||
|
||||
for( r = 1 ; r < ctx->rnd ; ++r )
|
||||
#if defined( VERSION_1 )
|
||||
{
|
||||
mix_sub_columns( s1 );
|
||||
add_round_key( s1, ctx->ksch + r * N_BLOCK);
|
||||
}
|
||||
#else
|
||||
{ uint8_t s2[N_BLOCK];
|
||||
mix_sub_columns( s2, s1 );
|
||||
copy_and_key( s1, s2, ctx->ksch + r * N_BLOCK);
|
||||
}
|
||||
#endif
|
||||
shift_sub_rows( s1 );
|
||||
copy_and_key( out, s1, ctx->ksch + r * N_BLOCK );
|
||||
}
|
||||
else
|
||||
return ( uint8_t )-1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* CBC encrypt a number of blocks (input and return an IV) */
|
||||
|
||||
return_type aes_cbc_encrypt( const uint8_t *in, uint8_t *out,
|
||||
int32_t n_block, uint8_t iv[N_BLOCK], const aes_context ctx[1] )
|
||||
{
|
||||
|
||||
while(n_block--)
|
||||
{
|
||||
xor_block(iv, in);
|
||||
if(aes_encrypt(iv, iv, ctx) != EXIT_SUCCESS)
|
||||
return EXIT_FAILURE;
|
||||
//memcpy(out, iv, N_BLOCK);
|
||||
block_copy(out, iv);
|
||||
in += N_BLOCK;
|
||||
out += N_BLOCK;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( AES_DEC_PREKEYED )
|
||||
|
||||
/* Decrypt a single block of 16 bytes */
|
||||
|
||||
return_type aes_decrypt( const uint8_t in[N_BLOCK], uint8_t out[N_BLOCK], const aes_context ctx[1] )
|
||||
{
|
||||
if( ctx->rnd )
|
||||
{
|
||||
uint8_t s1[N_BLOCK], r;
|
||||
copy_and_key( s1, in, ctx->ksch + ctx->rnd * N_BLOCK );
|
||||
inv_shift_sub_rows( s1 );
|
||||
|
||||
for( r = ctx->rnd ; --r ; )
|
||||
#if defined( VERSION_1 )
|
||||
{
|
||||
add_round_key( s1, ctx->ksch + r * N_BLOCK );
|
||||
inv_mix_sub_columns( s1 );
|
||||
}
|
||||
#else
|
||||
{ uint8_t s2[N_BLOCK];
|
||||
copy_and_key( s2, s1, ctx->ksch + r * N_BLOCK );
|
||||
inv_mix_sub_columns( s1, s2 );
|
||||
}
|
||||
#endif
|
||||
copy_and_key( out, s1, ctx->ksch );
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* CBC decrypt a number of blocks (input and return an IV) */
|
||||
|
||||
return_type aes_cbc_decrypt( const uint8_t *in, uint8_t *out,
|
||||
int32_t n_block, uint8_t iv[N_BLOCK], const aes_context ctx[1] )
|
||||
{
|
||||
while(n_block--)
|
||||
{ uint8_t tmp[N_BLOCK];
|
||||
|
||||
//memcpy(tmp, in, N_BLOCK);
|
||||
block_copy(tmp, in);
|
||||
if(aes_decrypt(in, out, ctx) != EXIT_SUCCESS)
|
||||
return EXIT_FAILURE;
|
||||
xor_block(out, iv);
|
||||
//memcpy(iv, tmp, N_BLOCK);
|
||||
block_copy(iv, tmp);
|
||||
in += N_BLOCK;
|
||||
out += N_BLOCK;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( AES_ENC_128_OTFK )
|
||||
|
||||
/* The 'on the fly' encryption key update for for 128 bit keys */
|
||||
|
||||
static void update_encrypt_key_128( uint8_t k[N_BLOCK], uint8_t *rc )
|
||||
{ uint8_t cc;
|
||||
|
||||
k[0] ^= s_box(k[13]) ^ *rc;
|
||||
k[1] ^= s_box(k[14]);
|
||||
k[2] ^= s_box(k[15]);
|
||||
k[3] ^= s_box(k[12]);
|
||||
*rc = f2( *rc );
|
||||
|
||||
for(cc = 4; cc < 16; cc += 4 )
|
||||
{
|
||||
k[cc + 0] ^= k[cc - 4];
|
||||
k[cc + 1] ^= k[cc - 3];
|
||||
k[cc + 2] ^= k[cc - 2];
|
||||
k[cc + 3] ^= k[cc - 1];
|
||||
}
|
||||
}
|
||||
|
||||
/* Encrypt a single block of 16 bytes with 'on the fly' 128 bit keying */
|
||||
|
||||
void aes_encrypt_128( const uint8_t in[N_BLOCK], uint8_t out[N_BLOCK],
|
||||
const uint8_t key[N_BLOCK], uint8_t o_key[N_BLOCK] )
|
||||
{ uint8_t s1[N_BLOCK], r, rc = 1;
|
||||
|
||||
if(o_key != key)
|
||||
block_copy( o_key, key );
|
||||
copy_and_key( s1, in, o_key );
|
||||
|
||||
for( r = 1 ; r < 10 ; ++r )
|
||||
#if defined( VERSION_1 )
|
||||
{
|
||||
mix_sub_columns( s1 );
|
||||
update_encrypt_key_128( o_key, &rc );
|
||||
add_round_key( s1, o_key );
|
||||
}
|
||||
#else
|
||||
{ uint8_t s2[N_BLOCK];
|
||||
mix_sub_columns( s2, s1 );
|
||||
update_encrypt_key_128( o_key, &rc );
|
||||
copy_and_key( s1, s2, o_key );
|
||||
}
|
||||
#endif
|
||||
|
||||
shift_sub_rows( s1 );
|
||||
update_encrypt_key_128( o_key, &rc );
|
||||
copy_and_key( out, s1, o_key );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( AES_DEC_128_OTFK )
|
||||
|
||||
/* The 'on the fly' decryption key update for for 128 bit keys */
|
||||
|
||||
static void update_decrypt_key_128( uint8_t k[N_BLOCK], uint8_t *rc )
|
||||
{ uint8_t cc;
|
||||
|
||||
for( cc = 12; cc > 0; cc -= 4 )
|
||||
{
|
||||
k[cc + 0] ^= k[cc - 4];
|
||||
k[cc + 1] ^= k[cc - 3];
|
||||
k[cc + 2] ^= k[cc - 2];
|
||||
k[cc + 3] ^= k[cc - 1];
|
||||
}
|
||||
*rc = d2(*rc);
|
||||
k[0] ^= s_box(k[13]) ^ *rc;
|
||||
k[1] ^= s_box(k[14]);
|
||||
k[2] ^= s_box(k[15]);
|
||||
k[3] ^= s_box(k[12]);
|
||||
}
|
||||
|
||||
/* Decrypt a single block of 16 bytes with 'on the fly' 128 bit keying */
|
||||
|
||||
void aes_decrypt_128( const uint8_t in[N_BLOCK], uint8_t out[N_BLOCK],
|
||||
const uint8_t key[N_BLOCK], uint8_t o_key[N_BLOCK] )
|
||||
{
|
||||
uint8_t s1[N_BLOCK], r, rc = 0x6c;
|
||||
if(o_key != key)
|
||||
block_copy( o_key, key );
|
||||
|
||||
copy_and_key( s1, in, o_key );
|
||||
inv_shift_sub_rows( s1 );
|
||||
|
||||
for( r = 10 ; --r ; )
|
||||
#if defined( VERSION_1 )
|
||||
{
|
||||
update_decrypt_key_128( o_key, &rc );
|
||||
add_round_key( s1, o_key );
|
||||
inv_mix_sub_columns( s1 );
|
||||
}
|
||||
#else
|
||||
{ uint8_t s2[N_BLOCK];
|
||||
update_decrypt_key_128( o_key, &rc );
|
||||
copy_and_key( s2, s1, o_key );
|
||||
inv_mix_sub_columns( s1, s2 );
|
||||
}
|
||||
#endif
|
||||
update_decrypt_key_128( o_key, &rc );
|
||||
copy_and_key( out, s1, o_key );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( AES_ENC_256_OTFK )
|
||||
|
||||
/* The 'on the fly' encryption key update for for 256 bit keys */
|
||||
|
||||
static void update_encrypt_key_256( uint8_t k[2 * N_BLOCK], uint8_t *rc )
|
||||
{ uint8_t cc;
|
||||
|
||||
k[0] ^= s_box(k[29]) ^ *rc;
|
||||
k[1] ^= s_box(k[30]);
|
||||
k[2] ^= s_box(k[31]);
|
||||
k[3] ^= s_box(k[28]);
|
||||
*rc = f2( *rc );
|
||||
|
||||
for(cc = 4; cc < 16; cc += 4)
|
||||
{
|
||||
k[cc + 0] ^= k[cc - 4];
|
||||
k[cc + 1] ^= k[cc - 3];
|
||||
k[cc + 2] ^= k[cc - 2];
|
||||
k[cc + 3] ^= k[cc - 1];
|
||||
}
|
||||
|
||||
k[16] ^= s_box(k[12]);
|
||||
k[17] ^= s_box(k[13]);
|
||||
k[18] ^= s_box(k[14]);
|
||||
k[19] ^= s_box(k[15]);
|
||||
|
||||
for( cc = 20; cc < 32; cc += 4 )
|
||||
{
|
||||
k[cc + 0] ^= k[cc - 4];
|
||||
k[cc + 1] ^= k[cc - 3];
|
||||
k[cc + 2] ^= k[cc - 2];
|
||||
k[cc + 3] ^= k[cc - 1];
|
||||
}
|
||||
}
|
||||
|
||||
/* Encrypt a single block of 16 bytes with 'on the fly' 256 bit keying */
|
||||
|
||||
void aes_encrypt_256( const uint8_t in[N_BLOCK], uint8_t out[N_BLOCK],
|
||||
const uint8_t key[2 * N_BLOCK], uint8_t o_key[2 * N_BLOCK] )
|
||||
{
|
||||
uint8_t s1[N_BLOCK], r, rc = 1;
|
||||
if(o_key != key)
|
||||
{
|
||||
block_copy( o_key, key );
|
||||
block_copy( o_key + 16, key + 16 );
|
||||
}
|
||||
copy_and_key( s1, in, o_key );
|
||||
|
||||
for( r = 1 ; r < 14 ; ++r )
|
||||
#if defined( VERSION_1 )
|
||||
{
|
||||
mix_sub_columns(s1);
|
||||
if( r & 1 )
|
||||
add_round_key( s1, o_key + 16 );
|
||||
else
|
||||
{
|
||||
update_encrypt_key_256( o_key, &rc );
|
||||
add_round_key( s1, o_key );
|
||||
}
|
||||
}
|
||||
#else
|
||||
{ uint8_t s2[N_BLOCK];
|
||||
mix_sub_columns( s2, s1 );
|
||||
if( r & 1 )
|
||||
copy_and_key( s1, s2, o_key + 16 );
|
||||
else
|
||||
{
|
||||
update_encrypt_key_256( o_key, &rc );
|
||||
copy_and_key( s1, s2, o_key );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
shift_sub_rows( s1 );
|
||||
update_encrypt_key_256( o_key, &rc );
|
||||
copy_and_key( out, s1, o_key );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( AES_DEC_256_OTFK )
|
||||
|
||||
/* The 'on the fly' encryption key update for for 256 bit keys */
|
||||
|
||||
static void update_decrypt_key_256( uint8_t k[2 * N_BLOCK], uint8_t *rc )
|
||||
{ uint8_t cc;
|
||||
|
||||
for(cc = 28; cc > 16; cc -= 4)
|
||||
{
|
||||
k[cc + 0] ^= k[cc - 4];
|
||||
k[cc + 1] ^= k[cc - 3];
|
||||
k[cc + 2] ^= k[cc - 2];
|
||||
k[cc + 3] ^= k[cc - 1];
|
||||
}
|
||||
|
||||
k[16] ^= s_box(k[12]);
|
||||
k[17] ^= s_box(k[13]);
|
||||
k[18] ^= s_box(k[14]);
|
||||
k[19] ^= s_box(k[15]);
|
||||
|
||||
for(cc = 12; cc > 0; cc -= 4)
|
||||
{
|
||||
k[cc + 0] ^= k[cc - 4];
|
||||
k[cc + 1] ^= k[cc - 3];
|
||||
k[cc + 2] ^= k[cc - 2];
|
||||
k[cc + 3] ^= k[cc - 1];
|
||||
}
|
||||
|
||||
*rc = d2(*rc);
|
||||
k[0] ^= s_box(k[29]) ^ *rc;
|
||||
k[1] ^= s_box(k[30]);
|
||||
k[2] ^= s_box(k[31]);
|
||||
k[3] ^= s_box(k[28]);
|
||||
}
|
||||
|
||||
/* Decrypt a single block of 16 bytes with 'on the fly'
|
||||
256 bit keying
|
||||
*/
|
||||
void aes_decrypt_256( const uint8_t in[N_BLOCK], uint8_t out[N_BLOCK],
|
||||
const uint8_t key[2 * N_BLOCK], uint8_t o_key[2 * N_BLOCK] )
|
||||
{
|
||||
uint8_t s1[N_BLOCK], r, rc = 0x80;
|
||||
|
||||
if(o_key != key)
|
||||
{
|
||||
block_copy( o_key, key );
|
||||
block_copy( o_key + 16, key + 16 );
|
||||
}
|
||||
|
||||
copy_and_key( s1, in, o_key );
|
||||
inv_shift_sub_rows( s1 );
|
||||
|
||||
for( r = 14 ; --r ; )
|
||||
#if defined( VERSION_1 )
|
||||
{
|
||||
if( ( r & 1 ) )
|
||||
{
|
||||
update_decrypt_key_256( o_key, &rc );
|
||||
add_round_key( s1, o_key + 16 );
|
||||
}
|
||||
else
|
||||
add_round_key( s1, o_key );
|
||||
inv_mix_sub_columns( s1 );
|
||||
}
|
||||
#else
|
||||
{ uint8_t s2[N_BLOCK];
|
||||
if( ( r & 1 ) )
|
||||
{
|
||||
update_decrypt_key_256( o_key, &rc );
|
||||
copy_and_key( s2, s1, o_key + 16 );
|
||||
}
|
||||
else
|
||||
copy_and_key( s2, s1, o_key );
|
||||
inv_mix_sub_columns( s1, s2 );
|
||||
}
|
||||
#endif
|
||||
copy_and_key( out, s1, o_key );
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
LICENSE TERMS
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
1. source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
2. binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation;
|
||||
|
||||
3. the name of the copyright holder is not used to endorse products
|
||||
built using this software without specific written permission.
|
||||
|
||||
DISCLAIMER
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its properties, including, but not limited to, correctness
|
||||
and/or fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue 09/09/2006
|
||||
|
||||
This is an AES implementation that uses only 8-bit byte operations on the
|
||||
cipher state.
|
||||
*/
|
||||
|
||||
#ifndef AES_H
|
||||
#define AES_H
|
||||
|
||||
#if 1
|
||||
# define AES_ENC_PREKEYED /* AES encryption with a precomputed key schedule */
|
||||
#endif
|
||||
#if 1
|
||||
# define AES_DEC_PREKEYED /* AES decryption with a precomputed key schedule */
|
||||
#endif
|
||||
#if 0
|
||||
# define AES_ENC_128_OTFK /* AES encryption with 'on the fly' 128 bit keying */
|
||||
#endif
|
||||
#if 0
|
||||
# define AES_DEC_128_OTFK /* AES decryption with 'on the fly' 128 bit keying */
|
||||
#endif
|
||||
#if 0
|
||||
# define AES_ENC_256_OTFK /* AES encryption with 'on the fly' 256 bit keying */
|
||||
#endif
|
||||
#if 0
|
||||
# define AES_DEC_256_OTFK /* AES decryption with 'on the fly' 256 bit keying */
|
||||
#endif
|
||||
|
||||
#define N_ROW 4
|
||||
#define N_COL 4
|
||||
#define N_BLOCK (N_ROW * N_COL)
|
||||
#define N_MAX_ROUNDS 14
|
||||
|
||||
typedef uint8_t return_type;
|
||||
|
||||
/* Warning: The key length for 256 bit keys overflows a byte
|
||||
(see comment below)
|
||||
*/
|
||||
|
||||
typedef uint8_t length_type;
|
||||
|
||||
typedef struct
|
||||
{ uint8_t ksch[(N_MAX_ROUNDS + 1) * N_BLOCK];
|
||||
uint8_t rnd;
|
||||
} aes_context;
|
||||
|
||||
/* The following calls are for a precomputed key schedule
|
||||
|
||||
NOTE: If the length_type used for the key length is an
|
||||
unsigned 8-bit character, a key length of 256 bits must
|
||||
be entered as a length in bytes (valid inputs are hence
|
||||
128, 192, 16, 24 and 32).
|
||||
*/
|
||||
|
||||
#if defined( AES_ENC_PREKEYED ) || defined( AES_DEC_PREKEYED )
|
||||
|
||||
return_type aes_set_key( const uint8_t key[],
|
||||
length_type keylen,
|
||||
aes_context ctx[1] );
|
||||
#endif
|
||||
|
||||
#if defined( AES_ENC_PREKEYED )
|
||||
|
||||
return_type aes_encrypt( const uint8_t in[N_BLOCK],
|
||||
uint8_t out[N_BLOCK],
|
||||
const aes_context ctx[1] );
|
||||
|
||||
return_type aes_cbc_encrypt( const uint8_t *in,
|
||||
uint8_t *out,
|
||||
int32_t n_block,
|
||||
uint8_t iv[N_BLOCK],
|
||||
const aes_context ctx[1] );
|
||||
#endif
|
||||
|
||||
#if defined( AES_DEC_PREKEYED )
|
||||
|
||||
return_type aes_decrypt( const uint8_t in[N_BLOCK],
|
||||
uint8_t out[N_BLOCK],
|
||||
const aes_context ctx[1] );
|
||||
|
||||
return_type aes_cbc_decrypt( const uint8_t *in,
|
||||
uint8_t *out,
|
||||
int32_t n_block,
|
||||
uint8_t iv[N_BLOCK],
|
||||
const aes_context ctx[1] );
|
||||
#endif
|
||||
|
||||
/* The following calls are for 'on the fly' keying. In this case the
|
||||
encryption and decryption keys are different.
|
||||
|
||||
The encryption subroutines take a key in an array of bytes in
|
||||
key[L] where L is 16, 24 or 32 bytes for key lengths of 128,
|
||||
192, and 256 bits respectively. They then encrypts the input
|
||||
data, in[] with this key and put the reult in the output array
|
||||
out[]. In addition, the second key array, o_key[L], is used
|
||||
to output the key that is needed by the decryption subroutine
|
||||
to reverse the encryption operation. The two key arrays can
|
||||
be the same array but in this case the original key will be
|
||||
overwritten.
|
||||
|
||||
In the same way, the decryption subroutines output keys that
|
||||
can be used to reverse their effect when used for encryption.
|
||||
|
||||
Only 128 and 256 bit keys are supported in these 'on the fly'
|
||||
modes.
|
||||
*/
|
||||
|
||||
#if defined( AES_ENC_128_OTFK )
|
||||
void aes_encrypt_128( const uint8_t in[N_BLOCK],
|
||||
uint8_t out[N_BLOCK],
|
||||
const uint8_t key[N_BLOCK],
|
||||
uint8_t o_key[N_BLOCK] );
|
||||
#endif
|
||||
|
||||
#if defined( AES_DEC_128_OTFK )
|
||||
void aes_decrypt_128( const uint8_t in[N_BLOCK],
|
||||
uint8_t out[N_BLOCK],
|
||||
const uint8_t key[N_BLOCK],
|
||||
uint8_t o_key[N_BLOCK] );
|
||||
#endif
|
||||
|
||||
#if defined( AES_ENC_256_OTFK )
|
||||
void aes_encrypt_256( const uint8_t in[N_BLOCK],
|
||||
uint8_t out[N_BLOCK],
|
||||
const uint8_t key[2 * N_BLOCK],
|
||||
uint8_t o_key[2 * N_BLOCK] );
|
||||
#endif
|
||||
|
||||
#if defined( AES_DEC_256_OTFK )
|
||||
void aes_decrypt_256( const uint8_t in[N_BLOCK],
|
||||
uint8_t out[N_BLOCK],
|
||||
const uint8_t key[2 * N_BLOCK],
|
||||
uint8_t o_key[2 * N_BLOCK] );
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,153 @@
|
||||
/**************************************************************************
|
||||
Copyright (C) 2009 Lander Casado, Philippas Tsigas
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files
|
||||
(the "Software"), to deal with the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimers. Redistributions in
|
||||
binary form must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimers in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
|
||||
In no event shall the authors or copyright holders be liable for any special,
|
||||
incidental, indirect or consequential damages of any kind, or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether or not
|
||||
advised of the possibility of damage, and on any theory of liability,
|
||||
arising out of or in connection with the use or performance of this software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS WITH THE SOFTWARE
|
||||
|
||||
*****************************************************************************/
|
||||
//#include <sys/param.h>
|
||||
//#include <sys/systm.h>
|
||||
#include <stdint.h>
|
||||
#include "aes.h"
|
||||
#include "cmac.h"
|
||||
#include "utilities.h"
|
||||
|
||||
#define LSHIFT(v, r) do { \
|
||||
int32_t i; \
|
||||
for (i = 0; i < 15; i++) \
|
||||
(r)[i] = (v)[i] << 1 | (v)[i + 1] >> 7; \
|
||||
(r)[15] = (v)[15] << 1; \
|
||||
} while (0)
|
||||
|
||||
#define XOR(v, r) do { \
|
||||
int32_t i; \
|
||||
for (i = 0; i < 16; i++) \
|
||||
{ \
|
||||
(r)[i] = (r)[i] ^ (v)[i]; \
|
||||
} \
|
||||
} while (0) \
|
||||
|
||||
|
||||
void AES_CMAC_Init(AES_CMAC_CTX *ctx)
|
||||
{
|
||||
memset1(ctx->X, 0, sizeof ctx->X);
|
||||
ctx->M_n = 0;
|
||||
memset1(ctx->rijndael.ksch, '\0', 240);
|
||||
}
|
||||
|
||||
void AES_CMAC_SetKey(AES_CMAC_CTX *ctx, const uint8_t key[AES_CMAC_KEY_LENGTH])
|
||||
{
|
||||
//rijndael_set_key_enc_only(&ctx->rijndael, key, 128);
|
||||
aes_set_key( key, AES_CMAC_KEY_LENGTH, &ctx->rijndael);
|
||||
}
|
||||
|
||||
void AES_CMAC_Update(AES_CMAC_CTX *ctx, const uint8_t *data, uint32_t len)
|
||||
{
|
||||
uint32_t mlen;
|
||||
uint8_t in[16];
|
||||
|
||||
if (ctx->M_n > 0) {
|
||||
mlen = MIN(16 - ctx->M_n, len);
|
||||
memcpy1(ctx->M_last + ctx->M_n, data, mlen);
|
||||
ctx->M_n += mlen;
|
||||
if (ctx->M_n < 16 || len == mlen)
|
||||
return;
|
||||
XOR(ctx->M_last, ctx->X);
|
||||
//rijndael_encrypt(&ctx->rijndael, ctx->X, ctx->X);
|
||||
aes_encrypt( ctx->X, ctx->X, &ctx->rijndael);
|
||||
data += mlen;
|
||||
len -= mlen;
|
||||
}
|
||||
while (len > 16) { /* not last block */
|
||||
|
||||
XOR(data, ctx->X);
|
||||
//rijndael_encrypt(&ctx->rijndael, ctx->X, ctx->X);
|
||||
|
||||
memcpy1(in, &ctx->X[0], 16); //Bestela ez du ondo iten
|
||||
aes_encrypt( in, in, &ctx->rijndael);
|
||||
memcpy1(&ctx->X[0], in, 16);
|
||||
|
||||
data += 16;
|
||||
len -= 16;
|
||||
}
|
||||
/* potential last block, save it */
|
||||
memcpy1(ctx->M_last, data, len);
|
||||
ctx->M_n = len;
|
||||
}
|
||||
|
||||
void AES_CMAC_Final(uint8_t digest[AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX *ctx)
|
||||
{
|
||||
uint8_t K[16];
|
||||
uint8_t in[16];
|
||||
/* generate subkey K1 */
|
||||
memset1(K, '\0', 16);
|
||||
|
||||
//rijndael_encrypt(&ctx->rijndael, K, K);
|
||||
|
||||
aes_encrypt( K, K, &ctx->rijndael);
|
||||
|
||||
if (K[0] & 0x80) {
|
||||
LSHIFT(K, K);
|
||||
K[15] ^= 0x87;
|
||||
} else
|
||||
LSHIFT(K, K);
|
||||
|
||||
|
||||
if (ctx->M_n == 16) {
|
||||
/* last block was a complete block */
|
||||
XOR(K, ctx->M_last);
|
||||
|
||||
} else {
|
||||
/* generate subkey K2 */
|
||||
if (K[0] & 0x80) {
|
||||
LSHIFT(K, K);
|
||||
K[15] ^= 0x87;
|
||||
} else
|
||||
LSHIFT(K, K);
|
||||
|
||||
/* padding(M_last) */
|
||||
ctx->M_last[ctx->M_n] = 0x80;
|
||||
while (++ctx->M_n < 16)
|
||||
ctx->M_last[ctx->M_n] = 0;
|
||||
|
||||
XOR(K, ctx->M_last);
|
||||
|
||||
|
||||
}
|
||||
XOR(ctx->M_last, ctx->X);
|
||||
|
||||
//rijndael_encrypt(&ctx->rijndael, ctx->X, digest);
|
||||
|
||||
memcpy1(in, &ctx->X[0], 16); //Bestela ez du ondo iten
|
||||
aes_encrypt(in, digest, &ctx->rijndael);
|
||||
memset1(K, 0, sizeof K);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/**************************************************************************
|
||||
Copyright (C) 2009 Lander Casado, Philippas Tsigas
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files
|
||||
(the "Software"), to deal with the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimers. Redistributions in
|
||||
binary form must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimers in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
|
||||
In no event shall the authors or copyright holders be liable for any special,
|
||||
incidental, indirect or consequential damages of any kind, or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether or not
|
||||
advised of the possibility of damage, and on any theory of liability,
|
||||
arising out of or in connection with the use or performance of this software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS WITH THE SOFTWARE
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _CMAC_H_
|
||||
#define _CMAC_H_
|
||||
|
||||
#include "aes.h"
|
||||
|
||||
#define AES_CMAC_KEY_LENGTH 16
|
||||
#define AES_CMAC_DIGEST_LENGTH 16
|
||||
|
||||
typedef struct _AES_CMAC_CTX {
|
||||
aes_context rijndael;
|
||||
uint8_t X[16];
|
||||
uint8_t M_last[16];
|
||||
uint32_t M_n;
|
||||
} AES_CMAC_CTX;
|
||||
|
||||
//#include <sys/cdefs.h>
|
||||
|
||||
//__BEGIN_DECLS
|
||||
void AES_CMAC_Init(AES_CMAC_CTX * ctx);
|
||||
void AES_CMAC_SetKey(AES_CMAC_CTX * ctx, const uint8_t key[AES_CMAC_KEY_LENGTH]);
|
||||
void AES_CMAC_Update(AES_CMAC_CTX * ctx, const uint8_t * data, uint32_t len);
|
||||
// __attribute__((__bounded__(__string__,2,3)));
|
||||
void AES_CMAC_Final(uint8_t digest[AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX * ctx);
|
||||
// __attribute__((__bounded__(__minbytes__,1,AES_CMAC_DIGEST_LENGTH)));
|
||||
//__END_DECLS
|
||||
|
||||
#endif /* _CMAC_H_ */
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
/ _____) _ | |
|
||||
( (____ _____ ____ _| |_ _____ ____| |__
|
||||
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||
_____) ) ____| | | || |_| ____( (___| | | |
|
||||
(______/|_____)_|_|_| \__)_____)\____)_| |_|
|
||||
(C)2013 Semtech
|
||||
|
||||
Description: Helper functions implementation
|
||||
|
||||
License: Revised BSD License, see LICENSE.TXT file include in the project
|
||||
|
||||
Maintainer: Miguel Luis and Gregory Cristian
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
//#include "board.h"
|
||||
#include "utilities.h"
|
||||
|
||||
/*!
|
||||
* Redefinition of rand() and srand() standard C functions.
|
||||
* These functions are redefined in order to get the same behavior across
|
||||
* different compiler toolchains implementations.
|
||||
*/
|
||||
// Standard random functions redefinition start
|
||||
#define RAND_LOCAL_MAX 2147483647L
|
||||
|
||||
static uint32_t next = 1;
|
||||
|
||||
int32_t rand1( void )
|
||||
{
|
||||
return ( ( next = next * 1103515245L + 12345L ) % RAND_LOCAL_MAX );
|
||||
}
|
||||
|
||||
void srand1( uint32_t seed )
|
||||
{
|
||||
next = seed;
|
||||
}
|
||||
// Standard random functions redefinition end
|
||||
|
||||
int32_t randr( int32_t min, int32_t max )
|
||||
{
|
||||
return ( int32_t )rand1( ) % ( max - min + 1 ) + min;
|
||||
}
|
||||
|
||||
void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size )
|
||||
{
|
||||
while( size-- )
|
||||
{
|
||||
*dst++ = *src++;
|
||||
}
|
||||
}
|
||||
|
||||
void memcpyr( uint8_t *dst, const uint8_t *src, uint16_t size )
|
||||
{
|
||||
dst = dst + ( size - 1 );
|
||||
while( size-- )
|
||||
{
|
||||
*dst-- = *src++;
|
||||
}
|
||||
}
|
||||
|
||||
void memset1( uint8_t *dst, uint8_t value, uint16_t size )
|
||||
{
|
||||
while( size-- )
|
||||
{
|
||||
*dst++ = value;
|
||||
}
|
||||
}
|
||||
|
||||
int8_t Nibble2HexChar( uint8_t a )
|
||||
{
|
||||
if( a < 10 )
|
||||
{
|
||||
return '0' + a;
|
||||
}
|
||||
else if( a < 16 )
|
||||
{
|
||||
return 'A' + ( a - 10 );
|
||||
}
|
||||
else
|
||||
{
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
/ _____) _ | |
|
||||
( (____ _____ ____ _| |_ _____ ____| |__
|
||||
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
||||
_____) ) ____| | | || |_| ____( (___| | | |
|
||||
(______/|_____)_|_|_| \__)_____)\____)_| |_|
|
||||
(C)2013 Semtech
|
||||
|
||||
Description: Helper functions implementation
|
||||
|
||||
License: Revised BSD License, see LICENSE.TXT file include in the project
|
||||
|
||||
Maintainer: Miguel Luis and Gregory Cristian
|
||||
*/
|
||||
#ifndef __UTILITIES_H__
|
||||
#define __UTILITIES_H__
|
||||
|
||||
/*!
|
||||
* \brief Returns the minimum value between a and b
|
||||
*
|
||||
* \param [IN] a 1st value
|
||||
* \param [IN] b 2nd value
|
||||
* \retval minValue Minimum value
|
||||
*/
|
||||
#define MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
|
||||
|
||||
/*!
|
||||
* \brief Returns the maximum value between a and b
|
||||
*
|
||||
* \param [IN] a 1st value
|
||||
* \param [IN] b 2nd value
|
||||
* \retval maxValue Maximum value
|
||||
*/
|
||||
#define MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
|
||||
|
||||
/*!
|
||||
* \brief Returns 2 raised to the power of n
|
||||
*
|
||||
* \param [IN] n power value
|
||||
* \retval result of raising 2 to the power n
|
||||
*/
|
||||
#define POW2( n ) ( 1 << n )
|
||||
|
||||
/*!
|
||||
* \brief Initializes the pseudo random generator initial value
|
||||
*
|
||||
* \param [IN] seed Pseudo random generator initial value
|
||||
*/
|
||||
void srand1( uint32_t seed );
|
||||
|
||||
/*!
|
||||
* \brief Computes a random number between min and max
|
||||
*
|
||||
* \param [IN] min range minimum value
|
||||
* \param [IN] max range maximum value
|
||||
* \retval random random value in range min..max
|
||||
*/
|
||||
int32_t randr( int32_t min, int32_t max );
|
||||
|
||||
/*!
|
||||
* \brief Copies size elements of src array to dst array
|
||||
*
|
||||
* \remark STM32 Standard memcpy function only works on pointers that are aligned
|
||||
*
|
||||
* \param [OUT] dst Destination array
|
||||
* \param [IN] src Source array
|
||||
* \param [IN] size Number of bytes to be copied
|
||||
*/
|
||||
void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size );
|
||||
|
||||
/*!
|
||||
* \brief Copies size elements of src array to dst array reversing the byte order
|
||||
*
|
||||
* \param [OUT] dst Destination array
|
||||
* \param [IN] src Source array
|
||||
* \param [IN] size Number of bytes to be copied
|
||||
*/
|
||||
void memcpyr( uint8_t *dst, const uint8_t *src, uint16_t size );
|
||||
|
||||
/*!
|
||||
* \brief Set size elements of dst array with value
|
||||
*
|
||||
* \remark STM32 Standard memset function only works on pointers that are aligned
|
||||
*
|
||||
* \param [OUT] dst Destination array
|
||||
* \param [IN] value Default value
|
||||
* \param [IN] size Number of bytes to be copied
|
||||
*/
|
||||
void memset1( uint8_t *dst, uint8_t value, uint16_t size );
|
||||
|
||||
/*!
|
||||
* \brief Converts a nibble to an hexadecimal character
|
||||
*
|
||||
* \param [IN] a Nibble to be converted
|
||||
* \retval hexChar Converted hexadecimal character
|
||||
*/
|
||||
int8_t Nibble2HexChar( uint8_t a );
|
||||
|
||||
#endif // __UTILITIES_H__
|
||||
@@ -39,7 +39,7 @@
|
||||
* ENV version number defined by user.
|
||||
* Please change it when your firmware add a new ENV to default_env_set.
|
||||
*/
|
||||
#define EF_ENV_VER_NUM 3 /* @note you must define it for a value, such as 0 */
|
||||
#define EF_ENV_VER_NUM 5 /* @note you must define it for a value, such as 0 */
|
||||
|
||||
/* MCU Endian Configuration, default is Little Endian Order. */
|
||||
/* #define EF_BIG_ENDIAN */
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <sfud.h>
|
||||
#include <rtthread.h>
|
||||
#include "user_config.h"
|
||||
|
||||
|
||||
|
||||
@@ -43,17 +44,23 @@ static const ef_env default_env_set[] = {
|
||||
{"boot_times", "0"},
|
||||
{"jump_boot_time", "10"}, // BOOT 等待时间 10s
|
||||
// 基础参数设置
|
||||
{"device_id", "7322070012"},
|
||||
{"device_id", "0000000003"},
|
||||
{"app_id", "220000"}, // 业务ID
|
||||
{"user_pass", "123456"},
|
||||
{"sys_pass", "898909"},
|
||||
{"mqtt_user", "admin"},
|
||||
{"mqtt_pass", "admin"},
|
||||
#ifdef USER_MINLE_CHAN2
|
||||
{"mqtt_addr", "minle.zyjzjs.cn"},
|
||||
{"mqtt_port", "8102"},
|
||||
#else
|
||||
|
||||
{"mqtt_addr", "mqtt.zyjzjs.cn"},
|
||||
{"mqtt_port", "1883"},
|
||||
{"mqtt_topic", "syksk"}, //订阅topic
|
||||
#endif
|
||||
{"mqtt_topic", "sluice"}, //订阅topic
|
||||
|
||||
{"net_drv", "dtu"}, // mqtt dtu ec200 eth
|
||||
{"net_drv", "ec200"}, // mqtt dtu ec200 eth
|
||||
{"eth2_chann", "0"}, //以太网通道2 支持modbus
|
||||
|
||||
// 传感器基础参数配置
|
||||
@@ -85,7 +92,7 @@ static const ef_env default_env_set[] = {
|
||||
{"max_open", "1600"}, // 最大开度
|
||||
{"max_ecode", "25712"}, // 编码器最大编码
|
||||
{"min_ecode", "31770"}, // 编码器最小编码
|
||||
{"exec_time", "50"}, // 异常检测时间 单位100ms 50 就是 5s
|
||||
{"exec_time", "50"}, // 开度异常监测 异常检测时间 单位100ms 50 就是 5s
|
||||
|
||||
// 闸门参数设置
|
||||
{"ctrl_mode", "0"}, // 控制模式 // 1 直接开度控制,0 反馈开度控制
|
||||
@@ -93,21 +100,26 @@ static const ef_env default_env_set[] = {
|
||||
{"simu_flow", "0"}, // 0 未启动 1 水位流量关系表 2巴歇尔槽启动流量关系表
|
||||
{"parshall", "7"}, // 巴歇尔槽规格
|
||||
// 流量数据存储
|
||||
{"ttflow", "0"}, // 累计流量
|
||||
{"ttflow", "[0,0,0,0,0,0]"}, // 累计流量
|
||||
{"chancnt", "1"}, // 流量计通道数
|
||||
{"site_type", "sluice"}, // 0,闸门站,1,流量站,2,渗流渗压站,3,自动化采集站,4,串口服务器
|
||||
{"level","[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]"},
|
||||
{"flow", "[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]"},
|
||||
{"wsid","[1,2,3,4,5,6]"},
|
||||
{"sl427ip","116.176.77.72"},
|
||||
{"sl427port","6200"},
|
||||
{"sl427code","0000000002"},
|
||||
{"wsid","[128,2,3,4,5,6]"},
|
||||
|
||||
//EF_ENV_VER_NUM 4
|
||||
{"curr1","0.6"}, // 保护电流1 开度 > openk 时的保护电流 // V4
|
||||
{"curr2","3"}, // 保护电流2 开度 < openk 时的保护电流 // V4
|
||||
{"openk","50"}, // 开度限制,开度 < 50mm 不限制荷重 V5
|
||||
{"curr_count","3"}, // 电流三次报警,就停止,除非重启设备 V5
|
||||
{"sl427open","0"}, // 是否打开427 配置 V5
|
||||
{"sl427ip","116.176.77.72"}, // V4
|
||||
{"sl427port","6200"}, // V4
|
||||
{"sl427code","0000000002"}, // V4
|
||||
//EF_ENV_VER_NUM 5
|
||||
{"loadp","2600"}, // 荷重系数,电流*k = load 单位kg V5
|
||||
// 水位流量关系表 配置10 个点
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
static char log_buf[128];
|
||||
|
||||
@@ -863,7 +863,7 @@ void elog_hexdump(const char *name, uint8_t width, const void *buf, uint16_t siz
|
||||
}
|
||||
|
||||
/* level filter */
|
||||
if (ELOG_LVL_DEBUG > elog.filter.level) {
|
||||
if (ELOG_LVL_VERBOSE > elog.filter.level) {
|
||||
return;
|
||||
} else if (!strstr(name, elog.filter.tag)) { /* tag filter */
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#*******************************************************************************
|
||||
# Copyright (c) 2017 IBM Corp.
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# and Eclipse Distribution License v1.0 which accompany this distribution.
|
||||
#
|
||||
# The Eclipse Public License is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
# and the Eclipse Distribution License is available at
|
||||
# http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
#
|
||||
# Contributors:
|
||||
# Ian Craggs - initial version
|
||||
#*******************************************************************************/
|
||||
|
||||
# MQTTPacket Library
|
||||
file(GLOB SOURCES "*.c")
|
||||
add_library(paho-embed-mqtt3c SHARED ${SOURCES})
|
||||
install(TARGETS paho-embed-mqtt3c DESTINATION /usr/lib)
|
||||
target_compile_definitions(paho-embed-mqtt3c PRIVATE MQTT_SERVER MQTT_CLIENT)
|
||||
|
||||
add_library(MQTTPacketClient SHARED MQTTFormat MQTTPacket
|
||||
MQTTSerializePublish MQTTDeserializePublish
|
||||
MQTTConnectClient MQTTSubscribeClient MQTTUnsubscribeClient)
|
||||
target_compile_definitions(MQTTPacketClient PRIVATE MQTT_CLIENT)
|
||||
|
||||
add_library(MQTTPacketServer SHARED MQTTFormat MQTTPacket
|
||||
MQTTSerializePublish MQTTDeserializePublish
|
||||
MQTTConnectServer MQTTSubscribeServer MQTTUnsubscribeServer)
|
||||
target_compile_definitions(MQTTPacketServer PRIVATE MQTT_SERVER)
|
||||
Reference in new issue
Block a user