mirror of
https://github.com/armfly/H7-TOOL_STM32H7_App.git
synced 2024-08-09 10:05:34 +08:00
1.GBK->UTF-8
2.TAB -> 4个空格 3.完善高侧电流表功能:电压、电流、功率、放电容量 4.增加二极管测量,和电阻测量同一个界面。
This commit is contained in:
parent
6cea3eb29f
commit
a8ed6fead2
1
.gitignore
vendored
1
.gitignore
vendored
@ -29,7 +29,6 @@
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
|
@ -3,6 +3,14 @@
|
||||
2. usbd_cdc_interface.h 文件中的宏定义移到c文件中,编译过,但是运行异常,奇怪。
|
||||
3. qspi_read(), lua连续读取存在问题. 2019-07-07
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
2019-11-03 V1.03a
|
||||
1.GBK->UTF-8
|
||||
2.TAB -> 4个空格
|
||||
3.完善高侧电流表功能:电压、电流、功率、放电容量
|
||||
4.增加二极管测量,和电阻测量同一个界面。
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
2019-10-20 V1.02
|
||||
1.lua脚本增加bsp_GetRunTimer等时间函数,方便统计时间
|
||||
|
@ -171,7 +171,7 @@ DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
|
||||
uint32_t alignedAddr;
|
||||
#endif
|
||||
|
||||
#if 0 /* <EFBFBD><EFBFBD>DMAģʽ */
|
||||
#if 0 /* 非DMA模式 */
|
||||
if(BSP_MMC_ReadBlocks((uint32_t *) buff, (uint32_t) (sector), count, 1000) == MMC_OK)
|
||||
{
|
||||
res = RES_OK;
|
||||
@ -181,7 +181,7 @@ DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
|
||||
res = RES_ERROR;
|
||||
}
|
||||
return res;
|
||||
#else /* DMAģʽ */
|
||||
#else /* DMA模式 */
|
||||
if(BSP_MMC_ReadBlocks_DMA((uint32_t*)buff,
|
||||
(uint32_t) (sector),
|
||||
count) == MMC_OK)
|
||||
|
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<component_viewer schemaVersion="0.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="Component_Viewer.xsd">
|
||||
|
||||
<component name="EventRecorderStub" version="1.0.0"/> <!--name and version of the component-->
|
||||
<events>
|
||||
</events>
|
||||
|
||||
</component_viewer>
|
BIN
Project/MDK-ARM(uV5)/hex2bin.exe
Normal file
BIN
Project/MDK-ARM(uV5)/hex2bin.exe
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -263,7 +263,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>App</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -439,7 +439,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>BSP</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -1963,7 +1963,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>USB_Device_Library_Core</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -2075,7 +2075,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>USBD_Virtual_COM</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -2083,7 +2083,7 @@
|
||||
<GroupNumber>13</GroupNumber>
|
||||
<FileNumber>144</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\User\usbd_virtual_com\usbd_cdc_interface.c</PathWithFileName>
|
||||
@ -2143,7 +2143,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>USBD_Mass Storage</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -2627,7 +2627,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>LwIP_PhyDrv</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -2647,7 +2647,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>LwIP_IF</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -2715,7 +2715,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>LwIP_HTTP</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -2771,7 +2771,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>LwIP_TCP</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -2847,7 +2847,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>Programmer</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -2867,7 +2867,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>Lua src 5.3.5</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -3435,7 +3435,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>DAP_bsp</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -3515,7 +3515,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>DAP_Host</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
|
@ -68,7 +68,7 @@ __Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0x00000102 ; Reserved H7-TOOL APP<50>̼<EFBFBD><CCBC>汾
|
||||
DCD 0x00000103 ; Reserved H7-TOOL APP<50>̼<EFBFBD><CCBC>汾
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
|
Binary file not shown.
@ -158,6 +158,9 @@ typedef struct
|
||||
float ADC_TVCCCurr; /* TVCC实测电压 */
|
||||
float ADC_NTCRes; /* NTC电阻 */
|
||||
|
||||
float BatteryCapacity; /* 电池容量累计 */
|
||||
uint8_t StartBatCap; /* 开始累计容量 */
|
||||
|
||||
uint16_t OutTVCCDac; /* 输出TVCC dac值 */
|
||||
uint16_t OutTVCCmV; /* 输出TVCC mV值 */
|
||||
|
||||
@ -171,7 +174,7 @@ typedef struct
|
||||
|
||||
uint8_t CalibEnable;
|
||||
|
||||
uint8_t GpioMode[16]; /* 保存GPIO模式参数,输入,输出或特殊功能 */
|
||||
uint8_t GpioMode[16]; /* 保存GPIO模式参数、输入、输出或特殊功能 */
|
||||
|
||||
} VAR_T;
|
||||
|
||||
|
@ -3,19 +3,20 @@
|
||||
*
|
||||
* 模块名称 : H7-TOOL App主程序
|
||||
* 文件名称 : main.c
|
||||
* 版 本 : V1.0
|
||||
* 版 本 : V1.1
|
||||
* 说 明 :
|
||||
*
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* V1.0 2019-10-01 armfly 正式发布
|
||||
* V1.1 2019-11-02 armfly 整理格式。增加功能。
|
||||
*
|
||||
* Copyright (C), 2019-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
#include "bsp.h" /* printf函数定向输出到串口,所以必须包含这个文件 */
|
||||
#include "bsp.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "status_link_mode.h"
|
||||
@ -41,11 +42,11 @@
|
||||
|
||||
static void DispLogo(void);
|
||||
|
||||
uint16_t g_MainStatus;
|
||||
uint16_t g_MainStatus; /* 主状态字 */
|
||||
|
||||
/* 主状态切换顺序 */
|
||||
static const uint16_t StatusOrder[] =
|
||||
{
|
||||
{
|
||||
MS_LINK_MODE, /* 联机状态 */
|
||||
MS_VOLTAGE_METER, /* 电压表 */
|
||||
MS_RESISTOR_METER, /* 电阻表 */
|
||||
@ -58,7 +59,7 @@ static const uint16_t StatusOrder[] =
|
||||
*********************************************************************************************************
|
||||
* 函 数 名: main
|
||||
* 功能说明: c程序入口
|
||||
* 形 参:无
|
||||
* 形 参: 无
|
||||
* 返 回 值: 错误代码(无需处理)
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -251,7 +252,8 @@ static void DispLogo(void)
|
||||
uint16_t y = 3;
|
||||
uint16_t line_cap = 20;
|
||||
|
||||
LCD_DispStr(x, y, "H7-TOOL多功能开发工具", &tFont);
|
||||
//LCD_DispStr(x, y, "H7-TOOL多功能开发工具", &tFont);
|
||||
LCD_DispStr(x, y, "H7-TOOL", &tFont);
|
||||
y += line_cap;
|
||||
|
||||
sprintf(buf, "App Ver:%d.%02X",
|
||||
|
@ -3,11 +3,12 @@
|
||||
*
|
||||
* 模块名称 : 高侧电压电流表
|
||||
* 文件名称 : status_current_meter.c
|
||||
* 版 本 : V1.0
|
||||
* 版 本 : V1.1
|
||||
* 说 明 :
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* V1.0 2019-10-19 armfly 正式发布
|
||||
* V1.1 2019-10-19 armfly 正式发布
|
||||
* V1.2 2019-11-03 armfly 完善功能。增加电池容量计算。
|
||||
*
|
||||
* Copyright (C), 2018-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
@ -16,6 +17,10 @@
|
||||
#include "bsp.h"
|
||||
#include "main.h"
|
||||
|
||||
static void DispCurrentVolt(void);
|
||||
static void AutoCurrentRange(void);
|
||||
static void DispHelpCurrentMeter(void);
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* 函 数 名: status_CurrentMeter
|
||||
@ -28,19 +33,15 @@ void status_CurrentMeter(void)
|
||||
{
|
||||
uint8_t ucKeyCode; /* 按键代码 */
|
||||
uint8_t fRefresh;
|
||||
FONT_T tFont; /* 定义字体结构体变量 */
|
||||
uint8_t ucIgnoreKey = 0;
|
||||
|
||||
DispHeader("高侧电流表");
|
||||
|
||||
/* 设置字体参数 */
|
||||
{
|
||||
tFont.FontCode = FC_ST_16; /* 字体代码 16点阵 */
|
||||
tFont.FrontColor = CL_BLACK; /* 字体颜色 */
|
||||
tFont.BackColor = FORM_BACK_COLOR; /* 文字背景颜色 */
|
||||
tFont.Space = 0; /* 文字间距,单位 = 像素 */
|
||||
}
|
||||
DispHelpCurrentMeter();
|
||||
|
||||
fRefresh = 1;
|
||||
|
||||
bsp_StartAutoTimer(0, 300);
|
||||
bsp_StartAutoTimer(1, 1000);
|
||||
while (g_MainStatus == MS_CURRENT_METER)
|
||||
{
|
||||
bsp_Idle();
|
||||
@ -48,6 +49,24 @@ void status_CurrentMeter(void)
|
||||
if (fRefresh) /* 刷新整个界面 */
|
||||
{
|
||||
fRefresh = 0;
|
||||
|
||||
DispCurrentVolt();
|
||||
AutoCurrentRange();
|
||||
}
|
||||
|
||||
if (bsp_CheckTimer(0))
|
||||
{
|
||||
fRefresh = 1;
|
||||
}
|
||||
|
||||
/* 每秒统计一次 */
|
||||
if (bsp_CheckTimer(1))
|
||||
{
|
||||
if (g_tVar.StartBatCap == 1)
|
||||
{
|
||||
/* 1mAh = 0.001安培*3600秒 = 3.6安培秒 = 3.6库仑 */
|
||||
g_tVar.BatteryCapacity += g_tVar.HighSideCurr / 3600;
|
||||
}
|
||||
}
|
||||
|
||||
ucKeyCode = bsp_GetKey(); /* 读取键值, 无键按下时返回 KEY_NONE = 0 */
|
||||
@ -60,20 +79,34 @@ void status_CurrentMeter(void)
|
||||
break;
|
||||
|
||||
case KEY_UP_S: /* S键释放 */
|
||||
if (g_tVar.StartBatCap == 0)
|
||||
{
|
||||
g_MainStatus = NextStatus(MS_CURRENT_METER);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case KEY_LONG_S: /* S键长按 */
|
||||
g_tVar.StartBatCap = 1;
|
||||
g_tVar.BatteryCapacity = 0;
|
||||
BEEP_KeyTone();
|
||||
break;
|
||||
|
||||
case KEY_DOWN_C: /* C键按下 */
|
||||
break;
|
||||
|
||||
case KEY_UP_C: /* C键释放 */
|
||||
if (g_tVar.StartBatCap == 0 && ucIgnoreKey == 0)
|
||||
{
|
||||
g_MainStatus = LastStatus(MS_CURRENT_METER);
|
||||
}
|
||||
ucIgnoreKey = 0;
|
||||
break;
|
||||
|
||||
case KEY_LONG_C: /* C键长按 */
|
||||
g_tVar.StartBatCap = 0;
|
||||
ucIgnoreKey = 1; /* 需要丢弃即将到来的C键弹起事件 */
|
||||
BEEP_KeyTone();
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -81,6 +114,84 @@ void status_CurrentMeter(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
bsp_StopTimer(0);
|
||||
bsp_StopTimer(1);
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* 函 数 名: AutoCurrentRange
|
||||
* 功能说明: 自动调节量程
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static void AutoCurrentRange(void)
|
||||
{
|
||||
if (g_tVar.HighSideCurr < 120)
|
||||
{
|
||||
WriteRegValue_06H(0x0211, 0); /* 0表示120mA, 1表示1.2A量程 */
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteRegValue_06H(0x0211, 1); /* 0表示120mA, 1表示1.2A量程 */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* 函 数 名: DispHelpCurrentMeter
|
||||
* 功能说明: 显示操作提示
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static void DispHelpCurrentMeter(void)
|
||||
{
|
||||
FONT_T tFont; /* 定义字体结构体变量 */
|
||||
|
||||
tFont.FontCode = FC_ST_16; /* 字体代码 16点阵 */
|
||||
tFont.FrontColor = CL_YELLOW; /* 字体颜色 */
|
||||
tFont.BackColor = FORM_BACK_COLOR; /* 文字背景颜色 */
|
||||
tFont.Space = 0; /* 文字间距,单位 = 像素 */
|
||||
tFont.FrontColor = CL_BLACK; /* 黑字 */
|
||||
|
||||
LCD_DispStr(5, 240 - 40, "长按S开始测量电池放电容量", &tFont);
|
||||
LCD_DispStr(5, 240 - 20, "长按C停止测量", &tFont);
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* 函 数 名: DispCurrentVolt
|
||||
* 功能说明: 显示电压电流功率
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static void DispCurrentVolt(void)
|
||||
{
|
||||
FONT_T tFont;
|
||||
char buf[64];
|
||||
|
||||
/* 设置字体参数 */
|
||||
{
|
||||
tFont.FontCode = FC_ST_24; /* 字体代码 16点阵 */
|
||||
tFont.FrontColor = CL_WHITE; /* 字体颜色 */
|
||||
tFont.BackColor = HEAD_BAR_COLOR; /* 文字背景颜色 */
|
||||
tFont.Space = 0; /* 文字间距,单位 = 像素 */
|
||||
}
|
||||
|
||||
sprintf(buf, "电压: %8.3fV", g_tVar.HighSideVolt);
|
||||
LCD_DispStrEx(10, 50 + 32 * 0, buf, &tFont, 220, ALIGN_CENTER);
|
||||
|
||||
sprintf(buf, "电流: %8.1fmA", g_tVar.HighSideCurr);
|
||||
LCD_DispStrEx(10, 50 + 32 * 1, buf, &tFont, 220, ALIGN_CENTER);
|
||||
|
||||
sprintf(buf, "功率: %8.3fW", g_tVar.HighSideVolt * g_tVar.HighSideCurr / 1000);
|
||||
LCD_DispStrEx(10, 50 + 32 * 2, buf, &tFont, 220, ALIGN_CENTER);
|
||||
|
||||
sprintf(buf, "容量: %8.3fmAh", g_tVar.BatteryCapacity);
|
||||
LCD_DispStrEx(10, 50 + 32 * 3, buf, &tFont, 220, ALIGN_CENTER);
|
||||
}
|
||||
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
#include "bsp.h"
|
||||
#include "main.h"
|
||||
#include "usbd_user.h"
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
@ -78,11 +79,11 @@ void status_LinkMode(void)
|
||||
|
||||
tFont.FrontColor = CL_BLACK; /* 黑字 */
|
||||
y = 10 * line_cap;
|
||||
sprintf(buf, "长按S进入系统设置", &tFont);
|
||||
sprintf(buf, "长按S进入系统设置");
|
||||
|
||||
LCD_DispStr(x, y, buf, &tFont);
|
||||
y = 11 * line_cap;
|
||||
sprintf(buf, "长按C切换方向", &tFont);
|
||||
sprintf(buf, "长按C切换方向");
|
||||
LCD_DispStr(x, y, buf, &tFont);
|
||||
}
|
||||
}
|
||||
@ -136,8 +137,11 @@ void status_LinkMode(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (g_MainStatus != MS_SYSTEM_SET)
|
||||
{
|
||||
usbd_CloseCDC();
|
||||
usbd_OpenCDC(1); /* 启用USB虚拟串口1, 用于虚拟串口,RS232 RS485 TTL-UART */
|
||||
}
|
||||
}
|
||||
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -31,7 +31,7 @@ void status_ResistorMeter(void)
|
||||
uint8_t ucKeyCode; /* 按键代码 */
|
||||
uint8_t fRefresh;
|
||||
|
||||
DispHeader("电阻测量");
|
||||
DispHeader("电阻、二极管测量");
|
||||
|
||||
fRefresh = 1;
|
||||
bsp_StartAutoTimer(0, 300);
|
||||
@ -92,7 +92,7 @@ void status_ResistorMeter(void)
|
||||
}
|
||||
}
|
||||
bsp_StopTimer(0);
|
||||
BEEP_Stop();
|
||||
//BEEP_Stop(); 打开会导致切换的按键音消失
|
||||
}
|
||||
|
||||
/*
|
||||
@ -107,6 +107,8 @@ static void DispResistor(void)
|
||||
{
|
||||
FONT_T tFont;
|
||||
char buf[64];
|
||||
float volt;
|
||||
float curr;
|
||||
|
||||
/* 设置字体参数 */
|
||||
{
|
||||
@ -116,7 +118,7 @@ static void DispResistor(void)
|
||||
tFont.Space = 0; /* 文字间距,单位 = 像素 */
|
||||
}
|
||||
|
||||
if (g_tVar.NTCRes < 1.0)
|
||||
if (g_tVar.NTCRes < 1.0f)
|
||||
{
|
||||
sprintf(buf, "电阻: %0.1fΩ", g_tVar.NTCRes * 1000);
|
||||
}
|
||||
@ -128,8 +130,27 @@ static void DispResistor(void)
|
||||
{
|
||||
sprintf(buf, "电阻: > 1MΩ");
|
||||
}
|
||||
|
||||
LCD_DispStrEx(10, 50, buf, &tFont, 220, ALIGN_CENTER);
|
||||
|
||||
/* 大致计算,不是很精确 */
|
||||
volt = 2.5f * g_tVar.NTCRes / (g_tVar.NTCRes + 5.1f);
|
||||
curr = volt / g_tVar.NTCRes;
|
||||
if (volt > 2.4f)
|
||||
{
|
||||
sprintf(buf, " 压降: > 2.4V");
|
||||
LCD_DispStrEx(10, 50 + 50, buf, &tFont, 220, ALIGN_LEFT);
|
||||
|
||||
sprintf(buf, " 电流: %0.3fmA", curr);
|
||||
LCD_DispStrEx(10, 50 + 50 + 24, buf, &tFont, 220, ALIGN_LEFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(buf, " 压降: %0.3fV", volt);
|
||||
LCD_DispStrEx(10, 50 + 50, buf, &tFont, 220, ALIGN_LEFT);
|
||||
|
||||
sprintf(buf, " 电流: %0.3fmA", curr);
|
||||
LCD_DispStrEx(10, 50 + 50 + 24, buf, &tFont, 220, ALIGN_LEFT);
|
||||
}
|
||||
}
|
||||
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -421,7 +421,9 @@ void bsp_RunPer1ms(void)
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
extern void lwip_pro(void);
|
||||
extern void lua_Poll();
|
||||
extern void lua_Poll(void);
|
||||
extern void wifi_task(void);
|
||||
extern void EXIO_ScanTask(void);
|
||||
void bsp_Idle(void)
|
||||
{
|
||||
/* --- 喂狗 */
|
||||
|
@ -2370,10 +2370,6 @@ float bsp_AdcToCH1Volt(float _adc)
|
||||
g_tCalib.CH1[g_tDSO.Gain1].x1, g_tCalib.CH1[g_tDSO.Gain1].y1,
|
||||
g_tCalib.CH1[g_tDSO.Gain1].x2, g_tCalib.CH1[g_tDSO.Gain1].y2,
|
||||
_adc);
|
||||
// if (volt > (float)-0.020 && volt < (float)0.020) /* 0值.正负20mV以内自动归零 */
|
||||
// {
|
||||
// volt = 0;
|
||||
// }
|
||||
return volt;
|
||||
}
|
||||
|
||||
@ -2393,10 +2389,6 @@ float bsp_AdcToCH2Volt(float _adc)
|
||||
g_tCalib.CH2[g_tDSO.Gain2].x1, g_tCalib.CH2[g_tDSO.Gain2].y1,
|
||||
g_tCalib.CH2[g_tDSO.Gain2].x2, g_tCalib.CH2[g_tDSO.Gain2].y2,
|
||||
_adc);
|
||||
// if (volt > (float)-0.020 && volt < (float)0.020) /* 0值.正负20mV以内自动归零 */
|
||||
// {
|
||||
// volt = 0;
|
||||
// }
|
||||
return volt;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ extern SPI_HandleTypeDef hspi2;
|
||||
void SWD_SendBitsOK(uint8_t _bits, uint32_t _data)
|
||||
{
|
||||
#if 1
|
||||
static uint8_t s_first = 1;
|
||||
//static uint8_t s_first = 1;
|
||||
|
||||
// if (s_first == 0)
|
||||
// {
|
||||
|
@ -287,8 +287,6 @@ static void ST7789_SendByteQuick(uint8_t data)
|
||||
/*写数据到 LCD 模块*/
|
||||
void Lcd_WriteData(uint8_t data1)
|
||||
{
|
||||
char i;
|
||||
|
||||
LCD_RS_1();
|
||||
LCD_CS_0();
|
||||
ST7789_SendByteQuick(data1);
|
||||
|
@ -189,7 +189,7 @@ static void UartVarInit(void);
|
||||
static void InitHardUart(void);
|
||||
static void UartSend(UART_T *_pUart, uint8_t *_ucaBuf, uint16_t _usLen);
|
||||
static uint8_t UartGetChar(UART_T *_pUart, uint8_t *_pByte);
|
||||
static void UartIRQ(UART_T *_pUart);
|
||||
//static void UartIRQ(UART_T *_pUart);
|
||||
|
||||
void RS485_InitTXE(void);
|
||||
|
||||
@ -848,7 +848,7 @@ void bsp_SetUartParam(USART_TypeDef *Instance, uint32_t BaudRate, uint32_t Parit
|
||||
*/
|
||||
static void InitHardUart(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
// GPIO_InitTypeDef GPIO_InitStruct;
|
||||
RCC_PeriphCLKInitTypeDef RCC_PeriphClkInit;
|
||||
UART_HandleTypeDef UartHandle;
|
||||
|
||||
@ -1287,7 +1287,7 @@ void comPutRxFifo(COM_PORT_E _ucPort, uint8_t *_buf, uint16_t _len)
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static void UartIRQ(UART_T *_pUart)
|
||||
void UartIRQ(UART_T *_pUart)
|
||||
{
|
||||
uint32_t isrflags = READ_REG(_pUart->uart->ISR);
|
||||
uint32_t cr1its = READ_REG(_pUart->uart->CR1);
|
||||
@ -1530,6 +1530,7 @@ int fgetc(FILE *f)
|
||||
|
||||
// return (int)USART_ReceiveData(USART1);
|
||||
//#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -794,7 +794,6 @@ void FloatToBEBuf(float _f, uint8_t *_pBuf)
|
||||
{
|
||||
float f;
|
||||
uint8_t *p;
|
||||
uint8_t buf[4];
|
||||
|
||||
f = _f;
|
||||
p = (uint8_t *)&f;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* @file DAP.c
|
||||
* @brief Implementation of DAP.h
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* @file DAP.h
|
||||
* @brief Access to ARM DAP using CMSIS-DAP protocol
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* @file DAP_queue.c
|
||||
* @brief DAP processing queue
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* @file DAP_queue.h
|
||||
* @brief DAP processing queue
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) 2013-2016 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
@ -62,7 +62,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
|
||||
uint32_t num = (1U << 16) | 1U;
|
||||
|
||||
*response++ = *request; // copy Command ID
|
||||
#if 0 // armfly <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#if 0 // armfly 临时屏蔽
|
||||
switch (*request++) { // first byte in request is Command ID
|
||||
case ID_DAP_Vendor0: {
|
||||
const char *id_str = info_get_unique_id();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* @file JTAG_DP.c
|
||||
* @brief JTAG driver
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) 2013-2016 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* @file SW_DP.c
|
||||
* @brief SWD driver
|
||||
*
|
||||
@ -31,22 +31,22 @@
|
||||
#include "DAP_config.h"
|
||||
#include "DAP.h"
|
||||
|
||||
#define SPI_MODE_ENABLE 1 /* 1 <EFBFBD><EFBFBD>ʾSPIģʽ<EFBFBD><EFBFBD> 0<><30>ʾGPIOģʽ */
|
||||
#define SPI_MODE_ENABLE 1 /* 1 表示SPI模式, 0表示GPIO模式 */
|
||||
|
||||
/*
|
||||
SPI_BAUDRATEPRESCALER_4 = 50MHz SCKʱ<EFBFBD>ӣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
SPI_BAUDRATEPRESCALER_8 = 25MHz SCKʱ<EFBFBD>ӣ<EFBFBD><EFBFBD>ȶ<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD> д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2048<EFBFBD>ֽڣ<EFBFBD><EFBFBD><EFBFBD>ʱ5ms<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD> 800KB/s
|
||||
SPI_BAUDRATEPRESCALER_4 = 50MHz SCK时钟,不能工作。
|
||||
SPI_BAUDRATEPRESCALER_8 = 25MHz SCK时钟,稳定读写。 写并读2048字节,耗时5ms,等效传输速度 800KB/s
|
||||
|
||||
SPI_BAUDRATEPRESCALER_16 = 12.5MHz
|
||||
SPI_BAUDRATEPRESCALER_32 = 6.25MHz
|
||||
SPI_BAUDRATEPRESCALER_64 = 3.125MHz
|
||||
SPI_BAUDRATEPRESCALER_128 = 1.5625MHz
|
||||
|
||||
ʵ<EFBFBD><EFBFBD>ST-LINK<EFBFBD><EFBFBD><EFBFBD><EFBFBD>640K<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ9<EFBFBD>루<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CPU<EFBFBD><EFBFBD>FLASH<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺<EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ13<EFBFBD>롣
|
||||
<EFBFBD><EFBFBD>H7-TOOL<EFBFBD><EFBFBD>800KB/S<EFBFBD><EFBFBD><EFBFBD>ٶȣ<EFBFBD>SWDʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>ʣ<EFBFBD>µ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>USBͨ<EFBFBD>ź<EFBFBD>CPU<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD>ʡ<EFBFBD>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SWD<EFBFBD>ײ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ż<EFBFBD><EFBFBD>Ѿ<EFBFBD>û<EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>Ҫ<EFBFBD>ˣ<EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>1MB/S<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>û<EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||||
实测ST-LINK下载640K程序,擦除需要9秒(这是CPU的FLASH擦除时间较慢导致),编程和校验需要13秒。
|
||||
按H7-TOOL的800KB/S的速度,SWD时序传输可以在1秒内完成,剩下的时间主要靠USB通信和CPU运算来提高效率。
|
||||
因此在SWD底层时序上优化已经没有多大的必要了,也许可以提高到1MB/S。但是对整体效率没有多大改善。
|
||||
*/
|
||||
#define SPI_MODE_BAUD SPI_BAUDRATEPRESCALER_8 /* SPI_BAUDRATEPRESCALER_4 <EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD> */
|
||||
#define SPI_MODE_BAUD SPI_BAUDRATEPRESCALER_8 /* SPI_BAUDRATEPRESCALER_4 不稳定 */
|
||||
|
||||
|
||||
#define PIN_SWCLK_SET PIN_SWCLK_TCK_SET
|
||||
@ -236,7 +236,7 @@ uint8_t SWD_Transfer(uint32_t request, uint32_t *data)
|
||||
}
|
||||
}
|
||||
|
||||
/********************************* armfly <EFBFBD>Ż<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD> ***************************/
|
||||
/********************************* armfly 优化时序速度 ***************************/
|
||||
// SWD Transfer I/O
|
||||
// request: A[3:2] RnW APnDP
|
||||
// data: DATA[31:0]
|
||||
@ -425,7 +425,7 @@ void SWD_DIO_OutDisable(void)
|
||||
{
|
||||
#if SPI_MODE_ENABLE == 1
|
||||
SPI2->CR1 = SPI_CR1_SSI;
|
||||
GPIOG->BSRRH = GPIO_PIN_9; /* PG9 = 0 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> /
|
||||
GPIOG->BSRRH = GPIO_PIN_9; /* PG9 = 0 是输入 */
|
||||
#else
|
||||
PIN_SWDIO_OUT_DISABLE();
|
||||
#endif
|
||||
@ -434,7 +434,7 @@ void SWD_DIO_OutDisable(void)
|
||||
void SWD_DIO_OutEnable(void)
|
||||
{
|
||||
#if SPI_MODE_ENABLE == 1
|
||||
GPIOG->BSRRL = GPIO_PIN_9; /* PG9 = 1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
GPIOG->BSRRL = GPIO_PIN_9; /* PG9 = 1 是输出 */
|
||||
SPI2->CR1 = SPI_CR1_SSI | SPI_CR1_HDDIR;
|
||||
#else
|
||||
PIN_SWDIO_OUT_ENABLE();
|
||||
@ -472,7 +472,7 @@ void SWJ_Sequence (uint32_t count, const uint8_t *data) {
|
||||
|
||||
if (rem)
|
||||
{
|
||||
val = *(uint32_t *)data; /* <EFBFBD><EFBFBD><EFBFBD>ܶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD> */
|
||||
val = *(uint32_t *)data; /* 可能多访问内存 */
|
||||
SWD_SendBits(rem, val);
|
||||
}
|
||||
}
|
||||
@ -558,7 +558,7 @@ uint8_t SWD_TransferFastH7(uint32_t request, uint32_t *data)
|
||||
// if (ack == DAP_TRANSFER_OK)
|
||||
{ /* OK response */
|
||||
/* Data transfer */
|
||||
if (request & DAP_TRANSFER_RnW) /* <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD> - 32 + 1 bit */
|
||||
if (request & DAP_TRANSFER_RnW) /* 读指令 - 32 + 1 bit */
|
||||
{
|
||||
ack = SWD_ReadBits(3 + DAP_Data.swd_conf.turnaround);
|
||||
ack >>= DAP_Data.swd_conf.turnaround;
|
||||
@ -625,7 +625,7 @@ uint8_t SWD_TransferFastH7(uint32_t request, uint32_t *data)
|
||||
return ((uint8_t)ack);
|
||||
}
|
||||
}
|
||||
else // дָ<EFBFBD><EFBFBD>
|
||||
else // 写指令
|
||||
{
|
||||
ack = SWD_ReadBits(3 + DAP_Data.swd_conf.turnaround + 1);
|
||||
ack >>= DAP_Data.swd_conf.turnaround;
|
||||
@ -669,7 +669,7 @@ uint8_t SWD_TransferFastH7(uint32_t request, uint32_t *data)
|
||||
SWD_SendBits(16, val);
|
||||
SWD_SendBits(16 + 1 + DAP_Data.transfer.idle_cycles, (val >> 16) + (parity << 16));
|
||||
|
||||
//PIN_SWDIO_OUT(1U); <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DZ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ<EFBFBD>
|
||||
//PIN_SWDIO_OUT(1U); 好像不是必须的。
|
||||
|
||||
return ((uint8_t)ack);
|
||||
}
|
||||
@ -679,7 +679,7 @@ uint8_t SWD_TransferFastH7(uint32_t request, uint32_t *data)
|
||||
|
||||
if ((ack == DAP_TRANSFER_WAIT) || (ack == DAP_TRANSFER_FAULT))
|
||||
{
|
||||
if (request & DAP_TRANSFER_RnW) /* <EFBFBD><EFBFBD><EFBFBD>쳣 */
|
||||
if (request & DAP_TRANSFER_RnW) /* 读异常 */
|
||||
{
|
||||
/* WAIT or FAULT response */
|
||||
// if (DAP_Data.swd_conf.data_phase && ((request & DAP_TRANSFER_RnW) != 0U))
|
||||
@ -710,7 +710,7 @@ uint8_t SWD_TransferFastH7(uint32_t request, uint32_t *data)
|
||||
PIN_SWDIO_OUT(1U);
|
||||
return ((uint8_t)ack);
|
||||
}
|
||||
else /* д<EFBFBD>쳣 - ǰ<><C7B0><EFBFBD><EFBFBD><E0B7A2>1<EFBFBD><31>clk */
|
||||
else /* 写异常 - 前面多发了1个clk */
|
||||
{
|
||||
/* WAIT or FAULT response */
|
||||
// if (DAP_Data.swd_conf.data_phase && ((request & DAP_TRANSFER_RnW) != 0U))
|
||||
@ -804,7 +804,7 @@ uint8_t SWD_TransferFastH7_ok(uint32_t request, uint32_t *data)
|
||||
if (ack == DAP_TRANSFER_OK)
|
||||
{ /* OK response */
|
||||
/* Data transfer */
|
||||
if (request & DAP_TRANSFER_RnW) /* <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD> - 32 + 1 bit */
|
||||
if (request & DAP_TRANSFER_RnW) /* 读指令 - 32 + 1 bit */
|
||||
{
|
||||
/* Read data */
|
||||
val = 0U;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* @file debug_ca.h
|
||||
* @brief Access to ARM DAP (Cortex-A) using CMSIS-DAP protocol
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* @file debug_cm.h
|
||||
* @brief Access to ARM DAP (Cortex-M) using CMSIS-DAP protocol
|
||||
*
|
||||
|
@ -1232,6 +1232,19 @@ unsigned char const g_Hz16[] = {
|
||||
0xCF,0xB5, 0x00,0xF8,0x3F,0x00,0x04,0x00,0x08,0x20,0x10,0x40,0x3F,0x80,0x01,0x00,0x06,0x10,// 系 //
|
||||
0x18,0x08,0x7F,0xFC,0x01,0x04,0x09,0x20,0x11,0x10,0x21,0x08,0x45,0x04,0x02,0x00,
|
||||
|
||||
0xB3,0xD8, 0x00,0x40,0x20,0x40,0x12,0x40,0x12,0x58,0x82,0x68,0x42,0xC8,0x53,0x48,0x1E,0x48,// 池 //
|
||||
0x12,0x48,0x22,0x48,0xE2,0x58,0x22,0x42,0x22,0x02,0x22,0x02,0x21,0xFE,0x00,0x00,
|
||||
|
||||
|
||||
0xB5,0xE7, 0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,// 电 //
|
||||
0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x0A,0x01,0x02,0x01,0x02,0x00,0xFE,
|
||||
|
||||
|
||||
0xB7,0xC5, 0x20,0x40,0x10,0x40,0x00,0x40,0xFE,0x80,0x20,0xFE,0x21,0x08,0x3E,0x88,0x24,0x88,// 放 //
|
||||
0x24,0x88,0x24,0x50,0x24,0x50,0x24,0x20,0x44,0x50,0x54,0x88,0x89,0x04,0x02,0x02,
|
||||
|
||||
0xC8,0xDD, 0x02,0x00,0x01,0x00,0x7F,0xFE,0x40,0x02,0x88,0x24,0x11,0x10,0x22,0x88,0x04,0x40,// 容 //
|
||||
0x08,0x20,0x30,0x18,0xDF,0xF6,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x10,
|
||||
|
||||
/* 最后一行必须用0xFF,0xFF结束,这是字库数组结束标志 */
|
||||
0xFF,0xFF
|
||||
|
@ -377,7 +377,59 @@ unsigned char const g_Hz24[] = {
|
||||
0x0C,0x60,0x30,0x0C,0x7F,0xF0,0x0C,0x60,0x30,0x0C,0x60,0x30,0x0C,0x60,0x34,0x0D,
|
||||
0xFF,0xFE,0x0C,0x00,0x00,0x08,0x00,0x00,
|
||||
|
||||
0xB9,0xA6, 0x00,0x04,0x00,0x00,0x07,0x00,0x00,0x06,0x00,0x00,0xC6,0x00,0x7F,0xE6,0x00,0x06,// 功 //
|
||||
0x06,0x00,0x06,0x06,0x18,0x06,0x7F,0xFC,0x06,0x06,0x18,0x06,0x06,0x18,0x06,0x06,
|
||||
0x18,0x06,0x06,0x18,0x06,0x06,0x18,0x06,0x0C,0x18,0x06,0x6C,0x18,0x07,0x8C,0x18,
|
||||
0x0E,0x18,0x18,0x78,0x18,0x18,0x30,0x30,0x18,0x20,0x60,0x38,0x00,0xC3,0xF0,0x01,
|
||||
0x00,0xE0,0x02,0x00,0x40,0x00,0x00,0x00,
|
||||
|
||||
0xC2,0xCA, 0x00,0x30,0x00,0x00,0x18,0x00,0x00,0x0C,0x00,0x00,0x08,0x18,0x3F,0xFF,0xFC,0x00,// 率 //
|
||||
0x20,0x00,0x10,0x32,0x10,0x18,0x43,0x38,0x0D,0xFE,0x40,0x04,0x8C,0x00,0x00,0x1A,
|
||||
0x60,0x06,0x21,0x30,0x18,0x4F,0x98,0x71,0xF1,0x90,0x20,0x90,0x80,0x00,0x1C,0x00,
|
||||
0x00,0x18,0x0C,0x7F,0xFF,0xFE,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,
|
||||
0x18,0x00,0x00,0x18,0x00,0x00,0x10,0x00,
|
||||
|
||||
0xC8,0xDD, 0x00,0x30,0x00,0x00,0x18,0x00,0x00,0x0C,0x00,0x10,0x08,0x04,0x1F,0xFF,0xFE,0x31,// 容 //
|
||||
0x00,0x0C,0x71,0xC3,0x08,0x61,0x90,0xC0,0x03,0x1C,0x70,0x06,0x38,0x38,0x0C,0x34,
|
||||
0x18,0x10,0x62,0x10,0x00,0xC1,0x80,0x01,0x80,0xE0,0x03,0x00,0x38,0x07,0xFF,0xDF,
|
||||
0x19,0x80,0xC4,0x61,0x80,0xC0,0x81,0x80,0xC0,0x01,0x80,0xC0,0x01,0x80,0xC0,0x01,
|
||||
0xFF,0xC0,0x01,0x80,0xC0,0x01,0x00,0x80,
|
||||
|
||||
0xB7,0xC5, 0x00,0x02,0x00,0x0C,0x03,0x80,0x06,0x03,0x00,0x03,0x03,0x00,0x02,0x03,0x00,0x00,// 放 //
|
||||
0x63,0x0C,0x7F,0xF7,0xFE,0x0C,0x06,0x30,0x0C,0x06,0x30,0x0C,0x64,0x30,0x0F,0xEA,
|
||||
0x30,0x0C,0x6A,0x30,0x0C,0x72,0x30,0x0C,0x62,0x60,0x0C,0x61,0x60,0x0C,0x61,0xC0,
|
||||
0x18,0x60,0xC0,0x18,0x61,0xC0,0x10,0x63,0x60,0x33,0xE6,0x30,0x20,0xCC,0x1C,0x40,
|
||||
0x98,0x0F,0x80,0x60,0x04,0x01,0x80,0x00,
|
||||
|
||||
0xBD,0xB5, 0x00,0x08,0x00,0x21,0x8E,0x00,0x3F,0xCC,0x30,0x31,0x9F,0xF8,0x31,0x18,0x30,0x33,// 降 //
|
||||
0x24,0x60,0x32,0x24,0xC0,0x32,0x43,0x80,0x34,0x03,0x80,0x32,0x06,0xE0,0x31,0x18,
|
||||
0x7E,0x31,0xE1,0x18,0x31,0x81,0xC0,0x31,0x81,0x98,0x31,0xBF,0xFC,0x31,0x91,0x80,
|
||||
0x3F,0x99,0x80,0x33,0x31,0x8C,0x32,0x7F,0xFE,0x30,0x21,0x80,0x30,0x01,0x80,0x30,
|
||||
0x01,0x80,0x30,0x01,0x80,0x20,0x01,0x00,
|
||||
|
||||
0xA1,0xA2, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 、 //
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,
|
||||
0x0C,0x00,0x00,0x07,0x00,0x00,0x03,0x80,0x00,0x01,0x80,0x00,0x01,0x80,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
|
||||
0xB6,0xFE, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x1F,// 二 //
|
||||
0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x7F,0xFF,0xFE,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
|
||||
0xB9,0xDC, 0x04,0x02,0x00,0x06,0x03,0x00,0x0C,0x66,0x0C,0x0F,0xF7,0xFE,0x1A,0x08,0x80,0x11,// 管 //
|
||||
0xB0,0x60,0x21,0x18,0x40,0x50,0x10,0x04,0x1F,0xFF,0xFE,0x30,0x00,0x0C,0x32,0x00,
|
||||
0xC8,0x63,0xFF,0xE0,0x03,0x00,0xC0,0x03,0x00,0xC0,0x03,0xFF,0xC0,0x03,0x00,0x00,
|
||||
0x03,0x00,0x60,0x03,0xFF,0xF0,0x03,0x00,0x60,0x03,0x00,0x60,0x03,0x00,0x60,0x03,
|
||||
0xFF,0xE0,0x03,0x00,0x40,0x02,0x00,0x00,
|
||||
|
||||
0xBC,0xAB, 0x08,0x00,0x00,0x0E,0x00,0x20,0x0C,0x7F,0xF0,0x0C,0x18,0x60,0x0C,0x18,0x60,0x0D,// 极 //
|
||||
0x98,0x40,0x7F,0xD8,0xC0,0x0C,0x18,0xC0,0x0C,0x18,0x90,0x1C,0x19,0xF8,0x1E,0x18,
|
||||
0xB0,0x3D,0x1C,0x30,0x2D,0xB4,0x30,0x2C,0xB2,0x60,0x4C,0x32,0x60,0x4C,0x33,0xC0,
|
||||
0x8C,0x61,0x80,0x0C,0x61,0x80,0x0C,0x43,0xC0,0x0C,0xC6,0x60,0x0C,0x8C,0x38,0x0D,
|
||||
0x30,0x1F,0x0E,0x40,0x0C,0x08,0x00,0x00,
|
||||
|
||||
/* 最后一行必须用0xFF,0xFF结束,这是字库数组结束标志 */
|
||||
0xFF,0xFF
|
||||
|
@ -3,21 +3,21 @@
|
||||
#include "param.h"
|
||||
|
||||
/*
|
||||
lua <EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD>:
|
||||
lua 增加调试代码的方法:
|
||||
|
||||
lobject.c<EFBFBD>ļ<EFBFBD>:
|
||||
lobject.c文件:
|
||||
const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {
|
||||
#if 1
|
||||
printf("%s", msg);
|
||||
#endif
|
||||
|
||||
ldebug.c <EFBFBD>ļ<EFBFBD> luaG_runerror <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>printf
|
||||
ldebug.c 文件 luaG_runerror 函数,增加printf
|
||||
|
||||
lauxlib.c <EFBFBD>ļ<EFBFBD> luaL_error<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>printf
|
||||
lauxlib.c 文件 luaL_error函数,增加printf
|
||||
|
||||
ldo.c <EFBFBD>ļ<EFBFBD> luaD_throw <EFBFBD><EFBFBD> printf("\r\nthrow errcode=%d\r\n", errcode);
|
||||
ldo.c 文件 luaD_throw 函 printf("\r\nthrow errcode=%d\r\n", errcode);
|
||||
|
||||
lua.h <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
lua.h 定义错误代码
|
||||
#define LUA_ERRRUN 2
|
||||
#define LUA_ERRSYNTAX 3
|
||||
#define LUA_ERRMEM 4
|
||||
@ -27,7 +27,7 @@ lua.h
|
||||
*/
|
||||
|
||||
/*
|
||||
luaconf.h <EFBFBD>ļ<EFBFBD><EFBFBD>Ը<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ȱʡ64λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˫<EFBFBD><EFBFBD><EFBFBD>ȸ<EFBFBD><EFBFBD><EFBFBD>
|
||||
luaconf.h 文件对浮点和整数的处理。 缺省64位整数,双精度浮点
|
||||
default configuration for 64-bit Lua ('long long' and 'double')
|
||||
*/
|
||||
|
||||
@ -60,41 +60,41 @@ int system(const char *cmd)
|
||||
/* time_t : date/time in unix secs past 1-Jan-70 */
|
||||
time_t time(time_t *_t)
|
||||
{
|
||||
/* <EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD> https://blog.csdn.net/qq_29350001/article/details/87637350 */
|
||||
#define xMINUTE (60) /* 1<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
#define xHOUR (60*xMINUTE) /* 1Сʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
#define xDAY (24*xHOUR ) /* 1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
#define xYEAR (365*xDAY ) /* 1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
/* 以下代码来自于: https://blog.csdn.net/qq_29350001/article/details/87637350 */
|
||||
#define xMINUTE (60) /* 1分的秒数 */
|
||||
#define xHOUR (60*xMINUTE) /* 1小时的秒数 */
|
||||
#define xDAY (24*xHOUR ) /* 1天的秒数 */
|
||||
#define xYEAR (365*xDAY ) /* 1年的秒数 */
|
||||
|
||||
/* <EFBFBD><EFBFBD>localtime<EFBFBD><EFBFBD>UTC+8<><38><EFBFBD><EFBFBD>ʱ<EFBFBD>䣩תΪUNIX TIME<4D><45><EFBFBD><EFBFBD>1970<37><30>1<EFBFBD><31>1<EFBFBD><31>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD> */
|
||||
/* 将localtime(UTC+8北京时间)转为UNIX TIME,以1970年1月1日为起点 */
|
||||
static unsigned int month[12] =
|
||||
{
|
||||
/*01<EFBFBD><EFBFBD>*/xDAY*(0),
|
||||
/*02<EFBFBD><EFBFBD>*/xDAY*(31),
|
||||
/*03<EFBFBD><EFBFBD>*/xDAY*(31+28),
|
||||
/*04<EFBFBD><EFBFBD>*/xDAY*(31+28+31),
|
||||
/*05<EFBFBD><EFBFBD>*/xDAY*(31+28+31+30),
|
||||
/*06<EFBFBD><EFBFBD>*/xDAY*(31+28+31+30+31),
|
||||
/*07<EFBFBD><EFBFBD>*/xDAY*(31+28+31+30+31+30),
|
||||
/*08<EFBFBD><EFBFBD>*/xDAY*(31+28+31+30+31+30+31),
|
||||
/*09<EFBFBD><EFBFBD>*/xDAY*(31+28+31+30+31+30+31+31),
|
||||
/*10<EFBFBD><EFBFBD>*/xDAY*(31+28+31+30+31+30+31+31+30),
|
||||
/*11<EFBFBD><EFBFBD>*/xDAY*(31+28+31+30+31+30+31+31+30+31),
|
||||
/*12<EFBFBD><EFBFBD>*/xDAY*(31+28+31+30+31+30+31+31+30+31+30)
|
||||
/*01月*/xDAY*(0),
|
||||
/*02月*/xDAY*(31),
|
||||
/*03月*/xDAY*(31+28),
|
||||
/*04月*/xDAY*(31+28+31),
|
||||
/*05月*/xDAY*(31+28+31+30),
|
||||
/*06月*/xDAY*(31+28+31+30+31),
|
||||
/*07月*/xDAY*(31+28+31+30+31+30),
|
||||
/*08月*/xDAY*(31+28+31+30+31+30+31),
|
||||
/*09月*/xDAY*(31+28+31+30+31+30+31+31),
|
||||
/*10月*/xDAY*(31+28+31+30+31+30+31+31+30),
|
||||
/*11月*/xDAY*(31+28+31+30+31+30+31+31+30+31),
|
||||
/*12月*/xDAY*(31+28+31+30+31+30+31+31+30+31+30)
|
||||
};
|
||||
unsigned int seconds = 0;
|
||||
unsigned int year = 0;
|
||||
|
||||
RTC_ReadClock();
|
||||
year = g_tRTC.Year - 1970; /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2100<EFBFBD><EFBFBD>ǧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
seconds = xYEAR * year + xDAY * ((year + 1) /4); /* ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
seconds += month[g_tRTC.Mon - 1]; /* <EFBFBD><EFBFBD><EFBFBD>Ͻ<EFBFBD><EFBFBD>걾<EFBFBD>¹<EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if ((g_tRTC.Mon > 2) && (((year + 2) % 4) == 0)) /* 2008<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
seconds += xDAY; /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
seconds += xDAY * (g_tRTC.Day-1); /* <EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
seconds += xHOUR * g_tRTC.Hour; /* <EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>Сʱ<EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
seconds += xMINUTE * g_tRTC.Min; /* <EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӹ<EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
seconds += g_tRTC.Sec; /* <EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><br><3E><>seconds -= 8 * xHOUR; */
|
||||
year = g_tRTC.Year - 1970; /* 不考虑2100年千年虫问题 */
|
||||
seconds = xYEAR * year + xDAY * ((year + 1) /4); /* 前几年过去的秒数 */
|
||||
seconds += month[g_tRTC.Mon - 1]; /* 加上今年本月过去的秒数 */
|
||||
if ((g_tRTC.Mon > 2) && (((year + 2) % 4) == 0)) /* 2008年为闰年 */
|
||||
seconds += xDAY; /* 闰年加1天秒数 */
|
||||
seconds += xDAY * (g_tRTC.Day-1); /* 加上本天过去的秒数 */
|
||||
seconds += xHOUR * g_tRTC.Hour; /* 加上本小时过去的秒数 */
|
||||
seconds += xMINUTE * g_tRTC.Min; /* 加上本分钟过去的秒数 */
|
||||
seconds += g_tRTC.Sec; /* 加上当前秒数<br> seconds -= 8 * xHOUR; */
|
||||
*_t = seconds;
|
||||
return *_t;
|
||||
}
|
||||
@ -132,32 +132,32 @@ const char lua_test[] = {
|
||||
|
||||
void lua_Test(void)
|
||||
{
|
||||
luaL_dostring(g_Lua, lua_test); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Lua<EFBFBD>ű<EFBFBD> */
|
||||
luaL_dostring(g_Lua, lua_test); /* 运行Lua脚本 */
|
||||
|
||||
luaL_dostring(g_Lua, "print(add_f(1.0, 9.09))\n print(sub_f(20.1,19.01))");
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_Init
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>lua<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_Init
|
||||
* 功能说明: 初始化lua虚拟机
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void lua_Init(void)
|
||||
{
|
||||
g_Lua = luaL_newstate(); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Lua<EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD> */
|
||||
g_Lua = luaL_newstate(); /* 建立Lua运行环境 */
|
||||
luaL_openlibs(g_Lua);
|
||||
luaopen_base(g_Lua);
|
||||
|
||||
lua_RegisterFunc(); /* ע<EFBFBD><EFBFBD>c<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lua<EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_RegisterFunc(); /* 注册c函数,供lua调用 */
|
||||
}
|
||||
|
||||
/* <EFBFBD>ر<EFBFBD><EFBFBD>ͷ<EFBFBD>Lua */
|
||||
/* 关闭释放Lua */
|
||||
void lua_DeInit(void)
|
||||
{
|
||||
lua_close(g_Lua); /* <EFBFBD>ͷ<EFBFBD><EFBFBD>ڴ<EFBFBD> */
|
||||
lua_close(g_Lua); /* 释放内存 */
|
||||
g_Lua = 0;
|
||||
}
|
||||
|
||||
@ -199,12 +199,12 @@ void lua_DoInit(void)
|
||||
luaL_dostring(g_Lua, "init()");
|
||||
}
|
||||
|
||||
// ͨ<EFBFBD><EFBFBD>д<EFBFBD>ļ<EFBFBD>
|
||||
// 通信写文件
|
||||
uint8_t lua_66H_Write(uint32_t _addr, uint8_t *_buf, uint32_t _len)
|
||||
{
|
||||
uint8_t re;
|
||||
|
||||
lua_getglobal(g_Lua, "write"); // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ <20><>ȡlua<75><61><EFBFBD><EFBFBD>write
|
||||
lua_getglobal(g_Lua, "write"); // 函数入栈 获取lua函数write
|
||||
lua_pushinteger(g_Lua, _addr);
|
||||
lua_pushlstring(g_Lua, (char *)_buf, _len);
|
||||
lua_pushinteger(g_Lua, _len);
|
||||
@ -213,22 +213,22 @@ uint8_t lua_66H_Write(uint32_t _addr, uint8_t *_buf, uint32_t _len)
|
||||
/*
|
||||
lua_pcall(lua_State *L,int nargs,int nresults,int errfunc)
|
||||
1
|
||||
nargs <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
nresults <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
errFunc <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><EFBFBD>ʾ<EFBFBD>ޣ<EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
nargs 参数个数
|
||||
nresults 返回值个数
|
||||
errFunc 错误处理函数,0表示无,表示错误处理函数在栈中的索引
|
||||
*/
|
||||
re = lua_tonumber(g_Lua, -1);
|
||||
lua_pop(g_Lua, 1);
|
||||
return re;
|
||||
}
|
||||
|
||||
// ͨ<EFBFBD>Ŷ<EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
// 通信读文件
|
||||
uint8_t lua_67H_Read(uint32_t _addr, uint8_t *_buf, uint32_t _len)
|
||||
{
|
||||
uint8_t re = 0;
|
||||
uint32_t i;
|
||||
|
||||
lua_getglobal(g_Lua, "read"); // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ <20><>ȡlua<75><61><EFBFBD><EFBFBD>write
|
||||
lua_getglobal(g_Lua, "read"); // 函数入栈 获取lua函数write
|
||||
lua_pushinteger(g_Lua, _addr);
|
||||
lua_pushinteger(g_Lua, _len);
|
||||
|
||||
@ -236,9 +236,9 @@ uint8_t lua_67H_Read(uint32_t _addr, uint8_t *_buf, uint32_t _len)
|
||||
/*
|
||||
lua_pcall(lua_State *L,int nargs,int nresults,int errfunc)
|
||||
1
|
||||
nargs <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
nresults <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
errFunc <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><EFBFBD>ʾ<EFBFBD>ޣ<EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
nargs 参数个数
|
||||
nresults 返回值个数
|
||||
errFunc 错误处理函数,0表示无,表示错误处理函数在栈中的索引
|
||||
*/
|
||||
|
||||
for (i = 0; i < _len; i++)
|
||||
@ -251,34 +251,34 @@ uint8_t lua_67H_Read(uint32_t _addr, uint8_t *_buf, uint32_t _len)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: beep
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> lua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: beep
|
||||
* 功能说明: 蜂鸣函数 lua调用
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int beep(lua_State* L)
|
||||
{
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD>еIJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ʾLua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ĵ<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Lua<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ݵIJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊnumber<EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>С<EFBFBD>
|
||||
//检查栈中的参数是否合法,1表示Lua调用时的第一个参数(从左到右),依此类推。
|
||||
//如果Lua代码在调用时传递的参数不为number,该函数将报错并终止程序的执行。
|
||||
// double op1 = luaL_checknumber(L, 1);
|
||||
// double op2 = luaL_checknumber(L, 2);
|
||||
|
||||
BEEP_KeyTone();
|
||||
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD>ջ<EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD>ջ<EFBFBD>С<EFBFBD>
|
||||
//将函数的结果压入栈中。如果有多个返回值,可以在这里多次压入栈中。
|
||||
//lua_pushnumber(L, op1 + op2);
|
||||
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD>ջ<EFBFBD>еķ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//返回值用于提示该C函数的返回值数量,即压入栈中的返回值数量。
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: delayus
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD> lua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: delayus
|
||||
* 功能说明: 微秒延迟 lua函数
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int delayus(lua_State* L)
|
||||
@ -291,10 +291,10 @@ static int delayus(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: delayms
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD> lua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: delayms
|
||||
* 功能说明: 毫秒延迟 lua函数
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int delayms(lua_State* L)
|
||||
@ -308,22 +308,22 @@ static int delayms(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: printhex
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>ӡhex<EFBFBD><EFBFBD>ʽ. pr nthex(100, 2); p inthex("123");
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: printhex
|
||||
* 功能说明: 打印hex格式. pr nthex(100, 2); p inthex("123");
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
extern uint8_t USBCom_SendBuf(int _Port, uint8_t *_Buf, uint16_t _Len);
|
||||
extern void lua_udp_SendBuf(uint8_t *_buf, uint16_t _len, uint16_t _port);
|
||||
static int printhex(lua_State* L)
|
||||
{
|
||||
if (lua_type(L, 1) == LUA_TSTRING) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TSTRING) /* 判断第1个参数 */
|
||||
{
|
||||
const char *data;
|
||||
size_t len;
|
||||
|
||||
data = luaL_checklstring(L, 1, &len); /* 1<EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD> len<65><6E>string<6E>ij<EFBFBD><C4B3><EFBFBD> */
|
||||
data = luaL_checklstring(L, 1, &len); /* 1是参数的位置, len是string的长度 */
|
||||
#if PRINT_TO_UDP == 1
|
||||
lua_udp_SendBuf((uint8_t *)data, len, LUA_UDP_PORT);
|
||||
#else
|
||||
@ -331,14 +331,14 @@ static int printhex(lua_State* L)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
char buf[32];
|
||||
uint32_t num;
|
||||
uint32_t bytes;
|
||||
|
||||
num = luaL_checknumber(L, 1);
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* 判断第2个参数 */
|
||||
{
|
||||
bytes = luaL_checknumber(L, 2);
|
||||
if (bytes == 1)
|
||||
@ -378,10 +378,10 @@ static int printhex(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: write_clock
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: дʱ<EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: write_clock
|
||||
* 功能说明: 写时钟
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int write_clock(lua_State* L)
|
||||
@ -389,7 +389,7 @@ static int write_clock(lua_State* L)
|
||||
uint16_t year;
|
||||
uint8_t mon, day, hour, min, sec;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
year = luaL_checknumber(L, 1);
|
||||
}
|
||||
@ -420,10 +420,10 @@ static int write_clock(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: read_clock
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: дʱ<EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: read_clock
|
||||
* 功能说明: 写时钟
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int read_clock(lua_State* L)
|
||||
@ -447,10 +447,10 @@ static int read_clock(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: get_runtime
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>CPU<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䡣ms<EFBFBD><EFBFBD>λ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: get_runtime
|
||||
* 功能说明: 获得CPU运行时间。ms单位
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int get_runtime(lua_State* L)
|
||||
@ -464,10 +464,10 @@ static int get_runtime(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: check_runtime
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD>ж<EFBFBD>ʱ<EFBFBD>䳤<EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: check_runtime
|
||||
* 功能说明: 判断时间长度
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int check_runtime(lua_State* L)
|
||||
@ -475,7 +475,7 @@ static int check_runtime(lua_State* L)
|
||||
int32_t lasttime;
|
||||
uint8_t re;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
lasttime = luaL_checknumber(L, 1);
|
||||
}
|
||||
@ -488,16 +488,16 @@ static int check_runtime(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_RegisterFunc
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: ע<EFBFBD><EFBFBD>lua<EFBFBD>ɵ<EFBFBD><EFBFBD>õ<EFBFBD>c<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_RegisterFunc
|
||||
* 功能说明: 注册lua可调用的c函数
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static void lua_RegisterFunc(void)
|
||||
{
|
||||
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<EFBFBD>õ<EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʵ<EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>롣
|
||||
//将指定的函数注册为Lua的全局函数变量,其中第一个字符串参数为Lua代码
|
||||
//在调用C函数时使用的全局函数名,第二个参数为实际C函数的指针。
|
||||
lua_register(g_Lua, "beep", beep);
|
||||
lua_register(g_Lua, "delayus", delayus);
|
||||
lua_register(g_Lua, "delayms", delayms);
|
||||
@ -507,7 +507,7 @@ static void lua_RegisterFunc(void)
|
||||
lua_register(g_Lua, "get_runtime", get_runtime);
|
||||
lua_register(g_Lua, "check_runtime", check_runtime);
|
||||
|
||||
/* ע<EFBFBD><EFBFBD><EFBFBD>ӿں<EFBFBD><EFBFBD><EFBFBD> */
|
||||
/* 注册接口函数 */
|
||||
lua_gpio_RegisterFun();
|
||||
lua_i2c_RegisterFun();
|
||||
lua_spi_RegisterFun();
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua<EFBFBD>ӿ<EFBFBD>ģ<EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua_if.h
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* v1.0 2015-04-25 armfly ST<EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾 V2.1.0
|
||||
* 模块名称 : lua接口模块
|
||||
* 文件名称 : lua_if.h
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 。
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* v1.0 2015-04-25 armfly ST固件库版本 V2.1.0
|
||||
*
|
||||
* Copyright (C), 2014-2015, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2014-2015, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -57,4 +57,4 @@ extern uint32_t s_lua_prog_len;
|
||||
|
||||
#endif
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -5,33 +5,33 @@
|
||||
#include "bsp.h"
|
||||
#include "param.h"
|
||||
|
||||
/* Ϊ<EFBFBD>˱<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DAP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>麯<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD> h7swd */
|
||||
/* 为了避免和DAP驱动中的函数混淆,本模块函数名前缀用 h7swd */
|
||||
|
||||
static int lua_ReadAdc(lua_State* L);
|
||||
static int lua_ReadAnalog(lua_State* L);
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_adc_RegisterFun
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: ע<EFBFBD><EFBFBD>lua C<EFBFBD><EFBFBD><EFBFBD>Խӿں<EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_adc_RegisterFun
|
||||
* 功能说明: 注册lua C语言接口函数
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void lua_adc_RegisterFun(void)
|
||||
{
|
||||
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<EFBFBD>õ<EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʵ<EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>롣
|
||||
//将指定的函数注册为Lua的全局函数变量,其中第一个字符串参数为Lua代码
|
||||
//在调用C函数时使用的全局函数名,第二个参数为实际C函数的指针。
|
||||
lua_register(g_Lua, "read_adc", lua_ReadAdc);
|
||||
lua_register(g_Lua, "read_analog", lua_ReadAnalog);
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_ReadAdc
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>ADCֵ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0-8
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_ReadAdc
|
||||
* 功能说明: 读ADC值
|
||||
* 形 参: 通道号 0-8
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_ReadAdc(lua_State* L)
|
||||
@ -39,33 +39,33 @@ static int lua_ReadAdc(lua_State* L)
|
||||
uint8_t ch;
|
||||
float re;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
ch = luaL_checknumber(L, 1); /* ģ<EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD> */
|
||||
ch = luaL_checknumber(L, 1); /* 模拟通道 */
|
||||
}
|
||||
|
||||
if (ch == AN_CH1) re = g_tVar.ADC_CH1Volt; /* CH1<EFBFBD><EFBFBD>ѹ */
|
||||
else if (ch == AN_CH2) re = g_tVar.ADC_CH2Volt; /* CH2<EFBFBD><EFBFBD>ѹ */
|
||||
if (ch == AN_CH1) re = g_tVar.ADC_CH1Volt; /* CH1电压 */
|
||||
else if (ch == AN_CH2) re = g_tVar.ADC_CH2Volt; /* CH2电压 */
|
||||
else if (ch == AN_HIGH_SIDE_VOLT) re = g_tVar.ADC_HighSideVolt;
|
||||
else if (ch == AN_HIGH_SIDE_CURR) re = g_tVar.ADC_HighSideCurr;
|
||||
else if (ch == AN_TVCC_VOLT) re = g_tVar.ADC_TVCCVolt; /* TVCCʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ */
|
||||
else if (ch == AN_TVCC_CURR) re = g_tVar.ADC_TVCCCurr; /* TVCCʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ */
|
||||
else if (ch == AN_NTC_RES) re = g_tVar.ADC_NTCRes; /* NTC<EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
else if (ch == AN_TVCC_VOLT) re = g_tVar.ADC_TVCCVolt; /* TVCC实测电压 */
|
||||
else if (ch == AN_TVCC_CURR) re = g_tVar.ADC_TVCCCurr; /* TVCC实测电压 */
|
||||
else if (ch == AN_NTC_RES) re = g_tVar.ADC_NTCRes; /* NTC电阻 */
|
||||
else if (ch == AN_12V_VOLT) re = g_tVar.ADC_ExtPowerVolt;
|
||||
else if (ch == AN_USB_VOLT) re = g_tVar.ADC_USBPowerVolt;
|
||||
else re = 0;
|
||||
|
||||
lua_pushnumber(L, re); /* <EFBFBD>ɹ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, re); /* 成功,返回数据 */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_ReadAdc
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_ReadAdc
|
||||
* 功能说明: 读校准后的模拟量
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_ReadAnalog(lua_State* L)
|
||||
@ -73,25 +73,25 @@ static int lua_ReadAnalog(lua_State* L)
|
||||
uint8_t ch;
|
||||
float re;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
ch = luaL_checknumber(L, 1); /* ģ<EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD> */
|
||||
ch = luaL_checknumber(L, 1); /* 模拟通道 */
|
||||
}
|
||||
|
||||
if (ch == AN_CH1) re = g_tVar.CH1Volt; /* CH1<EFBFBD><EFBFBD>ѹ */
|
||||
else if (ch == AN_CH2) re = g_tVar.CH2Volt; /* CH2<EFBFBD><EFBFBD>ѹ */
|
||||
if (ch == AN_CH1) re = g_tVar.CH1Volt; /* CH1电压 */
|
||||
else if (ch == AN_CH2) re = g_tVar.CH2Volt; /* CH2电压 */
|
||||
else if (ch == AN_HIGH_SIDE_VOLT) re = g_tVar.HighSideVolt;
|
||||
else if (ch == AN_HIGH_SIDE_CURR) re = g_tVar.HighSideCurr;
|
||||
else if (ch == AN_TVCC_VOLT) re = g_tVar.TVCCVolt; /* TVCCʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ */
|
||||
else if (ch == AN_TVCC_CURR) re = g_tVar.TVCCCurr; /* TVCCʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ */
|
||||
else if (ch == AN_NTC_RES) re = g_tVar.NTCRes; /* NTC<EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
else if (ch == AN_TVCC_VOLT) re = g_tVar.TVCCVolt; /* TVCC实测电压 */
|
||||
else if (ch == AN_TVCC_CURR) re = g_tVar.TVCCCurr; /* TVCC实测电压 */
|
||||
else if (ch == AN_NTC_RES) re = g_tVar.NTCRes; /* NTC电阻 */
|
||||
else if (ch == AN_12V_VOLT) re = g_tVar.ExtPowerVolt;
|
||||
else if (ch == AN_USB_VOLT) re = g_tVar.USBPowerVolt;
|
||||
else re = 0;
|
||||
|
||||
lua_pushnumber(L, re); /* <EFBFBD>ɹ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, re); /* 成功,返回数据 */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua adcģ<EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua_if_adc.h
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* v1.0 2019-10-15 armfly <EFBFBD><EFBFBD>
|
||||
* 模块名称 : lua adc模块
|
||||
* 文件名称 : lua_if_adc.h
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 。
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* v1.0 2019-10-15 armfly 首发
|
||||
*
|
||||
* Copyright (C), 2019-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2019-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -21,4 +21,4 @@ void lua_adc_RegisterFun(void);
|
||||
|
||||
#endif
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "modbus_reg_addr.h"
|
||||
#include "modbus_register.h"
|
||||
|
||||
/* Ϊ<EFBFBD>˱<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DAP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>麯<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD> h7swd */
|
||||
/* 为了避免和DAP驱动中的函数混淆,本模块函数名前缀用 h7swd */
|
||||
|
||||
static int lua_WriteDac(lua_State* L);
|
||||
static int lua_WriteVolt(lua_State* L);
|
||||
@ -19,16 +19,16 @@ static int lua_PowerOffDac(lua_State* L);
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_adc_RegisterFun
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: ע<EFBFBD><EFBFBD>lua C<EFBFBD><EFBFBD><EFBFBD>Խӿں<EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_adc_RegisterFun
|
||||
* 功能说明: 注册lua C语言接口函数
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void lua_dac_RegisterFun(void)
|
||||
{
|
||||
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<EFBFBD>õ<EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʵ<EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>롣
|
||||
//将指定的函数注册为Lua的全局函数变量,其中第一个字符串参数为Lua代码
|
||||
//在调用C函数时使用的全局函数名,第二个参数为实际C函数的指针。
|
||||
lua_register(g_Lua, "dac_on", lua_PowerOnDac);
|
||||
lua_register(g_Lua, "dac_off", lua_PowerOffDac);
|
||||
lua_register(g_Lua, "dac_write", lua_WriteDac);
|
||||
@ -40,47 +40,47 @@ void lua_dac_RegisterFun(void)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_PowerOnDac
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>DAC<EFBFBD><EFBFBD>Դ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_PowerOnDac
|
||||
* 功能说明: 打开DAC电源
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_PowerOnDac(lua_State* L)
|
||||
{
|
||||
WriteRegValue_06H(REG03_DAC_WAVE_TYPE, 0); /* ֱ<EFBFBD><EFBFBD> */
|
||||
WriteRegValue_06H(REG03_DAC_WAVE_TYPE, 0); /* 直流 */
|
||||
WriteRegValue_06H(REG03_DAC_WAVE_START, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_PowerOffDac
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD>ر<EFBFBD>DAC<EFBFBD><EFBFBD>Դ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_PowerOffDac
|
||||
* 功能说明: 关闭DAC电源
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_PowerOffDac(lua_State* L)
|
||||
{
|
||||
WriteRegValue_06H(REG03_DAC_WAVE_TYPE, 0); /* ֱ<EFBFBD><EFBFBD> */
|
||||
WriteRegValue_06H(REG03_DAC_WAVE_TYPE, 0); /* 直流 */
|
||||
WriteRegValue_06H(REG03_DAC_WAVE_START, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_WriteDac
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: дDAC
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: dacֵ 0-4095
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_WriteDac
|
||||
* 功能说明: 写DAC
|
||||
* 形 参: dac值 0-4095
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_WriteDac(lua_State* L)
|
||||
{
|
||||
uint16_t value;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
value = luaL_checknumber(L, 1); /* dac */
|
||||
}
|
||||
@ -92,19 +92,19 @@ static int lua_WriteDac(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_WriteVolt
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: д<EFBFBD><EFBFBD>ѹֵ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>ѹmv
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_WriteVolt
|
||||
* 功能说明: 写电压值
|
||||
* 形 参: 电压mv
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_WriteVolt(lua_State* L)
|
||||
{
|
||||
int16_t value;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
value = luaL_checknumber(L, 1); /* <EFBFBD><EFBFBD>ѹ */
|
||||
value = luaL_checknumber(L, 1); /* 电压 */
|
||||
}
|
||||
|
||||
WriteRegValue_06H(REG03_OUT_VOLT_MV, value);
|
||||
@ -114,10 +114,10 @@ static int lua_WriteVolt(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_WriteCurr
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵuA
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_WriteCurr
|
||||
* 功能说明: 写电流值
|
||||
* 形 参: 电流值uA
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_WriteCurr(lua_State* L)
|
||||
@ -125,7 +125,7 @@ static int lua_WriteCurr(lua_State* L)
|
||||
uint16_t value;
|
||||
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
value = luaL_checknumber(L, 1); /* dac */
|
||||
}
|
||||
@ -137,17 +137,17 @@ static int lua_WriteCurr(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_WriteTvccDac
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: дTVCC DAC
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: dac 0-127
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_WriteTvccDac
|
||||
* 功能说明: 写TVCC DAC
|
||||
* 形 参: dac 0-127
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_WriteTvccDac(lua_State* L)
|
||||
{
|
||||
uint16_t value;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
value = luaL_checknumber(L, 1); /* dac */
|
||||
}
|
||||
@ -159,17 +159,17 @@ static int lua_WriteTvccDac(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_WriteTvccVolt
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: дTVCC <EFBFBD><EFBFBD>ѹ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: dac 1200-5000
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_WriteTvccVolt
|
||||
* 功能说明: 写TVCC 电压
|
||||
* 形 参: dac 1200-5000
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_WriteTvccVolt(lua_State* L)
|
||||
{
|
||||
uint16_t value;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
value = luaL_checknumber(L, 1); /* dac */
|
||||
}
|
||||
@ -179,4 +179,4 @@ static int lua_WriteTvccVolt(lua_State* L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua dacģ<EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua_if_dac.h
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* v1.0 2019-10-15 armfly <EFBFBD><EFBFBD>
|
||||
* 模块名称 : lua dac模块
|
||||
* 文件名称 : lua_if_dac.h
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 。
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* v1.0 2019-10-15 armfly 首发
|
||||
*
|
||||
* Copyright (C), 2019-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2019-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -21,4 +21,4 @@ void lua_dac_RegisterFun(void);
|
||||
|
||||
#endif
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -15,16 +15,16 @@ static int lua_ReadADC(lua_State* L);
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_extio_RegisterFun
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: ע<EFBFBD><EFBFBD>lua C<EFBFBD><EFBFBD><EFBFBD>Խӿں<EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_extio_RegisterFun
|
||||
* 功能说明: 注册lua C语言接口函数
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void lua_extio_RegisterFun(void)
|
||||
{
|
||||
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<EFBFBD>õ<EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʵ<EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>롣
|
||||
//将指定的函数注册为Lua的全局函数变量,其中第一个字符串参数为Lua代码
|
||||
//在调用C函数时使用的全局函数名,第二个参数为实际C函数的指针。
|
||||
lua_register(g_Lua, "ex_start", lua_StartExtIO);
|
||||
lua_register(g_Lua, "ex_stop", lua_StopExtIO);
|
||||
lua_register(g_Lua, "ex_dout", lua_WriteDO);
|
||||
@ -36,10 +36,10 @@ void lua_extio_RegisterFun(void)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_StartExtIO
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չIO<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: 0-23
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_StartExtIO
|
||||
* 功能说明: 启动扩展IO任务
|
||||
* 形 参: 0-23
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_StartExtIO(lua_State* L)
|
||||
@ -50,10 +50,10 @@ static int lua_StartExtIO(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_StopExtIO
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: ֹͣ<EFBFBD><EFBFBD>չIO<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: 0-23
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_StopExtIO
|
||||
* 功能说明: 停止扩展IO任务
|
||||
* 形 参: 0-23
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_StopExtIO(lua_State* L)
|
||||
@ -64,10 +64,10 @@ static int lua_StopExtIO(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_WriteDO
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: дDO
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: 0-23
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_WriteDO
|
||||
* 功能说明: 写DO
|
||||
* 形 参: 0-23
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_WriteDO(lua_State* L)
|
||||
@ -75,12 +75,12 @@ static int lua_WriteDO(lua_State* L)
|
||||
uint8_t pin;
|
||||
uint8_t value;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
pin = luaL_checknumber(L, 1); /* dac */
|
||||
}
|
||||
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* 判断第2个参数 */
|
||||
{
|
||||
value = luaL_checknumber(L, 2); /* dac */
|
||||
}
|
||||
@ -92,10 +92,10 @@ static int lua_WriteDO(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_ReadDI
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>DI
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: 0-15
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_ReadDI
|
||||
* 功能说明: 读DI
|
||||
* 形 参: 0-15
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_ReadDI(lua_State* L)
|
||||
@ -103,24 +103,24 @@ static int lua_ReadDI(lua_State* L)
|
||||
uint8_t pin;
|
||||
uint8_t value;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
pin = luaL_checknumber(L, 1); /* dac */
|
||||
}
|
||||
|
||||
value = EX165_GetPin(pin);
|
||||
|
||||
lua_pushnumber(L, value); /* <EFBFBD>ɹ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, value); /* 成功,返回数据 */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_WriteDAC
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: дDAC
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: 0-1
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_WriteDAC
|
||||
* 功能说明: 写DAC
|
||||
* 形 参: 0-1
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_WriteDAC(lua_State* L)
|
||||
@ -128,12 +128,12 @@ static int lua_WriteDAC(lua_State* L)
|
||||
uint8_t ch;
|
||||
uint16_t dac;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
ch = luaL_checknumber(L, 1); /* dac */
|
||||
}
|
||||
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* 判断第2个参数 */
|
||||
{
|
||||
dac = luaL_checknumber(L, 2); /* dac */
|
||||
}
|
||||
@ -145,10 +145,10 @@ static int lua_WriteDAC(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_ReadADC
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>ADC
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: 0-7
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_ReadADC
|
||||
* 功能说明: 读ADC
|
||||
* 形 参: 0-7
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_ReadADC(lua_State* L)
|
||||
@ -156,16 +156,16 @@ static int lua_ReadADC(lua_State* L)
|
||||
uint8_t ch;
|
||||
int16_t adc;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
ch = luaL_checknumber(L, 1); /* dac */
|
||||
}
|
||||
|
||||
adc = AD7606_ReadAdc(ch); /* dac */
|
||||
|
||||
lua_pushnumber(L, adc); /* <EFBFBD>ɹ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, adc); /* 成功,返回数据 */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua extioģ<EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua_if_extio.h
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* v1.0 2019-10-15 armfly <EFBFBD><EFBFBD>
|
||||
* 模块名称 : lua extio模块
|
||||
* 文件名称 : lua_if_extio.h
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 。
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* v1.0 2019-10-15 armfly 首发
|
||||
*
|
||||
* Copyright (C), 2019-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2019-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -21,4 +21,4 @@ void lua_extio_RegisterFun(void);
|
||||
|
||||
#endif
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -11,7 +11,7 @@
|
||||
FATFS g_lua_fs;
|
||||
FIL g_lua_file1;
|
||||
|
||||
char luaDiskPath[4]; /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>FatFS <20><><EFBFBD><EFBFBD>·<EFBFBD><C2B7> */
|
||||
char luaDiskPath[4]; /* 保存FatFS 磁盘路径 */
|
||||
|
||||
static int lua_f_mount(lua_State* L);
|
||||
static int lua_f_dir(lua_State* L);
|
||||
@ -19,28 +19,28 @@ void ViewDir(char *_path);
|
||||
|
||||
void lua_fatfs_RegisterFun(void)
|
||||
{
|
||||
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<EFBFBD>õ<EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʵ<EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>롣
|
||||
//将指定的函数注册为Lua的全局函数变量,其中第一个字符串参数为Lua代码
|
||||
//在调用C函数时使用的全局函数名,第二个参数为实际C函数的指针。
|
||||
lua_register(g_Lua, "f_init", lua_f_mount);
|
||||
lua_register(g_Lua, "f_dir", lua_f_dir);
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_udp_SendBytes
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>UDP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>UDPĿ<EFBFBD><EFBFBD>IP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ν<EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD>UDP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ͨ<EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>:
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_udp_SendBytes
|
||||
* 功能说明: 向UDP发送一包数据。UDP目标IP由最后一次接收到的UDP包中提取,也就是只发给最后一次通信的主机
|
||||
* 形 参:
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_f_mount(lua_State* L)
|
||||
{
|
||||
FATFS_LinkDriver(&SD_Driver, luaDiskPath);
|
||||
|
||||
/* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ϵͳ */
|
||||
/* 挂载文件系统 */
|
||||
if (f_mount(&g_lua_fs, luaDiskPath, 0) != FR_OK)
|
||||
{
|
||||
printf("f_mount<EFBFBD>ļ<EFBFBD>ϵͳʧ<EFBFBD><EFBFBD>");
|
||||
printf("f_mount文件系统失败");
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -48,10 +48,10 @@ static int lua_f_mount(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_f_dir
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>:
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>:
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_f_dir
|
||||
* 功能说明:
|
||||
* 形 参:
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_f_dir(lua_State* L)
|
||||
@ -59,9 +59,9 @@ static int lua_f_dir(lua_State* L)
|
||||
const char *data;
|
||||
uint32_t len;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TSTRING) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TSTRING) /* 判断第1个参数 */
|
||||
{
|
||||
data = luaL_checklstring(L, 1, &len); /* 1<EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD> len<65><6E>stri <20>ij<EFBFBD><C4B3><EFBFBD> */
|
||||
data = luaL_checklstring(L, 1, &len); /* 1是参数的位置, len是stri 的长度 */
|
||||
}
|
||||
|
||||
ViewDir((char *)data);
|
||||
@ -71,35 +71,35 @@ static int lua_f_dir(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: ViewDir
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>Ŀ¼<EFBFBD>µ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: ViewDir
|
||||
* 功能说明: 显示根目录下的文件名
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void ViewDir(char *_path)
|
||||
{
|
||||
/* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õľֲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>ý϶࣬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD>ջ<EFBFBD>ռ乻<EFBFBD><EFBFBD> */
|
||||
/* 本函数使用的局部变量占用较多,请修改启动文件,保证堆栈空间够用 */
|
||||
FRESULT result;
|
||||
DIR DirInf;
|
||||
FILINFO FileInf;
|
||||
uint32_t cnt = 0;
|
||||
|
||||
/* <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ f_closedir */
|
||||
result = f_opendir(&DirInf, _path); /* 1: <EFBFBD><EFBFBD>ʾ<EFBFBD>̷<EFBFBD> */
|
||||
/* 打开根文件夹 - 用完后需要 f_closedir */
|
||||
result = f_opendir(&DirInf, _path); /* 1: 表示盘符 */
|
||||
if (result != FR_OK)
|
||||
{
|
||||
printf("<EFBFBD><EFBFBD>Ŀ¼ʧ<EFBFBD><EFBFBD> (%d)\r\n", result);
|
||||
printf("打开根目录失败 (%d)\r\n", result);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("\r\n<EFBFBD><EFBFBD>ǰĿ¼<EFBFBD><EFBFBD>%s\r\n", _path);
|
||||
printf("\r\n当前目录:%s\r\n", _path);
|
||||
|
||||
/* <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>Ŀ¼ */
|
||||
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD> | <20>ļ<EFBFBD><C4BC><EFBFBD>С | <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> | <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>\r\n");
|
||||
/* 读取当前文件夹下的文件和目录 */
|
||||
printf("属性 | 文件大小 | 短文件名 | 长文件名\r\n");
|
||||
for (cnt = 0; ;cnt++)
|
||||
{
|
||||
result = f_readdir(&DirInf,&FileInf); /* <EFBFBD><EFBFBD>ȡĿ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
result = f_readdir(&DirInf,&FileInf); /* 读取目录项,索引会自动下移 */
|
||||
if (result != FR_OK || FileInf.fname[0] == 0)
|
||||
{
|
||||
break;
|
||||
@ -110,26 +110,26 @@ void ViewDir(char *_path)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* <EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼ */
|
||||
/* 判断是文件还是子目录 */
|
||||
if (FileInf.fattrib & AM_DIR)
|
||||
{
|
||||
printf("(0x%02d)Ŀ¼ ", FileInf.fattrib);
|
||||
printf("(0x%02d)目录 ", FileInf.fattrib);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("(0x%02d)<EFBFBD>ļ<EFBFBD> ", FileInf.fattrib);
|
||||
printf("(0x%02d)文件 ", FileInf.fattrib);
|
||||
}
|
||||
|
||||
/* <EFBFBD><EFBFBD>ӡ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>С, <20><><EFBFBD><EFBFBD>4G */
|
||||
/* 打印文件大小, 最大4G */
|
||||
printf(" %10d", FileInf.fsize);
|
||||
|
||||
printf(" %s |", FileInf.altname); /* <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD> */
|
||||
printf(" %s |", FileInf.altname); /* 短文件名 */
|
||||
|
||||
printf(" %s\r\n", (char *)FileInf.fname); /* <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD> */
|
||||
printf(" %s\r\n", (char *)FileInf.fname); /* 长文件名 */
|
||||
}
|
||||
|
||||
f_closedir(&DirInf); /*<EFBFBD><EFBFBD><EFBFBD>رմ<EFBFBD>Ŀ¼ */
|
||||
f_closedir(&DirInf); /* 关闭打开的目录 */
|
||||
}
|
||||
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua fat<EFBFBD>ļ<EFBFBD>ϵͳ
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua_if_fatfs.h
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* v1.0 2019-07-03 armfly <EFBFBD><EFBFBD>
|
||||
* 模块名称 : lua fat文件系统
|
||||
* 文件名称 : lua_if_fatfs.h
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 。
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* v1.0 2019-07-03 armfly 首发
|
||||
*
|
||||
* Copyright (C), 2019-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2019-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -21,4 +21,4 @@ void lua_fatfs_RegisterFun(void);
|
||||
|
||||
#endif
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -12,16 +12,16 @@ static int lua_ReadFmcBus(lua_State* L);
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_GpioCfg
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>GPIO<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>:
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_GpioCfg
|
||||
* 功能说明: 配置GPIO功能
|
||||
* 形 参:
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void lua_gpio_RegisterFun(void)
|
||||
{
|
||||
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<EFBFBD>õ<EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʵ<EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>롣
|
||||
//将指定的函数注册为Lua的全局函数变量,其中第一个字符串参数为Lua代码
|
||||
//在调用C函数时使用的全局函数名,第二个参数为实际C函数的指针。
|
||||
lua_register(g_Lua, "gpio_cfg", lua_GpioCfg); /* gpio_cfg(0, 1) */
|
||||
lua_register(g_Lua, "gpio_write", lua_GpioWrite); /* gpio_write(0, 1) */
|
||||
lua_register(g_Lua, "gpio_read", lua_GpioRead); /* gpio_write(0, 1) */
|
||||
@ -33,10 +33,10 @@ void lua_gpio_RegisterFun(void)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_GpioCfg
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>GPIO<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>:
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_GpioCfg
|
||||
* 功能说明: 配置GPIO功能
|
||||
* 形 参:
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_GpioCfg(lua_State* L)
|
||||
@ -44,7 +44,7 @@ static int lua_GpioCfg(lua_State* L)
|
||||
uint8_t _no;
|
||||
uint8_t _dir;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
_no = luaL_checknumber(L, 1);
|
||||
}
|
||||
@ -53,7 +53,7 @@ static int lua_GpioCfg(lua_State* L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* 判断第2个参数 */
|
||||
{
|
||||
_dir = luaL_checknumber(L, 2);
|
||||
}
|
||||
@ -79,10 +79,10 @@ static int lua_GpioCfg(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_GpioWrite
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>GPIO<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>:
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_GpioWrite
|
||||
* 功能说明: 设置GPIO输出电平
|
||||
* 形 参:
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_GpioWrite(lua_State* L)
|
||||
@ -90,7 +90,7 @@ static int lua_GpioWrite(lua_State* L)
|
||||
uint8_t _no;
|
||||
uint8_t _value;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
_no = luaL_checknumber(L, 1);
|
||||
}
|
||||
@ -99,7 +99,7 @@ static int lua_GpioWrite(lua_State* L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* 判断第2个参数 */
|
||||
{
|
||||
_value = luaL_checknumber(L, 2);
|
||||
}
|
||||
@ -121,10 +121,10 @@ static int lua_GpioWrite(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_GpioRead
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>ȡGPIO<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>:
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_GpioRead
|
||||
* 功能说明: 读取GPIO输出电平
|
||||
* 形 参:
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_GpioRead(lua_State* L)
|
||||
@ -132,7 +132,7 @@ static int lua_GpioRead(lua_State* L)
|
||||
uint8_t _no;
|
||||
uint8_t _value;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
_no = luaL_checknumber(L, 1);
|
||||
}
|
||||
@ -143,21 +143,21 @@ static int lua_GpioRead(lua_State* L)
|
||||
|
||||
if (EIO_GetInputLevel(_no) == 0)
|
||||
{
|
||||
lua_pushnumber(L, 0); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ */
|
||||
lua_pushnumber(L, 0); /* 返回值 */
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnumber(L, 1); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ */
|
||||
lua_pushnumber(L, 1); /* 返回值 */
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_ReadFmcBus
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: ͨ<EFBFBD><EFBFBD>FMC<EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>ƽ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: 16bit<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_ReadFmcBus
|
||||
* 功能说明: 通过FMC总线读取口线电平
|
||||
* 形 参: 无
|
||||
* 返 回 值: 16bit数据
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_ReadFmcBus(lua_State* L)
|
||||
@ -166,23 +166,23 @@ static int lua_ReadFmcBus(lua_State* L)
|
||||
|
||||
in = EIO_ReadFMC();
|
||||
|
||||
lua_pushnumber(L, in); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ */
|
||||
lua_pushnumber(L, in); /* 返回值 */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_SetTVCC
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>TVCC<EFBFBD><EFBFBD>ѹ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO<EFBFBD><EFBFBD>ѹ. <EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_SetTVCC
|
||||
* 功能说明: 设置TVCC电压
|
||||
* 形 参: 输入IO电压. 单位伏。支持浮点
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_SetTVCC(lua_State* L)
|
||||
{
|
||||
float volt;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
volt = luaL_checknumber(L, 1);
|
||||
bsp_SetTVCC(volt * 1000);
|
||||
@ -190,4 +190,4 @@ static int lua_SetTVCC(lua_State* L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua gpioģ<EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua_gpio.h
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* v1.0 2019-07-03 armfly <EFBFBD><EFBFBD>
|
||||
* 模块名称 : lua gpio模块
|
||||
* 文件名称 : lua_gpio.h
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 。
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* v1.0 2019-07-03 armfly 首发
|
||||
*
|
||||
* Copyright (C), 2019-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2019-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -21,4 +21,4 @@ void lua_gpio_RegisterFun(void);
|
||||
|
||||
#endif
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -11,8 +11,8 @@ static int lua_I2C_ReciveBytes(lua_State* L);
|
||||
|
||||
void lua_i2c_RegisterFun(void)
|
||||
{
|
||||
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<EFBFBD>õ<EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʵ<EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>롣
|
||||
//将指定的函数注册为Lua的全局函数变量,其中第一个字符串参数为Lua代码
|
||||
//在调用C函数时使用的全局函数名,第二个参数为实际C函数的指针。
|
||||
lua_register(g_Lua, "i2c_start", lua_I2C_Start);
|
||||
lua_register(g_Lua, "i2c_stop", lua_I2C_Stop);
|
||||
lua_register(g_Lua, "i2c_send", lua_I2C_SendBytes);
|
||||
@ -32,8 +32,8 @@ static int lua_I2C_Stop(lua_State* L)
|
||||
}
|
||||
|
||||
/*
|
||||
<EFBFBD><EFBFBD>ʽ1: i2c_send(buf);
|
||||
<EFBFBD><EFBFBD>ʽ2: i2c_send(3 );
|
||||
形式1: i2c_send(buf);
|
||||
形式2: i2c_send(3 );
|
||||
*/
|
||||
static int lua_I2C_SendBytes(lua_State* L)
|
||||
{
|
||||
@ -43,12 +43,12 @@ static int lua_I2C_SendBytes(lua_State* L)
|
||||
uint8_t buf[1];
|
||||
int re;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TSTRING) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TSTRING) /* 判断第1个参数 */
|
||||
{
|
||||
data = luaL_checklstring(L, 1, &len); /* 1<EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD> len<65><6E>stri <20>ij<EFBFBD><C4B3><EFBFBD> */
|
||||
data = luaL_checklstring(L, 1, &len); /* 1是参数的位置, len是stri 的长度 */
|
||||
}
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
len = 1;
|
||||
buf[0] = luaL_checknumber(L, 1);
|
||||
@ -67,15 +67,15 @@ static int lua_I2C_SendBytes(lua_State* L)
|
||||
break;
|
||||
}
|
||||
}
|
||||
lua_pushnumber(L, re); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ */
|
||||
lua_pushnumber(L, re); /* 返回值 */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
Lua<EFBFBD><EFBFBD>C++<EFBFBD><EFBFBD>bufferʱ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>string<EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD>C++<EFBFBD>ģ<EFBFBD>tolua++<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡbuffer
|
||||
Lua给C++传buffer时,使用string就行,再C++的,tolua++中使用下面代码读取buffer
|
||||
size_t ld;
|
||||
const char *data = luaL_checklstring(tolua_S, 2, &ld); // 2<EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD> ld<6C><64>buffer<65>ij<EFBFBD><C4B3><EFBFBD>
|
||||
C++<EFBFBD><EFBFBD>Lua<EFBFBD><EFBFBD>bufferʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>C++<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>봫<EFBFBD><EFBFBD>buffer
|
||||
const char *data = luaL_checklstring(tolua_S, 2, &ld); // 2是参数的位置, ld是buffer的长度
|
||||
C++给Lua传buffer时,在C++代码中使用下面代码传入buffer
|
||||
LuaStack *stack = LuaEngine::getInstance()->getLuaStack();
|
||||
stack->
|
||||
|
||||
@ -89,26 +89,26 @@ static int lua_I2C_ReciveBytes(lua_State* L)
|
||||
len = luaL_checknumber(L, 1);
|
||||
if (len == 0 || len > LUA_READ_LEN_MAX)
|
||||
{
|
||||
lua_pushnumber(L, 0); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ */
|
||||
lua_pushnumber(L, 0); /* 返回值 */
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
s_lua_read_buf[i] = i2c_ReadByte(); /* <EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD> */
|
||||
s_lua_read_buf[i] = i2c_ReadByte(); /* 读1个字节 */
|
||||
|
||||
/* ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD>ֽں<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ack<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽڲ<D6BD><DAB2><EFBFBD>ҪAck<63><6B><EFBFBD><EFBFBD>Nack */
|
||||
/* 每读完1个字节后,需要发送Ack, 最后一个字节不需要Ack,发Nack */
|
||||
if (i != len - 1)
|
||||
{
|
||||
i2c_Ack(); /* <EFBFBD>м<EFBFBD><EFBFBD>ֽڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CPU<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ACK<EFBFBD>ź<EFBFBD>(<28><><EFBFBD><EFBFBD>SDA = 0) */
|
||||
i2c_Ack(); /* 中间字节读完后,CPU产生ACK信号(驱动SDA = 0) */
|
||||
}
|
||||
else
|
||||
{
|
||||
i2c_NAck(); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD>ֽڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CPU<EFBFBD><EFBFBD><EFBFBD><EFBFBD>NACK<EFBFBD>ź<EFBFBD>(<28><><EFBFBD><EFBFBD>SDA = 1) */
|
||||
i2c_NAck(); /* 最后1个字节读完后,CPU产生NACK信号(驱动SDA = 1) */
|
||||
}
|
||||
}
|
||||
|
||||
//lua_pushnumber(L, 1); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ */
|
||||
//lua_pushnumber(L, 1); /* 返回值 */
|
||||
// strcpy(s_lua_read_buf, "s_lua_read_buf");
|
||||
lua_pushlstring(L, (char *)s_lua_read_buf, len);
|
||||
return 1;
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua i2cģ<EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua_i2c.h
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* v1.0 2019-07-03 armfly ST<EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾 V2.1.0
|
||||
* 模块名称 : lua i2c模块
|
||||
* 文件名称 : lua_i2c.h
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 。
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* v1.0 2019-07-03 armfly ST固件库版本 V2.1.0
|
||||
*
|
||||
* Copyright (C), 2019-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2019-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -21,4 +21,4 @@ void lua_i2c_RegisterFun(void);
|
||||
|
||||
#endif
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -11,8 +11,8 @@ static int qspi_erase4k(lua_State* L);
|
||||
|
||||
void lua_qspi_RegisterFun(void)
|
||||
{
|
||||
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<EFBFBD>õ<EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʵ<EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>롣
|
||||
//将指定的函数注册为Lua的全局函数变量,其中第一个字符串参数为Lua代码
|
||||
//在调用C函数时使用的全局函数名,第二个参数为实际C函数的指针。
|
||||
lua_register(g_Lua, "qspi_readid", qspi_readid);
|
||||
lua_register(g_Lua, "qspi_read", qspi_read);
|
||||
lua_register(g_Lua, "qspi_write", qspi_write);
|
||||
@ -21,10 +21,10 @@ void lua_qspi_RegisterFun(void)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: qspi_readid
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>оƬID
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>:
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: qspi_readid
|
||||
* 功能说明: 读芯片ID
|
||||
* 形 参:
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int qspi_readid(lua_State* L)
|
||||
@ -32,7 +32,7 @@ static int qspi_readid(lua_State* L)
|
||||
uint32_t id;
|
||||
|
||||
id = QSPI_ReadID();
|
||||
lua_pushnumber(L, id); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ */
|
||||
lua_pushnumber(L, id); /* 返回值 */
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -40,17 +40,17 @@ static int qspi_readid(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: qspi_erase4k
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4KB
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>:
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: qspi_erase4k
|
||||
* 功能说明: 擦除一个扇区,4KB
|
||||
* 形 参:
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int qspi_erase4k(lua_State* L)
|
||||
{
|
||||
uint32_t addr;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第2个参数 */
|
||||
{
|
||||
addr = luaL_checknumber(L, 1);
|
||||
|
||||
@ -59,17 +59,17 @@ static int qspi_erase4k(lua_State* L)
|
||||
}
|
||||
|
||||
QSPI_EraseSector(addr);
|
||||
lua_pushnumber(L, 1); /* <EFBFBD>ɹ<EFBFBD> */
|
||||
lua_pushnumber(L, 1); /* 成功 */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: qspi_write
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: дһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>С<EFBFBD><EFBFBD>256<EFBFBD>ֽ<EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>:
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: qspi_write
|
||||
* 功能说明: 写一包数据,小于256字节
|
||||
* 形 参:
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int qspi_write(lua_State* L)
|
||||
@ -78,39 +78,39 @@ static int qspi_write(lua_State* L)
|
||||
const char *data;
|
||||
uint32_t addr;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第2个参数 */
|
||||
{
|
||||
addr = luaL_checknumber(L, 1);
|
||||
}
|
||||
|
||||
if (lua_type(L, 2) == LUA_TSTRING) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 2) == LUA_TSTRING) /* 判断第1个参数 */
|
||||
{
|
||||
data = luaL_checklstring(L, 2, &len); /* 1<EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD> len<65><6E>stri <20>ij<EFBFBD><C4B3><EFBFBD> */
|
||||
data = luaL_checklstring(L, 2, &len); /* 1是参数的位置, len是stri 的长度 */
|
||||
}
|
||||
|
||||
if (len > QSPI_PAGE_SIZE)
|
||||
{
|
||||
lua_pushnumber(L, 0); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, 0); /* 出错 */
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (QSPI_WriteBuffer((uint8_t *)data, addr, len) == 0)
|
||||
{
|
||||
lua_pushnumber(L, 0); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, 0); /* 出错 */
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnumber(L, 1); /* <EFBFBD>ɹ<EFBFBD> */
|
||||
lua_pushnumber(L, 1); /* 成功 */
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: qspi_read
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><EFBFBD>ɴ<EFBFBD><EFBFBD><EFBFBD>256<EFBFBD>ֽ<EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>:
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: qspi_read
|
||||
* 功能说明: 读一包数据,可大于256字节
|
||||
* 形 参:
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int qspi_read(lua_State* L)
|
||||
@ -118,12 +118,12 @@ static int qspi_read(lua_State* L)
|
||||
uint32_t addr;
|
||||
uint32_t num;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
addr = luaL_checknumber(L, 1); /* 1<EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD> len<65><6E>stri <20>ij<EFBFBD><C4B3><EFBFBD> */
|
||||
addr = luaL_checknumber(L, 1); /* 1是参数的位置, len是stri 的长度 */
|
||||
}
|
||||
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* 判断第2个参数 */
|
||||
{
|
||||
num = luaL_checknumber(L, 2);
|
||||
|
||||
@ -142,4 +142,4 @@ static int qspi_read(lua_State* L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua qspiģ<EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua_qspi.h
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* v1.0 2019-07-03 armfly <EFBFBD><EFBFBD>
|
||||
* 模块名称 : lua qspi模块
|
||||
* 文件名称 : lua_qspi.h
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 。
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* v1.0 2019-07-03 armfly 首发
|
||||
*
|
||||
* Copyright (C), 2019-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2019-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -21,4 +21,4 @@ void lua_qspi_RegisterFun(void);
|
||||
|
||||
#endif
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "modbus_reg_addr.h"
|
||||
#include "modbus_register.h"
|
||||
|
||||
/* Ϊ<EFBFBD>˱<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DAP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>麯<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD> h7swd */
|
||||
/* 为了避免和DAP驱动中的函数混淆,本模块函数名前缀用 h7swd */
|
||||
static int lua_WriteReg16(lua_State* L);
|
||||
static int lua_WriteReg32(lua_State* L);
|
||||
static int lua_WriteRegFloat(lua_State* L);
|
||||
@ -19,16 +19,16 @@ static int lua_SaveParam(lua_State* L);
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_reg_RegisterFun
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: ע<EFBFBD><EFBFBD>lua C<EFBFBD><EFBFBD><EFBFBD>Խӿں<EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_reg_RegisterFun
|
||||
* 功能说明: 注册lua C语言接口函数
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void lua_reg_RegisterFun(void)
|
||||
{
|
||||
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<EFBFBD>õ<EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʵ<EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>롣
|
||||
//将指定的函数注册为Lua的全局函数变量,其中第一个字符串参数为Lua代码
|
||||
//在调用C函数时使用的全局函数名,第二个参数为实际C函数的指针。
|
||||
lua_register(g_Lua, "write_reg16", lua_WriteReg16);
|
||||
lua_register(g_Lua, "write_reg32", lua_WriteReg32);
|
||||
lua_register(g_Lua, "write_regfloat", lua_WriteRegFloat);
|
||||
@ -42,10 +42,10 @@ void lua_reg_RegisterFun(void)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_SaveParam
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ<EFBFBD>µ<EFBFBD>eeprom
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_SaveParam
|
||||
* 功能说明: 写参数。将参数刷新到eeprom
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_SaveParam(lua_State* L)
|
||||
@ -61,10 +61,10 @@ static int lua_SaveParam(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_WriteReg16
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: д<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD> 16bit
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: Addr<EFBFBD><EFBFBD>ַ <EFBFBD><EFBFBD> <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_WriteReg16
|
||||
* 功能说明: 写寄存器 16bit
|
||||
* 形 参: Addr地址 和 寄存器值
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_WriteReg16(lua_State* L)
|
||||
@ -73,14 +73,14 @@ static int lua_WriteReg16(lua_State* L)
|
||||
int16_t value;
|
||||
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
addr = luaL_checknumber(L, 1); /* <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ */
|
||||
addr = luaL_checknumber(L, 1); /* 寄存器地址 */
|
||||
}
|
||||
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
value = luaL_checknumber(L, 2); /* <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>ֵ */
|
||||
value = luaL_checknumber(L, 2); /* 寄存器值 */
|
||||
}
|
||||
|
||||
WriteRegValue_06H(addr, (uint16_t)value);
|
||||
@ -90,10 +90,10 @@ static int lua_WriteReg16(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_ReadReg16
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD> 16bit
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: Addr<EFBFBD><EFBFBD>ַ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
* 函 数 名: lua_ReadReg16
|
||||
* 功能说明: 读寄存器 16bit
|
||||
* 形 参: Addr地址
|
||||
* 返 回 值: 寄存器值
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_ReadReg16(lua_State* L)
|
||||
@ -101,18 +101,18 @@ static int lua_ReadReg16(lua_State* L)
|
||||
uint16_t addr;
|
||||
uint16_t value;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
addr = luaL_checknumber(L, 1); /* <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ */
|
||||
addr = luaL_checknumber(L, 1); /* 寄存器地址 */
|
||||
}
|
||||
|
||||
if (ReadRegValue_03H(addr, &value) == 1)
|
||||
{
|
||||
lua_pushnumber(L, value); /* <EFBFBD>ɹ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, value); /* 成功,返回数据 */
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnumber(L, 0); /* <EFBFBD>ɹ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, 0); /* 成功,返回数据 */
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -120,10 +120,10 @@ static int lua_ReadReg16(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_WriteReg32
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: д<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD> 32Bit<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: Addr<EFBFBD><EFBFBD>ַ <EFBFBD><EFBFBD> <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_WriteReg32
|
||||
* 功能说明: 写寄存器 32Bit整数
|
||||
* 形 参: Addr地址 和 寄存器值
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_WriteReg32(lua_State* L)
|
||||
@ -131,14 +131,14 @@ static int lua_WriteReg32(lua_State* L)
|
||||
uint16_t addr;
|
||||
int32_t value;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
addr = luaL_checknumber(L, 1); /* <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ */
|
||||
addr = luaL_checknumber(L, 1); /* 寄存器地址 */
|
||||
}
|
||||
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* 判断第2个参数 */
|
||||
{
|
||||
value = luaL_checknumber(L, 2); /* <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ */
|
||||
value = luaL_checknumber(L, 2); /* 寄存器地址 */
|
||||
}
|
||||
|
||||
WriteRegValue_06H(addr, (uint32_t)value >> 16);
|
||||
@ -148,10 +148,10 @@ static int lua_WriteReg32(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_ReadReg32
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD> 32bit <EFBFBD>з<EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: Addr<EFBFBD><EFBFBD>ַ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
* 函 数 名: lua_ReadReg32
|
||||
* 功能说明: 读寄存器 32bit 有符号
|
||||
* 形 参: Addr地址
|
||||
* 返 回 值: 寄存器值
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_ReadReg32(lua_State* L)
|
||||
@ -162,9 +162,9 @@ static int lua_ReadReg32(lua_State* L)
|
||||
int32_t value32;
|
||||
uint8_t re = 0;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
addr = luaL_checknumber(L, 1); /* <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ */
|
||||
addr = luaL_checknumber(L, 1); /* 寄存器地址 */
|
||||
}
|
||||
|
||||
re = ReadRegValue_03H(addr, &value1);
|
||||
@ -173,11 +173,11 @@ static int lua_ReadReg32(lua_State* L)
|
||||
if (re == 2)
|
||||
{
|
||||
value32 =(value1 << 8) + value2;
|
||||
lua_pushnumber(L, value32); /* <EFBFBD>ɹ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, value32); /* 成功,返回数据 */
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnumber(L, 0); /* <EFBFBD>ɹ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, 0); /* 成功,返回数据 */
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -186,10 +186,10 @@ static int lua_ReadReg32(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_WriteRegFloat
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: д<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD> 32Bit<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: Addr<EFBFBD><EFBFBD>ַ <EFBFBD><EFBFBD> <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_WriteRegFloat
|
||||
* 功能说明: 写寄存器 32Bit浮点
|
||||
* 形 参: Addr地址 和 寄存器值
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_WriteRegFloat(lua_State* L)
|
||||
@ -197,14 +197,14 @@ static int lua_WriteRegFloat(lua_State* L)
|
||||
uint16_t addr;
|
||||
float ff;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
addr = luaL_checknumber(L, 1); /* <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ */
|
||||
addr = luaL_checknumber(L, 1); /* 寄存器地址 */
|
||||
}
|
||||
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* 判断第2个参数 */
|
||||
{
|
||||
ff = luaL_checknumber(L, 2); /* <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ */
|
||||
ff = luaL_checknumber(L, 2); /* 寄存器地址 */
|
||||
}
|
||||
|
||||
WriteRegValue_06H(addr, GetHigh16OfFloat(ff));
|
||||
@ -214,10 +214,10 @@ static int lua_WriteRegFloat(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_ReadRegFloat
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: Addr<EFBFBD><EFBFBD>ַ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
* 函 数 名: lua_ReadRegFloat
|
||||
* 功能说明: 读寄存器 浮点
|
||||
* 形 参: Addr地址
|
||||
* 返 回 值: 寄存器值
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int lua_ReadRegFloat(lua_State* L)
|
||||
@ -229,9 +229,9 @@ static int lua_ReadRegFloat(lua_State* L)
|
||||
uint8_t re = 0;
|
||||
uint8_t buf[4];
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
addr = luaL_checknumber(L, 1); /* <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ */
|
||||
addr = luaL_checknumber(L, 1); /* 寄存器地址 */
|
||||
}
|
||||
|
||||
re = ReadRegValue_03H(addr, &value1);
|
||||
@ -246,14 +246,14 @@ static int lua_ReadRegFloat(lua_State* L)
|
||||
|
||||
ff = BEBufToFloat(buf);
|
||||
|
||||
lua_pushnumber(L, ff); /* <EFBFBD>ɹ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, ff); /* 成功,返回数据 */
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnumber(L, 0); /* <EFBFBD>ɹ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, 0); /* 成功,返回数据 */
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua_reg_register.h
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* v1.0 2019-10-15 armfly <EFBFBD><EFBFBD>
|
||||
* 模块名称 : lua 寄存器操作模块
|
||||
* 文件名称 : lua_reg_register.h
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 。
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* v1.0 2019-10-15 armfly 首发
|
||||
*
|
||||
* Copyright (C), 2019-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2019-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -21,4 +21,4 @@ void lua_reg_RegisterFun(void);
|
||||
|
||||
#endif
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
void lua_spi_RegisterFun(void)
|
||||
{
|
||||
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<EFBFBD>õ<EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʵ<EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>롣
|
||||
//将指定的函数注册为Lua的全局函数变量,其中第一个字符串参数为Lua代码
|
||||
//在调用C函数时使用的全局函数名,第二个参数为实际C函数的指针。
|
||||
//lua_register(g_Lua, "udp_print", lua_udp_print);
|
||||
}
|
||||
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua spiģ<EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua_spi.h
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* v1.0 2019-07-03 armfly <EFBFBD><EFBFBD>
|
||||
* 模块名称 : lua spi模块
|
||||
* 文件名称 : lua_spi.h
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 。
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* v1.0 2019-07-03 armfly 首发
|
||||
*
|
||||
* Copyright (C), 2019-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2019-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -21,4 +21,4 @@ void lua_spi_RegisterFun(void);
|
||||
|
||||
#endif
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "swd_host.h"
|
||||
#include "Systick_Handler.h"
|
||||
|
||||
/* Ϊ<EFBFBD>˱<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DAP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>麯<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD> h7swd */
|
||||
/* 为了避免和DAP驱动中的函数混淆,本模块函数名前缀用 h7swd */
|
||||
|
||||
static int h7swd_Init(lua_State* L);
|
||||
static int h7swd_ReadID(lua_State* L);
|
||||
@ -18,16 +18,16 @@ static int h7swd_ReadMemory(lua_State* L);
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: lua_swd_RegisterFun
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: ע<EFBFBD><EFBFBD>lua C<EFBFBD><EFBFBD><EFBFBD>Խӿں<EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: lua_swd_RegisterFun
|
||||
* 功能说明: 注册lua C语言接口函数
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void lua_swd_RegisterFun(void)
|
||||
{
|
||||
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<EFBFBD>õ<EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʵ<EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>롣
|
||||
//将指定的函数注册为Lua的全局函数变量,其中第一个字符串参数为Lua代码
|
||||
//在调用C函数时使用的全局函数名,第二个参数为实际C函数的指针。
|
||||
lua_register(g_Lua, "swd_init", h7swd_Init);
|
||||
lua_register(g_Lua, "swd_getid", h7swd_ReadID);
|
||||
lua_register(g_Lua, "swd_write", h7swd_WriteMemory);
|
||||
@ -36,37 +36,37 @@ void lua_swd_RegisterFun(void)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: h7swd_Init
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>оƬID
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: vcc : CPU<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: h7swd_Init
|
||||
* 功能说明: 读芯片ID
|
||||
* 形 参: vcc : CPU供电电压
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int h7swd_Init(lua_State* L)
|
||||
{
|
||||
float vcc;
|
||||
|
||||
sysTickInit(); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>DAP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еij<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ȫ<>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC> */
|
||||
sysTickInit(); /* 这是DAP驱动中的初始化函数,全局变量初始化 */
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
vcc = luaL_checknumber(L, 1); /* VCC<EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㣬<EFBFBD><EFBFBD>λV */
|
||||
vcc = luaL_checknumber(L, 1); /* VCC电压,浮点,单位V */
|
||||
}
|
||||
|
||||
bsp_SetTVCC(vcc * 1000); /* <EFBFBD><EFBFBD><EFBFBD>ýӿڵ<EFBFBD>ƽ3.3V */
|
||||
bsp_DelayUS(100 * 100); /* <EFBFBD>ӳ<EFBFBD>100ms */
|
||||
bsp_SetTVCC(vcc * 1000); /* 设置接口电平3.3V */
|
||||
bsp_DelayUS(100 * 100); /* 延迟100ms */
|
||||
|
||||
swd_init_debug(); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>swd debug״̬ */
|
||||
swd_init_debug(); /* 进入swd debug状态 */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: h7swd_ReadID
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>оƬID
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: h7swd_ReadID
|
||||
* 功能说明: 读芯片ID
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int h7swd_ReadID(lua_State* L)
|
||||
@ -75,22 +75,22 @@ static int h7swd_ReadID(lua_State* L)
|
||||
|
||||
if (swd_read_idcode(&id) == 0)
|
||||
{
|
||||
lua_pushnumber(L, 0); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, 0); /* 出错 */
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnumber(L, id); /* <EFBFBD>ɹ<EFBFBD>,<2C><><EFBFBD><EFBFBD>ID */
|
||||
lua_pushnumber(L, id); /* 成功,返回ID */
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: h7swd_WriteMemory
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: дCPU<EFBFBD>ڴ棨<EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: addr : Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
* data : <EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: 0 ʧ<EFBFBD><EFBFBD> 1 <EFBFBD>ɹ<EFBFBD>
|
||||
* 函 数 名: h7swd_WriteMemory
|
||||
* 功能说明: 写CPU内存(或寄存器)
|
||||
* 形 参: addr : 目标地址
|
||||
* data : 数据缓冲区,含长度
|
||||
* 返 回 值: 0 失败 1 成功
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int h7swd_WriteMemory(lua_State* L)
|
||||
@ -99,36 +99,36 @@ static int h7swd_WriteMemory(lua_State* L)
|
||||
const char *data;
|
||||
size_t len = 0;
|
||||
|
||||
sysTickInit(); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>DAP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еij<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ȫ<>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC> */
|
||||
sysTickInit(); /* 这是DAP驱动中的初始化函数,全局变量初始化 */
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
addr = luaL_checknumber(L, 1); /* Ŀ<EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ */
|
||||
addr = luaL_checknumber(L, 1); /* 目标内存地址 */
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnumber(L, 0); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, 0); /* 出错 */
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lua_type(L, 2) == LUA_TSTRING) /* <EFBFBD>жϵ<EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 2) == LUA_TSTRING) /* 判断第2个参数 */
|
||||
{
|
||||
data = luaL_checklstring(L, 2, &len); /* 1<EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD> len<65><6E>stri <20>ij<EFBFBD><C4B3><EFBFBD> */
|
||||
data = luaL_checklstring(L, 2, &len); /* 1是参数的位置, len是stri 的长度 */
|
||||
}
|
||||
|
||||
if (len > 128 * 1024)
|
||||
{
|
||||
lua_pushnumber(L, 0); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, 0); /* 出错 */
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (swd_write_memory(addr, (uint8_t *)data, len) == 0)
|
||||
{
|
||||
lua_pushnumber(L, 0); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, 0); /* 出错 */
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnumber(L, 1); /* <EFBFBD>ɹ<EFBFBD> */
|
||||
lua_pushnumber(L, 1); /* 成功 */
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -136,11 +136,11 @@ static int h7swd_WriteMemory(lua_State* L)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: h7swd_ReadMemory
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>CPU<EFBFBD>ڴ棨<EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: addr : Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
* data : <EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: 0 ʧ<EFBFBD><EFBFBD> 1 <EFBFBD>ɹ<EFBFBD>
|
||||
* 函 数 名: h7swd_ReadMemory
|
||||
* 功能说明: 读CPU内存(或寄存器)
|
||||
* 形 参: addr : 目标地址
|
||||
* data : 数据缓冲区,含长度
|
||||
* 返 回 值: 0 失败 1 成功
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int h7swd_ReadMemory(lua_State* L)
|
||||
@ -148,17 +148,17 @@ static int h7swd_ReadMemory(lua_State* L)
|
||||
uint32_t addr;
|
||||
uint32_t num;
|
||||
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
|
||||
{
|
||||
addr = luaL_checknumber(L, 1); /* 1<EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD> len<65><6E>stri <20>ij<EFBFBD><C4B3><EFBFBD> */
|
||||
addr = luaL_checknumber(L, 1); /* 1是参数的位置, len是stri 的长度 */
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnumber(L, 0); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, 0); /* 出错 */
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* <EFBFBD>жϵ<EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
if (lua_type(L, 2) == LUA_TNUMBER) /* 判断第2个参数 */
|
||||
{
|
||||
num = luaL_checknumber(L, 2);
|
||||
|
||||
@ -167,21 +167,21 @@ static int h7swd_ReadMemory(lua_State* L)
|
||||
|
||||
if (num > LUA_READ_LEN_MAX)
|
||||
{
|
||||
lua_pushnumber(L, 0); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, 0); /* 出错 */
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (swd_read_memory(addr, s_lua_read_buf, num) == 0)
|
||||
{
|
||||
lua_pushnumber(L, 0); /* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
lua_pushnumber(L, 0); /* 出错 */
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnumber(L, 1); /* <EFBFBD>ɹ<EFBFBD> */
|
||||
lua_pushnumber(L, 1); /* 成功 */
|
||||
}
|
||||
|
||||
lua_pushlstring(L, (char *)s_lua_read_buf, num);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua swdģ<EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua_if_swd.h
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* v1.0 2019-09-29 armfly <EFBFBD><EFBFBD>
|
||||
* 模块名称 : lua swd模块
|
||||
* 文件名称 : lua_if_swd.h
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 。
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* v1.0 2019-09-29 armfly 首发
|
||||
*
|
||||
* Copyright (C), 2019-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2019-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -21,4 +21,4 @@ void lua_swd_RegisterFun(void);
|
||||
|
||||
#endif
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
void lua_tcp_RegisterFun(void)
|
||||
{
|
||||
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<EFBFBD>õ<EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʵ<EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>롣
|
||||
//将指定的函数注册为Lua的全局函数变量,其中第一个字符串参数为Lua代码
|
||||
//在调用C函数时使用的全局函数名,第二个参数为实际C函数的指针。
|
||||
//lua_register(g_Lua, "udp_print", lua_udp_print);
|
||||
}
|
||||
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua tcp udpģ<EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua_tcp_udp.h
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* v1.0 2019-07-03 armfly <EFBFBD><EFBFBD>
|
||||
* 模块名称 : lua tcp udp模块
|
||||
* 文件名称 : lua_tcp_udp.h
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 。
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* v1.0 2019-07-03 armfly 首发
|
||||
*
|
||||
* Copyright (C), 2019-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2019-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -21,4 +21,4 @@ void lua_tcp_RegisterFun(void);
|
||||
|
||||
#endif
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -1,4 +1,4 @@
|
||||
//<EFBFBD><EFBFBD>ģ<EFBFBD>黹δʵ<EFBFBD><EFBFBD>
|
||||
//本模块还未实现
|
||||
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
@ -10,12 +10,12 @@ static int lua_udp_print(lua_State* L);
|
||||
|
||||
void lua_tim_RegisterFun(void)
|
||||
{
|
||||
//<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪLua<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<EFBFBD>õ<EFBFBD>ȫ<EFBFBD>ֺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʵ<EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>롣
|
||||
//将指定的函数注册为Lua的全局函数变量,其中第一个字符串参数为Lua代码
|
||||
//在调用C函数时使用的全局函数名,第二个参数为实际C函数的指针。
|
||||
//lua_register(g_Lua, "udp_print", lua_udp_print);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua TIM<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : lua_ttim.h
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* v1.0 2019-07-03 armfly <EFBFBD><EFBFBD>
|
||||
* 模块名称 : lua TIM定时器模块
|
||||
* 文件名称 : lua_ttim.h
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 。
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* v1.0 2019-07-03 armfly 首发
|
||||
*
|
||||
* Copyright (C), 2019-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2019-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -21,4 +21,4 @@ void lua_tim_RegisterFun(void);
|
||||
|
||||
#endif
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "modbus_register.h"
|
||||
#include "modbus_iap.h"
|
||||
#include "lua_if.h"
|
||||
#include "usbd_cdc_interface.h"
|
||||
|
||||
|
||||
static void MODS_AnalyzeApp(void);
|
||||
|
||||
@ -34,9 +36,9 @@ static void MODS_10H(void);
|
||||
static void MODS_0FH(void);
|
||||
static void MODS_64H(void);
|
||||
static void MODS_65H(void);
|
||||
static void MODS_66H(void);
|
||||
static void MODS_67H(void);
|
||||
static void MODS_68H(void);
|
||||
//static void MODS_66H(void);
|
||||
//static void MODS_67H(void);
|
||||
//static void MODS_68H(void);
|
||||
|
||||
static void MODS_60H(void); /* PC发这个指令读取波形数据 */
|
||||
|
||||
@ -1191,7 +1193,7 @@ err_ret:
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static void MODS_66H(void)
|
||||
void MODS_66H(void)
|
||||
{
|
||||
/*
|
||||
66H - write file
|
||||
@ -1253,7 +1255,7 @@ err_ret:
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static void MODS_67H(void)
|
||||
void MODS_67H(void)
|
||||
{
|
||||
/*
|
||||
67H - read file
|
||||
@ -1429,7 +1431,7 @@ err_ret:
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static void Send_61H(uint8_t _Ch, uint32_t _Offset, uint16_t _PackageLen)
|
||||
void Send_61H(uint8_t _Ch, uint32_t _Offset, uint16_t _PackageLen)
|
||||
{
|
||||
/*
|
||||
从机应答: (然后开始多包连续应答)
|
||||
|
@ -1,16 +1,16 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : USB device <EFBFBD>жϷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : usb_it.c
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB device<EFBFBD>жϷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD>轫<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>빤<EFBFBD>̼<EFBFBD><EFBFBD>ɣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٵ<EFBFBD> stm32f4xx_it.c <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ЩISR<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 模块名称 : USB device 中断服务程序
|
||||
* 文件名称 : usb_it.c
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 本文件存放USB device中断服务程序。只需将该文件加入工程即可,无需再到 stm32f4xx_it.c 中添加这些ISR程序
|
||||
*
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* V1.0 2018-09-08 armfly <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* V1.0 2018-09-08 armfly 正式发布
|
||||
*
|
||||
* Copyright (C), 2018-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2018-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -20,10 +20,10 @@
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: OTG_FS_IRQHandler, OTG_HS_IRQHandler
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: USB HOST<EFBFBD>жϷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: OTG_FS_IRQHandler, OTG_HS_IRQHandler
|
||||
* 功能说明: USB HOST中断服务程序
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
#ifdef USE_USB_FS
|
||||
@ -35,4 +35,4 @@ void OTG_HS_IRQHandler(void)
|
||||
HAL_PCD_IRQHandler(&hpcd);
|
||||
}
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -65,7 +65,7 @@
|
||||
//#define LUN_NAND 2
|
||||
|
||||
|
||||
/* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>SDRAM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵ĵ<CCB5>ַ<EFBFBD>Ϳռ䡣 4M<34>ֽ<EFBFBD> */
|
||||
/* 定义SDRAM 虚拟磁盘的地址和空间。 4M字节 */
|
||||
#define SDRAM_DISK_ADDR SDRAM_APP_BUF
|
||||
#define SDRAM_DISK_SIZE (4 * 1024 * 1024)
|
||||
|
||||
@ -272,7 +272,7 @@ int8_t STORAGE_Read(uint8_t lun, uint8_t * buf, uint32_t blk_addr,
|
||||
//
|
||||
// if (blk_len * 512 > SDRAM_DISK_SIZE)
|
||||
// {
|
||||
// break; /* <EFBFBD>쳣 */
|
||||
// break; /* 异常 */
|
||||
// }
|
||||
//
|
||||
// p_buf = (uint32_t *)buf;
|
||||
@ -325,7 +325,7 @@ int8_t STORAGE_Write(uint8_t lun, uint8_t * buf, uint32_t blk_addr,
|
||||
//
|
||||
// if (blk_len * 512 > SDRAM_DISK_SIZE)
|
||||
// {
|
||||
// break; /* <EFBFBD>쳣 */
|
||||
// break; /* 异常 */
|
||||
// }
|
||||
//
|
||||
// printf_ok("sdram_Write ok: BlockNo=%d, Count=%d", blk_addr, blk_len);
|
||||
|
@ -1,16 +1,16 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : USB devie <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : usbd_usr.c
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>U<EFBFBD>̲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṩ<EFBFBD><EFBFBD>APPʹ<EFBFBD><EFBFBD>.
|
||||
* 模块名称 : USB devie 虚拟磁盘驱动
|
||||
* 文件名称 : usbd_usr.c
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 封装虚拟U盘操作函数,提供给APP使用.
|
||||
*
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* V1.0 2018-09-05 armfly <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* V1.0 2018-09-05 armfly 正式发布
|
||||
*
|
||||
* Copyright (C), 2015-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2015-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -27,10 +27,10 @@ PCD_HandleTypeDef hpcd;
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: usbd_OpenMassStorage
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: usbd_OpenMassStorage
|
||||
* 功能说明: 打开USB
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void usbd_OpenMassStorage(void)
|
||||
@ -54,10 +54,10 @@ void usbd_OpenMassStorage(void)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: usbd_CloseMassStorage
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD>ر<EFBFBD>USB
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 函 数 名: usbd_CloseMassStorage
|
||||
* 功能说明: 关闭USB
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void usbd_CloseMassStorage(void)
|
||||
@ -67,4 +67,4 @@ void usbd_CloseMassStorage(void)
|
||||
USBD_DeInit(&USBD_Device);
|
||||
}
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : USB Device<EFBFBD>ӿ<EFBFBD>ģ<EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : usbd_usr.h
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* 模块名称 : USB Device接口模块
|
||||
* 文件名称 : usbd_usr.h
|
||||
* 版 本 : V1.0
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -16,5 +16,5 @@ void usbd_CloseMassStorage(void);
|
||||
|
||||
#endif
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/
|
||||
|
||||
|
@ -52,7 +52,7 @@ This is a typical application on how to use the STM32H743xx USB OTG Device perip
|
||||
behaves as a USB-to-RS232 bridge following the Virtual COM Port (VCP) implementation.
|
||||
- On one side, the STM32 exchanges data with a PC host through USB interface in Device mode.
|
||||
- On the other side, the STM32 exchanges data with other devices (same host, other host,
|
||||
other devices<65>) through the UART interface (RS232).
|
||||
other devices<65> through the UART interface (RS232).
|
||||
|
||||
At the beginning of the main program the HAL_Init() function is called to reset
|
||||
all the peripherals, initialize the Flash interface and the systick.
|
||||
@ -148,20 +148,17 @@ compiler preprocessor (already done in the preconfigured projects provided with
|
||||
- "USE_USB_FS" when using USB Full Speed (FS) Core
|
||||
|
||||
@Note If the application is using the DTCM/ITCM memories (@0x20000000/ 0x0000000: not cacheable and only accessible
|
||||
by the Cortex M7 and the <20>MDMA), no need for cache maintenance when the Cortex M7 and the MDMA access these RAMs.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> If the application needs to use DMA(or other masters) based access or requires more RAM, then <20>the user has to:
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> - Use a non TCM SRAM. (example : D1 AXI-SRAM @ 0x24000000)
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> - Add a cache maintenance mechanism to ensure the cache coherence between CPU and other masters(DMAs,DMA2D,LTDC,MDMA).
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - The addresses and the size of cacheable buffers (shared between CPU and other masters)
|
||||
must be properly<6C>defined to be aligned to L1-CACHE line size (32 bytes).
|
||||
<EFBFBD>
|
||||
@Note It is recommended to enable the cache and maintain its coherence, but depending on the use case
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> It is also possible to configure the MPU as "Write through", to guarantee the write access coherence.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> In that case, the MPU must be configured as Cacheable/Bufferable/Not Shareable.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> Even though the user must manage the cache coherence for read accesses.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Please refer to the AN4838 <20>Managing memory protection unit (MPU) in STM32 MCUs<55>
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Please refer to the AN4839 <20>Level 1 cache on STM32F7 Series<65>
|
||||
|
||||
by the Cortex M7 and the 燤DMA), no need for cache maintenance when the Cortex M7 and the MDMA access these RAMs.
|
||||
牋牋<EFBFBD>If the application needs to use DMA(or other masters) based access or requires more RAM, then 爐he user has to:
|
||||
牋牋牋牋牋<EFBFBD><EFBFBD>- Use a non TCM SRAM. (example : D1 AXI-SRAM @ 0x24000000)
|
||||
牋牋牋牋牋<EFBFBD><EFBFBD>- Add a cache maintenance mechanism to ensure the cache coherence between CPU and other masters(DMAs,DMA2D,LTDC,MDMA).
|
||||
牋牋牋<EFBFBD> - The addresses and the size of cacheable buffers (shared between CPU and other masters)
|
||||
must be properly燿efined to be aligned to L1-CACHE line size (32 bytes).
|
||||
<EFBFBD>@Note It is recommended to enable the cache and maintain its coherence, but depending on the use case
|
||||
牋牋<EFBFBD>It is also possible to configure the MPU as "Write through", to guarantee the write access coherence.
|
||||
牋牋牋牋牋<EFBFBD><EFBFBD>In that case, the MPU must be configured as Cacheable/Bufferable/Not Shareable.
|
||||
牋牋牋牋牋<EFBFBD><EFBFBD>Even though the user must manage the cache coherence for read accesses.
|
||||
牋牋牋牋牋牋牋Please refer to the AN4838 揗anaging memory protection unit (MPU) in STM32 MCUs<55>牋牋牋牋牋牋牋Please refer to the AN4839 揕evel 1 cache on STM32F7 Series<65>
|
||||
@par Directory contents
|
||||
|
||||
- USB_Device/CDC_Standalone/Src/main.c Main program
|
||||
|
@ -1,16 +1,16 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : CDC<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : usbd_cdc_interface.c
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> :
|
||||
* 妯″潡鍚岖О : CDC铏氭嫙涓插彛纭欢閰岖疆
|
||||
* 鏂囦欢鍚岖О : usbd_cdc_interface.c
|
||||
* 鐗? 链?: V1.0
|
||||
* 璇? 鏄?:
|
||||
*
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* V1.0 2018-12-11 armfly <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 淇敼璁板綍 :
|
||||
* 鐗堟湰鍙? 镞ユ湡 浣滆€? 璇存槑
|
||||
* V1.0 2018-12-11 armfly 姝e纺鍙戝竷
|
||||
*
|
||||
* Copyright (C), 2018-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2018-2030, 瀹夊瘜銮辩数瀛?www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -25,7 +25,7 @@ uint16_t g_ModbusRxLen = 0;
|
||||
|
||||
/* Private typedef ----------------------------------------------------------- */
|
||||
/* Private define ------------------------------------------------------------ */
|
||||
#define APP_RX_DATA_SIZE 2048 // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>512<EFBFBD>ֽ<EFBFBD>ûɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
#define APP_RX_DATA_SIZE 2048 // 濂藉儚澶т簬512瀛楄妭娌″暐浣灭敤 */
|
||||
#define APP_TX_DATA_SIZE 2048
|
||||
|
||||
/* Private macro ------------------------------------------------------------- */
|
||||
@ -56,7 +56,7 @@ uint32_t UserTxBufPtrOut = 0; /* Increment this pointer or roll it back to
|
||||
UART_HandleTypeDef A_UartHandle;
|
||||
UART_HandleTypeDef B_UartHandle;
|
||||
|
||||
UART_HandleTypeDef *NowUartHandle = &A_UartHandle; /* <EFBFBD><EFBFBD>ǰѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Uart */
|
||||
UART_HandleTypeDef *NowUartHandle = &A_UartHandle; /* 褰揿墠阃夋嫨镄刄art */
|
||||
|
||||
/* TIM handler declaration */
|
||||
TIM_HandleTypeDef TimHandle;
|
||||
@ -81,10 +81,10 @@ USBD_CDC_ItfTypeDef USBD_CDC_fops = {
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: SelectCDCUart
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: ѡ<EFBFBD><EFBFBD>CDC<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: _com : 1, 4
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 鍑?鏁?鍚? SelectCDCUart
|
||||
* 锷熻兘璇存槑: 阃夋嫨CDC涓插彛
|
||||
* 褰? 鍙? _com : 1, 4
|
||||
* 杩?锲?链? 镞?
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void SelectCDCUart(uint8_t _com)
|
||||
@ -259,7 +259,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef * huart)
|
||||
HAL_NVIC_EnableIRQ(B_USARTx_IRQn);
|
||||
}
|
||||
|
||||
// <EFBFBD>ѵ<EFBFBD>TIM<EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>UART<EFBFBD><EFBFBD>
|
||||
// 宸插埌TIM閰岖疆鍑芥暟锛屽拰UART镞犲叧
|
||||
// /* ##-7- Enable TIM peripherals Clock #######################################
|
||||
// */
|
||||
// TIMx_CLK_ENABLE();
|
||||
@ -510,10 +510,10 @@ static int8_t CDC_Itf_Control(uint8_t cmd, uint8_t * pbuf, uint16_t length)
|
||||
*/
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: HAL_TIM_PeriodElapsedCallback
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ѯ. 5ms <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD><EFBFBD><EFBFBD>1ms
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: _com : 1, 4
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 鍑?鏁?鍚? HAL_TIM_PeriodElapsedCallback
|
||||
* 锷熻兘璇存槑: 瀹氭椂杞. 5ms 锛屾渶蹇彲浠ヨ皟鍒?ms
|
||||
* 褰? 鍙? _com : 1, 4
|
||||
* 杩?锲?链? 镞?
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef * htim)
|
||||
@ -580,11 +580,11 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef * huart)
|
||||
*/
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CDC_Itf_Receive
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: STM32<EFBFBD>յ<EFBFBD>USB<EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD>ִ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>512<EFBFBD>ֽڡ<EFBFBD> CDC_DATA_HS_MAX_PACKET_SIZE = 512
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>512<EFBFBD>ֽڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>䡣
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 鍑?鏁?鍚? CDC_Itf_Receive
|
||||
* 锷熻兘璇存槑: STM32鏀跺埌USB鏁版嵁鍚庢墽琛屾湰鍑芥暟銆?鏁版嵁闀垮害链€澶?12瀛楄妭銆? CDC_DATA_HS_MAX_PACKET_SIZE = 512
|
||||
* 濡傛灉涓娄綅链烘湁澶т簬512瀛楄妭镄勬暟鎹紝鍒欎细鍒嗗寘浼犺緭銆?
|
||||
* 褰? 鍙? 镞?
|
||||
* 杩?锲?链? 镞?
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
static int8_t CDC_Itf_Receive(uint8_t * Buf, uint32_t *Len)
|
||||
@ -603,7 +603,7 @@ static int8_t CDC_Itf_Receive(uint8_t * Buf, uint32_t *Len)
|
||||
g_ModbusRxLen += len;
|
||||
}
|
||||
|
||||
/* <EFBFBD>жϳ<EFBFBD><EFBFBD>Ȳ<EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD>õķ<EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>512<31>ֽ<EFBFBD> */
|
||||
/* 鍒ゆ柇闀垮害涓嶆槸澶ソ镄勬柟妗? 濡傛灉澶т簬512瀛楄妭 */
|
||||
if (len != 512)
|
||||
{
|
||||
MODS_Poll(g_ModbusRxBuf, g_ModbusRxLen);
|
||||
@ -635,7 +635,7 @@ static int8_t CDC_Itf_Receive(uint8_t * Buf, uint32_t *Len)
|
||||
{
|
||||
if (NowUartHandle == &A_UartHandle)
|
||||
{
|
||||
RS485_TX_EN(); /* 485<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> */
|
||||
RS485_TX_EN(); /* 485鍙戦€佷娇鑳?*/
|
||||
|
||||
HAL_UART_Transmit_DMA(&A_UartHandle, Buf, *Len);
|
||||
|
||||
@ -655,17 +655,17 @@ static int8_t CDC_Itf_Receive(uint8_t * Buf, uint32_t *Len)
|
||||
*/
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: HAL_UART_TxCpltCallback
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: STM32<EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱִ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 鍑?鏁?鍚? HAL_UART_TxCpltCallback
|
||||
* 锷熻兘璇存槑: STM32涓插彛鍙戝嚭镄勬暟鎹叏閮ㄥ彂阃佸畲姣曟椂镓ц链嚱鏁般€?
|
||||
* 褰? 鍙? 镞?
|
||||
* 杩?锲?链? 镞?
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void HAL_UART_TxCpltCallback(UART_HandleTypeDef * huart)
|
||||
{
|
||||
if (NowUartHandle == &A_UartHandle)
|
||||
{
|
||||
RS485_RX_EN(); /* <EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϡ<EFBFBD><EFBFBD><EFBFBD>ֹ485<EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ */
|
||||
RS485_RX_EN(); /* 涓插彛鍙戦€佸畲姣曘€傜姝?85鍙戦€侊紝璁剧疆涓烘帴鏀舵ā寮?*/
|
||||
}
|
||||
else if (NowUartHandle == &B_UartHandle)
|
||||
{
|
||||
@ -824,10 +824,10 @@ void HAL_UART_ErrorCallback(UART_HandleTypeDef * UartHandle)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: USBCom_SendBufNow
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: STM32<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>PC<EFBFBD><EFBFBD>USB<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 鍑?鏁?鍚? USBCom_SendBufNow
|
||||
* 锷熻兘璇存槑: STM32鍙戦€佷竴涓叉暟鎹埌PC链篣SB锛岀珛鍗冲彂阃?
|
||||
* 褰? 鍙? 镞?
|
||||
* 杩?锲?链? 镞?
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
uint8_t USBCom_SendBufNow(int _Port, uint8_t *_Buf, uint16_t _Len)
|
||||
@ -843,10 +843,10 @@ uint8_t USBCom_SendBufNow(int _Port, uint8_t *_Buf, uint16_t _Len)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: USBCom_SendBuf
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>USB<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>棬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 鍑?鏁?鍚? USBCom_SendBuf
|
||||
* 锷熻兘璇存槑: 鍙戦€佷竴涓叉暟鎹埌USB涓插彛, 浠呬粎缂揿瓨锛屼笉鍙戦€?
|
||||
* 褰? 鍙? 镞?
|
||||
* 杩?锲?链? 镞?
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
uint8_t USBCom_SendBuf(int _Port, uint8_t *_Buf, uint16_t _Len)
|
||||
|
@ -51,17 +51,17 @@
|
||||
#include "usbd_cdc.h"
|
||||
|
||||
/*
|
||||
H7-TOOL <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>RS232<EFBFBD><EFBFBD> RS485<EFBFBD><EFBFBD>TTL-UART<EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD>PA9 PA10
|
||||
H7-TOOL 虚拟串口(RS232, RS485,TTL-UART)使用的PA9 PA10
|
||||
PA9/USART1_TX/PE13/FMC_D10
|
||||
PA10/USART1_RX/PE14/FMC_D11
|
||||
|
||||
<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ESP32ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>䵽UART4<EFBFBD>ڣ<EFBFBD>ͨ<EFBFBD><EFBFBD>PC<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD><EFBFBD><EFBFBD>ATָ<EFBFBD>
|
||||
临时调试ESP32时,可以将其映射到UART4口,通过PC串口助手测试AT指令。
|
||||
PH13/UART4_TX
|
||||
PH14/UART4_RX
|
||||
*/
|
||||
|
||||
/* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> A<>ڣ<EFBFBD>B<EFBFBD><42><EFBFBD>л<EFBFBD> */
|
||||
#if 1 /* H7-TOOL ȱʡʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>UART */
|
||||
/* 定义物理串口 A口,B口切换 */
|
||||
#if 1 /* H7-TOOL 缺省使用这个UART */
|
||||
#define A_USARTx USART1
|
||||
#define A_USARTx_CLK_ENABLE() __HAL_RCC_USART1_CLK_ENABLE()
|
||||
|
||||
@ -102,7 +102,7 @@
|
||||
#define A_USARTx_DMA_RX_IRQHandler DMA1_Stream5_IRQHandler
|
||||
#endif
|
||||
|
||||
#if 1 /* H7-TOOL <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ESP32ģ<EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD>ʱʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>UART */
|
||||
#if 1 /* H7-TOOL 升级ESP32模块固件时使用这个UART */
|
||||
#define B_USARTx UART4
|
||||
#define B_USARTx_CLK_ENABLE() __HAL_RCC_UART4_CLK_ENABLE()
|
||||
|
||||
@ -143,7 +143,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
/* Definition for TIMx clock resources . TIM3 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>DSOʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ */
|
||||
/* Definition for TIMx clock resources . TIM3 用于DSO示波器ADC触发源 */
|
||||
#define TIMx TIM15
|
||||
#define TIMx_CLK_ENABLE __HAL_RCC_TIM15_CLK_ENABLE
|
||||
#define TIMx_FORCE_RESET() __HAL_RCC_TIM15_FORCE_RESET()
|
||||
|
@ -1,16 +1,16 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : USB device <EFBFBD>жϷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : usb_it.c
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB device<EFBFBD>жϷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD>轫<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>빤<EFBFBD>̼<EFBFBD><EFBFBD>ɣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٵ<EFBFBD> stm32f4xx_it.c <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ЩISR<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 妯″潡鍚岖О : USB device 涓柇链嶅姟绋嫔簭
|
||||
* 鏂囦欢鍚岖О : usb_it.c
|
||||
* 鐗? 链?: V1.0
|
||||
* 璇? 鏄?: 链枃浠跺瓨鏀绾SB device涓柇链嶅姟绋嫔簭銆傚彧闇€灏呜鏂囦欢锷犲叆宸ョ▼鍗冲彲锛屾棤闇€鍐嶅埌 stm32f4xx_it.c 涓坊锷犺繖浜汭SR绋嫔簭
|
||||
*
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* V1.0 2018-09-08 armfly <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 淇敼璁板綍 :
|
||||
* 鐗堟湰鍙? 镞ユ湡 浣滆€? 璇存槑
|
||||
* V1.0 2018-09-08 armfly 姝e纺鍙戝竷
|
||||
*
|
||||
* Copyright (C), 2018-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2018-2030, 瀹夊瘜銮辩数瀛?www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
@ -1,16 +1,16 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : USB devie <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : usbd_user.c
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṩ<EFBFBD><EFBFBD>APPʹ<EFBFBD><EFBFBD>.
|
||||
* 妯″潡鍚岖О : USB devie 铏氭嫙涓插彛椹卞姩
|
||||
* 鏂囦欢鍚岖О : usbd_user.c
|
||||
* 鐗? 链?: V1.0
|
||||
* 璇? 鏄?: 灏佽铏氭嫙涓插彛鎿崭綔鍑芥暟锛屾彁渚涚粰APP浣跨敤.
|
||||
*
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* V1.0 2018-12-11 armfly <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 淇敼璁板綍 :
|
||||
* 鐗堟湰鍙? 镞ユ湡 浣滆€? 璇存槑
|
||||
* V1.0 2018-12-11 armfly 姝e纺鍙戝竷
|
||||
*
|
||||
* Copyright (C), 2018-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2018-2030, 瀹夊瘜銮辩数瀛?www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
@ -23,15 +23,15 @@ extern PCD_HandleTypeDef hpcd;
|
||||
extern void SelectCDCUart(uint8_t _com);
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: usbd_OpenCDC
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: _com : 1, 4
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 鍑?鏁?鍚? usbd_OpenCDC
|
||||
* 锷熻兘璇存槑: 镓揿紑USB
|
||||
* 褰? 鍙? _com : 1, 4
|
||||
* 杩?锲?链? 镞?
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void usbd_OpenCDC(uint8_t _com)
|
||||
{
|
||||
SelectCDCUart(_com); /* ѡ<EFBFBD><EFBFBD>uart1<EFBFBD><EFBFBD>uart4<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
SelectCDCUart(_com); /* 阃夋嫨uart1鎴杣art4浣滀负铏氭嫙涓插彛 */
|
||||
|
||||
/* Init Device Library */
|
||||
USBD_Init(&USBD_Device, &VCP_Desc, 0);
|
||||
@ -48,10 +48,10 @@ void usbd_OpenCDC(uint8_t _com)
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: usbd_CloseCDC
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD>ر<EFBFBD>USB
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
* 鍑?鏁?鍚? usbd_CloseCDC
|
||||
* 锷熻兘璇存槑: 鍏抽棴USB
|
||||
* 褰? 鍙? 镞?
|
||||
* 杩?锲?链? 镞?
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void usbd_CloseCDC(void)
|
||||
@ -66,4 +66,4 @@ void usbd_CloseCDC(void)
|
||||
USBD_DeInit(&USBD_Device);
|
||||
}
|
||||
|
||||
/***************************** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/
|
||||
/***************************** 瀹夊瘜銮辩数瀛?www.armfly.com (END OF FILE) *********************************/
|
||||
|
@ -1,16 +1,16 @@
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
*
|
||||
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : USB devie <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : usbd_user.h
|
||||
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
|
||||
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṩ<EFBFBD><EFBFBD>APPʹ<EFBFBD><EFBFBD>.
|
||||
* 模块名称 : USB devie 虚拟串口驱动
|
||||
* 文件名称 : usbd_user.h
|
||||
* 版 本 : V1.0
|
||||
* 说 明 : 封装虚拟串口操作函数,提供给APP使用.
|
||||
*
|
||||
* <EFBFBD>ļ<EFBFBD>¼ :
|
||||
* <EFBFBD>汾<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
|
||||
* V1.0 2018-12-11 armfly <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* 修改记录 :
|
||||
* 版本号 日期 作者 说明
|
||||
* V1.0 2018-12-11 armfly 正式发布
|
||||
*
|
||||
* Copyright (C), 2018-2030, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
|
||||
* Copyright (C), 2018-2030, 安富莱电子 www.armfly.com
|
||||
*
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
@ -4,7 +4,8 @@ rd /Q /S project\MDK-ARM(uV5)\DebugConfig
|
||||
del /Q project\MDK-ARM(uV5)\*.bak
|
||||
del /Q project\MDK-ARM(uV5)\*.dep
|
||||
del /Q project\MDK-ARM(uV5)\JLink*
|
||||
del /Q project\MDK-ARM(uV5)\project.uvgui.*
|
||||
del /Q project\MDK-ARM(uV5)\project.uvguix.*
|
||||
del /Q project\MDK-ARM(uV5)\*.scvd
|
||||
|
||||
rd /Q /S project\MDK5-DAPLink\Objects
|
||||
rd /Q /S project\MDK5-DAPLink\Listings
|
||||
|
Loading…
x
Reference in New Issue
Block a user